Diskussion:PostGIS Terminal: Unterschied zwischen den Versionen
Stefan (Diskussion | Beiträge) (→Implementations-Details) |
Stefan (Diskussion | Beiträge) |
||
Zeile 67: | Zeile 67: | ||
== PostGIS-Terminal Documentation == | == PostGIS-Terminal Documentation == | ||
− | === Database === | + | === Database EOSMDBOne === |
Data comes from [[OpenStreetMap]] and is imported once every early morning using [[Osm2pgsql]]. For more information about the database see [[EOSMDBOne|'Enhanced OpenStreetMap Database One' (EOSMDBOne)]]. | Data comes from [[OpenStreetMap]] and is imported once every early morning using [[Osm2pgsql]]. For more information about the database see [[EOSMDBOne|'Enhanced OpenStreetMap Database One' (EOSMDBOne)]]. | ||
Zeile 112: | Zeile 112: | ||
* Spaces sind in Values auch zugelassen, vgl. node[name=Knie's Kinderzoo] | * Spaces sind in Values auch zugelassen, vgl. node[name=Knie's Kinderzoo] | ||
* das XAPI-to-Map funktioniert auch mit Permalink, z.B. node[amenity=hospital][bbox=-6,50,2,61]?zoom=18&lat=47.223&lon=8.822&layers=B0T | * das XAPI-to-Map funktioniert auch mit Permalink, z.B. node[amenity=hospital][bbox=-6,50,2,61]?zoom=18&lat=47.223&lon=8.822&layers=B0T | ||
− | * Für häufige | + | * Für häufige Abfragen siehe auch die [http://jxapi.openstreetmap.org/xapi/admin/stats JXAPI-Logs] (live!) sowie den [http://fsi.spline.de/osm/xapi-access-23-01-2011.log.bz2 Log-Backup von XAPI] mit unbestätigter Herkunft. |
− | |||
− | |||
− | |||
− | |||
Beispiel (man beachte, dass nicht der '->'- sondern der '@>'-Operator verwendet wird wegen GiST-Index): | Beispiel (man beachte, dass nicht der '->'- sondern der '@>'-Operator verwendet wird wegen GiST-Index): | ||
Zeile 148: | Zeile 144: | ||
=== Security Features === | === Security Features === | ||
− | + | ||
− | + | Siehe auch [[EOSMDBOne]]. | |
− | + | ||
+ | Client (JavaScript) fügt "LIMIT 100" dazu. | ||
DB-Server-Timeout: als Parameter der PostgreSQL-Verbindung in process-query.php (oder als "statement_timeout (60000)" in postgresql.conf); siehe [http://www.postgresql.org/docs/9.0/interactive/runtime-config-client.html] | DB-Server-Timeout: als Parameter der PostgreSQL-Verbindung in process-query.php (oder als "statement_timeout (60000)" in postgresql.conf); siehe [http://www.postgresql.org/docs/9.0/interactive/runtime-config-client.html] | ||
Zeile 161: | Zeile 158: | ||
=== Data Features === | === Data Features === | ||
− | + | Siehe auch [[EOSMDBOne]]. | |
+ | |||
* Webservice indicating database update time and a list of tables => about-db-query.php . ''-- realisiert'' | * Webservice indicating database update time and a list of tables => about-db-query.php . ''-- realisiert'' | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
Version vom 1. September 2011, 10:35 Uhr
Please note here your questions and feedback below. You can also send them directly to Stefan Keller.
Inhaltsverzeichnis
Feature Requests
Query mit gid-Attribut (1): Mit 'Mouse Over' wird der Wer vom Attribut label angezeigt.
Query mit gid-Attribut (2): Mit 'Mouse Click' auf eine Geometrie wird ein Weblink angezeigt, d.h. OpenLayers-Objekte klickbar machen mit Link zu OSM, z.B. http://www.openstreetmap.org/browse/way/82142220
Weitere:
- Data... Next update scheduled on ....
- DB-unabhängig machen! D.h. "Weitere Parameter" (aus config.php) in HTML/Javascript laden.
- DB Zugangsparameter mit Port und Zugangsweise (Text, TSL, SSL) erweitern.
- Besseres Verwalten von Layern, die aus Map und Marker Queries entstanden sind.
- Wie geht das mit Wait-Cursor in OpenLayers???
- Marker Query with attribute 'icon', mit dem man Icons von externen Quellen (url) darstellen kann.
More Queries...
Marker Queries
--- marker query (must have exactly field names lon, lat, title and description): SELECT X(p2.way) AS lon, Y(p2.way) AS lat, 'Briefkasten' AS title, p2.ref AS description FROM planet_osm_polygon p1 JOIN planet_osm_point p2 ON CONTAINS(p1.way, p2.way) WHERE p1.name = 'Uster' AND p2.amenity = 'post_box'
--- Extension with user defined marker icon (attribute 'icon'): SELECT X(p2.way) AS lon, Y(p2.way) AS lat, 'Briefkasten' AS title, p2.ref AS description, 'http://myserver/marker.png' as icon FROM planet_osm_polygon p1 JOIN planet_osm_point p2 ON CONTAINS(p1.way, p2.way) WHERE p1.name = 'Uster' AND p2.amenity = 'post_box'
All Tag-Value-Pairs of OSM data
Kann anstelle mit osm_point auch mit osm_all durchgeführt werden.
-- -- Key-Value Statistics of OSM Data -- Return all key-value-pairs of type 'enum' without some -- types numeric, date/time etc. chosen by hand: -- -- Alternative with separate tag-value: -- SELECT tmp.key as tag, tmp.value as value, count(*)::integer as freq SELECT tmp.key||'='||tmp.value as kvp, count(*)::integer as freq FROM ( SELECT (each(tags)).key as key, (each(tags)).value as value FROM osm_point) as tmp WHERE (trim(value) !~ '^[-]*[0-9,.:\ ]+[m]*$') AND NOT (value ILIKE '%fixme%' OR key ILIKE '%fixme%') AND key NOT LIKE '%:%' AND key NOT LIKE '%description%' AND key NOT LIKE '%comment%' AND key NOT LIKE '%name' AND key NOT LIKE 'uic_%' AND key NOT LIKE '%ref' AND key NOT ILIKE '%fixme%' AND key NOT ILIKE '%todo%' AND key NOT IN ('name','operator','_picture_','_waypoint_','address','alt','is_in','url','website','wikipedia','email', 'converted_by','phone','information','opening_hours','date','time','collection_times','colour','fee', 'population','access','noexit','towards','bus_routes','busline','lines','type','denotation', 'CONTINUE','continue','copyright','stop') GROUP BY tmp.key, tmp.value -- HAVING COUNT(*) > 1 ORDER by key, freq DESC
PostGIS-Terminal Documentation
Database EOSMDBOne
Data comes from OpenStreetMap and is imported once every early morning using Osm2pgsql. For more information about the database see 'Enhanced OpenStreetMap Database One' (EOSMDBOne).
XAPI-to-Map
About
Die XAPI-to-Map-Funktion wandelt Anfragen in der Query-Sprache XAPI nach SQL um, fragt die OSM-Datenbank ab und stellt das Resultat direkt in der Webkarte dar. XAPI-to-Map ist - wie der Name sagt - kein Webservice (Maschine-Maschine) sondern eine Mensch-Maschine-Webapplikation. Die Syntax kennt häufige Requests, bestehend aus einem oder mehrerer Tag/Value-Paar sowie ggf. einer Bounding Box-Angabe. Nicht implementiert ist z.B. 'Union-Filter' (OR) im Key (node[amenity|leisure=golf_course]). Im Gegensatz zu anderen XAPI-Implementationn kann man dafür mehrere Filter-Prädikate angeben (z.B. node[amenity=golf_course]node[leisure=golf_course]).
Notes on the "xapi=..." parameter and the weblink: Special query characters - except A-Z, a-z and " - must be "percent-encoded US-ASCII octet". There are online tools to help out like this one. (see [1]
Some test examples:
Use PostGIS Terminal for <postgisterminal_url>: <postgisterminal_url>?xapi=node[tourism=zoo]</nowiki> <postgisterminal_url>/?xapi=node[amenity=*][bbox=5.943,45.935,10.612,47.731]</nowiki> <postgisterminal_url>/?xapi=node[highway=busstop]</nowiki> <postgisterminal_url>/?xapi=node[amenity=hospital][bbox=-6,50,2,61]?zoom=18&lat=47.223&lon=8.822&layers=B0T</nowiki> <postgisterminal_url>/?xapi=*[seamark:type=signal_station_warning]</nowiki>
Supported syntax elements (Original XAPI-Dokumentation und andere XAPI-Server: Siehe XAPI):
- Abbildung aller Tabellen sowie '*' (siehe Tabellen-Abbildungen unten)
- Equality Filter (1x): way[highway=motorway]
- Wildcard Filter: im Value way[highway=*]
- BBox-Filter (1x): [bbox=left,bottom,right,top]
- 'Union-Filter' (OR) im Value: way[highway=motorway|motorway_link|trunk|primary]
- Mehrere Filter-Prädikate: node[amenity=golf_course]node[leisure=golf_course]
- It's not possible to do an OR query with nodes OR ways. This is a limitation of the XAPI syntax.
Syntax-Abbildungen
Abbildung XAPI-Tabellen zu EOSMDBOne-Schema:
- node, way und relation => osm_point, osm_polygon und osm_rels (wie XAPI-Syntax ausser way zu dem ways fehlt (vgl. line)).
- point, line und polygon => osm_point, osm_line und osm_polygon (zusätzlich zur XAPI-Syntax).
- '*' => osm_all (d.h. osm_point, osm_line und osm_polygon).
Abbildung XAPI-zu-SQL (Sample SQL-Requests):
- BBox search ("bbox") becomes "WHERE ST_CONTAINS(<bbox>,<point_or_way_geom>)"
- equality search ("key=value") becomes AND hstore(tags)->'key' = 'value'
- wildcard search ("key=*") becomes AND hstore(tags)?'fee'
Implementations-Details
- Wegen URL-Spezialzeichen '[', '*' sowie ':' (in Keys wie 'name:de') muss die URL kanonisiert werden?
- Spaces sind in Values auch zugelassen, vgl. node[name=Knie's Kinderzoo]
- das XAPI-to-Map funktioniert auch mit Permalink, z.B. node[amenity=hospital][bbox=-6,50,2,61]?zoom=18&lat=47.223&lon=8.822&layers=B0T
- Für häufige Abfragen siehe auch die JXAPI-Logs (live!) sowie den Log-Backup von XAPI mit unbestätigter Herkunft.
Beispiel (man beachte, dass nicht der '->'- sondern der '@>'-Operator verwendet wird wegen GiST-Index):
.../node[tourism=zoo][bbox=6.2,46.1,10.0,47.6] wird abgebildet auf: SELECT ST_AsText(way) geom, name||' '||osm_id label FROM osm_point WHERE tags @> hstore('tourism','zoo') -- nicht hstore(tags)->'tourism' = 'zoo' -- OR ... abhängig von XAPI-Syntax AND ST_Contains(ST_Transform(ST_SetSRID('BOX(6.2 46.1, 10.0 47.6)'::box2d, 4326),900913),way)
.../way[xxx] wird abgebildet auf osm_line (oder osm_polygon?)
Webservices API
Date and Table List of Database
- Request: about-db-query.php
- Response besteht aus Datum der letzten erfolgreichen Aktualisierung der OSM Daten mit Hilfe des daily jobs und allen Tabellen in der DB 'gisdb':
LastUpdate=17.06.2011 Tables=geography_columns,geometry_columns,osm_all,osm_line,osm_nodes,osm_point,osm_polygon,osm_rels,osm_roads,osm_ways,spatial_ref_sys
XAPI-to-SQL
- Request:
http://labs.geometa.info/postgisterminal/xapi.py?query=node[amenity=*]
- Response: SQL gemäss dem gegebenen XAPI-String:
SELECT ST_AsText(way) geom, COALESCE(name, )||' '||osm_id label FROM osm_point WHERE hstore(tags)?'amenity'
Security Features
Siehe auch EOSMDBOne.
Client (JavaScript) fügt "LIMIT 100" dazu.
DB-Server-Timeout: als Parameter der PostgreSQL-Verbindung in process-query.php (oder als "statement_timeout (60000)" in postgresql.conf); siehe [2]
SET STATEMENT_TIMEOUT TO 60000; SET transaction_read_only TO TRUE; ALTER DATABASE x SET default_transaction_read_only = on;
Logging: Log von IP, Query-String und Response-Infos (success/error/etc. und Prozess-Zeit) speichert. Lösung über process-query.php oder Analyse (grep) Apache-Log?
Data Features
Siehe auch EOSMDBOne.
- Webservice indicating database update time and a list of tables => about-db-query.php . -- realisiert