Changes between Version 32 and Version 33 of Help/Preferences/RemoteControl


Ignore:
Timestamp:
2016-11-24T12:03:38+01:00 (9 years ago)
Author:
openstreetmap.org-user-d1g
Comment:

split commands from preferences menu

Legend:

Unmodified
Added
Removed
Modified
  • Help/Preferences/RemoteControl

    v32 v33  
    1 [[TranslatedPages(outdated=This page is missing command features. The list of commands is probably better situated on a separate page.)]]
     1[[TranslatedPages(outdated=This page is missing command features.)]]
    22= Preferences > Remote Control =
    33
     
    2727* **Confirm all Remote Control actions manually**
    2828
    29 == List of Commands ==
    30 
    31 A complete list of commands and mandatory/optional parameters is shown at http://127.0.0.1:8111/ (when JOSM is running).
    32 
    33 === {{{load_and_zoom}}} ===
    34 Instructs JOSM to download a bounding box from the API, zoom to the downloaded area and optionally select one or more objects.
    35 {{{
    36 GET /load_and_zoom?left=...&right=...&top=...&bottom=...&select=object[,object...]
    37 }}}
    38 where
    39 ||= **Parameter** =||= **Required/Optional** =||= **Meaning** =||
    40 || `bottom` || R || Minimum latitude ||
    41 || `top` || R || Maximum latitude ||
    42 || `left` || R || Minimum longitude ||
    43 || `right` || R || Maximum longitude ||
    44 || `new_layer` || O || If '''true''', downloads to a new layer ||
    45 || `addtags` || O || Optional parameter to add tags. The key and value is separated by "=" and multiple tags can be separated by a Pipe "|". See [#addtags details]. ||
    46 || `select` || O || Comma-separated list of objects that should be selected. Object specifiers are combinations of the words "way", "node", or "relation", and the numerical object id. Example: {{{select=way38473,node12399,node54646}}} ||
    47 || `zoom_mode` || O || '''download''' | '''selection''', defaults to selection ||
    48 || `changeset_comment` || O || Comment of the changeset ||
    49 || `changeset_source` || O || Source of the changeset ||
    50 || `search` || O || Search objects in the current data layer. See [wiki:/Help/Action/Search Search] ||
    51 
    52 ==== Example ====
    53 
    54 Start JOSM (don't forget to enable the !RemoteControl feature), then click on:
    55 
    56 [http://127.0.0.1:8111/load_and_zoom?left=8.19&right=8.20&top=48.605&bottom=48.590&select=node413602999]
    57 
    58 JOSM should now load an area in the German Schwarzwald and have the specified node selected.
    59 
    60 === {{{zoom}}} ===
    61 Instructs JOSM to zoom to the specified area and optionally select one or more objects.
    62 {{{
    63 GET /zoom?left=...&right=...&top=...&bottom=...&select=object[,object...]
    64 }}}
    65 Accepts the same parameters as the [#load_and_zoom load_and_zoom] command and uses the same code for zoom and selection. The only difference is that no data will be loaded from the API.
    66 
    67 **Hint**: This command can also be used to select objects only. Just enter a small arbitrary area to the left..bottom entries and add the object list to the select= option.
    68 === {{{import}}} ===
    69 Instructs JOSM to download the specified OSM file and add it to the current data set.
    70 {{{
    71 GET /import?url=...
    72 }}}
    73 where
    74 ||= **Parameter** =||= **Required/Optional** =||= **Meaning** =||
    75 || `url` || R ||  ||
    76 || `new_layer` || O || If '''true''', downloads to a new layer ||
    77 
    78 === {{{load_data}}} ===
    79 (since version 1.6)
    80 Instruct JOSM to load OSM data, directly encoded in the URL, instead of coming from an external file. This is only suited for smaller data (some browsers limit the maximum URL length), but it is faster (since no download is required), and in many cases where dynamically generated data is needed, it's easier to generate.
    81 
    82 {{{
    83 GET /load_data?new_layer=(true/false)&layer_name=...&mime_type=...&data=...
    84 }}}
    85 where
    86 ||= **Parameter** =||= **Required/Optional** =||= **Meaning** =||
    87 || `data` || R || The XML data to load, this should be URL encoded in a way that also encodes the special characters &, = and ? to resp. %26, %3D and %3F. The JS [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent encodeUriComponent()] method provides this functionality out of the box. ||
    88 || `new_layer` || O || Chose to load the data in a new layer ||
    89 || `mime_type` || O || Mime type of the data, by default this is "application/x-osm+xml", which is currently the only supported mime type, but in the future other mime types could be supported ||
    90 || `layer_name` || O || Only valid when the data is loaded in a new layer; Gives JOSM a hint on how to name the layer ||
    91 
    92 === {{{open_file }}} ===
    93 Open a local file in JOSM.
    94 
    95 {{{
    96 GET /open_file?filename=...
    97 }}}
    98 where
    99 ||= **Parameter** =||= **Required/Optional** =||= **Meaning** =||
    100 || `filename` || R || The local file to open in JOSM (Ie: /tmp/test.osm) ||
    101 
    102 
    103 === {{{imagery}}} ===
    104 Instructs JOSM to add an imagery (WMS/TMS) layer.
    105 {{{
    106 GET /imagery?title=...&type=...&url=...
    107 }}}
    108 where
    109 ||= **Parameter** =||= **Required/Optional** =||= **Meaning** =||
    110 || `url` || R || The Request URL, including patterns. Must be the last parameter, everything after "&url=" is interpreted as URL, even if it contains "&" characters.  ||
    111 || `title` || O || The display name of the layer ||
    112 || `type` || O || Type of the layer. Possible values are `wms`, `tms` and `bing` [[BR]] (since !RemoteControl Version 1.3) ||
    113 || `cookies` || O ||  ||
    114 || `min_zoom` || O || The minimum zoom level [[BR]] (since !RemoteControl Version 1.4) ||
    115 || `max_zoom` || O || The maximum zoom level. For higher scales, the images of the maximum level is enlarged [[BR]] (since !RemoteControl Version 1.4) ||
    116 
    117 
    118 mandatory parameters: url
    119 optional parameters: title, type, cookies, min_zoom, max_zoom
    120 
    121 ==== Examples ====
    122 * TMS layer "osm" {{{http://tile.openstreetmap.org/{zoom}/{x}/{y}.png}}}
    123 
    124 [http://localhost:8111/imagery?title=osm&type=tms&url=http://tile.openstreetmap.org/%7Bzoom%7D/%7Bx%7D/%7By%7D.png]
    125 
    126 * WMS layer "landsat" {{{http://irs.gis-lab.info/?layers=landsat&SRS={proj}&WIDTH={width}&HEIGHT={height}&BBOX={bbox} }}}
    127 [http://localhost:8111/imagery?title=landsat&type=wms&url=http://irs.gis-lab.info/?layers=landsat&SRS=%7Bproj%7D&WIDTH=%7Bwidth%7D&HEIGHT=%7Bheight%7D&BBOX=%7Bbbox%7D]
    128 
    129 === {{{load_object}}} ===
    130 
    131 Instructs JOSM to download objects with a given id.
    132 {{{
    133 GET /load_object?new_layer=true|false&objects=...
    134 }}}
    135 where
    136 ||= **Parameter** =||= **Required/Optional** =||= **Meaning** =||
    137 || `objects` || R || Comma separated list of object ids, e.g. "{{{n1234,n1235,w84,r958493}}}" ||
    138 || `new_layer` || O || If '''true''', downloads to a new layer ||
    139 || `addtags` || O || Optional parameter to add tags. The key and value is separated by "=" and multiple tags can be separated by a Pipe "|". See [#addtags details]. ||
    140 || `relation_members` || O || If '''true''', downloads objects members of the relations as well. ||
    141 || `referrers` || O || If '''true''', downloads referrers of the object as well. I.e. parent relations, and for nodes, additionally, parent ways. (since r6782) ||
    142 
    143 ==== Example ====
    144 
    145 [http://localhost:8111/load_object?new_layer=true&objects=w106159509]
    146 
    147 === {{{add_node}}} ===
    148 
    149 Instructs JOSM to create a new node at the given coordinates.
    150 
    151 **Note**: This action requires the permission ''Create new objects'' which is disabled by default.
    152 
    153 {{{
    154 GET /add_node?lon=...&lat=...
    155 }}}
    156 where
    157 ||= **Parameter** =||= **Required/Optional** =||= **Meaning** =||
    158 || `lon` || R || The longitude of the node ||
    159 || `lat` || R || The latitude of the node ||
    160 || `addtags` since v1.5|| O || Optional parameter to add tags. The key and value is separated by "=" and multiple tags can be separated by a Pipe "|". See [#addtags details]. ||
    161 
    162 ==== Example ====
    163 http://localhost:8111/add_node?lon=13.3&lat=53.2
    164 
    165 === {{{add_way}}} ===
    166 
    167 Instructs JOSM to create a new way with new way nodes at given coordinates.
    168 
    169 **Note**: This action requires the permission ''Create new objects'' which is disabled by default.
    170 
    171 {{{
    172 GET /add_way?way=lat1,lon1;lat2,lon2;...
    173 }}}
    174 where
    175 ||= **Parameter** =||= **Required/Optional** =||= **Meaning** =||
    176 || `way` || R || Pairs of latitude, longitude coordinates separated by semicolon. ||
    177 || `addtags` since v1.5|| O || Optional parameter to add tags. The key and value is separated by "=" and multiple tags can be separated by a Pipe "|". See [#addtags details]. ||
    178 
    179 ==== Example ====
    180 
    181 http://localhost:8111/add_way?way=53.2,13.3;53.3,13.3;53.3,13.2
    182 
    183 
    184 === {{{version}}} ===
    185 This command returns the current protocol version of the installed !RemoteControl interface. Developers can use it to query for a running instance of JOSM and also determine whether the requested functionality is available in the client.
    186 {{{
    187 GET /version[?jsonp=callback]
    188 }}}
    189 where
    190 ||= **Parameter** =||= **Required/Optional** =||= **Meaning** =||
    191 || `jsonp` || O|| Jsonp callback for older browsers not implementing ​Cross-Origin Resource Sharing (CORS) ||
    192 
    193 The command returns a json object containing an application identifier that is always "JOSM !RemoteControl", a major number and a minor number. Compatible protocol changes result in an increase of the minor number. Incompatible changes increase the major number. So a client application knowing of protocol version 1.0 can still talk to JOSM having 1.1. But it's not guaranteed to be working with 2.0. So the client should verify the major number.
    194 
    195 A typical output looks like this:
    196 {{{
    197 #!js
    198 {
    199    "protocolversion": {
    200       "major": 1,
    201       "minor": 0
    202    },
    203    "application": "JOSM RemoteControl"
    204 }
    205 }}}
    206 For older browsers not implementing [http://en.wikipedia.org/wiki/Cross-Origin_Resource_Sharing Cross-Origin Resource Sharing (CORS)] the command provides the possibility for jsonp callback. Load the URL in a script tag and supply the name of a callback that will receive the JSON data.
    207 
    208 Following is some sample code that checks for CORS capabilities and uses [http://en.wikipedia.org/wiki/JSONP JSONP] as a fallback solution.
    209 {{{
    210 #!js
    211 // in addition to the CC-BY-SA of the wiki feel free to use the following source for any purpose without restrictions (PD)
    212 // credits and additions appreciated: https://wiki.openstreetmap.org/wiki/User:Stephankn
    213 
    214 function checkJOSM(version){
    215    alert(version.application + " uses protocol version " + version.protocolversion.major + "." + version.protocolversion.minor);
    216    // do something useful, maybe showing edit button
    217 }
    218 
    219 var url = "http://127.0.0.1:8111/version";
    220 var useFallback = false;
    221 // currently FF3.5, Safari 4 and IE8 implement CORS
    222 if (XMLHttpRequest) {
    223    var request = new XMLHttpRequest();
    224    if ("withCredentials" in request) {
    225       request.open('GET', url, true);
    226       request.onreadystatechange = function(){
    227          if (request.readyState != 4) {
    228             return;
    229          }
    230          if (request.status == 200) {
    231             checkJOSM(eval('(' + request.responseText + ')'));
    232          }
    233       };
    234       request.send();
    235    }
    236    else if (XDomainRequest) {
    237       var xdr = new XDomainRequest();
    238       xdr.open("get", url);
    239       xdr.onload = function(){
    240          checkJOSM(eval('(' + xdr.responseText + ')'));
    241       };
    242       xdr.send();
    243    } else {
    244       useFallback = true;
    245    }
    246 }
    247 else {
    248    // no XMLHttpRequest available
    249    useFallback = true;
    250 }
    251 
    252 if (useFallback) {
    253    // Use legacy jsonp call
    254    var s = document.createElement('script');
    255    s.src = url + '?jsonp=checkJOSM';
    256    s.type = 'text/javascript';
    257    
    258    if (document.getElementsByTagName('head').length > 0) {
    259       document.getElementsByTagName('head')[0].appendChild(s);
    260    }
    261    
    262 }
    263 }}}
    264 
    265 
    266 === Adding, changing or deleting tags === #addtags
    267 Try this example: 
    268 [http://localhost:8111/load_and_zoom?addtags=wikipedia%3Ade=Weiße_Gasse%7Cmaxspeed=5&select=way23071688,way23076176,way23076177,&left=13.739727546842&right=13.740890970188&top=51.049987191025&bottom=51.048466954325].
    269 (Works also with the zoom-command)
    270 
    271 The user must review the tags and the selection before the tags are applied to the selected objects.
    272 If the tag exists on some objects, it will be can be replaced.
    273 
    274 Since protocol version 1.5
    275 - `add_node` and `add_way` commands support `addtags` parameter
    276 - It is possible to use `=` character in value and all leading/trailing spaces are trimmed.
    277 [http://localhost:8111/add_node?lon=13.3&lat=53.2&addtags=natural=tree%7Cname=%20%20%20==Great%20Oak==] (creates node with natural=tree an name="==Great Oak==")
    278 - If empty value is found, tag is to be deleted from objects (checkbox-confirmation is needed)
    279 [http://localhost:8111/load_and_zoom?addtags=wikipedia%3Ade=%7Cmaxspeed=&select=way23071688,way23076176,way23076177,&left=13.739727546842&right=13.740890970188&top=51.049987191025&bottom=51.048466954325].
    280 
    281 === Other commands ===
    282 Remotecontrol allows other plugins to add additional commands. The other registers a RequestHandler class and specifies a command to be handled by this class. The command syntax has to be defined by the other plugin.
    283 
    284 Reverter plugin since version 27091 makes use of this feature.
     29== See also ==
     30* '''[[Help/RemoteControlCommands]]''' - the list of commands
    28531
    28632----