]> granicus.if.org Git - postgis/commitdiff
Split the basic geometry accessors into a separate static library liblwgeom.a; this...
authorMark Cave-Ayland <mark.cave-ayland@siriusit.co.uk>
Sun, 29 Jun 2008 19:11:48 +0000 (19:11 +0000)
committerMark Cave-Ayland <mark.cave-ayland@siriusit.co.uk>
Sun, 29 Jun 2008 19:11:48 +0000 (19:11 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@2815 b70326c6-7e19-0410-871a-916f4a2858ee

41 files changed:
GNUmakefile
configure.ac
liblwgeom/Makefile.in [new file with mode: 0644]
liblwgeom/box2d.c [moved from lwgeom/box2d.c with 100% similarity]
liblwgeom/lex.yy.c [moved from lwgeom/lex.yy.c with 100% similarity]
liblwgeom/liblwgeom.h [moved from lwgeom/liblwgeom.h with 99% similarity]
liblwgeom/lwcollection.c [moved from lwgeom/lwcollection.c with 99% similarity]
liblwgeom/lwcompound.c [moved from lwgeom/lwcompound.c with 100% similarity]
liblwgeom/lwcurve.c [moved from lwgeom/lwcurve.c with 100% similarity]
liblwgeom/lwcurvepoly.c [moved from lwgeom/lwcurvepoly.c with 100% similarity]
liblwgeom/lwgeom.c [moved from lwgeom/lwgeom.c with 99% similarity]
liblwgeom/lwgeom_api.c [moved from lwgeom/lwgeom_api.c with 100% similarity]
liblwgeom/lwgparse.c [moved from lwgeom/lwgparse.c with 100% similarity]
liblwgeom/lwgunparse.c [moved from lwgeom/wktunparse.c with 99% similarity]
liblwgeom/lwline.c [moved from lwgeom/lwline.c with 99% similarity]
liblwgeom/lwmcurve.c [moved from lwgeom/lwmcurve.c with 100% similarity]
liblwgeom/lwmline.c [moved from lwgeom/lwmline.c with 98% similarity]
liblwgeom/lwmpoint.c [moved from lwgeom/lwmpoint.c with 97% similarity]
liblwgeom/lwmpoly.c [moved from lwgeom/lwmpoly.c with 97% similarity]
liblwgeom/lwmsurface.c [moved from lwgeom/lwmsurface.c with 100% similarity]
liblwgeom/lwpoint.c [moved from lwgeom/lwpoint.c with 99% similarity]
liblwgeom/lwpoly.c [moved from lwgeom/lwpoly.c with 99% similarity]
liblwgeom/lwutil.c [moved from lwgeom/liblwgeom.c with 59% similarity]
liblwgeom/measures.c [moved from lwgeom/measures.c with 99% similarity]
liblwgeom/ptarray.c [moved from lwgeom/ptarray.c with 99% similarity]
liblwgeom/vsprintf.c [moved from lwgeom/vsprintf.c with 100% similarity]
liblwgeom/wktparse.h [moved from lwgeom/wktparse.h with 100% similarity]
liblwgeom/wktparse.lex [moved from lwgeom/wktparse.lex with 100% similarity]
liblwgeom/wktparse.tab.c [moved from lwgeom/wktparse.tab.c with 100% similarity]
liblwgeom/wktparse.tab.h [moved from lwgeom/wktparse.tab.h with 100% similarity]
liblwgeom/wktparse.y [moved from lwgeom/wktparse.y with 100% similarity]
lwgeom/Makefile.in
lwgeom/lwgeom_dump.c
lwgeom/lwgeom_functions_basic.c
lwgeom/lwgeom_geos_c.c
lwgeom/lwgeom_gist.c
lwgeom/lwgeom_inout.c
lwgeom/lwgeom_ogc.c
lwgeom/lwgeom_pg.c
lwgeom/lwgeom_pg.h
lwgeom/lwgeom_sqlmm.c

index 55baf36c0d81311a2452f558f7a53fe4a0d99ff6..119b3114830f7c629af456ba6f5e72983aaa76b0 100644 (file)
@@ -4,13 +4,13 @@
 #
 #-----------------------------------------------------
 
-all: liblwgeom loaderdumper utils 
+all: postgis loaderdumper utils 
 
-install: all liblwgeom-install loaderdumper-install 
+install: all postgis-install loaderdumper-install 
 
-uninstall: liblwgeom-uninstall loaderdumper-uninstall docs-uninstall 
+uninstall: postgis-uninstall loaderdumper-uninstall docs-uninstall 
 
-clean: liblwgeom-clean loaderdumper-clean docs-clean test-clean 
+clean: liblwgeom-clean postgis-clean loaderdumper-clean docs-clean test-clean 
        rm -f lwpostgis.sql lwpostgis_upgrade.sql
 
 distclean: clean
@@ -35,16 +35,24 @@ test check:
 test-clean:
        $(MAKE) -C regress clean
 
-liblwgeom: 
-       $(MAKE) -C lwgeom 
+liblwgeom/liblwgeom.a:
+       $(MAKE) -C liblwgeom 
+
+liblwgeom: liblwgeom/liblwgeom.a 
 
 liblwgeom-clean:
+       $(MAKE) -C liblwgeom clean
+
+postgis: liblwgeom/liblwgeom.a 
+       $(MAKE) -C lwgeom 
+
+postgis-clean:
        $(MAKE) -C lwgeom clean
 
-liblwgeom-install:
+postgis-install:
        $(MAKE) -C lwgeom install
 
-liblwgeom-uninstall:
+postgis-uninstall:
        $(MAKE) -C lwgeom uninstall
 
 loaderdumper:
index 7d50a312dd4d9358accc0d81aa1e91c0d47a33b4..bd9697a9a25496df008c6ed5bedd6f5dfc9fe1fd 100644 (file)
@@ -357,5 +357,5 @@ AC_SUBST([SHLIB_LINK])
 dnl AC_MSG_RESULT([SHLIB_LINK: $SHLIB_LINK])
 
 dnl Output the relevant files
-AC_OUTPUT([lwgeom/Makefile lwgeom/sqldefines.h loader/Makefile.pgsql2shp loader/Makefile.shp2pgsql regress/Makefile doc/Makefile])
+AC_OUTPUT([liblwgeom/Makefile lwgeom/Makefile lwgeom/sqldefines.h loader/Makefile.pgsql2shp loader/Makefile.shp2pgsql regress/Makefile doc/Makefile])
 
diff --git a/liblwgeom/Makefile.in b/liblwgeom/Makefile.in
new file mode 100644 (file)
index 0000000..ffbbbb4
--- /dev/null
@@ -0,0 +1,51 @@
+# **********************************************************************
+# * $Id: Makefile.in 
+# *
+# * PostGIS - Spatial Types for PostgreSQL
+# * http://postgis.refractions.net
+# * Copyright 2008 Mark Cave-Ayland
+# *
+# * This is free software; you can redistribute and/or modify it under
+# * the terms of the GNU General Public Licence. See the COPYING file.
+# *
+# **********************************************************************
+
+CC=@CC@
+CFLAGS=@CFLAGS@ -Wall -Wmissing-prototypes -fPIC 
+
+# Standalone LWGEOM objects
+SA_OBJS=measures.o \
+       box2d.o \
+       ptarray.o \
+       lwgeom_api.o \
+       lwgeom.o \
+       lwpoint.o \
+       lwline.o \
+       lwpoly.o \
+       lwmpoint.o \
+       lwmline.o \
+       lwmpoly.o \
+       lwcollection.o \
+       lwcurve.o \
+       lwcompound.o \
+       lwcurvepoly.o \
+       lwmcurve.o \
+       lwmsurface.o \
+       lwutil.o \
+       lwgunparse.o \
+       lwgparse.o \
+       wktparse.tab.o \
+       lex.yy.o \
+       vsprintf.o      
+
+all: $(SA_OBJS)
+       ar rs liblwgeom.a $(SA_OBJS)    
+
+clean:
+       rm -f $(SA_OBJS) 
+       rm -f liblwgeom.a 
+
+# Command to build each of the .o files
+$(SA_OBJS): %.o: %.c
+       $(CC) $(CFLAGS) -c -o $@ $<
similarity index 100%
rename from lwgeom/box2d.c
rename to liblwgeom/box2d.c
similarity index 100%
rename from lwgeom/lex.yy.c
rename to liblwgeom/lex.yy.c
similarity index 99%
rename from lwgeom/liblwgeom.h
rename to liblwgeom/liblwgeom.h
index b9ca41cced477d921d8ff6a41b83a48baa74ace5..4067b871fa7c0879573f07d143d0ea5fb90c52e3 100644 (file)
@@ -3,7 +3,7 @@
 
 #include "../postgis_config.h"
 #include <stdio.h>
-#include "compat.h"
+/* #include "compat.h" */
 
 #define INTEGRITY_CHECKS 1
 
@@ -24,6 +24,8 @@
 /*
  * Memory management function types
  */
+extern void lwgeom_init_allocators(void);
+
 typedef void* (*lwallocator)(size_t size);
 typedef void* (*lwreallocator)(void *mem, size_t size);
 typedef void (*lwfreeor)(void* mem);
@@ -1111,8 +1113,12 @@ extern LWCOLLECTION *lwcollection_segmentize2d(LWCOLLECTION *coll, double dist);
 
 extern uchar parse_hex(char *str);
 extern void deparse_hex(uchar str, char *result);
-extern SERIALIZED_LWGEOM *parse_lwgeom_wkt(char *wkt_input);
 
+/* Parser access routines */
+extern char *unparse_WKT(uchar* serialized, lwallocator alloc, lwfreeor free);
+extern char *unparse_WKB(uchar* serialized, lwallocator alloc, lwfreeor free, char endian, size_t *outsize, uchar hex);
+
+extern SERIALIZED_LWGEOM *parse_lwgeom_wkt(char *wkt_input);
 extern char *lwgeom_to_ewkt(LWGEOM *lwgeom);
 extern char *lwgeom_to_hexwkb(LWGEOM *lwgeom, unsigned int byteorder);
 extern LWGEOM *lwgeom_from_ewkb(uchar *ewkb, size_t ewkblen);
similarity index 99%
rename from lwgeom/lwcollection.c
rename to liblwgeom/lwcollection.c
index 6cb8515fab2218166d0bbe5f28a5240516d99695..9f7374b62317b7d7c767c4bf9c135d4bf471f193 100644 (file)
@@ -1,5 +1,5 @@
 /**********************************************************************
- * $Id$
+ * $Id: lwcollection.c 2797 2008-05-31 09:56:44Z mcayland $
  *
  * PostGIS - Spatial Types for PostgreSQL
  * http://postgis.refractions.net
similarity index 100%
rename from lwgeom/lwcompound.c
rename to liblwgeom/lwcompound.c
similarity index 100%
rename from lwgeom/lwcurve.c
rename to liblwgeom/lwcurve.c
similarity index 100%
rename from lwgeom/lwcurvepoly.c
rename to liblwgeom/lwcurvepoly.c
similarity index 99%
rename from lwgeom/lwgeom.c
rename to liblwgeom/lwgeom.c
index cb492c5629dd700dcaff8b425c528fad65b6d739..a6972b5818f864a670bc253837b890bce755860a 100644 (file)
@@ -1,5 +1,5 @@
 /**********************************************************************
- * $Id$
+ * $Id: lwgeom.c 2797 2008-05-31 09:56:44Z mcayland $
  *
  * PostGIS - Spatial Types for PostgreSQL
  * http://postgis.refractions.net
similarity index 100%
rename from lwgeom/lwgeom_api.c
rename to liblwgeom/lwgeom_api.c
similarity index 100%
rename from lwgeom/lwgparse.c
rename to liblwgeom/lwgparse.c
similarity index 99%
rename from lwgeom/wktunparse.c
rename to liblwgeom/lwgunparse.c
index b6dffed3165123e29155e6251d5be71eece08f43..c68ecf82a4316bf02fc62961906038808b3c2450 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright Telogis 2004
  * www.telogis.com
  *
- * $Id$
+ * $Id: wktunparse.c 2781 2008-05-22 20:43:00Z mcayland $
  */
 
 
similarity index 99%
rename from lwgeom/lwline.c
rename to liblwgeom/lwline.c
index 6078c2e68df259d783cd25d63644f1a9f2355449..69a063d945cfcacc894c6d449ef1bf4c481f77e0 100644 (file)
@@ -1,5 +1,5 @@
 /**********************************************************************
- * $Id$
+ * $Id: lwline.c 2797 2008-05-31 09:56:44Z mcayland $
  *
  * PostGIS - Spatial Types for PostgreSQL
  * http://postgis.refractions.net
similarity index 100%
rename from lwgeom/lwmcurve.c
rename to liblwgeom/lwmcurve.c
similarity index 98%
rename from lwgeom/lwmline.c
rename to liblwgeom/lwmline.c
index 7f8d45568117a1ea108edd00d5c3893aa08dabe6..ba6a861661deb66340b6b47468cf91281491ba2b 100644 (file)
@@ -1,5 +1,5 @@
 /**********************************************************************
- * $Id$
+ * $Id: lwmline.c 2369 2006-05-30 08:38:58Z strk $
  *
  * PostGIS - Spatial Types for PostgreSQL
  * http://postgis.refractions.net
similarity index 97%
rename from lwgeom/lwmpoint.c
rename to liblwgeom/lwmpoint.c
index 1faa3724a26dd61cc326f4af2b2876e8023ef49d..7421454e9b5540e768721358d45f5e6135625b32 100644 (file)
@@ -1,5 +1,5 @@
 /**********************************************************************
- * $Id$
+ * $Id: lwmpoint.c 2369 2006-05-30 08:38:58Z strk $
  *
  * PostGIS - Spatial Types for PostgreSQL
  * http://postgis.refractions.net
similarity index 97%
rename from lwgeom/lwmpoly.c
rename to liblwgeom/lwmpoly.c
index 3673c16ae10e173e78ae5b94b208929319d8ae1b..b94baa62b35ccaf31663cabbb59482cf0f1a4c11 100644 (file)
@@ -1,5 +1,5 @@
 /**********************************************************************
- * $Id$
+ * $Id: lwmpoly.c 2797 2008-05-31 09:56:44Z mcayland $
  *
  * PostGIS - Spatial Types for PostgreSQL
  * http://postgis.refractions.net
similarity index 100%
rename from lwgeom/lwmsurface.c
rename to liblwgeom/lwmsurface.c
similarity index 99%
rename from lwgeom/lwpoint.c
rename to liblwgeom/lwpoint.c
index bf6e2b995b41b5fea24d557bbd67dfd3ae20b7de..6557e2760105cd93a618ba2743036df061a783ad 100644 (file)
@@ -1,5 +1,5 @@
 /**********************************************************************
- * $Id$
+ * $Id: lwpoint.c 2797 2008-05-31 09:56:44Z mcayland $
  *
  * PostGIS - Spatial Types for PostgreSQL
  * http://postgis.refractions.net
similarity index 99%
rename from lwgeom/lwpoly.c
rename to liblwgeom/lwpoly.c
index adb681ac61efad5d47b149e2919a9f6702be94ac..80b1aec4edaea3b6ff609a051e39d21b944e7247 100644 (file)
@@ -1,5 +1,5 @@
 /**********************************************************************
- * $Id$
+ * $Id: lwpoly.c 2797 2008-05-31 09:56:44Z mcayland $
  *
  * PostGIS - Spatial Types for PostgreSQL
  * http://postgis.refractions.net
similarity index 59%
rename from lwgeom/liblwgeom.c
rename to liblwgeom/lwutil.c
index 1253577b3a87eeb8133c41744c56625ce4b41afb..5ed0702361ca3bdeebe9c26f8244bd27ee55caef 100644 (file)
@@ -1,39 +1,24 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdarg.h>
+#include <string.h>
 
-#define CONTEXT_PG 0
-#define CONTEXT_SA 1
-
-
-
-#ifdef STANDALONE
-#define DEFAULT_CONTEXT CONTEXT_SA
-#else
-#define DEFAULT_CONTEXT CONTEXT_PG
-#endif
 
 /* Global variables */
 #include "../postgis_config.h"
-
-#if DEFAULT_CONTEXT == CONTEXT_SA
-#include "liblwgeom.h"
-lwallocator lwalloc_var = default_allocator;
-lwreallocator lwrealloc_var = default_reallocator;
-lwfreeor lwfree_var = default_freeor;
-lwreporter lwerror = default_errorreporter;
-lwreporter lwnotice = default_noticereporter;
-#else
-#include "lwgeom_pg.h"
 #include "liblwgeom.h"
 
-lwallocator lwalloc_var = pg_alloc;
-lwreallocator lwrealloc_var = pg_realloc;
-lwfreeor lwfree_var = pg_free;
-lwreporter lwerror = pg_error;
-lwreporter lwnotice = pg_notice;
-#endif
+void *init_allocator(size_t size);
+void init_freeor(void *mem);
+void *init_reallocator(void *mem, size_t size);
+void init_noticereporter(const char *fmt, ...);
+void init_errorreporter(const char *fmt, ...);
 
+lwallocator lwalloc_var = init_allocator;
+lwreallocator lwrealloc_var = init_reallocator;
+lwfreeor lwfree_var = init_freeor;
+lwreporter lwerror = init_errorreporter;
+lwreporter lwnotice = init_noticereporter;
 
 static char *lwgeomTypeName[] = {
        "Unknown",
@@ -54,6 +39,74 @@ static char *lwgeomTypeName[] = {
         "MultiSurface"
 };
 
+
+/*
+ * Initialisation allocators
+ *
+ * These are used the first time any of the allocators are called
+ * to enable executables/libraries that link into liblwgeom to
+ * be able to set up their own allocators. This is mainly useful
+ * for older PostgreSQL versions that don't have functions that
+ * are called upon startup.
+ */
+
+void *
+init_allocator(size_t size)
+{
+       lwgeom_init_allocators();
+
+       return lwalloc_var(size);
+}
+
+void 
+init_freeor(void *mem)
+{
+       lwgeom_init_allocators();
+
+       lwfree_var(mem);
+}
+
+void *
+init_reallocator(void *mem, size_t size)
+{
+       lwgeom_init_allocators();
+
+       return lwrealloc_var(mem, size);
+}
+
+void
+init_noticereporter(const char *fmt, ...)
+{
+       va_list ap;
+
+       lwgeom_init_allocators();
+
+       va_start(ap, fmt);
+       lwnotice(fmt, ap);
+       va_end(ap);
+}
+       
+void
+init_errorreporter(const char *fmt, ...)
+{
+       va_list ap;
+
+       lwgeom_init_allocators();
+
+       va_start(ap, fmt);
+       lwerror(fmt, ap);
+       va_end(ap);
+}
+
+
+/*
+ * Default allocators
+ *
+ * We include some default allocators that use malloc/free/realloc
+ * along with stdout/stderr since this is the most common use case
+ *
+ */
+
 void *
 default_allocator(size_t size)
 {
@@ -119,6 +172,22 @@ default_errorreporter(const char *fmt, ...)
        exit(1);
 }
 
+
+/*
+ * This function should be called from lwgeom_init_allocators() by programs
+ * which wish to use the default allocators above
+ */
+
+void lwgeom_install_default_allocators()
+{
+       lwalloc_var = default_allocator;
+       lwrealloc_var = default_reallocator;
+       lwfree_var = default_freeor;
+       lwerror = default_errorreporter;        
+       lwnotice = default_noticereporter;
+}
+
 const char *
 lwgeom_typename(int type)
 {
similarity index 99%
rename from lwgeom/measures.c
rename to liblwgeom/measures.c
index 3cffc3eb4ba7ab5dcfa447116d392bf2a6717cef..2b860975d233df3194d3d37956201f5f95eb01d5 100644 (file)
@@ -1,5 +1,5 @@
 /**********************************************************************
- * $Id$
+ * $Id: measures.c 2797 2008-05-31 09:56:44Z mcayland $
  *
  * PostGIS - Spatial Types for PostgreSQL
  * http://postgis.refractions.net
similarity index 99%
rename from lwgeom/ptarray.c
rename to liblwgeom/ptarray.c
index 3b3ef6c7b9a35309be42244f871e6d1e1121727b..02e5b6b1d22b20026dc26c823965fb2888b1ea81 100644 (file)
@@ -1,5 +1,5 @@
 /**********************************************************************
- * $Id$
+ * $Id: ptarray.c 2797 2008-05-31 09:56:44Z mcayland $
  *
  * PostGIS - Spatial Types for PostgreSQL
  * http://postgis.refractions.net
similarity index 100%
rename from lwgeom/vsprintf.c
rename to liblwgeom/vsprintf.c
similarity index 100%
rename from lwgeom/wktparse.h
rename to liblwgeom/wktparse.h
similarity index 100%
rename from lwgeom/wktparse.lex
rename to liblwgeom/wktparse.lex
similarity index 100%
rename from lwgeom/wktparse.y
rename to liblwgeom/wktparse.y
index 1cd0a829678a0c07fcedc4fa53469f22a9a96b87..076f89cdde652f94b4ddc7208cfe75d9532a1905 100644 (file)
@@ -20,33 +20,8 @@ DATA=../spatial_ref_sys.sql
 # SQL objects (files requiring C pre-processing)
 SQL_OBJS=lwpostgis.sql.in
 
-# Standalone LWGEOM objects
-SA_OBJS=measures.o \
-       box2d.o \
-       ptarray.o \
-       lwgeom_api.o \
-       lwgeom.o \
-       lwpoint.o \
-       lwline.o \
-       lwpoly.o \
-       lwmpoint.o \
-       lwmline.o \
-       lwmpoly.o \
-       lwcollection.o \
-       lwcurve.o \
-       lwcompound.o \
-       lwcurvepoly.o \
-       lwmcurve.o \
-       lwmsurface.o \
-       wktunparse.o \
-       lwgparse.o \
-       wktparse.tab.o \
-       lex.yy.o \
-       vsprintf.o      
-
 # PostgreSQL objects
-PG_OBJS=liblwgeom.o \
-       lwgeom_pg.o \
+PG_OBJS=lwgeom_pg.o \
        lwgeom_debug.o \
        lwgeom_spheroid.o \
        lwgeom_ogc.o \
@@ -75,10 +50,11 @@ PG_OBJS=liblwgeom.o \
        lwgeom_rtree.o
 
 # Objects to build using PGXS
-OBJS=$(SA_OBJS) $(PG_OBJS)
+OBJS=$(PG_OBJS)
 
 # Libraries to link into the module (proj, geos)
-SHLIB_LINK=@SHLIB_LINK@
+PG_CPPFLAGS=@CPPFLAGS@ -I../liblwgeom
+SHLIB_LINK=@SHLIB_LINK@ -L../liblwgeom -llwgeom
 
 # Extra files to remove during 'make clean'
 EXTRA_CLEAN=$(SQL_OBJS)
index f37225c235802212827f331e9da1dca95874f386..e3f4d28ba29caf6312b85ffa9ac4162532074ae6 100644 (file)
@@ -17,8 +17,6 @@
 #include "liblwgeom.h"
 #include "lwgeom_pg.h"
 #include "profile.h"
-#include "wktparse.h"
-
 
 Datum LWGEOM_dump(PG_FUNCTION_ARGS);
 Datum LWGEOM_dump_rings(PG_FUNCTION_ARGS);
index 2ee46a1430ed11ea3e060c4b56ae9d8ce8d08c35..474dc786bd2d922565ccefe9a2a4e7014024a569 100644 (file)
@@ -25,8 +25,6 @@
 #include "liblwgeom.h"
 #include "lwgeom_pg.h"
 #include "profile.h"
-#include "wktparse.h"
-
 
 Datum LWGEOM_mem_size(PG_FUNCTION_ARGS);
 Datum LWGEOM_summary(PG_FUNCTION_ARGS);
@@ -112,8 +110,6 @@ Datum LWGEOM_summary(PG_FUNCTION_ARGS)
        text *mytext;
        LWGEOM *lwgeom;
 
-       init_pg_func();
-
        lwgeom = lwgeom_deserialize(SERIALIZED_FORM(geom));
 
        result = lwgeom_summary(lwgeom, 0);
@@ -2910,11 +2906,9 @@ Datum LWGEOM_asEWKT(PG_FUNCTION_ARGS)
        PG_LWGEOM *lwgeom;
        char *result_cstring;
        int len;
-    char *result,*loc_wkt;
+       char *result,*loc_wkt;
        /*char *semicolonLoc; */
 
-       init_pg_func();
-
        lwgeom = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
        result_cstring =  unparse_WKT(SERIALIZED_FORM(lwgeom),lwalloc,lwfree);
 
@@ -2954,8 +2948,6 @@ Datum LWGEOM_azimuth(PG_FUNCTION_ARGS)
        double result;
        int SRID;
 
-       init_pg_func();
-
        /* Extract first point */
        geom = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
        lwpoint = lwpoint_deserialize(SERIALIZED_FORM(geom));
index cb210b68d88ae8767ddc0cd696988f91a84c421a..06f8d514ae575e42b7e3eac817100a2366babc66 100644 (file)
@@ -8,7 +8,7 @@
 #include "lwgeom_pg.h"
 #include "liblwgeom.h"
 #include "profile.h"
-#include "wktparse.h"
+
 #include "geos_c.h"
 #include "lwgeom_rtree.h"
 
index 01d3c2d05cd7a6024ab25f88772d0ba6fc8c7836..c69666026e2c4adf5a6781bbafca9474530d49e9 100644 (file)
 #include "lwgeom_pg.h"
 #include "stringBuffer.h"
 
-#if POSTGIS_DEBUG_LEVEL > 0
-#include "wktparse.h"
-#endif
-
 
 /*
  * implementation GiST support and basic LWGEOM operations (like &&)
index e981a1c41889e5d6f42e62e6875ff46a3d3ce1e7..8e75a7f633323aa4f2b8cec3c1936651460b9a96 100644 (file)
@@ -24,7 +24,6 @@
 
 
 #include "lwgeom_pg.h"
-#include "wktparse.h"
 #include "profile.h"
 
 void elog_ERROR(const char* string);
@@ -97,8 +96,6 @@ Datum LWGEOM_out(PG_FUNCTION_ARGS)
        PG_LWGEOM *lwgeom;
        char *result;
 
-       init_pg_func();
-
        lwgeom = (PG_LWGEOM *)  PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
        result = unparse_WKB(SERIALIZED_FORM(lwgeom),lwalloc,lwfree,-1,NULL,1);
 
@@ -118,8 +115,6 @@ Datum LWGEOM_asHEXEWKB(PG_FUNCTION_ARGS)
        text *type;
        unsigned int byteorder=-1;
 
-       init_pg_func();
-
        lwgeom = (PG_LWGEOM *)  PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
 
        if ( (PG_NARGS()>1) && (!PG_ARGISNULL(1)) )
@@ -169,8 +164,6 @@ Datum LWGEOM_to_text(PG_FUNCTION_ARGS)
        text *text_result;
        size_t size;
 
-       init_pg_func();
-
        lwgeom = (PG_LWGEOM *)  PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
        result = unparse_WKB(SERIALIZED_FORM(lwgeom),lwalloc,lwfree,-1,&size,1);
 
@@ -250,8 +243,6 @@ Datum WKBFromLWGEOM(PG_FUNCTION_ARGS)
        profstart(PROF_QRUN);
 #endif
 
-       init_pg_func();
-
        if ( (PG_NARGS()>1) && (!PG_ARGISNULL(1)) )
        {
                type = PG_GETARG_TEXT_P(1);
@@ -479,8 +470,6 @@ Datum parse_WKT_lwgeom(PG_FUNCTION_ARGS)
        char *wkt;
        int wkt_size ;
 
-       init_pg_func();
-
        wkt_size = VARSIZE(wkt_input)-VARHDRSZ; /* actual letters */
 
        wkt = palloc( wkt_size+1); /* +1 for null */
@@ -490,7 +479,7 @@ Datum parse_WKT_lwgeom(PG_FUNCTION_ARGS)
 
        POSTGIS_DEBUGF(3, "in parse_WKT_lwgeom with input: '%s'",wkt);
 
-       serialized_lwgeom = parse_lwg((const char *)wkt, (allocator)lwalloc, (report_error)elog_ERROR);
+       serialized_lwgeom = parse_lwgeom_wkt(wkt);
        lwgeom = lwgeom_deserialize(serialized_lwgeom->lwgeom);
     
        ret = pglwgeom_serialize(lwgeom);
index d0f1bd421691a8c0e63c0cb8f74a0a829c1a326f..51195282d90e9cde3bb908b4454b3b95023c5234 100644 (file)
@@ -28,9 +28,6 @@
 #include "lwgeom_pg.h"
 
 
-
-#include "wktparse.h"
-
 /* ---- SRID(geometry) */
 Datum LWGEOM_getSRID(PG_FUNCTION_ARGS);
 /* ---- SetSRID(geometry, integer) */
@@ -121,8 +118,6 @@ Datum LWGEOM_getTYPE(PG_FUNCTION_ARGS)
        int32 size;
        uchar type;
 
-       init_pg_func();
-
        lwgeom = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
        text_ob = lwalloc(20+VARHDRSZ);
        result = text_ob+VARHDRSZ;
@@ -1077,8 +1072,6 @@ Datum LWGEOM_asText(PG_FUNCTION_ARGS)
         
        POSTGIS_DEBUG(2, "LWGEOM_asText called.");
 
-       init_pg_func();
-
        lwgeom = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
 
        /* Force to 2d */
@@ -1113,8 +1106,6 @@ Datum LWGEOM_asBinary(PG_FUNCTION_ARGS)
        PG_LWGEOM *ogclwgeom;
        char *result;
 
-       init_pg_func();
-
        /* Force to 2d */
        ogclwgeom = (PG_LWGEOM *)DatumGetPointer(DirectFunctionCall1(
                LWGEOM_force_2d, PG_GETARG_DATUM(0)));
index d89c1f1a1ed44e8bb5cc27de1cb9cc68557ac65f..febf88feff95cfe711d1142ac9bbcd3d10185bfc 100644 (file)
@@ -8,8 +8,6 @@
 #include <executor/spi.h>
 #include "liblwgeom.h"
 #include "lwgeom_pg.h"
-#include "wktparse.h"
-
 
 
 #define PARANOIA_LEVEL 1
@@ -17,7 +15,6 @@
 /*
  * This is required for builds against pgsql 8.2
  */
-/*#include "pgmagic.h"*/
 #ifdef PG_MODULE_MAGIC
 PG_MODULE_MAGIC;
 #endif
@@ -100,8 +97,9 @@ pg_notice(const char *fmt, ...)
 }
 
 void
-init_pg_func(void)
+lwgeom_init_allocators(void)
 {
+       /* liblwgeom callback - install PostgreSQL handlers */
        lwalloc_var = pg_alloc;
        lwrealloc_var = pg_realloc;
        lwfree_var = pg_free;
index c82f87e1f37b3e7ee55b0b74ef577533f909a244..67873174d29a4ae73157decf8d34bd929d9dbc6c 100644 (file)
@@ -67,9 +67,6 @@ extern int pglwgeom_getSRID(PG_LWGEOM *pglwgeom);
 
 extern Oid getGeometryOID(void);
 
-/* call this as first thing of any PG function */
-void init_pg_func(void);
-
 /* PG-dependant */
 /* BOX is postgresql standard type */
 extern void box_to_box2df_p(BOX *box, BOX2DFLOAT4 *out);  
index 442d45498c264b48c23e0524bbb79845caa21014..9390ccaf129bb0d3b0d854327672a2056556ffed 100644 (file)
@@ -19,7 +19,7 @@
 #include "postgres.h"
 #include "liblwgeom.h"
 #include "fmgr.h"
-#include "wktparse.h"
+
 #include "lwgeom_pg.h"