[OpenStreetMap talk-lu] OSM database interface

Loll Loll78 at gmx.net
Wed Dec 5 19:26:27 GMT 2012


Hi

I do not know if it's possible to make/program, but here one idea. It 
would be great if one could use this data interface not only with a 
bounding box but also with other limits like administrative boundaries 
(districts, canton, communes).

CU
Laurent

Frank Broniewski said the following on 05/12/2012 08:54:
> Just a few working examples for you to try out.
>
> http://www.gis-hosting.lu/osm2web/export/points/amenity/restaurant.geojson?bbox=70503,69758,84957,80518&srid=2169 
>
> all restaurants in Luxembourg city
>
> http://www.gis-hosting.lu/osm2web/export/lines/waterway/river.geojson?bbox=70503,69758,84957,80518&srid=2169 
>
> rivers in Luxembourg city
>
> http://www.gis-hosting.lu/osm2web/export/polygons/leisure/park.geojson?bbox=70503,69758,84957,80518&srid=2169 
>
> parks in Luxembourg city
>
> I guess this might help trying things out ;-)
>
> Frank
>
>
>
>
>
> Am 2012-12-04 08:55, schrieb Frank Broniewski:
>> Hi all,
>>
>> I've developed an read-only interface to our OSM world database and I
>> want to contribute this to the community in order to give something 
>> back.
>>
>> It's a simple interface, as you can query features by key=value or by
>> OSM id. There're plans for a query language which allows broader queries
>> but I haven't started yet. Where're using the interface in our
>> OpenLayers Webapps and it's easy to integrate the URL as a Layer in
>> OpenLayers. Several outputformats are supported, namely GeoJSON, GML,
>> KML and GPX.
>>
>> Things are best explained by example:
>>
>> Query for restaurants:
>> http://www.gis-hosting.lu/osm2web/export/points/amenity/restaurant.geojson 
>>
>> Query for motorways:
>> http://www.gis-hosting.lu/osm2web/export/lines/highway/motorway.geojson
>> Query for restaurants:
>> http://www.gis-hosting.lu/osm2web/export/polygons/landuse/forest.geojson
>>
>> ... you get the idea: http://www.gis-hosting.lu/osm2web/export is a
>> fixed part of the URL, the next part tells about the geometry type you
>> want to retrieve, and the next two parts are the well known key=value
>> combinations from the map features page in the OSM wiki. The file
>> extension after the value part tells what kind of format you want to
>> retrieve. Simply add any of the above mentioned output formats in lower
>> case as file extension.
>>
>> A mandatory parameter is a bounding box (bbox=minx,miny,maxx,maxy) in
>> order to limit the region of the query. At the moment I only check if
>> the parameter is set, but I don't check the size. So you could go ahead
>> and download all restaurants in the world -  but I *strongly* discourage
>> that. So please keep your bounding box small. Downloading all
>> restaurants in Luxembourg isn't a deal though ...
>>
>> There's one more thing I'd like to mention. We support all coordinate
>> systems in the well known Proj4 database. So if you want LUREF
>> coordinates, pass srid=2169 as an additional parameter. As a convenience
>> feature, the bounding box needs to have the same CRS as the srid. The
>> default srid is 3857, which is also the srid for the databases native
>> CRS. So you can pass in the the srid as an additional query param to
>> OpenLayers, add the BBOX Strategy and you're ready to go:
>>
>> var layer = new OpenLayers.Layer.Vector(
>>      'Restaurants in LUREF',
>>      {
>>          'strategies': [
>>              new OpenLayers.Strategy.BBOX()
>>          ],
>>          'protocol': new OpenLayers.Protocol.HTTP({
>>              'url':
>> 'http://www.gis-hosting.lu/osm2web/export/points/amenity/restaurant.geojson', 
>>
>>
>>              'format': new OpenLayers.Format.GeoJSON(),
>>              'params': { 'srid': 2169 }
>>          })
>>      }
>> );
>> You probably need to set OpenLayers.ProxyHost [2] in order to use the
>> layer like this
>>
>> The other URL I implemented takes a geometry type - any of points,
>> lines, polygons - and an OSM id as parameter and returns exactly one
>> feature.
>> http://www.gis-hosting.lu/osm2web/export/points/id/1887429277.gpx for
>> example is a hotel in Cape Verde. This URL doesn't take any additional
>> parameters and returns the data always in WGS84 coordinate reference
>> system.
>>
>> You'll get the full osm2pgsql schema, that means probably a lot of empty
>> values in your attributes. But that's difficult to change right now. In
>> the future I want to enhance the application further. The most important
>> thing for me right now is a enhanced query language and SRID/EPSG
>> support for the export by OSM id, but I don't have a timeline set up. I
>> also plan on caching features retrieved from the database in order to
>> speed up the deliverance through the web.
>>
>> There's a bitbucket repo at [1] where any changes should show up.
>>
>> I hope you'll find this project useful. Any feedback, positive or
>> negative, or any questions are welcome.
>>
>>
>> Thanks for reading the email up to the end :-),
>>
>> Frank
>>
>>
>>
>>
>>
>> [1] https://bitbucket.org/metrico/osm2web
>> [2]
>> http://trac.osgeo.org/openlayers/wiki/FrequentlyAskedQuestions#ProxyHost
>
>




More information about the talk-lu mailing list