-
Notifications
You must be signed in to change notification settings - Fork 0
/
queries.sql
30 lines (22 loc) · 1.6 KB
/
queries.sql
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
/* Draw ConvexHull */
SELECT ST_AsText(ST_ConvexHull(
ST_Collect(
ST_GeomFromText('MULTIPOINT(-118.288387 34.0311826,-118.2876383 34.0205721,-118.287311 34.0223519,-118.2885265 34.0230628,-118.289418 34.025121,-118.2881922 34.0216336,-118.2836918 34.0193639,-118.2923786 34.0189075,-118.2925717 34.0200813,-118.2911207 34.0284488)')
)) ) as ConvexhullPolygon
/*Generate Polygon1(#1,#2,#8,#9,#10)*/
SELECT ST_AsText(ST_ConvexHull(
ST_Collect(
ST_GeomFromText('MULTIPOINT(-118.288387 34.0311826,-118.2876383 34.0205721,-118.2923786 34.0189075,-118.2925717 34.0200813,-118.2911207 34.0284488)')
)) ) as Polygon1
/* OUTPUT : POLYGON1((-118.292379 34.018907, -118.292572 34.020081, -118.291121 34.028449, -118.288387 34.031183, -118.287638 34.020572, -118.292379 34.018907)) */
/* Generate Polygon1(#3,#4,#5,#6,#7) */
SELECT ST_AsText(ST_ConvexHull(
ST_Collect(
ST_GeomFromText('MULTIPOINT(-118.287311 34.0223519,-118.2885265 34.0230628,-118.289418 34.025121,-118.2881922 34.0216336,-118.2836918 34.0193639)')
)) ) as Polygon2;
/*OUTPUT : OUTPUT : POLYGON2((-118.283692 34.019364, -118.288192 34.021634, -118.289418 34.025121, -118.283692 34.019364)) */
/* Overlaps between Polygon 1 (#) and Polygon 2 () */
SELECT ST_Intersects(a,b) As a_intersects_b
FROM (SELECT ST_Buffer(ST_GeomFromText('MULTIPOINT(-118.292379 34.018907, -118.292572 34.020081, -118.291121 34.028449, -118.288387 34.031183, -118.287638 34.020572, -118.292379 34.018907)'),1) As a,
ST_Buffer(ST_GeomFromText('MULTIPOINT(-118.283692 34.019364, -118.288192 34.021634, -118.289418 34.025121, -118.283692 34.019364)'),1) As b);
/* OUTPUT : 1*/