12345678910111213141516171819202122232425262728293031323334 |
- -- The ring_linestring table is created with two columns:
- -- a smallint column, gid, uniquely identifies the rows,
- -- while ln1, a ST_LineString column, stores the ST_LineString geometries.
- CREATE TABLE ring_linestring (gid smallint,
- ln1 ST_LineString);
- -- The INSERT statements insert three linestrings into the ln1 column.
- -- The first row contains a linestring that's not closed and isn't a ring.
- -- The second row contains a closed and simple linestring that is a ring.
- -- The third row contains a linestring that is closed but not simple because
- -- it intersects its own interior. It's also not a ring.
- INSERT INTO ring_linestring VALUES(
- 1,
- ST_LineFromText('linestring (10.02 20.01,10.32 23.98,11.92 25.64)', 1000)
- );
- INSERT INTO ring_linestring VALUES(
- 2,
- ST_LineFromText('linestring (10.02 20.01,11.92 35.64,25.02 34.15,19.15 33.94, 10.02 20.01)', 1000)
- );
- INSERT INTO ring_linestring VALUES(
- 3,
- ST_LineFromText('linestring (15.47 30.12,20.73 22.12,10.83 14.13,16.45 17.24,21.56 13.37,11.23 22.56,19.11 26.78,15.47 30.12)', 1000)
- );
- -- The query returns the results of the ST_IsRing function.
- -- The first and third rows return false because the linestrings aren't
- -- rings, while the second row returns t (TRUE) because it is a ring.
- SELECT gid, ST_IsRing(ln1) Is_it_a_ring
- FROM ring_linestring;
|