Imagery Offset Database/API

From OpenStreetMap Wiki
Jump to: navigation, search
Available languages — Imagery Offset Database/API
· Afrikaans · Alemannisch · aragonés · asturianu · azərbaycanca · Bahasa Indonesia · Bahasa Melayu · Bân-lâm-gú · Basa Jawa · Baso Minangkabau · bosanski · brezhoneg · català · čeština · dansk · Deutsch · eesti · English · español · Esperanto · estremeñu · euskara · français · Frysk · Gaeilge · Gàidhlig · galego · Hausa · hrvatski · Igbo · interlingua · Interlingue · isiXhosa · isiZulu · íslenska · italiano · Kiswahili · Kreyòl ayisyen · kréyòl gwadloupéyen · Kurdî · latviešu · Lëtzebuergesch · lietuvių · magyar · Malagasy · Malti · Nederlands · Nedersaksies · norsk bokmål · norsk nynorsk · occitan · Oromoo · oʻzbekcha/ўзбекча · Plattdüütsch · polski · português · português do Brasil · română · shqip · slovenčina · slovenščina · Soomaaliga · suomi · svenska · Tiếng Việt · Türkçe · Vahcuengh · vèneto · Wolof · Yorùbá · Zazaki · српски / srpski · беларуская · български · қазақша · македонски · монгол · русский · тоҷикӣ · українська · Ελληνικά · Հայերեն · ქართული · नेपाली · मराठी · हिन्दी · অসমীয়া · বাংলা · ਪੰਜਾਬੀ · ગુજરાતી · ଓଡ଼ିଆ · தமிழ் · తెలుగు · ಕನ್ನಡ · മലയാളം · සිංහල · ไทย · မြန်မာဘာသာ · ລາວ · ភាសាខ្មែរ · ⵜⴰⵎⴰⵣⵉⵖⵜ · አማርኛ · 한국어 · 日本語 · 中文(简体)‎ · 吴语 · 粵語 · 中文(繁體)‎ · ייִדיש · עברית · اردو · العربية · پښتو · سنڌي · فارسی · ދިވެހިބަސް

API server is located at http://offsets.textual.ru/. It is managed by User:Zverik, his contacts are listed on his wiki page.

Formats and Messages

By default responses are in XML, but you can add a parameter format=json to get data in JSON. CORS is enabled, but you can use JSONP by specifying a function name in jsonp parameter.

Error messages look like this:

<?xml version="1.0" encoding="utf-8" ?>
<imagery-offsets>
  <error>The unthinkable happened.</error>
</imagery-offsets>

Or like this:

{ "error" : "The unthinkable happened." }

Successful operations use "message" key in their responses instead of "error".

Imagery Identifier

An imagery parameter value is constructed in three ways, depending on imagery type. This algorithm has been tested on imagery lists used by major editors. See reference implementation in JOSM plugin source. Firstly you have to determine imagery type. TMS steps apply to WMS layers, but not vice-versa.

TMS

Protocol and variable URL parts like /{zoom}, /{y}.jpg (yes, along with an extension and a forward slash) are removed:

http://tile.openstreetmap.org/{zoom}/{x}/{y}.png
-> tile.openstreetmap.org
http://mapproxy.sosm.ch:8080/tiles/sogis2007/EPSG900913/$z/$x/$y.png?origin=nw
-> mapproxy.sosm.ch:8080/tiles/sogis2007/EPSG900913?origin=nw

All variable URL parts are removed. If they leave ".." or a dot as a first characted, those should be also removed.

http://oatile{switch:1,2,3,4}.mqcdn.com/tiles/1.0.0/sat/{zoom}/{x}/{y}.png
-> oatile.mqcdn.com/tiles/1.0.0/sat
http://{switch:a,b,c,d}.tile.osm-tools.org/osm_then/{zoom}/{x}/{y}.png
-> tile.osm-tools.org/osm_then

All query parameters which have variable parts are removed. Other parameters are sorted alphabetically, keys coverted to lower case:

http://maps.kosmosnimki.ru/TileService.ashx?Request=gettile&layerName=19195FD1&apikey=FAIL&crs=epsg:3857&z={zoom}&x={x}&y={y}
-> maps.kosmosnimki.ru/TileService.ashx?apikey=FAIL&crs=epsg:3857&layername=19195FD1&request=gettile

