Query-to-map

From OpenStreetMap Wiki
Jump to navigation Jump to search

Attention: The documentation of the first version with XAPI and google maps can be found under: Query-to-map/first version.

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

As alternative to a map you can get also a alphabetic list.

The query must contain a bbox or a coordinate of the center. You can request points, lines and areas object types. It's possible to ask for a name, a ref, a key or key/value pair.

So the following script give you a interactive street list for the city Dresden:

It's also possible to get i.e. a motorways of a city in a map:

Beside the lines you can also get point and areas. The following map shows all churches of Dresden:

This example contains also the string "info" in parameter "types", so you get also info-ballons for all objects.

Attention: It is the job of the user to take care that the query doesn't give a too big result. So please keep the bbox so small as possible. We hope you can accept that this procedure takes sometimes some time.

If the script gets a request it does the following things:

  1. It generates a sql-command to the PostGIS database which is used for mapnik on ptolemy.toolserver.org. This query contain a bounding box and can contain, a name, a key, a value and a types-parameter.

The parameter of name, key and value can either by "*". For more info on useful parameters read Map Features.

  1. In script osm-to-kml.php the query goes directly to the post GIS database and delivers a kml-file. This kml file can also be useful in Google Earth. (For large results Google Earth is much faster than Google Maps.) Try it as network link in Google Earth:Network-Link-OSM-Mapfeatures.kml.
  • The job of queryinmap.php is it to put the kml-result into a Openlayers map.
  • The generating of the lists is part of index.php.
  • The both scripts queryinmap.php and index.php are frames inside the featurelist.php script.

Restrictions

  • There are fixed limits of 10,000 objects for a list and 1,000 objects for a map.
  • The script can only support map features of OSM which are in the database.We have now a postgresql hstore, so all key/value pairs are possible also for huge areas if the key/value-combinations are rare.
  • Data is in the moment 3 months old (October 2009). Data is up-to-date

Objectives

The project should show that with free data of OSM is more possible than with closed systems like Google Maps. The project can used for education.

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 Toolforge (ptolemy). 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 perhaps more useful to concentrate the usage and benefit to Openstreetmap to start with.

Source code

To-Do

on the API side

  • Stability and performance (if a lot of wikipedia-queries will come)
  • Caching
  • Queries with a huge bounding box seems to be a problem.

output

  • find perhaps a better contrast on OSM tiles

...

on the OSM data

  • The requirements of database 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)
    • Template:Osm-query-name works already fine. Template:Osm-query was designed for the first versions of Query-to-map and was designed to work together with XAPI. The now used mapnik-database is incompatible and it was necessary to create a new template Template:Osm-query2. If it works fine as well in the next step all links have to transfered to the new one.
  • To bring this project inside the wikikpedia it would be important to support this feature also for the rendering of static maps. It should be so stable that it could run on Ptolemy (productive system).

Map Features Script

The Map Features Script is an 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:

You have the choice between the list and the map with this features.

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. ...

Interface to generate queries

A tiny HTML interface for those who are not comfortable with generating queries manually. Demo, Project

Creators / Contact

If you have questions or ideas please use the discussion-page. If you want to participate the project you are very welcome.

See also