1set client_min_messages to WARNING;
2
3\i load_topology.sql
4\i load_features.sql
5\i hierarchy.sql
6
7-- This edges perturbate the topology so that walking around the boundaries
8-- of P1 and P2 may require walking on some of them
9SELECT 'E' || TopoGeo_addLinestring('city_data', 'LINESTRING(9 14, 15 10)');
10SELECT 'E' || TopoGeo_addLinestring('city_data', 'LINESTRING(21 14, 15 18)');
11SELECT 'E' || TopoGeo_addLinestring('city_data', 'LINESTRING(21 14, 28 10)');
12SELECT 'E' || TopoGeo_addLinestring('city_data', 'LINESTRING(35 14, 28 18)');
13
14--- Lineal non-hierarchical
15SELECT 'L1-vanilla', feature_name, topology.AsTopoJSON(feature, NULL)
16 FROM features.city_streets
17 WHERE feature_name IN ('R3', 'R4', 'R1', 'R2' )
18 ORDER BY feature_name;
19
20--- Lineal hierarchical
21SELECT 'L2-vanilla', feature_name, topology.AsTopoJSON(feature, NULL)
22 FROM features.big_streets
23 WHERE feature_name IN ('R4', 'R1R2' )
24 ORDER BY feature_name;
25
26--- Areal non-hierarchical
27SELECT 'A1-vanilla', feature_name, topology.AsTopoJSON(feature, NULL)
28 FROM features.land_parcels
29 WHERE feature_name IN ('P1', 'P2', 'P3', 'P4', 'P5' )
30 ORDER BY feature_name;
31
32--- Areal hierarchical
33SELECT 'A2-vanilla', feature_name, topology.AsTopoJSON(feature, NULL)
34 FROM features.big_parcels
35 WHERE feature_name IN ('P1P2', 'P3P4')
36 ORDER BY feature_name;
37
38-- Now again with edge mapping {
39CREATE TEMP TABLE edgemap (arc_id serial, edge_id int unique);
40
41--- Lineal non-hierarchical
42SELECT 'L1-edgemap', feature_name, topology.AsTopoJSON(feature, 'edgemap')
43 FROM features.city_streets
44 WHERE feature_name IN ('R3', 'R4', 'R1', 'R2' )
45 ORDER BY feature_name;
46
47--- Lineal hierarchical
48TRUNCATE edgemap; SELECT NULLIF(setval('edgemap_arc_id_seq', 1, false), 1);
49SELECT 'L2-edgemap', feature_name, topology.AsTopoJSON(feature, 'edgemap')
50 FROM features.big_streets
51 WHERE feature_name IN ('R4', 'R1R2' )
52 ORDER BY feature_name;
53
54--- Areal non-hierarchical
55TRUNCATE edgemap; SELECT NULLIF(setval('edgemap_arc_id_seq', 1, false), 1);
56SELECT 'A1-edgemap', feature_name, topology.AsTopoJSON(feature, 'edgemap')
57 FROM features.land_parcels
58 WHERE feature_name IN ('P1', 'P2', 'P3', 'P4', 'P5' )
59 ORDER BY feature_name;
60
61--- Areal hierarchical
62TRUNCATE edgemap; SELECT NULLIF(setval('edgemap_arc_id_seq', 1, false), 1);
63SELECT 'A2-edgemap', feature_name, topology.AsTopoJSON(feature, 'edgemap')
64 FROM features.big_parcels
65 WHERE feature_name IN ('P1P2', 'P3P4')
66 ORDER BY feature_name;
67
68DROP TABLE edgemap;
69-- End edge mapping }
70
71-- This edge splits an hole in two faces
72SELECT 'E' || TopoGeo_addLinestring('city_data', 'LINESTRING(4 31, 7 34)');
73
74-- This edge wraps a couple of faces, to test holes at 2 level distance from parent
75SELECT 'E' || TopoGeo_addLinestring('city_data', 'LINESTRING(0 25, 33 25, 33 44, 0 44, 0 25)');
76
77-- Now add a new polygon
78SELECT 'E' || TopoGeo_addLinestring('city_data', 'LINESTRING(3 47, 33 47, 33 52, 3 52, 3 47)');
79SELECT 'E' || TopoGeo_addLinestring('city_data', 'LINESTRING(10 48, 16 48, 16 50, 10 50, 10 48)');
80
81-- And this defines a new feature including both face 1and the new
82-- wrapping face 11 plus the new (holed) face 12
83INSERT INTO features.land_parcels(feature_name, feature) VALUES ('P6',
84  topology.CreateTopoGeom(
85    'city_data', -- Topology name
86    3, -- Topology geometry type (polygon/multipolygon)
87    1, -- TG_LAYER_ID for this topology (from topology.layer)
88    '{{1,3},{11,3},{12,3}}'));
89
90SELECT 'A3-vanilla', feature_name, topology.AsTopoJSON(feature, null)
91 FROM features.land_parcels
92 WHERE feature_name IN ('P6')
93 ORDER BY feature_name;
94
95SELECT 'P1-vanilla', feature_name, topology.AsTopoJSON(feature, null)
96 FROM features.traffic_signs
97 WHERE feature_name IN ('S2')
98 ORDER BY feature_name;
99
100SELECT topology.DropTopology('city_data');
101DROP SCHEMA features CASCADE;
102