An example of processing Bing imagery quadtiles URL. Note that this imagery should be identified by a keyword "bing" (see #Dictionary). Parameters are not removed, because there is no way of knowing if they affect the tiles.

http://ecn.t${0|1|2|3}.tiles.virtualearth.net/tiles/a$quadkey.jpeg?g=587&mkt=en-gb&n=z
-> ecn.t.tiles.virtualearth.net/tiles/a?g=587&mkt=en-gb&n=z

WMS

Protocol is removed, also removed are srs (it is assumed to be EPSG:4326 for the database), width, height, bbox, service, request, version, format, styles, transparent. Other parameters are included in lower case alphabetically:

http://wms.craig.fr/osm?service=wms&request=getmap&version=1.1.1&layers=auvergne&format=image/jpeg
&SRS={proj}&WIDTH={width}&HEIGHT={height}&BBOX={bbox}
-> wms.craig.fr/osm?layers=auvergne

http://sit.provincia.lodi.it/mapserver/mapserv.exe?map=ortofoto_wgs84.map&SERVICE=WMS&VERSION=1.1.1
&REQUEST=GetMap&SRS={proj}&LAYERS=Terraitaly%20Ortofoto%202007&STYLES=%2C%2C&FORMAT=image/png&TRANSPARENT=TRUE
&WIDTH={width}&HEIGHT={height}&BBOX={bbox}
-> sit.provincia.lodi.it/mapserver/mapserv.exe?layers=Terraitaly%20Ortofoto%202007&map=ortofoto_wgs84.map

Dictionary

Some widespread imagery, e.g. "Bing", is identified by keywords. Such words can include only symbols in [a-z0-9_] and should be documented on this wiki page.

Getting an Offsets List

/get?lat=...&lon=...&imagery=...&radius=...

Only coordinates are required: latitude (lat) and longitude (lon) in decimal degrees, WGS-84 (EPSG:4326) projection. Radius specified the search radius in kilometers: 10 by default, 40 maximum (depends on server settings). Imagery parameter is described above.

An example of a response:

<?xml version="1.0" encoding="utf-8" ?>
<imagery-offsets timestamp="2013-03-21T18:21:33+0400">
  <offset id="57" lat="35.168" lon="59.93">
    <author>fserges</author>
    <description>Saint-Petersburg city centre: every island, from Neva River to Obvodny Channel</description>
    <date>2012-11-03</date>
    <imagery minzoom="10" maxzoom="20">bing</imagery>
    <imagery-position lat="35.1674" lon="59.93032" />
  </offset>
  <calibration id="999" lat="35.01923" lon="60.12341" deprecated="yes">
    <author>Zverik</author>
    <description>An intersection with markings, flat land around, the offset works for 20-30 km</description>
    <date>2012-02-21</date>
    <deprecated>
      <author>Dinamik</author>
      <reason>No intersection anymore</reason>
      <date>2013-03-19</date>
    </deprecated>
    <geometry>
      <node lat="35.01923" lon="60.12341" />
    </geometry>
  </calibration>
</imagery-offsets>

The same in JSON:

[
  {
    "type" : "meta",
    "timestamp" : "2013-03-21T18:21:33+0400"
  },
  {
    "type" : "offset",
    "id" : 57,
    "lat" : 35.168,
    "lon" : 59.93,
    "author" : "fserges",
    "description" : "Saint-Petersburg city centre: every island, from Neva River to Obvodny Channel",
    "date" : "2012-11-03",
    "imagery" : "bing",
    "min-zoom" : 10,
    "max-zoom" : 20,
    "imlat" : 35.1674,
    "imlon" : 59.93032
  },
  {
    "type" : "calibration",
    "id" : 999,
    "lat" : 35.01923,
    "lon" : 60.12341,
    "author" : "Zverik",
    "description" : "An intersection with markings, flat land around, the offset works for 20-30 km",
    "date" : "2012-02-21",
    "deprecated" : {
      "author" : "Dinamik",
      "reason" : "No intersection anymore",
      "date" : "2013-03-19"
    },
    "geometry" : [[60.12341, 35.01923]]
  }
]

Registering an Imagery Offset

/store?lat=...&lon=...&author=...&description=...&imagery=...&imlat=...&imlon=...

Parameters as defined as follows:

Parameter Value Description
lat, lon decimal degrees Point coordinates, for which the imagery offset was calculated.
author string in utf-8, up to 100 characters OSM nickname of a user uploading the offset.
description string in utf-8, 3 to 100 characters Description of an area and conditions for using this offset.
imagery string in utf-8 Imagery identifier.
imlat, imlon decimal degrees Location of a (lat, lon) point on the imagery.

Registering a Calibration Geometry

/store?author=...&description=...&geometry=...

Geometry parameter contains a comma-separated list of geometry nodes: lon1+lat1,lon2+lat2,lon3+lat3,lon1+lat1. Longitude and latitude are separated by a space (url-encoded into "+"). For a closed area the last node should be equal to the first one. For a point there's only one node. Note that there are no lat and lon parameters in the query string: those are calculated as an arithmetic mean of all coordinates.

Deprecating an Offset

/deprecate?id=...&author=...&reason=...

Offset identifiers are included in /get responses, reason parameter has the same restrictions as the description one for registering an offset.

Notifying Moderators

/report?id=...&reason=...

By reporting an offset it's flagged for moderators. Usual deletions are users' business, but if someone added a thousand fake offsets, moderators can easily fix it.

Downloads

The whole database is archived every six hours into http://offsets.textual.ru/download/ directory. Latest extracts have the fixed address: XML, JSON. All files are gzipped. In browsers that support gzip transfer encoding, http://offsets.textual.ru/all?format=json URL can be used in scripts to download data in JSON format.