|
|
(Není zobrazeno 44 mezilehlých verzí od stejného uživatele.) |
Řádek 1: |
Řádek 1: |
| {{Upravit}} | | {{freegiswiki|PostGIS Topology}} |
| | |
| [http://trac.osgeo.org/postgis/wiki/UsersWikiPostgisTopology PostGIS Topology] je rozšíření pro [[PostGIS]] umožňující ''topologickou'' správu vektorových dat v prostředí PostGIS/[[PostgreSQL]].
| |
| | |
| Více přednášky [[153UZPD#Přednášky|Úvod do zpracování prostorových dat]].
| |
| | |
| == Příklad ==
| |
| | |
| <source lang=sql>
| |
| CREATE SCHEMA my_schema;
| |
| SET search_path TO my_schema,public;
| |
| </source>
| |
| | |
| === Feature table 'kraje' ===
| |
| | |
| <source lang=sql>
| |
| CREATE TABLE kraje AS SELECT nuts3, st_multi(st_union(geom)) as geom FROM gis1.obce GROUP BY nuts3;
| |
| SELECT nuts3,st_geometrytype(geom) AS type, ROUND(st_area(geom)/1e6) AS area from kraje;
| |
| </source>
| |
| | |
| <pre>
| |
| nuts3 | type | area
| |
| -------+-----------------+-------
| |
| CZ042 | ST_MultiPolygon | 5341
| |
| CZ081 | ST_MultiPolygon | 5566
| |
| CZ053 | ST_MultiPolygon | 4523
| |
| CZ032 | ST_MultiPolygon | 7566
| |
| CZ041 | ST_MultiPolygon | 3317
| |
| CZ071 | ST_MultiPolygon | 5141
| |
| CZ061 | ST_MultiPolygon | 6924
| |
| CZ051 | ST_MultiPolygon | 3163
| |
| CZ062 | ST_MultiPolygon | 7065
| |
| CZ021 | ST_MultiPolygon | 11013
| |
| CZ072 | ST_MultiPolygon | 3961
| |
| CZ031 | ST_MultiPolygon | 10071
| |
| CZ052 | ST_MultiPolygon | 4767
| |
| CZ011 | ST_MultiPolygon | 496
| |
| (14 rows)
| |
| </pre>
| |
| | |
| === Vytvoření topologického schématu 'urbanarea' ===
| |
| | |
| * [http://postgis.org/documentation/manual-svn/CreateTopology.html CreateTopology()]
| |
| | |
| <source lang=sql>
| |
| SELECT topology.createtopology('urbanarea', 3358);
| |
| </source>
| |
| | |
| <source lang=sql>
| |
| SELECT * from topology.topology;
| |
| </source>
| |
| | |
| <pre>
| |
| id | name | srid | precision | hasz
| |
| ----+-----------+------+-----------+------
| |
| 1 | urbanarea | 3358 | 0 | f
| |
| </pre>
| |
| | |
| \dt urbanarea.
| |
| | |
| <pre>
| |
| List of relations
| |
| Schema | Name | Type | Owner
| |
| -----------+-----------+-------+--------
| |
| urbanarea | edge_data | table | martin
| |
| urbanarea | face | table | martin
| |
| urbanarea | node | table | martin
| |
| urbanarea | relation | table | martin
| |
| </pre>
| |
| | |
| <pre>
| |
| \d urbanarea.node
| |
| Table "urbanarea.node"
| |
| Column | Type | Modifiers
| |
| -----------------+----------------------+------------------------------------------------------------------
| |
| node_id | integer | not null default nextval('urbanarea.node_node_id_seq'::regclass)
| |
| containing_face | integer |
| |
| geom | geometry(Point,3358) |
| |
| Indexes:
| |
| "node_primary_key" PRIMARY KEY, btree (node_id)
| |
| "node_gist" gist (geom)
| |
| Foreign-key constraints:
| |
| "face_exists" FOREIGN KEY (containing_face) REFERENCES urbanarea.face(face_id)
| |
| Referenced by:
| |
| TABLE "urbanarea.edge_data" CONSTRAINT "end_node_exists" FOREIGN KEY (end_node) REFERENCES urbanarea.node(node_id)
| |
| TABLE "urbanarea.edge_data" CONSTRAINT "start_node_exists" FOREIGN KEY (start_node) REFERENCES urbanarea.node(node_id)
| |
| </pre>
| |
| <pre>
| |
| \d urbanarea.edge_data
| |
| Table "urbanarea.edge_data"
| |
| Column | Type | Modifiers
| |
| ---------------------+---------------------------+-----------------------------------------------------------------------
| |
| edge_id | integer | not null default nextval('urbanarea.edge_data_edge_id_seq'::regclass)
| |
| start_node | integer | not null
| |
| end_node | integer | not null
| |
| next_left_edge | integer | not null
| |
| abs_next_left_edge | integer | not null
| |
| next_right_edge | integer | not null
| |
| abs_next_right_edge | integer | not null
| |
| left_face | integer | not null
| |
| right_face | integer | not null
| |
| geom | geometry(LineString,3358) |
| |
| Indexes:
| |
| "edge_data_pkey" PRIMARY KEY, btree (edge_id)
| |
| "edge_gist" gist (geom)
| |
| "edge_left_face_idx" btree (left_face)
| |
| "edge_right_face_idx" btree (right_face)
| |
| Foreign-key constraints:
| |
| "end_node_exists" FOREIGN KEY (end_node) REFERENCES urbanarea.node(node_id)
| |
| "left_face_exists" FOREIGN KEY (left_face) REFERENCES urbanarea.face(face_id)
| |
| "next_left_edge_exists" FOREIGN KEY (abs_next_left_edge) REFERENCES urbanarea.edge_data(edge_id) DEFERRABLE INITIALLY DEFERRED
| |
| "next_right_edge_exists" FOREIGN KEY (abs_next_right_edge) REFERENCES urbanarea.edge_data(edge_id) DEFERRABLE INITIALLY DEFERRED
| |
| "right_face_exists" FOREIGN KEY (right_face) REFERENCES urbanarea.face(face_id)
| |
| "start_node_exists" FOREIGN KEY (start_node) REFERENCES urbanarea.node(node_id)
| |
| Referenced by:
| |
| TABLE "urbanarea.edge_data" CONSTRAINT "next_left_edge_exists" FOREIGN KEY (abs_next_left_edge) REFERENCES urbanarea.edge_data(edge_id) DEFERRABLE INITIALLY DEFERRED
| |
| TABLE "urbanarea.edge_data" CONSTRAINT "next_right_edge_exists" FOREIGN KEY (abs_next_right_edge) REFERENCES urbanarea.edge_data(edge_id) DEFERRABLE INITIALLY DEFERRED
| |
| </pre>
| |
| <pre>
| |
| \d urbanarea.face
| |
| Table "urbanarea.face"
| |
| Column | Type | Modifiers
| |
| ---------+------------------------+------------------------------------------------------------------
| |
| face_id | integer | not null default nextval('urbanarea.face_face_id_seq'::regclass)
| |
| mbr | geometry(Polygon,3358) |
| |
| Indexes:
| |
| "face_primary_key" PRIMARY KEY, btree (face_id)
| |
| "face_gist" gist (mbr)
| |
| Referenced by:
| |
| TABLE "urbanarea.node" CONSTRAINT "face_exists" FOREIGN KEY (containing_face) REFERENCES urbanarea.face(face_id)
| |
| TABLE "urbanarea.edge_data" CONSTRAINT "left_face_exists" FOREIGN KEY (left_face) REFERENCES urbanarea.face(face_id)
| |
| TABLE "urbanarea.edge_data" CONSTRAINT "right_face_exists" FOREIGN KEY (right_face) REFERENCES urbanarea.face(face_id)
| |
| </pre>
| |
| <pre>
| |
| \d urbanarea.relation
| |
| Table "urbanarea.relation"
| |
| Column | Type | Modifiers
| |
| --------------+---------+-----------
| |
| topogeo_id | integer | not null
| |
| layer_id | integer | not null
| |
| element_id | integer | not null
| |
| element_type | integer | not null
| |
| Indexes:
| |
| "relation_layer_id_key" UNIQUE, btree (layer_id, topogeo_id, element_id, element_type)
| |
| Triggers:
| |
| relation_integrity_checks BEFORE INSERT OR UPDATE ON urbanarea.relation FOR EACH ROW EXECUTE PROCEDURE relationtrigger('2', 'urbanarea')
| |
| </pre>
| |
| | |
| === Přidání atributu topologie do feature table ===
| |
| | |
| * [http://postgis.org/documentation/manual-svn/AddTopoGeometryColumn.html AddTopoGeometryColumn()]
| |
| | |
| <source lang=sql>
| |
| select topology.AddTopoGeometryColumn('urbanarea', 'my_schema', 'urbanarea', 'topo', 'POLYGON');
| |
| </source>
| |
| | |
| <pre>
| |
| \d urbanarea
| |
| | |
| ...
| |
| topo | topology.topogeometry |
| |
| ...
| |
| </pre>
| |
| | |
| <source lang=sql>
| |
| SELECT * FROM topology.layer;
| |
| </source>
| |
| | |
| <pre>
| |
| topology_id | layer_id | schema_name | table_name | feature_column | feature_type | level | child_id
| |
| -------------+----------+-------------+------------+----------------+--------------+-------+----------
| |
| 1 | 1 | my_schema | urbanarea | topo | 3 | 0 |
| |
| </pre>
| |
| | |
| ''Poznámka:'' <tt>feature_type</tt> '3' odpovídá 'face' (1 - node, 2 - edge).
| |
| | |
| === Sestavení topologie (Geometry → TopoGeometry) ===
| |
| | |
| * [http://postgis.org/documentation/manual-svn/toTopoGeom.html toTopoGeom()]
| |
| | |
| == Externí odkazy ==
| |
| | |
| * [http://2010.foss4g.org/presentations/3555.pdf State of the art of FOSS4G for topology and network analysis]
| |
| * [http://www.postgis.org/documentation/manual-svn/Topology.html PostGIS 2.0 Topology section of manual]
| |
| * [http://cs.wikipedia.org/wiki/Topologie Topogie] {{bullet}} [http://cs.wikipedia.org/wiki/Sedm_most%C5%AF_m%C4%9Bsta_Kr%C3%A1lovce Sedm mostů města Královce] {{bullet}} [http://en.wikipedia.org/wiki/Geographic_information_system#Topological_modeling Topological modeling]
| |
| * [http://cs.wikipedia.org/wiki/Geografick%C3%BD_informa%C4%8Dn%C3%AD_syst%C3%A9m#Vektorov.C3.A9_modely Vektorové modely]
| |
| * [http://strk.keybit.net/projects/postgis/ strk's page about PostGIS]
| |
| * [http://strk.keybit.net/blog/2011/10/14/postgis-topology-iso-sqlmm-complete/ PostGIS topology ISO SQL/MM complete]
| |
| | |
| {{Databáze}}
| |
| {{GIS}}
| |
| {{GFOSS}}
| |