Changes between Initial Version and Version 1 of Help/RemoteControlCommands


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

--

Legend:

Unmodified
Added
Removed
Modified
  • Help/RemoteControlCommands

    v1 v1  
     1== List of Commands ==
     2
     3A complete list of commands and mandatory/optional parameters is shown at http://127.0.0.1:8111/ (when JOSM is running).
     4
     5=== {{{load_and_zoom}}} ===
     6Instructs JOSM to download a bounding box from the API, zoom to the downloaded area and optionally select one or more objects.
     7{{{
     8GET /load_and_zoom?left=...&right=...&top=...&bottom=...&select=object[,object...]
     9}}}
     10where
     11||= **Parameter** =||= **Required/Optional** =||= **Meaning** =||
     12|| `bottom` || R || Minimum latitude ||
     13|| `top` || R || Maximum latitude ||
     14|| `left` || R || Minimum longitude ||
     15|| `right` || R || Maximum longitude ||
     16|| `new_layer` || O || If '''true''', downloads to a new layer ||
     17|| `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]. ||
     18|| `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}}} ||
     19|| `zoom_mode` || O || '''download''' | '''selection''', defaults to selection ||
     20|| `changeset_comment` || O || Comment of the changeset ||
     21|| `changeset_source` || O || Source of the changeset ||
     22|| `search` || O || Search objects in the current data layer. See [wiki:/Help/Action/Search Search] ||
     23
     24==== Example ====
     25
     26Start JOSM (don't forget to enable the !RemoteControl feature), then click on:
     27
     28[http://127.0.0.1:8111/load_and_zoom?left=8.19&right=8.20&top=48.605&bottom=48.590&select=node413602999]
     29
     30JOSM should now load an area in the German Schwarzwald and have the specified node selected.
     31
     32=== {{{zoom}}} ===
     33Instructs JOSM to zoom to the specified area and optionally select one or more objects.
     34{{{
     35GET /zoom?left=...&right=...&top=...&bottom=...&select=object[,object...]
     36}}}
     37Accepts 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.
     38
     39**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.
     40=== {{{import}}} ===
     41Instructs JOSM to download the specified OSM file and add it to the current data set.
     42{{{
     43GET /import?url=...
     44}}}
     45where
     46||= **Parameter** =||= **Required/Optional** =||= **Meaning** =||
     47|| `url` || R ||  ||
     48|| `new_layer` || O || If '''true''', downloads to a new layer ||
     49
     50=== {{{load_data}}} ===
     51(since version 1.6)
     52Instruct 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.
     53
     54{{{
     55GET /load_data?new_layer=(true/false)&layer_name=...&mime_type=...&data=...
     56}}}
     57where
     58||= **Parameter** =||= **Required/Optional** =||= **Meaning** =||
     59|| `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. ||
     60|| `new_layer` || O || Chose to load the data in a new layer ||
     61|| `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 ||
     62|| `layer_name` || O || Only valid when the data is loaded in a new layer; Gives JOSM a hint on how to name the layer ||
     63
     64=== {{{open_file }}} ===
     65Open a local file in JOSM.
     66
     67{{{
     68GET /open_file?filename=...
     69}}}
     70where
     71||= **Parameter** =||= **Required/Optional** =||= **Meaning** =||
     72|| `filename` || R || The local file to open in JOSM (Ie: /tmp/test.osm) ||
     73
     74
     75=== {{{imagery}}} ===
     76Instructs JOSM to add an imagery (WMS/TMS) layer.
     77{{{
     78GET /imagery?title=...&type=...&url=...
     79}}}
     80where
     81||= **Parameter** =||= **Required/Optional** =||= **Meaning** =||
     82|| `url` || R || The Request URL, including patterns. Must be the last parameter, everything after "&url=" is interpreted as URL, even if it contains "&" characters.  ||
     83|| `title` || O || The display name of the layer ||
     84|| `type` || O || Type of the layer. Possible values are `wms`, `tms` and `bing` [[BR]] (since !RemoteControl Version 1.3) ||
     85|| `cookies` || O ||  ||
     86|| `min_zoom` || O || The minimum zoom level [[BR]] (since !RemoteControl Version 1.4) ||
     87|| `max_zoom` || O || The maximum zoom level. For higher scales, the images of the maximum level is enlarged [[BR]] (since !RemoteControl Version 1.4) ||
     88
     89
     90mandatory parameters: url
     91optional parameters: title, type, cookies, min_zoom, max_zoom
     92
     93==== Examples ====
     94* TMS layer "osm" {{{http://tile.openstreetmap.org/{zoom}/{x}/{y}.png}}}
     95
     96[http://localhost:8111/imagery?title=osm&type=tms&url=http://tile.openstreetmap.org/%7Bzoom%7D/%7Bx%7D/%7By%7D.png]
     97
     98* WMS layer "landsat" {{{http://irs.gis-lab.info/?layers=landsat&SRS={proj}&WIDTH={width}&HEIGHT={height}&BBOX={bbox} }}}
     99[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]
     100
     101=== {{{load_object}}} ===
     102
     103Instructs JOSM to download objects with a given id.
     104{{{
     105GET /load_object?new_layer=true|false&objects=...
     106}}}
     107where
     108||= **Parameter** =||= **Required/Optional** =||= **Meaning** =||
     109|| `objects` || R || Comma separated list of object ids, e.g. "{{{n1234,n1235,w84,r958493}}}" ||
     110|| `new_layer` || O || If '''true''', downloads to a new layer ||
     111|| `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]. ||
     112|| `relation_members` || O || If '''true''', downloads objects members of the relations as well. ||
     113|| `referrers` || O || If '''true''', downloads referrers of the object as well. I.e. parent relations, and for nodes, additionally, parent ways. (since r6782) ||
     114
     115==== Example ====
     116
     117[http://localhost:8111/load_object?new_layer=true&objects=w106159509]
     118
     119=== {{{add_node}}} ===
     120
     121Instructs JOSM to create a new node at the given coordinates.
     122
     123**Note**: This action requires the permission ''Create new objects'' which is disabled by default.
     124
     125{{{
     126GET /add_node?lon=...&lat=...
     127}}}
     128where
     129||= **Parameter** =||= **Required/Optional** =||= **Meaning** =||
     130|| `lon` || R || The longitude of the node ||
     131|| `lat` || R || The latitude of the node ||
     132|| `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]. ||
     133
     134==== Example ====
     135http://localhost:8111/add_node?lon=13.3&lat=53.2
     136
     137=== {{{add_way}}} ===
     138
     139Instructs JOSM to create a new way with new way nodes at given coordinates.
     140
     141**Note**: This action requires the permission ''Create new objects'' which is disabled by default.
     142
     143{{{
     144GET /add_way?way=lat1,lon1;lat2,lon2;...
     145}}}
     146where
     147||= **Parameter** =||= **Required/Optional** =||= **Meaning** =||
     148|| `way` || R || Pairs of latitude, longitude coordinates separated by semicolon. ||
     149|| `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]. ||
     150
     151==== Example ====
     152
     153http://localhost:8111/add_way?way=53.2,13.3;53.3,13.3;53.3,13.2
     154
     155
     156=== {{{version}}} ===
     157This 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.
     158{{{
     159GET /version[?jsonp=callback]
     160}}}
     161where
     162||= **Parameter** =||= **Required/Optional** =||= **Meaning** =||
     163|| `jsonp` || O|| Jsonp callback for older browsers not implementing ​Cross-Origin Resource Sharing (CORS) ||
     164
     165The 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.
     166
     167A typical output looks like this:
     168{{{
     169#!js
     170{
     171   "protocolversion": {
     172      "major": 1,
     173      "minor": 0
     174   },
     175   "application": "JOSM RemoteControl"
     176}
     177}}}
     178For 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.
     179
     180Following is some sample code that checks for CORS capabilities and uses [http://en.wikipedia.org/wiki/JSONP JSONP] as a fallback solution.
     181{{{
     182#!js
     183// in addition to the CC-BY-SA of the wiki feel free to use the following source for any purpose without restrictions (PD)
     184// credits and additions appreciated: https://wiki.openstreetmap.org/wiki/User:Stephankn
     185
     186function checkJOSM(version){
     187   alert(version.application + " uses protocol version " + version.protocolversion.major + "." + version.protocolversion.minor);
     188   // do something useful, maybe showing edit button
     189}
     190
     191var url = "http://127.0.0.1:8111/version";
     192var useFallback = false;
     193// currently FF3.5, Safari 4 and IE8 implement CORS
     194if (XMLHttpRequest) {
     195   var request = new XMLHttpRequest();
     196   if ("withCredentials" in request) {
     197      request.open('GET', url, true);
     198      request.onreadystatechange = function(){
     199         if (request.readyState != 4) {
     200            return;
     201         }
     202         if (request.status == 200) {
     203            checkJOSM(eval('(' + request.responseText + ')'));
     204         }
     205      };
     206      request.send();
     207   }
     208   else if (XDomainRequest) {
     209      var xdr = new XDomainRequest();
     210      xdr.open("get", url);
     211      xdr.onload = function(){
     212         checkJOSM(eval('(' + xdr.responseText + ')'));
     213      };
     214      xdr.send();
     215   } else {
     216      useFallback = true;
     217   }
     218}
     219else {
     220   // no XMLHttpRequest available
     221   useFallback = true;
     222}
     223
     224if (useFallback) {
     225   // Use legacy jsonp call
     226   var s = document.createElement('script');
     227   s.src = url + '?jsonp=checkJOSM';
     228   s.type = 'text/javascript';
     229   
     230   if (document.getElementsByTagName('head').length > 0) {
     231      document.getElementsByTagName('head')[0].appendChild(s);
     232   }
     233   
     234}
     235}}}
     236
     237
     238=== Adding, changing or deleting tags === #addtags
     239Try this example: 
     240[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].
     241(Works also with the zoom-command)
     242
     243The user must review the tags and the selection before the tags are applied to the selected objects.
     244If the tag exists on some objects, it will be can be replaced.
     245
     246Since protocol version 1.5
     247- `add_node` and `add_way` commands support `addtags` parameter
     248- It is possible to use `=` character in value and all leading/trailing spaces are trimmed.
     249[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==")
     250- If empty value is found, tag is to be deleted from objects (checkbox-confirmation is needed)
     251[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].
     252
     253=== Other commands ===
     254Remotecontrol 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.
     255
     256Reverter plugin since version 27091 makes use of this feature.
     257
     258----
     259
     260Back to [[Help/Preferences/RemoteControl]][[br]]
     261Back to [[Help/Preferences]][[br]]
     262Back to [[Help]]