Query-to-map/first version

From OpenStreetMap Wiki
Jump to navigation Jump to search
Attention: This is the documentation of the first Query-to-map version which used XAPI. 
The actual version can be found under Query-to-map. --Kolossos 11:08, 20 October 2009 (UTC) 

Query-to-map is a script to show the results of an OSM database query in a map. The script is designed to work in real-time, so it should be used with queries returning only relatively small results.

How it works.

You can find the script here:

Or example queries where you only need to press the submit button:

Without parameters, the script shows a simple HTML form.

If the script gets an submit request it does the following things:

  1. It generates a query to OSMXAPI. This query can contain a bounding box and tags in key=value format for nodes or ways. The parameter of key and value can either by "*". Queries of both (nodes and ways) are at the moment not possible. For more info on useful parameters read Map Features.
    Attention: It is the job of the user to take care that the query doesn't give a too big result (The limit of the script is a 16Mbyte osm-file, but the size of the result should be much smaller). So please keep this in mind.
  2. The answer of the API is an OSM file. This goes through an XSLT-processor to produce a KML-file. If it is a way-query the XSL-file is osm2kml.xsl, for a node-query the XSL-file is osm2kmlPOI.xsl.
  3. The kml-file will be compressed using zip and stored as a kmz file in a cache.
  4. The script can generate 3 different outputs based (at the moment) on technology of Google, but KML is a OGC-standard, so it should be possible to later also develop an Open Source solution. First output option has the name "osm", it uses the tiles of OpenStreetMap through the Google Maps API. It based on a script of User:Joto. The next output option "gm" calls Google Maps. The last output is "kml" where the script delivers a kml file for Google Earth or something else. For large results Google Earth is much faster than Google Maps.

We hope you can accept that this procedure takes some time.


The project should show that with the free datas of OSM is more possible than with closed systems like Google Maps. The project can used for education, because the course of a river can show very clearly.

The query-to-map project should show that OSM is more than drawing a wonderful map, it's also the creating of a database. Query-to-map should help to find bugs in the map, so if a part of way has no name or the false name you can see it and you can check if all object of a map-feature are in OSM. So are all cinemas, fountains and so on of your city in OSM?

Server (Wikipedia)

Currently this script is running on Wikimedias Toolserver. The basic idea was to use the data from OpenStreetMap to describe geographical Wikipedia-objects which are not so good to show by only one point which is the scope of Wikipedia:WikiProject Geographical coordinates. At the moment it seems more useful to concentrate the usage and benefit to Openstreetmap to start with.

Source code


on the API side

  • The stability of the OSMXAPI is the main problem in the moment. You can control that the API runs here.
  • It would be good to integrate a time-out.
  • Make queries with more than one key-value pair possible. Find rivers with a special name or Cinemas with the name "Casablanca" and so on.
  • Stability and performance (if a lot of wikipedia-queries will come)


  • clean-up, reduce the size
  • show all key-value-pairs for a node in the description field
  • show names for paths
  • connect all paths which have the same endpoints to one line string, perhaps also with an additional script.


  • prove the license tags
  • find perhaps a better contrast on OSM tiles
  • support of openlayers as opensource solution. The names of placemarks should be visible, as balloon or directly.


on the OSM datas

  • The requirements of data base queries seem to be other than to draw a map. For instances, if a street ref=B170 going together with an other street ref=B6 than the tag is normally ref=B170/B6 for the indexing in the database it would be better to use two tags ref=B170 and ref=B6.

integration in the wiki

  • create a template to link to the script from the wiki (OSM-Wiki, Wikipedia or something else)


The OSMhack is an other script to generates the queries from all map features for an area and call the Query-to-map script with one mouse click. You can call the OSMhack via Template:Place or i.e for London (inner-area) by:

The content of this page based on User:Kolossos/features-page and can edit in the wiki. you can also get the sourcecode of the script.

So it'very easy to prove that all cinemas, fountains, etc. of a city have a OSM entry. You can also see the complexity of the powerline system of your town or find a place to do sports. ...

Creators / Contact

If you have questions or ideas please use the discussion-page. If you want to participate the project you are welcome, especially as XSLT expert.

See Also