]> granicus.if.org Git - postgis/commitdiff
Added point constructors PG funx.
authorSandro Santilli <strk@keybit.net>
Wed, 13 Oct 2004 15:19:10 +0000 (15:19 +0000)
committerSandro Santilli <strk@keybit.net>
Wed, 13 Oct 2004 15:19:10 +0000 (15:19 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@990 b70326c6-7e19-0410-871a-916f4a2858ee

lwgeom/liblwgeom.h
lwgeom/lwgeom_functions_basic.c
lwgeom/lwpostgis.sql.in

index 01e887b79f05ffefe85725a91b99ff6d618923d0..1ead401c3765bede1f0b21d27072463904c3209e 100644 (file)
@@ -350,10 +350,10 @@ extern int pointArray_ptsize(const POINTARRAY *pa);
 #define WKBZOFFSET 0x80000000
 #define WKBMOFFSET 0x40000000
 
-#define TYPE_SETTYPE(c,t) ((c)=(((c)&0xF0)|t))
-#define TYPE_SETZM(t,z,m) ((t)=(((t)&0xCF)|(z<<5)|(m<<4)))
-#define TYPE_SETHASBBOX(t,b) ((t)=(((t)&0x7F)|(b<<7)))
-#define TYPE_SETHASSRID(t,s) ((t)=(((t)&0xBF)|(s<<6)))
+#define TYPE_SETTYPE(c,t) ((c)=(((c)&0xF0)|(t)))
+#define TYPE_SETZM(t,z,m) ((t)=(((t)&0xCF)|((z)<<5)|((m)<<4)))
+#define TYPE_SETHASBBOX(t,b) ((t)=(((t)&0x7F)|((b)<<7)))
+#define TYPE_SETHASSRID(t,s) ((t)=(((t)&0xBF)|((s)<<6)))
 
 #define TYPE_HASZ(t) ( ((t)&0x20)>>5 )
 #define TYPE_HASM(t) ( ((t)&0x10)>>4 )
index 64061da317063e569a6a8cb6923daf93458aa226..5bb63bf96a5ed1bd97685ef875858ebeb7ca38f8 100644 (file)
@@ -50,6 +50,10 @@ Datum LWGEOM_reverse(PG_FUNCTION_ARGS);
 Datum LWGEOM_forceRHR_poly(PG_FUNCTION_ARGS);
 Datum LWGEOM_noop(PG_FUNCTION_ARGS);
 Datum LWGEOM_zmflag(PG_FUNCTION_ARGS);
+Datum LWGEOM_makepoint2d(PG_FUNCTION_ARGS);
+Datum LWGEOM_makepoint3dz(PG_FUNCTION_ARGS);
+Datum LWGEOM_makepoint3dm(PG_FUNCTION_ARGS);
+Datum LWGEOM_makepoint4d(PG_FUNCTION_ARGS);
 
 
 /*------------------------------------------------------------------*/
@@ -2076,3 +2080,98 @@ Datum LWGEOM_same(PG_FUNCTION_ARGS)
         PG_RETURN_BOOL(result);
 }
 
