PostGIS Topology: Porovnání verzí
Řádek 77: | Řádek 77: | ||
<pre> | <pre> | ||
\d urbanarea.node | \d urbanarea.node | ||
Table "urbanarea.node" | |||
Column | | Column | Type | Modifiers | ||
-----------------+----------+------------------------------------------------------------------ | -----------------+----------------------+------------------------------------------------------------------ | ||
node_id | integer | node_id | integer | not null default nextval('urbanarea.node_node_id_seq'::regclass) | ||
containing_face | integer | containing_face | integer | | ||
geom | geometry | | geom | geometry(Point,3358) | | ||
Indexes: | Indexes: | ||
"node_primary_key" PRIMARY KEY, btree (node_id) | "node_primary_key" PRIMARY KEY, btree (node_id) | ||
"node_gist" gist (geom) | "node_gist" gist (geom) | ||
Foreign-key constraints: | Foreign-key constraints: | ||
"face_exists" FOREIGN KEY (containing_face) REFERENCES urbanarea.face(face_id) | "face_exists" FOREIGN KEY (containing_face) REFERENCES urbanarea.face(face_id) | ||
Řádek 95: | Řádek 91: | ||
TABLE "urbanarea.edge_data" CONSTRAINT "end_node_exists" FOREIGN KEY (end_node) REFERENCES urbanarea.node(node_id) | 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) | TABLE "urbanarea.edge_data" CONSTRAINT "start_node_exists" FOREIGN KEY (start_node) REFERENCES urbanarea.node(node_id) | ||
</pre> | |||
<pre> | |||
\d urbanarea.edge_data | \d urbanarea.edge_data | ||
Table "urbanarea.edge_data" | |||
Column | | Column | Type | Modifiers | ||
---------------------+----------+----------------------------------------------------------------------- | ---------------------+---------------------------+----------------------------------------------------------------------- | ||
edge_id | integer | edge_id | integer | not null default nextval('urbanarea.edge_data_edge_id_seq'::regclass) | ||
start_node | integer | start_node | integer | not null | ||
end_node | integer | end_node | integer | not null | ||
next_left_edge | integer | next_left_edge | integer | not null | ||
abs_next_left_edge | integer | abs_next_left_edge | integer | not null | ||
next_right_edge | integer | next_right_edge | integer | not null | ||
abs_next_right_edge | integer | abs_next_right_edge | integer | not null | ||
left_face | integer | left_face | integer | not null | ||
right_face | integer | right_face | integer | not null | ||
geom | geometry | | geom | geometry(LineString,3358) | | ||
Indexes: | Indexes: | ||
"edge_data_pkey" PRIMARY KEY, btree (edge_id) | "edge_data_pkey" PRIMARY KEY, btree (edge_id) | ||
Řádek 115: | Řádek 112: | ||
"edge_left_face_idx" btree (left_face) | "edge_left_face_idx" btree (left_face) | ||
"edge_right_face_idx" btree (right_face) | "edge_right_face_idx" btree (right_face) | ||
Foreign-key constraints: | Foreign-key constraints: | ||
"end_node_exists" FOREIGN KEY (end_node) REFERENCES urbanarea.node(node_id) | "end_node_exists" FOREIGN KEY (end_node) REFERENCES urbanarea.node(node_id) | ||
Řádek 129: | Řádek 122: | ||
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_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 | 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 | \d urbanarea.face | ||
Table "urbanarea.face" | |||
Column | | Column | Type | Modifiers | ||
---------+----------+------------------------------------------------------------------ | ---------+------------------------+------------------------------------------------------------------ | ||
face_id | integer | face_id | integer | not null default nextval('urbanarea.face_face_id_seq'::regclass) | ||
mbr | geometry | | mbr | geometry(Polygon,3358) | | ||
Indexes: | Indexes: | ||
"face_primary_key" PRIMARY KEY, btree (face_id) | "face_primary_key" PRIMARY KEY, btree (face_id) | ||
"face_gist" gist (mbr) | "face_gist" gist (mbr) | ||
Referenced by: | Referenced by: | ||
TABLE "urbanarea.node" CONSTRAINT "face_exists" FOREIGN KEY (containing_face) REFERENCES urbanarea.face(face_id) | 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 "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) | 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> | </pre> | ||
Verze z 9. 4. 2012, 17:02
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 Úvod do zpracování prostorových dat.
Příklad
SET search_path TO public,nc;
Feature table 'urbanarea'
\d urbanarea
Table "nc.urbanarea" Column | Type | Modifiers ----------+------------------------+------------------------------------------------------------- ogc_fid | integer | not null default nextval('urbanarea_ogc_fid_seq'::regclass) geom | geometry(Polygon,3358) | cat | integer | objectid | integer | ua | character varying(5) | name | character varying(90) | ua_type | character varying(2) | Indexes: "urbanarea_pk" PRIMARY KEY, btree (ogc_fid) "urbanarea_geom_idx" gist (geom)
SELECT cat, ua, name, ST_GeometryType(geom) from urbanarea limit 5;
cat | ua | name | st_geometrytype -----+-------+------------+----------------- 1 | 29305 | Farmville | ST_Polygon 2 | 92404 | Washington | ST_Polygon 3 | 35380 | Greenville | ST_Polygon 4 | 46315 | La Grange | ST_Polygon 5 | 45397 | Kinston | ST_Polygon
Vytvoření topologického schématu 'urbanarea'
SELECT topology.createtopology('urbanarea', 3358);
SELECT * from topology.topology;
id | name | srid | precision | hasz ----+-----------+------+-----------+------ 1 | urbanarea | 3358 | 0 | f
\dt urbanarea.
List of relations Schema | Name | Type | Owner -----------+-----------+-------+-------- urbanarea | edge_data | table | martin urbanarea | face | table | martin urbanarea | node | table | martin urbanarea | relation | table | martin
\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)
\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
\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)
\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')
Přidání atributu topologie do feature table
select topology.AddTopoGeometryColumn('urbanarea', 'public', 'urbanarea', 'topo', 'POLYGON');
\d urbanarea ... topo | topology.topogeometry | ...
SELECT * FROM topology.layer;
topology_id | layer_id | schema_name | table_name | feature_column | feature_type | level | child_id -------------+----------+-------------+------------+----------------+--------------+-------+---------- 1 | 2 | public | urbanarea | topo | 3 | 0 |