File: topogeom_edit.sql

package info (click to toggle)
postgis 2.5.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 75,792 kB
  • sloc: ansic: 139,314; sql: 136,281; xml: 48,954; sh: 4,906; perl: 4,509; makefile: 2,897; python: 1,198; yacc: 441; cpp: 305; lex: 132
file content (23 lines) | stat: -rw-r--r-- 961 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
\set VERBOSITY terse
set client_min_messages to ERROR;

select 'create', createtopology('tt') > 0;

-- Create a line layer (will be layer 1)
CREATE TABLE tt.f_line(id serial);
SELECT 'simple_line_layer', AddTopoGeometryColumn('tt', 'tt', 'f_line','g','LINE');

INSERT INTO tt.f_line (g) VALUES
 ( toTopoGeom('LINESTRING(0 0, 10 0)'::geometry, 'tt', 1) );
INSERT INTO tt.f_line (g) VALUES
 ( toTopoGeom('LINESTRING(10 0, 30 0)'::geometry, 'tt', 1) );

-- Sane calls
SELECT id, 'start', id, ST_Length(g) FROM tt.f_line WHERE id = 1;
SELECT id, 'add',  id, ST_Length(TopoGeom_addElement(g, '{2,2}')) FROM tt.f_line WHERE id = 1;
SELECT id, 'rem',  id, ST_Length(TopoGeom_remElement(g, '{1,2}')) FROM tt.f_line WHERE id = 1;
SELECT id, 'dup',  id, ST_Length(TopoGeom_addElement(g, '{2,2}')) FROM tt.f_line WHERE id = 1;
SELECT id, 'mis',  id, ST_Length(TopoGeom_remElement(g, '{1,2}')) FROM tt.f_line WHERE id = 1;

DROP TABLE tt.f_line;
select droptopology('tt');