File: st_azimuthmath.sql

package info (click to toggle)
postgis 3.5.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, 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 (36 lines) | stat: -rw-r--r-- 2,118 bytes parent folder | download | duplicates (7)
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
-- st_azimuth01.wkt
POINT(25 45); --point 1
POINT(75 100); -- point 2
SELECT ST_AsText(
	ST_MakeLine(
		ST_Point(25,45), ST_Point(25 + ST_Length('LINESTRING(25 45,75 100)'::Geometry) ,45))
	); -- horizontal -- LINESTRING(25 45,99.33034 45)

-- control point
SELECT ST_AsText(
	ST_SnapToGrid(
		ST_PointN(ST_Boundary(ST_Buffer(ST_Point(25, 45),ST_Length('LINESTRING(25 45,75 100)'::Geometry))),30),
		0.0001)); --POINT(86.8034 86.2957)

-- arc from horizontal
-- LINESTRING(99.33034 45,98.9724 52.28569,97.90206 59.50121,96.12963 66.57707,93.67218 73.44514,90.55337 80.03925,86.80325 86.29593,82.45792 92.15489,77.55924 97.55973,75 100)
SELECT ST_AsText(ST_SnapToGrid(ST_CurveToLine('CIRCULARSTRING(99.33034 45, 86.8034 86.2957,75 100)',16),0.00001));

-- st_azimuth02.wkt
POINT(75 100); --point 1
POINT(25 45); -- point 2
SELECT ST_AsText(
	ST_MakeLine(
		ST_Point(75,100), ST_Point(75 + ST_Length('LINESTRING(25 45,75 100)'::Geometry) ,100))
	); -- horizontal -- LINESTRING(75 100,149.33034 100)

-- control point
SELECT ST_AsText(
	ST_SnapToGrid(
		ST_PointN(ST_Boundary(ST_Buffer(ST_Point(75, 100),ST_Length('LINESTRING(25 45,75 100)'::Geometry))),30),
		0.0001)); --POINT(136.8034 141.2957)

-- arc from horizontal
-- LINESTRING(149.33034 100,148.97241 107.28565,147.90209 114.50113,146.12969 121.57695,143.67226 128.44498,140.55349 135.03907,136.8034 141.29571,132.4581 147.15465,127.55946 152.55946,122.15464 157.4581,116.29569 161.80338,110.03905 165.55347,103.44496 168.67223,96.57693 171.12965,89.5011 172.90205,82.28562 173.97236,74.99997 174.33027,67.71433 173.97235,60.49885 172.90203,53.42302 171.12962,46.55499 168.6722,39.96091 165.55342,33.70427 161.80333,27.84533 157.45804,22.44051 152.55939,17.54187 147.15457,13.19659 141.29563,9.44651 135.03898,6.32774 128.44489,3.87032 121.57686,2.09792 114.50103,1.02761 107.28555,0.6697 99.99991,1.02762 92.71426,2.09794 85.49878,3.87035 78.42295,6.32777 71.55493,9.44655 64.96084,13.19664 58.7042,17.54193 52.84526,22.44058 47.44045,25 45)
SELECT ST_AsText(ST_SnapToGrid(ST_CurveToLine('CIRCULARSTRING(149.33034 100, 136.8034 141.2957,25 45)',16),0.00001));