Skip to content

Commit 7230e16

Browse files
committed
Support ST_Expand
Wow that function is overloaded...
1 parent a74b4c4 commit 7230e16

File tree

4 files changed

+364
-15
lines changed

4 files changed

+364
-15
lines changed

regress/expected/postgis.out

+161
Original file line numberDiff line numberDiff line change
@@ -2229,6 +2229,167 @@ RETURN ST_asewkt(st_scale('LINESTRING(1 1, 2 2)'::geometry, 'POINT(2 2)'::geomet
22292229
"LINESTRING(1 1,3 3)"
22302230
(1 row)
22312231

2232+
RETURN '200', ST_Expand(null::geometry, 1);
2233+
?column? | st_expand
2234+
----------+-----------
2235+
"200" |
2236+
(1 row)
2237+
2238+
RETURN '201', ST_AsText(ST_Expand('LINESTRING (1 2 3, 10 20 30)'::geometry, 1));
2239+
?column? | st_astext
2240+
----------+-----------------------------------------------------
2241+
"201" | "POLYGON Z ((0 1 2,0 21 2,11 21 31,11 1 31,0 1 2))"
2242+
(1 row)
2243+
2244+
RETURN '202', ST_AsText(ST_Expand('LINESTRINGM (1 2 3, 10 20 30)'::geometry, 1));
2245+
?column? | st_astext
2246+
----------+-----------------------------------------------------
2247+
"202" | "POLYGON M ((0 1 2,0 21 2,11 21 31,11 1 31,0 1 2))"
2248+
(1 row)
2249+
2250+
RETURN '203', ST_AsText(ST_Expand('LINESTRING (1 2, 10 20)'::geometry, 3));
2251+
?column? | st_astext
2252+
----------+--------------------------------------------
2253+
"203" | "POLYGON((-2 -1,-2 23,13 23,13 -1,-2 -1))"
2254+
(1 row)
2255+
2256+
RETURN '204', ST_AsText(ST_Expand('POLYGON EMPTY'::geometry, 4));
2257+
?column? | st_astext
2258+
----------+-----------------
2259+
"204" | "POLYGON EMPTY"
2260+
(1 row)
2261+
2262+
RETURN '205', ST_AsText(ST_Expand('POINT EMPTY'::geometry, 2));
2263+
?column? | st_astext
2264+
----------+---------------
2265+
"205" | "POINT EMPTY"
2266+
(1 row)
2267+
2268+
RETURN '206', ST_AsText(ST_Expand('POINT (2 3)'::geometry, 0));
2269+
?column? | st_astext
2270+
----------+----------------------------------
2271+
"206" | "POLYGON((2 3,2 3,2 3,2 3,2 3))"
2272+
(1 row)
2273+
2274+
RETURN '207', ST_AsText(ST_Expand('LINESTRING (1 2, 3 4)'::geometry, 0));
2275+
?column? | st_astext
2276+
----------+----------------------------------
2277+
"207" | "POLYGON((1 2,1 4,3 4,3 2,1 2))"
2278+
(1 row)
2279+
2280+
RETURN '208', ST_AsText(ST_Expand('POINT (0 0)'::geometry, -1));
2281+
?column? | st_astext
2282+
----------+--------------------------------------
2283+
"208" | "POLYGON((1 1,1 -1,-1 -1,-1 1,1 1))"
2284+
(1 row)
2285+
2286+
RETURN '209', ST_AsText(ST_Expand('LINESTRING (0 0, 10 10)'::geometry, -4));
2287+
?column? | st_astext
2288+
----------+----------------------------------
2289+
"209" | "POLYGON((4 4,4 6,6 6,6 4,4 4))"
2290+
(1 row)
2291+
2292+
RETURN '210', ST_Expand(null::box3d, 1);
2293+
?column? | st_expand
2294+
----------+-----------
2295+
"210" |
2296+
(1 row)
2297+
2298+
RETURN '211', ST_Expand('BOX3D(-1 3 5, -1 6 8)'::BOX3D, 1);
2299+
?column? | st_expand
2300+
----------+---------------------
2301+
"211" | BOX3D(-2 2 4,0 7 9)
2302+
(1 row)
2303+
2304+
RETURN '212', ST_Expand(null::box2d, 1);
2305+
?column? | st_expand
2306+
----------+-----------
2307+
"212" |
2308+
(1 row)
2309+
2310+
RETURN '213', ST_Expand('BOX(-2 3, -1 6'::BOX2D, 4);
2311+
?column? | st_expand
2312+
----------+-----------------
2313+
"213" | BOX(-6 -1,3 10)
2314+
(1 row)
2315+
2316+
RETURN '214', ST_Expand(null::geometry, 1, 1, 1, 1);
2317+
?column? | st_expand
2318+
----------+-----------
2319+
"214" |
2320+
(1 row)
2321+
2322+
RETURN '215', ST_AsText(ST_Expand('LINESTRING (1 2 3, 10 20 30)'::geometry, 1, 4, 2, 7));
2323+
?column? | st_astext
2324+
----------+--------------------------------------------------------
2325+
"215" | "POLYGON Z ((0 -2 1,0 24 1,11 24 32,11 -2 32,0 -2 1))"
2326+
(1 row)
2327+
2328+
RETURN '216', ST_AsText(ST_Expand('LINESTRINGM (1 2 3, 10 20 30)'::geometry, 1, 4, 2, 7));
2329+
?column? | st_astext
2330+
----------+-----------------------------------------------------------
2331+
"216" | "POLYGON M ((0 -2 -4,0 24 -4,11 24 37,11 -2 37,0 -2 -4))"
2332+
(1 row)
2333+
2334+
RETURN '217', ST_AsText(ST_Expand('LINESTRING (1 2, 10 20)'::geometry, 1, 4, 2, 7));
2335+
?column? | st_astext
2336+
----------+-----------------------------------------
2337+
"217" | "POLYGON((0 -2,0 24,11 24,11 -2,0 -2))"
2338+
(1 row)
2339+
2340+
RETURN '218', ST_AsText(ST_Expand('POLYGON EMPTY'::geometry, 4, 3, 1, 1));
2341+
?column? | st_astext
2342+
----------+-----------------
2343+
"218" | "POLYGON EMPTY"
2344+
(1 row)
2345+
2346+
RETURN '219', ST_AsText(ST_Expand('POINT EMPTY'::geometry, 2, 3, 1, -1));
2347+
?column? | st_astext
2348+
----------+---------------
2349+
"219" | "POINT EMPTY"
2350+
(1 row)
2351+
2352+
RETURN '220', ST_AsText(ST_Expand('POINT (2 3)'::geometry, 0, 4, -2, 8));
2353+
?column? | st_astext
2354+
----------+-------------------------------------
2355+
"220" | "POLYGON((2 -1,2 7,2 7,2 -1,2 -1))"
2356+
(1 row)
2357+
2358+
RETURN '221', ST_AsText(ST_Expand('POINT (0 0)'::geometry, -1, -2));
2359+
?column? | st_astext
2360+
----------+--------------------------------------
2361+
"221" | "POLYGON((1 2,1 -2,-1 -2,-1 2,1 2))"
2362+
(1 row)
2363+
2364+
RETURN '222', ST_Expand(null::box3d, 1, 1, 1);
2365+
?column? | st_expand
2366+
----------+-----------
2367+
"222" |
2368+
(1 row)
2369+
2370+
RETURN '223', ST_Expand('BOX3D(-1 3 5, -1 6 8)'::BOX3D, 1, -1, 7);
2371+
?column? | st_expand
2372+
----------+-----------------------
2373+
"223" | BOX3D(-2 4 -2,0 5 15)
2374+
(1 row)
2375+
2376+
RETURN '224', ST_Expand(null::box2d, 1, 1);
2377+
?column? | st_expand
2378+
----------+-----------
2379+
"224" |
2380+
(1 row)
2381+
2382+
RETURN '225', ST_Expand('BOX(-2 3, -1 6'::BOX2D, 4, 2);
2383+
?column? | st_expand
2384+
----------+---------------
2385+
"225" | BOX(-6 1,3 8)
2386+
(1 row)
2387+
2388+
RETURN '226', ST_SRID(ST_Expand('SRID=4326;POINT (0 0)'::geometry, 1))=4326;
2389+
ERROR: function postgraph.st_srid(gtype) does not exist
2390+
LINE 1: RETURN '226', ST_SRID(ST_Expand('SRID=4326;POINT (0 0)'::geo...
2391+
^
2392+
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
22322393
--
22332394
-- Measures
22342395
--

regress/sql/postgis.sql

+34
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,40 @@ RETURN ST_asewkt(ST_Scale('POINT(10 20 -5 3)'::geometry, ST_MakePoint(4, 2, -8))
537537
RETURN ST_asewkt(ST_Scale('POINT(-2 -1 3 2)'::geometry, ST_MakePointM(-2, 3, 4)));
538538
RETURN ST_asewkt(ST_Scale('POINT(10 20 -5 3)'::geometry, ST_MakePoint(-3, 2, -1, 3)));
539539
RETURN ST_asewkt(st_scale('LINESTRING(1 1, 2 2)'::geometry, 'POINT(2 2)'::geometry, 'POINT(1 1)'::geometry));
540+
541+
542+
543+
RETURN '200', ST_Expand(null::geometry, 1);
544+
RETURN '201', ST_AsText(ST_Expand('LINESTRING (1 2 3, 10 20 30)'::geometry, 1));
545+
RETURN '202', ST_AsText(ST_Expand('LINESTRINGM (1 2 3, 10 20 30)'::geometry, 1));
546+
RETURN '203', ST_AsText(ST_Expand('LINESTRING (1 2, 10 20)'::geometry, 3));
547+
RETURN '204', ST_AsText(ST_Expand('POLYGON EMPTY'::geometry, 4));
548+
RETURN '205', ST_AsText(ST_Expand('POINT EMPTY'::geometry, 2));
549+
RETURN '206', ST_AsText(ST_Expand('POINT (2 3)'::geometry, 0));
550+
RETURN '207', ST_AsText(ST_Expand('LINESTRING (1 2, 3 4)'::geometry, 0));
551+
RETURN '208', ST_AsText(ST_Expand('POINT (0 0)'::geometry, -1));
552+
RETURN '209', ST_AsText(ST_Expand('LINESTRING (0 0, 10 10)'::geometry, -4));
553+
RETURN '210', ST_Expand(null::box3d, 1);
554+
RETURN '211', ST_Expand('BOX3D(-1 3 5, -1 6 8)'::BOX3D, 1);
555+
RETURN '212', ST_Expand(null::box2d, 1);
556+
RETURN '213', ST_Expand('BOX(-2 3, -1 6'::BOX2D, 4);
557+
558+
RETURN '214', ST_Expand(null::geometry, 1, 1, 1, 1);
559+
RETURN '215', ST_AsText(ST_Expand('LINESTRING (1 2 3, 10 20 30)'::geometry, 1, 4, 2, 7));
560+
561+
RETURN '216', ST_AsText(ST_Expand('LINESTRINGM (1 2 3, 10 20 30)'::geometry, 1, 4, 2, 7));
562+
RETURN '217', ST_AsText(ST_Expand('LINESTRING (1 2, 10 20)'::geometry, 1, 4, 2, 7));
563+
RETURN '218', ST_AsText(ST_Expand('POLYGON EMPTY'::geometry, 4, 3, 1, 1));
564+
RETURN '219', ST_AsText(ST_Expand('POINT EMPTY'::geometry, 2, 3, 1, -1));
565+
RETURN '220', ST_AsText(ST_Expand('POINT (2 3)'::geometry, 0, 4, -2, 8));
566+
RETURN '221', ST_AsText(ST_Expand('POINT (0 0)'::geometry, -1, -2));
567+
RETURN '222', ST_Expand(null::box3d, 1, 1, 1);
568+
RETURN '223', ST_Expand('BOX3D(-1 3 5, -1 6 8)'::BOX3D, 1, -1, 7);
569+
RETURN '224', ST_Expand(null::box2d, 1, 1);
570+
RETURN '225', ST_Expand('BOX(-2 3, -1 6'::BOX2D, 4, 2);
571+
RETURN '226', ST_SRID(ST_Expand('SRID=4326;POINT (0 0)'::geometry, 1))=4326;
572+
573+
540574
--
541575
-- Measures
542576
--

sql/postgraph-postgis.sql.in

+44-15
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,30 @@
1515
* along with this program. If not, see <https://www.gnu.org/licenses/>.
1616
*/
1717

18-
--
19-
-- Box3D Functions
20-
--
18+
-----------------------------------------------------------------------------
19+
-- GEOMETRY Operators
20+
-----------------------------------------------------------------------------
21+
22+
23+
-- Availability: 2.2.0
24+
CREATE OR REPLACE FUNCTION ST_ShiftLongitude(gtype)
25+
RETURNS gtype
26+
LANGUAGE c
27+
IMMUTABLE
28+
RETURNS NULL ON NULL INPUT
29+
PARALLEL SAFE
30+
COST 1
31+
AS 'MODULE_PATHNAME', 'gtype_longitude_shift';
32+
33+
-- TODO: ST_Wrapx
34+
35+
36+
37+
38+
-----------------------------------------------------------------------------
39+
-- BOX3D FUNCTIONS
40+
-----------------------------------------------------------------------------
41+
2142
CREATE FUNCTION ST_XMin (gtype)
2243
RETURNS gtype
2344
LANGUAGE c
@@ -72,22 +93,30 @@ PARALLEL SAFE
7293
COST 1
7394
AS 'MODULE_PATHNAME', 'gtype_zmax';
7495

75-
-----------------------------------------------------------------------------
76-
-- GEOMETRY Operators
77-
-----------------------------------------------------------------------------
7896

97+
-- Availability: 1.2.2
98+
CREATE OR REPLACE FUNCTION ST_Expand(gtype,gtype)
99+
RETURNS gtype
100+
AS 'MODULE_PATHNAME', 'gtype_ST_Expand'
101+
LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE;
79102

80-
-- Availability: 2.2.0
81-
CREATE OR REPLACE FUNCTION ST_ShiftLongitude(gtype)
103+
CREATE OR REPLACE FUNCTION ST_Expand(gtype, dx float8, dy float8)
82104
RETURNS gtype
83-
LANGUAGE c
84-
IMMUTABLE
85-
RETURNS NULL ON NULL INPUT
86-
PARALLEL SAFE
87-
COST 1
88-
AS 'MODULE_PATHNAME', 'gtype_longitude_shift';
105+
AS 'MODULE_PATHNAME', 'gtype_ST_Expand'
106+
LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE;
107+
108+
-- Availability: 2.3.0
109+
CREATE OR REPLACE FUNCTION ST_Expand(box gtype, dx float8, dy float8, dz float8 DEFAULT 0)
110+
RETURNS gtype
111+
AS 'MODULE_PATHNAME', 'gtype_ST_Expand'
112+
LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE;
113+
114+
-- Availability: 2.3.0
115+
CREATE OR REPLACE FUNCTION ST_Expand(geom gtype, dx gtype, dy gtype, dz gtype DEFAULT '0.0'::gtype, dm gtype DEFAULT '0.0'::gtype)
116+
RETURNS gtype
117+
AS 'MODULE_PATHNAME', 'gtype_ST_Expand'
118+
LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE;
89119

90-
-- TODO: ST_Wrapx
91120

92121
--
93122
-- PostGIS 2D Geometry Operators

0 commit comments

Comments
 (0)