Diskussion:PostGIS Terminal: Unterschied zwischen den Versionen

Aus Geoinformation HSR
Wechseln zu: Navigation, Suche
(Feature Requests)
Zeile 1: Zeile 1:
Please note your questions and feedback below.  
+
Please note here your questions and feedback below. You can also send them directly to [http://gis.hsr.ch/index.php?option=com_contact&task=view&contact_id=2&Itemid=119 Stefan Keller].
  
You can also send them directly to [http://gis.hsr.ch/index.php?option=com_contact&task=view&contact_id=2&Itemid=119 Stefan Keller].
+
== XAPI-to-Map ==
  
== Feedback / Discussion ==
+
Siehe http://www.gis.hsr.ch/wiki/XAPI
  
...
+
Das Ziel ist nicht die vollständige "Syntax", sondern nur spezifische und häufige Requests, bestehend aus Key/Value Pairs (0, 1 ode mehrere) sowie einer Bounding Box-Angabe. Wegen '[' muss die URL kanonisiert werden. Achtung auch wegen ":".
  
== Interessante Queries ==
+
Hier einige Tests:
 +
<nowiki>
 +
* .../api/0.6/node[amenity=*]
 +
* .../api/0.6/node[highway=busstop]
 +
* .../api/0.6/node[bbox=-6,50,2,61]
 +
* .../api/0.6/node[amenity=hospital][bbox=-6,50,2,61]
 +
* .../api/0.6/*[seamark:type=signal_station_warning]
 +
</nowiki>
 +
 
 +
Hier konkrete, laufende Beispiele:
 +
* http://xapi.spline.de/api/0.6/node[amenity=*]
 +
* http://open.mapquestapi.com/xapi/api/0.6/node[operator=Stadtverkehr Lübeck]
 +
* http://open.mapquestapi.com/xapi/api/0.6/node[ref:svhl=*]
 +
 
 +
Logs:
 +
* http://jxapi.openstreetmap.org/xapi/admin/stats und log http://fsi.spline.de/osm/xapi-access-23-01-2011.log.bz2
 +
 
 +
XAPI => SQL:
 +
* gemäss osm2pgsql-Schema
 +
* Original wäre das OSM 'pgsnapshot_schema_0.6'
 +
** [http://trac.openstreetmap.org/browser/applications/utils/osmosis/trunk/package/script/pgsnapshot_schema_0.6.sql]
 +
** Siehe dazu https://github.com/osm-spline/xapi/blob/master/sql/sampleRequests.sql
 +
 
 +
Beispiel:
 +
  <nowiki>.../api/0.6/node[tourism=zoo][bbox=6.2,46.1,10.0,47.6]</nowiki>
 +
  =>
 +
  SELECT ST_AsText(way) geom, name label
 +
  FROM osm_point
 +
  WHERE hstore(tags)->'tourism'='zoo'
 +
  AND ST_Contains(ST_Transform(ST_SetSRID('BOX(6.2 46.1, 10.0 47.6)'::box2d, 4326),900913),way)
 +
 
 +
 
 +
== Weitere interessante Queries ==
  
 
=== Alle Tags der OSM-Daten ===
 
=== Alle Tags der OSM-Daten ===

Version vom 9. Juni 2011, 11:26 Uhr

Please note here your questions and feedback below. You can also send them directly to Stefan Keller.

XAPI-to-Map

Siehe http://www.gis.hsr.ch/wiki/XAPI

Das Ziel ist nicht die vollständige "Syntax", sondern nur spezifische und häufige Requests, bestehend aus Key/Value Pairs (0, 1 ode mehrere) sowie einer Bounding Box-Angabe. Wegen '[' muss die URL kanonisiert werden. Achtung auch wegen ":".

Hier einige Tests: * .../api/0.6/node[amenity=*] * .../api/0.6/node[highway=busstop] * .../api/0.6/node[bbox=-6,50,2,61] * .../api/0.6/node[amenity=hospital][bbox=-6,50,2,61] * .../api/0.6/*[seamark:type=signal_station_warning]

Hier konkrete, laufende Beispiele:

Logs:

XAPI => SQL:

Beispiel:

 .../api/0.6/node[tourism=zoo][bbox=6.2,46.1,10.0,47.6]
 => 
 SELECT ST_AsText(way) geom, name label
 FROM osm_point
 WHERE hstore(tags)->'tourism'='zoo'
 AND ST_Contains(ST_Transform(ST_SetSRID('BOX(6.2 46.1, 10.0 47.6)'::box2d, 4326),900913),way)


Weitere interessante Queries

Alle Tags der OSM-Daten

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

Artikel zum Laden von OSM Daten

Loading OpenStreetMap data into PostGIS: An Almost Idiot's Guide: [2]

Feature Requests

Security Features

SF1. Rechte entziehen, damit User Tables und Views nicht erzeugen oder löschen können!!!

 Schema nicht PUBLIC? Test: create table customer (id serial, name text); drop table customer; !!!
 Konfigurieren PostgreSQL Server (postgresql.conf parameters): Disabling autovacuum daemon, fsync=off etc.

=> RMI

SF2. Einbau Timeout als Parameter der PostgreSQL-Verbindung in process-query.php (oder als "statement_timeout (60000)" in postgresql.conf); siehe [3]

 SET STATEMENT_TIMEOUT TO 60000;
 SET transaction_read_only TO TRUE;
 ALTER DATABASE x SET default_transaction_read_only = on;

=> RMI

SF3. Logging, das IP, Query-String und Response-Infos (success/error/etc. und Prozess-Zeit) speichert. Lösung über process-query.php oder Analyse (grep) Apache-Log? => RMI

Data Features

DF1. Style-Datei anpassen, so dass Tabellennamen ohne "planet" und ohne Underscores erzeugt werden, also z.B. anstelle „planet_osm_point“ nur „osmpoint“. => RMI

DF2. Neu immer Laden mit hstore (-h Parameter bei osm2pgsql). Zudem folgende Tabelle hinzufügen:

 CREATE VIEW osm_all AS 
 SELECT osm_id, name, tags, 'pt' AS gtyp, way
 FROM osm_point
 UNION
 SELECT osm_id, name, tags, 'ln' AS gtyp, way
 FROM osm_line
 UNION
 SELECT osm_id, name, tags, 'po' AS gtyp, way
 FROM osm_polygon
 CREATE INDEX osm_point_name_idx
 ON osm_point(name) WITH (FILLFACTOR=100);
 CREATE INDEX osm_point_tags_idx
 ON osm_point USING gist(tags) WITH (FILLFACTOR=100);
 -- Kann "FEHLER:  invalid hstore value found" ergeben!
 
 ALTER TABLE osm_point CLUSTER ON osm_point_name_idx;
 VACUUM FREEZE ANALYZE;  -- das kann dauern...

=> RMI

DF3. Einrichten eines Cron-Jobs, der einmal pro Nacht die Schweiz neu einspielt (Bitte Vorschlag). => RMI

DF4. Siehe NF2. => RMI

New Functionality/Refactoring

NF1. Refactoring Marker Query from Text class to Vector Class (see Test Cases for Marker Query below). => Kemper/Hengartner

NF2. „Updated: 2011-03-25“ ist zurzeit fix in config.php festgehalten und wird über "?" angezeigt. Schöner wäre eine Anzeige über eine DB-Query (about-db-query.php).

NF3. Anzeige/Einfügen Tabellen und -Attribute als <options...> (laden via about-db-query.php).

NF4. Erweiterung Marker Query um Attribut 'icon', mit dem man Icons von externen Quellen (url) darstellen kann. => erledigt.

Nice-to-have

  • Permalink: Ergänzung Uebergabe Query als URL (siehe XAPI)
  • Umwandeln von OSM XAPI ('zappy') Requests nach SQL (SELECT FROM WHERE...) - auch als Ergänzung des Permalinks.
  • Features klickbar machen mit Link zu OSM mit osm_id, z.B. http://www.openstreetmap.org/browse/way/82142220
  • Vollständig 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.
  • Markers mit Maus-über ("hover") - wären toll... nicht Popup und wegklicken müssen! -
  • Wie geht das mit Wait-Cursor in OpenLayers???
  • Aufrufen von Google Earth (KML network link), falls output mit ST_KML und alias kml (als einzigem Ausgabe-Feld) angegeben.

Test Cases for Marker Query

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