+PG_FUNCTION_INFO_V1(LWGEOM_makepoint2d);
+Datum LWGEOM_makepoint2d(PG_FUNCTION_ARGS)
+{
+       double x,y;
+       int SRID;
+       LWPOINT *point;
+       PG_LWGEOM *result;
+       size_t size;
+
+       SRID = PG_GETARG_INT32(0);
+       x = PG_GETARG_FLOAT8(1);
+       y = PG_GETARG_FLOAT8(2);
+
+       point = make_lwpoint2d(SRID, x, y);
+
+       size = lwpoint_serialize_size(point);
+       result = (PG_LWGEOM *)palloc(size+4);
+       result->size = (size+4);
+       lwpoint_serialize_buf(point, SERIALIZED_FORM(result), NULL);
+
+       PG_RETURN_POINTER(result);
+}
+
+PG_FUNCTION_INFO_V1(LWGEOM_makepoint3dz);
+Datum LWGEOM_makepoint3dz(PG_FUNCTION_ARGS)
+{
+       double x,y,z;
+       int SRID;
+       LWPOINT *point;
+       PG_LWGEOM *result;
+       size_t size;
+
+       SRID = PG_GETARG_INT32(0);
+       x = PG_GETARG_FLOAT8(1);
+       y = PG_GETARG_FLOAT8(2);
+       z = PG_GETARG_FLOAT8(3);
+
+       point = make_lwpoint3dz(SRID, x, y, z);
+
+       size = lwpoint_serialize_size(point);
+       result = (PG_LWGEOM *)palloc(size+4);
+       result->size = (size+4);
+       lwpoint_serialize_buf(point, SERIALIZED_FORM(result), NULL);
+
+       PG_RETURN_POINTER(result);
+}
+
+PG_FUNCTION_INFO_V1(LWGEOM_makepoint3dm);
+Datum LWGEOM_makepoint3dm(PG_FUNCTION_ARGS)
+{
+       double x,y,m;
+       int SRID;
+       LWPOINT *point;
+       PG_LWGEOM *result;
+       size_t size;
+
+       SRID = PG_GETARG_INT32(0);
+       x = PG_GETARG_FLOAT8(1);
+       y = PG_GETARG_FLOAT8(2);
+       m = PG_GETARG_FLOAT8(3);
+
+       point = make_lwpoint3dm(SRID, x, y, m);
+
+       size = lwpoint_serialize_size(point);
+       result = (PG_LWGEOM *)palloc(size+4);
+       result->size = (size+4);
+       lwpoint_serialize_buf(point, SERIALIZED_FORM(result), NULL);
+
+       PG_RETURN_POINTER(result);
+}
+
+PG_FUNCTION_INFO_V1(LWGEOM_makepoint4d);
+Datum LWGEOM_makepoint4d(PG_FUNCTION_ARGS)
+{
+       double x,y,z,m;
+       int SRID;
+       LWPOINT *point;
+       PG_LWGEOM *result;
+       size_t size;
+
+       SRID = PG_GETARG_INT32(0);
+       x = PG_GETARG_FLOAT8(1);
+       y = PG_GETARG_FLOAT8(2);
+       z = PG_GETARG_FLOAT8(3);
+       m = PG_GETARG_FLOAT8(4);
+
+       point = make_lwpoint4d(SRID, x, y, z, m);
+
+       size = lwpoint_serialize_size(point);
+       result = (PG_LWGEOM *)palloc(size+4);
+       result->size = (size+4);
+       lwpoint_serialize_buf(point, SERIALIZED_FORM(result), NULL);
+
+       PG_RETURN_POINTER(result);
+}
index 75eb6bc0b8be6b82e9d8c7a5cb851e1ced3457f5..8efa5734348b0af986ab9a0b753b597ff07eae6b 100644 (file)
@@ -1648,6 +1648,30 @@ CREATEFUNCTION zmflag(geometry)
        AS '@MODULE_FILENAME@', 'LWGEOM_zmflag'
        LANGUAGE 'C' WITH (iscachable,isstrict);
 
+------------------------------------------------------------------------
+-- CONSTRUCTORS
+------------------------------------------------------------------------
+
+CREATEFUNCTION makepoint2d(integer, float8, float8)
+       RETURNS geometry
+       AS '@MODULE_FILENAME@', 'LWGEOM_makepoint2d'
+       LANGUAGE 'C' WITH (iscachable,isstrict);
+
+CREATEFUNCTION makepoint3dz(integer, float8, float8, float8)
+       RETURNS geometry
+       AS '@MODULE_FILENAME@', 'LWGEOM_makepoint3dz'
+       LANGUAGE 'C' WITH (iscachable,isstrict);
+
+CREATEFUNCTION makepoint3dm(integer, float8, float8, float8)
+       RETURNS geometry
+       AS '@MODULE_FILENAME@', 'LWGEOM_makepoint3dm'
+       LANGUAGE 'C' WITH (iscachable,isstrict);
+
+CREATEFUNCTION makepoint4d(integer, float8, float8, float8, float8)
+       RETURNS geometry
+       AS '@MODULE_FILENAME@', 'LWGEOM_makepoint4d'
+       LANGUAGE 'C' WITH (iscachable,isstrict);
+
 ------------------------------------------------------------------------
 
 --