Changes between Version 26 and Version 48 of Help/Preferences/RemoteControl


Ignore:
Timestamp:
(multiple changes)
Author:
(multiple changes)
Comment:
(multiple changes)

Legend:

Unmodified
Added
Removed
Modified
  • Help/Preferences/RemoteControl

    v26 v48  
    1 [[TranslatedPages(outdated=This page is missing some new options and the list of commands is probably better situated on a separate page.)]]
     1[[TranslatedPages(outdated=This page is incomplete. Options description is missing.)]]
    22= Preferences > Remote Control =
    33
    4 [[Image(source:trunk/images/preferences/remotecontrol.png)]] **Settings for the remote control feature.**
     4[[JOSMImage(preferences/remotecontrol,middle,,48,link=,margin-right=20)]] **Settings for the remote control feature**
    55
    6 Remote Control allows JOSM to be controlled from other applications, e.g. from a web browser, by opening a listening TCP port (8111) on localhost where it accepts commands.[[BR]]
    7 Since JOSM version 6941 it is also listening for HTTPS on port 8112.[[BR]]
    8 **Note**: Due to security reasons this feature is disabled in the default settings and has to be enabled manually.
     6Remote Control allows JOSM to be controlled from other applications, e.g. from a web browser, by opening a listening TCP port (8111) on localhost where it accepts commands. \\
     7From JOSM version r6941 through r15469 it was also listening for HTTPS on port 8112. \\
     8**Note**: Due to security reasons the Remote Control is disabled in the default settings and has to be enabled manually.
    99
    10 If you access the a website via HTTPS and use the Remote Control it will also use HTTPS to control your JOSM. If it does not work, note that your browser, security addons/plugins and firewalls may block this access (you may be able to whitelist/allow it inside these tools) – check your logs. In addition you may need to tell your browser to accept the self-signed JOSM HTTPS certificate. More details on some of these issues: [https://help.openstreetmap.org/questions/2208/how-do-i-enable-the-remote-control-in-josm How do I enable the "remote control" in JOSM?] (on the OSM help site).
     10For JOSM version r6941 through r15469, if you access a website via HTTPS and use the Remote Control it will also use HTTPS to control your JOSM. If it does not work, note that your browser, security addons/plugins and firewalls may block this access (you may be able to whitelist/allow it inside these tools) – check your logs. In addition you may need to tell your browser to accept the self-signed JOSM HTTPS certificate. More details on some of these issues: [https://help.openstreetmap.org/questions/2208/how-do-i-enable-the-remote-control-in-josm How do I enable the "remote control" in JOSM?] (on the OSM help site).
    1111
     12After JOSM r15469, websites cannot use HTTPS to control JOSM. Safari is the only major browser known to have issues with remote control commands on HTTPS websites.
    1213
    13 The following control options are available:
     14**See the list of [wikitr:/Help/RemoteControlCommands Remote control commands].**
    1415
    15 [[Image(RemoteControl6767.png)]]
    16 
    17 
    18 * **Enable remote control** allows to switch the remote control feature on or off.
    19  * **Load data from API**
    20  * **Import data from URL**
    21  * **Load imagery layers**
    22  * **Change the selection**
    23  * **Change the viewport**
    24  * **Create new objects**
    25  * **Read protocol version**
    26 
    27 * **Confirm all Remote Control actions manually**
    28 
    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 || `left` || R || minimum longitude ||
    41 || `right` || R || maximum longitude ||
    42 || `bottom` || R || minimum latitude ||
    43 || `top` || R || maximum latitude ||
    44 || `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}}} ||
    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 || `new_layer` || O || If true, downloads to a new layer ||
    47 
    48 ==== Example ====
    49 
    50 Start JOSM (don't forget to enable the !RemoteControl feature), then click on:
    51 
    52 [http://127.0.0.1:8111/load_and_zoom?left=8.19&right=8.20&top=48.605&bottom=48.590&select=node413602999]
    53 
    54 JOSM should now load an area in the German Schwarzwald and have the specified node selected.
    55 
    56 === {{{zoom}}} ===
    57 Instructs JOSM to zoom to the specified area and optionally select one or more objects.
    58 {{{
    59 GET /zoom?left=...&right=...&top=...&bottom=...&select=object[,object...]
    60 }}}
    61 Accepts the same parameters as the {{{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.
    62 
    63 **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.
    64 === {{{import}}} ===
    65 Instructs JOSM to download the specified OSM file and add it to the current data set.
    66 {{{
    67 GET /import?url=...
    68 }}}
    69 
    70 === {{{load_data}}} ===
    71 (since version 1.6)
    72 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.
    73 
    74 {{{
    75 GET /load_data?new_layer=(true/false)&layer_name=...&mime_type=...&data=...
    76 }}}
    77 where
    78 ||= **Parameter** =||= **Required/Optional** =||= **Meaning** =||
    79 || `new_layer` || O || Chose to load the data in a new layer ||
    80 || `layer_name` || O || Only valid when the data is loaded in a new layer; Gives JOSM a hint on how to name the layer ||
    81 || `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 ||
    82 || `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. ||
    83 
    84 === {{{imagery}}} ===
    85 Instructs JOSM to add an imagery (WMS/TMS) layer.
    86 {{{
    87 GET /imagery?title=...&type=...&url=...
    88 }}}
    89 where
    90 ||= **Parameter** =||= **Required/Optional** =||= **Meaning** =||
    91 || `title` || O || The display name of the layer ||
    92 || `type` || O || Type of the layer. Possible values are `wms`, `tms` and `bing` [[BR]] (since !RemoteControl Version 1.3) ||
    93 || `min_zoom` || O || The minimum zoom level [[BR]] (since !RemoteControl Version 1.4) ||
    94 || `max_zoom` || O || The maximum zoom level. For higher scales, the images of the maximum level is enlarged [[BR]] (since !RemoteControl Version 1.4) ||
    95 || `url` || R || The Request URL, including patterns. Must be the last parameter, everything after "&url=" is interpreted as URL, even if it contains "&" characters.  ||
    96 
    97 ==== Examples ====
    98 * TMS layer "osm" {{{http://tile.openstreetmap.org/{zoom}/{x}/{y}.png}}}
    99 
    100 [http://localhost:8111/imagery?title=osm&type=tms&url=http://tile.openstreetmap.org/%7Bzoom%7D/%7Bx%7D/%7By%7D.png]
    101 
    102 * WMS layer "landsat" {{{http://irs.gis-lab.info/?layers=landsat&SRS={proj}&WIDTH={width}&HEIGHT={height}&BBOX={bbox} }}}
    103 [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]
    104 
    105 === {{{load_object}}} ===
    106 
    107 Instructs JOSM to download objects with a given id.
    108 {{{
    109 GET /load_object?new_layer=true|false&objects=...
    110 }}}
    111 where
    112 ||= **Parameter** =||= **Required/Optional** =||= **Meaning** =||
    113 || `objects` || R || Comma separated list of object ids, e.g. "{{{n1234,n1235,w84,r958493}}}" ||
    114 || `new_layer` || O || If true, downloads to a new layer ||
    115 || `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]. ||
    116 || `referrers` || O || If true, downloads referrers of the object as well. I.e. parent relations, and for nodes, additionally, parent ways. (since r6782) ||
    117 
    118 ==== Example ====
    119 
    120 [http://localhost:8111/load_object?new_layer=true&objects=w106159509]
    121 
    122 === {{{add_node}}} ===
    123 
    124 Instructs JOSM to create a new node at the given coordinates.
    125 
    126 **Note**: This action requires the permission ''Create new objects'' which is disabled by default.
    127 
    128 {{{
    129 GET /add_node?lon=...&lat=...
    130 }}}
    131 where
    132 ||= **Parameter** =||= **Required/Optional** =||= **Meaning** =||
    133 || `lon` || R || The longitude of the node ||
    134 || `lat` || R || The latitude of the node ||
    135 || `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]. ||
    136 
    137 ==== Example ====
    138 http://localhost:8111/add_node?lon=13.3&lat=53.2
    139 
    140 === {{{add_way}}} ===
    141 
    142 Instructs JOSM to create a new way with new way nodes at given coordinates.
    143 
    144 **Note**: This action requires the permission ''Create new objects'' which is disabled by default.
    145 
    146 {{{
    147 GET /add_way?way=lat1,lon1;lat2,lon2;...
    148 }}}
    149 where
    150 ||= **Parameter** =||= **Required/Optional** =||= **Meaning** =||
    151 || `way` || R || Pairs of latitude, longitude coordinates separated by semicolon. ||
    152 || `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]. ||
    153 
    154 ==== Example ====
    155 
    156 http://localhost:8111/add_way?way=53.2,13.3;53.3,13.3;53.3,13.2
    157 
    158 
    159 === {{{version}}} ===
    160 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.
    161 {{{
    162 GET /version[?jsonp=callback]
    163 }}}
    164 
    165 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.
    166 
    167 A typical output looks like this:
    168 {{{
    169 #!js
    170 {
    171    "protocolversion": {
    172       "major": 1,
    173       "minor": 0
    174    },
    175    "application": "JOSM RemoteControl"
    176 }
    177 }}}
    178 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.
    179 
    180 Following 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 
    186 function 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 
    191 var url = "http://127.0.0.1:8111/version";
    192 var useFallback = false;
    193 // currently FF3.5, Safari 4 and IE8 implement CORS
    194 if (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 }
    219 else {
    220    // no XMLHttpRequest available
    221    useFallback = true;
    222 }
    223 
    224 if (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
    239 Try this example: 
    240 [http://localhost:8111/load_and_zoom?addtags=wikipedia:de=Weiße_Gasse|maxspeed=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 
    243 The user must review the tags and the selection before the tags are applied to the selected objects.
    244 If the tag exists on some objects, it will be can be replaced.
    245 
    246 Since 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|name=%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:de=|maxspeed=&select=way23071688,way23076176,way23076177,&left=13.739727546842&right=13.740890970188&top=51.049987191025&bottom=51.048466954325].
    252 
    253 === Other commands ===
    254 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.
    255 
    256 Reverter plugin since version 27091 makes use of this feature.
    257 
    258 == See also ==
    259 [osmwiki:JOSM/Plugins/RemoteControl Old JOSM Remote-Plugin page at OSM wiki]
     16[[Image(PreferencesRemoteControl.2.png​,link=,800)]]
    26017
    26118----
    262 Back to [wiki:Help/Action/Preferences Preferences][[Br]]
    263 Back to [wiki:/Help Main Help]
     19Back to [wikitr:/Help/Action/Preferences Preferences] \\
     20Back to [wikitr:/Help Main Help]