File: geos39.sql

package info (click to toggle)
postgis 3.5.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 69,528 kB
  • sloc: ansic: 162,229; sql: 93,970; xml: 53,139; cpp: 12,646; perl: 5,658; sh: 5,369; makefile: 3,435; python: 1,205; yacc: 447; lex: 151; pascal: 58
file content (54 lines) | stat: -rw-r--r-- 2,219 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54

SELECT 'mic-box' AS name,
       st_astext(center, 1) AS center,
       st_astext(nearest, 1) AS nearest,
       round(radius::numeric,1) AS radius
FROM ST_MaximumInscribedCircle('Polygon((0 0, 100 0, 99 98, 0 100, 0 0))'::geometry);

SELECT 'mic-empty' AS name,
       st_astext(center, 4) AS center,
       st_astext(nearest, 4) AS nearest,
       round(radius::numeric,4) AS radius
FROM ST_MaximumInscribedCircle('Polygon Empty'::geometry);

SELECT 'mic-null' AS name, center, nearest, radius
FROM ST_MaximumInscribedCircle(NULL);

SELECT 'mic-line' AS name,
       st_astext(center, 4) AS center,
       st_astext(nearest, 4) AS nearest,
       round(radius::numeric,4) AS radius
FROM ST_MaximumInscribedCircle('LINESTRING(0 0, 100 0, 99 98, 0 100, 0 0)'::geometry);

SELECT 'mic-mpoint' AS name,
       st_astext(center, 4) AS center,
       st_astext(nearest, 4) AS nearest,
       round(radius::numeric,4) AS radius
FROM ST_MaximumInscribedCircle('MULTIPOINT(0 0, 100 0, 99 98, 0 100, 0 0)'::geometry);

SELECT 'mic-point' AS name,
       st_astext(center, 4) AS center,
       st_astext(nearest, 4) AS nearest,
       round(radius::numeric,4) AS radius
FROM ST_MaximumInscribedCircle('POINT(0 0)'::geometry);

WITH p AS (
	SELECT 'Polygon((0 0, 100 0, 99 98, 0 100, 0 0))'::geometry AS ply
)
SELECT 'mic-cte' AS name, ST_AsText(st_snaptogrid((ST_MaximumInscribedCircle(ply)).center,0.1))
	FROM p;

-- ST_ReducePrecision
SELECT 'rp-1', ST_AsText(ST_ReducePrecision('POINT(1.412 19.323)', 0.1));
SELECT 'rp-2', ST_AsText(ST_ReducePrecision('POINT(1.412 19.323)', 1.0));
SELECT 'rp-3', ST_AsText(ST_ReducePrecision('POINT(1.412 19.323)', 10));

-- ST_MaximumInscribedCircle infinite check https://trac.osgeo.org/postgis/ticket/5318
SELECT '#5318', ST_MaximumInscribedCircle('0106000020E61000000100000001030000000100000005000000000000000000F07F000000000000F07F000000000000F07F000000000000F07F000000000000F07F000000000000F07F000000000000F07F000000000000F07F000000000000F07F000000000000F07F'::geometry) As result;

-- ST_LargestEmptyCircle
SELECT 'lec-1', round(radius::numeric,3),
  ST_AsText(center,3) AS center,
  ST_AsText(nearest,3) AS nearest
FROM ST_LargestEmptyCircle(
  'MULTIPOINT ((4 3), (7 6), (4 6))');