Class LoadAndZoomHandler
- java.lang.Object
-
- org.openstreetmap.josm.io.remotecontrol.handler.RequestHandler
-
- org.openstreetmap.josm.io.remotecontrol.handler.LoadAndZoomHandler
-
public class LoadAndZoomHandler extends RequestHandler
Handler forload_and_zoom
andzoom
requests.- Since:
- 3707
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.openstreetmap.josm.io.remotecontrol.handler.RequestHandler
RequestHandler.PermissionCache, RequestHandler.RawURLParseRequestHandler, RequestHandler.RequestHandlerBadRequestException, RequestHandler.RequestHandlerErrorException, RequestHandler.RequestHandlerException, RequestHandler.RequestHandlerForbiddenException, RequestHandler.RequestHandlerOsmApiException
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
ADDTAGS
private static java.lang.String
CHANGESET_COMMENT
private static java.lang.String
CHANGESET_HASHTAGS
private static java.lang.String
CHANGESET_SOURCE
private static java.lang.String
CHANGESET_TAGS
static java.lang.String
command
The remote control command name used to load data and zoom.static java.lang.String
command2
The remote control command name used to zoom.private static java.lang.String
CURRENT_SELECTION
private boolean
isKeepingCurrentSelection
private double
maxlat
private double
maxlon
private double
minlat
private double
minlon
private static java.lang.String
SEARCH
private static java.lang.String
SELECT
private java.util.Set<SimplePrimitiveId>
toSelect
-
Fields inherited from class org.openstreetmap.josm.io.remotecontrol.handler.RequestHandler
args, content, contentType, GLOBAL_CONFIRMATION, LOAD_IN_NEW_LAYER, myCommand, OSM_DOWNLOAD_TIMEOUT, PERMISSIONS, request, sender, SPLITTER_COMMA, SPLITTER_SEMIC
-
-
Constructor Summary
Constructors Constructor Description LoadAndZoomHandler()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addChangesetTags()
private void
addTags(java.util.Collection<OsmPrimitive> forTagAdd)
private void
download()
java.lang.String[]
getMandatoryParams()
Returns the mandatory parameters.java.lang.String[]
getOptionalParams()
Returns the optional parameters.java.lang.String
getPermissionMessage()
Get a specific message to ask the user for permission for the operation requested via remote control.PermissionPrefWithDefault
getPermissionPref()
Get a PermissionPref object containing the name of a special permission preference to individually allow the requested operation and an error message to be displayed when a disabled operation is requested.java.lang.String
getUsage()
Returns usage description, for bad requests and documentation.java.lang.String[]
getUsageExamples()
Returns usage examples, for bad requests and documentation.java.lang.String[]
getUsageExamples(java.lang.String cmd)
Returns usage examples for the given command.protected void
handleRequest()
Handle a specific command sent as remote control.(package private) static void
parseChangesetTags(java.util.Map<java.lang.String,java.lang.String> args)
private void
performDownload(DownloadOsmTask osmTask, DownloadParams settings)
Perform the actual download; this is synchronized to ensure that we only have one download going on at a timeprivate java.util.Collection<OsmPrimitive>
performSearchZoom()
private java.awt.geom.Area
removeAlreadyDownloadedArea()
Remove areas that has already been downloadedprivate void
searchAndZoom(java.util.Collection<OsmPrimitive> forTagAdd, Bounds bbox)
private void
selectAndZoom(java.util.Collection<OsmPrimitive> forTagAdd, Bounds bbox)
protected void
validateRequest()
Validates the request before attempting to perform it.private void
validateSelect()
protected void
zoom(java.util.Collection<OsmPrimitive> primitives, Bounds bbox)
-
Methods inherited from class org.openstreetmap.josm.io.remotecontrol.handler.RequestHandler
checkMandatoryParams, checkPermission, getCommand, getContent, getContentType, getDownloadParams, getRequestParameter, handle, parseArgs, setCommand, setSender, setUrl, splitArg, validateDownloadParams
-
-
-
-
Field Detail
-
command
public static final java.lang.String command
The remote control command name used to load data and zoom.- See Also:
- Constant Field Values
-
command2
public static final java.lang.String command2
The remote control command name used to zoom.- See Also:
- Constant Field Values
-
CURRENT_SELECTION
private static final java.lang.String CURRENT_SELECTION
- See Also:
- Constant Field Values
-
SELECT
private static final java.lang.String SELECT
- See Also:
- Constant Field Values
-
ADDTAGS
private static final java.lang.String ADDTAGS
- See Also:
- Constant Field Values
-
CHANGESET_COMMENT
private static final java.lang.String CHANGESET_COMMENT
- See Also:
- Constant Field Values
-
CHANGESET_SOURCE
private static final java.lang.String CHANGESET_SOURCE
- See Also:
- Constant Field Values
-
CHANGESET_HASHTAGS
private static final java.lang.String CHANGESET_HASHTAGS
- See Also:
- Constant Field Values
-
CHANGESET_TAGS
private static final java.lang.String CHANGESET_TAGS
- See Also:
- Constant Field Values
-
SEARCH
private static final java.lang.String SEARCH
- See Also:
- Constant Field Values
-
minlat
private double minlat
-
maxlat
private double maxlat
-
minlon
private double minlon
-
maxlon
private double maxlon
-
toSelect
private final java.util.Set<SimplePrimitiveId> toSelect
-
isKeepingCurrentSelection
private boolean isKeepingCurrentSelection
-
-
Constructor Detail
-
LoadAndZoomHandler
public LoadAndZoomHandler()
-
-
Method Detail
-
getPermissionMessage
public java.lang.String getPermissionMessage()
Description copied from class:RequestHandler
Get a specific message to ask the user for permission for the operation requested via remote control.This message will be displayed to the user if the preference remotecontrol.always-confirm is true.
- Specified by:
getPermissionMessage
in classRequestHandler
- Returns:
- the message
-
getMandatoryParams
public java.lang.String[] getMandatoryParams()
Description copied from class:RequestHandler
Returns the mandatory parameters. Both used to enforce their presence at runtime and for documentation.- Specified by:
getMandatoryParams
in classRequestHandler
- Returns:
- the mandatory parameters
-
getOptionalParams
public java.lang.String[] getOptionalParams()
Description copied from class:RequestHandler
Returns the optional parameters. Both used to enforce their presence at runtime and for documentation.- Overrides:
getOptionalParams
in classRequestHandler
- Returns:
- the optional parameters
-
getUsage
public java.lang.String getUsage()
Description copied from class:RequestHandler
Returns usage description, for bad requests and documentation.- Overrides:
getUsage
in classRequestHandler
- Returns:
- usage description
-
getUsageExamples
public java.lang.String[] getUsageExamples()
Description copied from class:RequestHandler
Returns usage examples, for bad requests and documentation.- Overrides:
getUsageExamples
in classRequestHandler
- Returns:
- Usage examples
-
getUsageExamples
public java.lang.String[] getUsageExamples(java.lang.String cmd)
Description copied from class:RequestHandler
Returns usage examples for the given command. To be overridden only my handlers that define several commands.- Overrides:
getUsageExamples
in classRequestHandler
- Parameters:
cmd
- The command asked- Returns:
- Usage examples for the given command
-
handleRequest
protected void handleRequest() throws RequestHandler.RequestHandlerErrorException
Description copied from class:RequestHandler
Handle a specific command sent as remote control. Any time-consuming operation must be performed asynchronously to avoid delaying the HTTP response.This method of the subclass will do the real work.
- Specified by:
handleRequest
in classRequestHandler
- Throws:
RequestHandler.RequestHandlerErrorException
- if an error occurs while processing request
-
download
private void download() throws RequestHandler.RequestHandlerErrorException
-
removeAlreadyDownloadedArea
private java.awt.geom.Area removeAlreadyDownloadedArea()
Remove areas that has already been downloaded- Returns:
- The area to download
-
performDownload
private void performDownload(DownloadOsmTask osmTask, DownloadParams settings) throws RequestHandler.RequestHandlerErrorException
Perform the actual download; this is synchronized to ensure that we only have one download going on at a time- Parameters:
osmTask
- The task that will show a dialogsettings
- The download settings- Throws:
RequestHandler.RequestHandlerErrorException
- If there is an issue getting data
-
performSearchZoom
private java.util.Collection<OsmPrimitive> performSearchZoom() throws RequestHandler.RequestHandlerErrorException
-
selectAndZoom
private void selectAndZoom(java.util.Collection<OsmPrimitive> forTagAdd, Bounds bbox)
-
searchAndZoom
private void searchAndZoom(java.util.Collection<OsmPrimitive> forTagAdd, Bounds bbox) throws RequestHandler.RequestHandlerErrorException
-
addChangesetTags
private void addChangesetTags()
-
addTags
private void addTags(java.util.Collection<OsmPrimitive> forTagAdd)
-
parseChangesetTags
static void parseChangesetTags(java.util.Map<java.lang.String,java.lang.String> args)
-
zoom
protected void zoom(java.util.Collection<OsmPrimitive> primitives, Bounds bbox)
-
getPermissionPref
public PermissionPrefWithDefault getPermissionPref()
Description copied from class:RequestHandler
Get a PermissionPref object containing the name of a special permission preference to individually allow the requested operation and an error message to be displayed when a disabled operation is requested.Default is not to check any special preference. Override this in a subclass to define permission preference and error message.
- Specified by:
getPermissionPref
in classRequestHandler
- Returns:
- the preference name and error message or null
-
validateRequest
protected void validateRequest() throws RequestHandler.RequestHandlerBadRequestException
Description copied from class:RequestHandler
Validates the request before attempting to perform it.- Specified by:
validateRequest
in classRequestHandler
- Throws:
RequestHandler.RequestHandlerBadRequestException
- if request is invalid
-
validateSelect
private void validateSelect()
-
-