CREATE TABLE features.big_parcels (
feature_name varchar primary key
-);
+) WITH OIDS;
SELECT topology.AddTopoGeometryColumn('city_data', 'features',
'big_parcels', 'feature', 'POLYGON',
(SELECT layer_id FROM topology.layer WHERE table_name = 'big_parcels'),
'{{6,1},{7,1}}')); -- F3 and F6
-SELECT feature_name,ST_AsText(topology.geometry(feature)) from features.big_parcels;
+--
+-- Streets
+--
+
+CREATE TABLE features.big_streets (
+ feature_name varchar primary key
+) WITH OIDS;
+
+SELECT topology.AddTopoGeometryColumn('city_data', 'features',
+ 'big_streets', 'feature', 'LINE',
+ 3 -- the city_streets layer id
+);
-SELECT a.feature_name, b.feature_name
- FROM features.land_parcels a, features.big_parcels b
- WHERE topology.equals(a.feature, b.feature);
+INSERT INTO features.big_streets VALUES ('R1R2', -- Feature name
+ topology.CreateTopoGeom(
+ 'city_data', -- Topology name
+ 2, -- Topology geometry type (lineal)
+ (SELECT layer_id FROM topology.layer WHERE table_name = 'big_streets'),
+ (SELECT topoelementarray_agg(ARRAY[id(feature), 3])
+ FROM features.city_streets
+ WHERE feature_name in ('R1','R2')) -- R1 and R2
+ ));
+
+INSERT INTO features.big_streets VALUES ('R4', -- Feature name
+ topology.CreateTopoGeom(
+ 'city_data', -- Topology name
+ 2, -- Topology geometry type (lineal)
+ (SELECT layer_id FROM topology.layer WHERE table_name = 'big_streets'),
+ (SELECT topoelementarray_agg(ARRAY[id(feature), 3])
+ FROM features.city_streets
+ WHERE feature_name in ('R4'))
+ ));
--
-- Signs
CREATE TABLE features.big_signs (
feature_name varchar primary key
-);
+) WITH OIDS;
SELECT topology.AddTopoGeometryColumn('city_data', 'features',
'big_signs', 'feature', 'POINT',
(SELECT layer_id FROM topology.layer WHERE table_name = 'big_signs'),
'{{1,2},{2,2}}')); -- S1 and S2
-SELECT feature_name, ST_AsText(topology.geometry(feature)) from features.big_signs;
-
-SELECT a.feature_name, b.feature_name
- FROM features.traffic_signs a, features.big_signs b
- WHERE topology.equals(a.feature, b.feature);
+++ /dev/null
-BEGIN
- POINT/POINT INTERSECTS
-
- S1 | N1N6N14
- S3 | N1N6N14
- S4 | N3N4
- S4 | N4
- N1N2N3 | N1N6N14
- N1N2N3 | N3N4
- N3N4 | N4
-
- POINT/LINE INTERSECTS
-
- S1 | R1
- S1 | E20E19
- S1 | R1a
- S2 | R1
- S2 | R1a
- S3 | R2
- N1N2N3 | R4
- N1N6N14 | R1
- N1N6N14 | R2
- N1N6N14 | E20E19
- N1N6N14 | R1a
- N3N4 | R4
-
- LINE/LINE INTERSECTS
-
- R1 | E20E19
- R1 | R1a
- R3 | E25
- E7E8 | E20E19
- E20E19 | R1a
-
- POINT/POLY INTERSECTS
-
- S1 | P1
- S1 | P2
- S1 | F3
- S1 | F6
- S1 | F3F4
- S2 | P2
- S2 | P3
- S2 | F3F4
- S4 | P4
- N1N2N3 | P4
- N1N2N3 | P5
- N1N2N3 | F1
- N1N6N14 | P1
- N1N6N14 | P2
- N1N6N14 | P5
- N1N6N14 | F3
- N1N6N14 | F6
- N1N6N14 | F3F4
- N1N6N14 | F1
- N3N4 | P4
- N4 | P4
-
- LINE/POLY INTERSECTS
-
- R1 | P1
- R1 | P2
- R1 | P3
- R1 | F3
- R1 | F6
- R1 | F3F4
- R3 | P5
- R3 | F1
- R4 | P4
- E7E8 | P1
- E7E8 | P2
- E7E8 | P3
- E7E8 | F3
- E7E8 | F3F4
- E20E19 | P1
- E20E19 | P2
- E20E19 | F3
- E20E19 | F6
- E20E19 | F3F4
- E25 | P5
- E25 | F1
- R1a | P1
- R1a | P2
- R1a | P3
- R1a | F3
- R1a | F6
- R1a | F3F4
-
- POLY/POLY INTERSECTS
-
- P1 | P2
- P1 | F3
- P1 | F6
- P1 | F3F4
- P2 | P3
- P2 | F3
- P2 | F6
- P2 | F3F4
- P3 | F3F4
- P5 | F1
- F3 | F6
- F3 | F3F4
- F6 | F3F4
-
- POINT/POINT EQUALS
-
- S4 | N4
-
- LINE/LINE EQUALS
-
- R1 | R1a
- R3 | E25
-
- POLYGON/POLYGON EQUALS
-
- P5 | F1
-
-COMMIT
#endif
+SELECT 'POINT/POINT EQUALS (simple/hierarchical)' as operation;
+SELECT a.feature_name, b.feature_name
+ FROM features.traffic_signs a, features.big_signs b
+ WHERE a.oid < b.oid AND @SCHEMA@equals(a.feature, b.feature)
+ ORDER BY a.oid;
+SELECT 'POLYGON/POLYGON EQUALS (simple/hierarchical)' as operation;
+
+SELECT a.feature_name, b.feature_name
+ FROM features.land_parcels a, features.big_parcels b
+ WHERE a.oid < b.oid AND @SCHEMA@equals(a.feature, b.feature)
+ ORDER BY a.oid;
END;
ST_AsText(topology.Geometry(a.feature)) as geom
FROM features.city_streets a;
+-- Query hierarchical feautures
+SELECT feature_name, ST_AsText(topology.geometry(feature))
+FROM features.big_signs;
+
+SELECT feature_name,ST_AsText(topology.geometry(feature))
+FROM features.big_streets;
+
+SELECT feature_name,ST_AsText(topology.geometry(feature))
+FROM features.big_parcels;
+
+
--NOTYET--
--NOTYET--/* Window is city_streets */
--NOTYET--SELECT a.feature_name, b.feature_name
COMMIT
4
features.big_parcels.the_geom SRID:0 TYPE:MULTIPOLYGON DIMS:2
-P1P2|POLYGON((21 6,9 6,9 14,9 22,21 22,35 22,35 14,35 6,21 6))
-P3P4|MULTIPOLYGON(((47 14,47 6,35 6,35 14,35 22,47 22,47 14)),((25 30,17 30,17 40,31 40,31 30,25 30)))
-F3F6|POLYGON((21 14,21 6,9 6,9 14,9 22,21 22,21 14))
-P1|F3F6
5
+6
features.big_signs.the_geom SRID:0 TYPE:MULTIPOINT DIMS:2
-S1S2|MULTIPOINT(21 14,35 14)
BEGIN
POINT/POINT INTERSECTS
S1|N1N6N14
R3|E25
POLYGON/POLYGON EQUALS
P5|F1
+POINT/POINT EQUALS (simple/hierarchical)
+POLYGON/POLYGON EQUALS (simple/hierarchical)
+P1|F3F6
COMMIT
Topology 'city_data' dropped
COMMIT
4
features.big_parcels.the_geom SRID:0 TYPE:MULTIPOLYGON DIMS:2
-P1P2|POLYGON((21 6,9 6,9 14,9 22,21 22,35 22,35 14,35 6,21 6))
-P3P4|MULTIPOLYGON(((47 14,47 6,35 6,35 14,35 22,47 22,47 14)),((25 30,17 30,17 40,31 40,31 30,25 30)))
-F3F6|POLYGON((21 14,21 6,9 6,9 14,9 22,21 22,21 14))
-P1|F3F6
5
+6
features.big_signs.the_geom SRID:0 TYPE:MULTIPOINT DIMS:2
-S1S2|MULTIPOINT(21 14,35 14)
BEGIN
P1|1|POLYGON((21 14,21 6,9 6,9 14,9 22,21 22,21 14))
P2|2|POLYGON((35 14,35 6,21 6,21 14,21 22,35 22,35 14))
E20E19|6|LINESTRING(21 6,21 14,21 22)
E25|7|LINESTRING(9 35,13 35)
R1a|8|LINESTRING(9 14,21 14,35 14)
+S1S2|MULTIPOINT(21 14,35 14)
+R1R2|MULTILINESTRING((36 38,38 35,41 34,42 33,45 32,47 28,50 28,52 32,57 33,57 36,59 39,61 38,62 41,47 42,45 40,41 40),(9 14,21 14,35 14))
+R4|LINESTRING(25 30,25 35)
+P1P2|POLYGON((21 6,9 6,9 14,9 22,21 22,35 22,35 14,35 6,21 6))
+P3P4|MULTIPOLYGON(((47 14,47 6,35 6,35 14,35 22,47 22,47 14)),((25 30,17 30,17 40,31 40,31 30,25 30)))
+F3F6|POLYGON((21 14,21 6,9 6,9 14,9 22,21 22,21 14))
COMMIT
Topology 'city_data' dropped