]> granicus.if.org Git - postgis/commitdiff
Move the circ tree caching code out of libpgcommon and into the geography area that...
authorPaul Ramsey <pramsey@cleverelephant.ca>
Mon, 18 Jun 2012 22:02:30 +0000 (22:02 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Mon, 18 Jun 2012 22:02:30 +0000 (22:02 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@9934 b70326c6-7e19-0410-871a-916f4a2858ee

libpgcommon/lwgeom_cache.c
libpgcommon/lwgeom_cache.h
postgis/Makefile.in
postgis/geography_measurement_trees.c [new file with mode: 0644]
postgis/geography_measurement_trees.h [new file with mode: 0644]

index f045f32b323b0027c864268f0c5e04a0ec068dbb..cfdc85bffd3f175ee8fdf4b64352fc31fcdbcbff 100644 (file)
@@ -224,74 +224,3 @@ GetGeomCache(FunctionCallInfoData* fcinfo, const GeomCacheMethods* cache_methods
 }
 
 
-/**
-* Builder, freeer and public accessor for cached CIRC_NODE trees
-*/
-static int
-CircTreeBuilder(const LWGEOM* lwgeom, GeomCache* cache)
-{
-       CircTreeGeomCache* circ_cache = (CircTreeGeomCache*)cache;
-       CIRC_NODE* tree = lwgeom_calculate_circ_tree(lwgeom);
-
-       if ( circ_cache->index )
-       {
-               circ_tree_free(circ_cache->index);
-               circ_cache->index = 0;
-       }
-       if ( ! tree )
-               return LW_FAILURE;
-       
-       circ_cache->index = tree;
-       return LW_SUCCESS;
-}
-
-static int
-CircTreeFreer(GeomCache* cache)
-{
-       CircTreeGeomCache* circ_cache = (CircTreeGeomCache*)cache;
-       if ( circ_cache->index ) 
-       {
-               circ_tree_free(circ_cache->index);
-               circ_cache->index = 0;
-               circ_cache->argnum = 0;
-       }
-       return LW_SUCCESS;
-}
-
-static GeomCache*
-CircTreeAllocator(void)
-{
-       CircTreeGeomCache* cache = palloc(sizeof(CircTreeGeomCache));
-       memset(cache, 0, sizeof(CircTreeGeomCache));
-       return (GeomCache*)cache;
-}
-
-static GeomCacheMethods CircTreeCacheMethods =
-{
-       CIRC_CACHE_ENTRY,
-       CircTreeBuilder,
-       CircTreeFreer,
-       CircTreeAllocator
-};
-
-CIRC_NODE* 
-GetCircTree(FunctionCallInfoData* fcinfo, const GSERIALIZED* g1, const GSERIALIZED* g2, int* argnum_of_cache)
-{
-       CircTreeGeomCache* cache = (CircTreeGeomCache*)GetGeomCache(fcinfo, &CircTreeCacheMethods, g1, g2);
-
-       if ( ! cache )
-               return NULL;
-
-       if ( argnum_of_cache )
-               *argnum_of_cache = cache->argnum;
-               
-       return cache->index;
-}
-
-CircTreeGeomCache* 
-GetCircTreeGeomCache(FunctionCallInfoData* fcinfo, const GSERIALIZED* g1, const GSERIALIZED* g2)
-{
-       return (CircTreeGeomCache*)GetGeomCache(fcinfo, &CircTreeCacheMethods, g1, g2);
-}
-
-
index 5ea08dff61332fc8e1539b72c05f3051c9a9dc37..115b212289c0888f8c45a2a126f08bcb84d35321 100644 (file)
@@ -17,9 +17,7 @@
 #include "fmgr.h"
 
 #include "liblwgeom_internal.h"
-#include "lwgeodetic.h"
 #include "lwgeodetic_tree.h"
-
 #include "lwgeom_pg.h"
 
 
@@ -47,23 +45,6 @@ typedef struct {
        int32                       argnum; 
 } GeomCache;
 
-/*
-* Specific tree types include all the generic slots and 
-* their own slots for their trees. We put the implementation
-* for the CircTreeGeomCache here because we can't shove
-* the PgSQL specific bits of the code (fcinfo) back into
-* liblwgeom, where most of the circtree logic lives.
-*/
-typedef struct {
-       int                         type;       // <GeomCache>
-       GSERIALIZED*                geom1;      // 
-       GSERIALIZED*                geom2;      // 
-       size_t                      geom1_size; // 
-       size_t                      geom2_size; // 
-       int32                       argnum;     // </GeomCache>
-       CIRC_NODE*                  index;
-} CircTreeGeomCache;
-
 /*
 * Other specific geometry cache types are the 
 * RTreeGeomCache - lwgeom_rtree.h
@@ -122,9 +103,5 @@ typedef struct
 */
 PROJ4PortalCache*  GetPROJ4SRSCache(FunctionCallInfoData *fcinfo);
 GeomCache*         GetGeomCache(FunctionCallInfoData *fcinfo, const GeomCacheMethods* cache_methods, const GSERIALIZED* g1, const GSERIALIZED* g2);
-CIRC_NODE*         GetCircTree(FunctionCallInfoData* fcinfo, const GSERIALIZED* g1, const GSERIALIZED* g2, int* argnum_of_cache);
-CircTreeGeomCache* GetCircTreeGeomCache(FunctionCallInfoData* fcinfo, const GSERIALIZED* g1, const GSERIALIZED* g2);
-
-
 
 #endif /* LWGEOM_CACHE_H_ */
index a6d4ea16785c667c5f2aa78e2747dcc1b269a892..43554e076e7155b3b8e079ebd892c122073cb7e8 100644 (file)
@@ -58,6 +58,7 @@ PG_OBJS= \
        geography_btree.o \
        geography_estimate.o \
        geography_measurement.o \
+       geography_measurement_trees.o \
        geometry_estimate.o 
 
 # Objects to build using PGXS
diff --git a/postgis/geography_measurement_trees.c b/postgis/geography_measurement_trees.c
new file mode 100644 (file)
index 0000000..9c9cc7f
--- /dev/null
@@ -0,0 +1,58 @@
+#include "geography_measurement_trees.h"
+
+/**
+* Builder, freeer and public accessor for cached CIRC_NODE trees
+*/
+static int
+CircTreeBuilder(const LWGEOM* lwgeom, GeomCache* cache)
+{
+       CircTreeGeomCache* circ_cache = (CircTreeGeomCache*)cache;
+       CIRC_NODE* tree = lwgeom_calculate_circ_tree(lwgeom);
+
+       if ( circ_cache->index )
+       {
+               circ_tree_free(circ_cache->index);
+               circ_cache->index = 0;
+       }
+       if ( ! tree )
+               return LW_FAILURE;
+       
+       circ_cache->index = tree;
+       return LW_SUCCESS;
+}
+
+static int
+CircTreeFreer(GeomCache* cache)
+{
+       CircTreeGeomCache* circ_cache = (CircTreeGeomCache*)cache;
+       if ( circ_cache->index ) 
+       {
+               circ_tree_free(circ_cache->index);
+               circ_cache->index = 0;
+               circ_cache->argnum = 0;
+       }
+       return LW_SUCCESS;
+}
+
+static GeomCache*
+CircTreeAllocator(void)
+{
+       CircTreeGeomCache* cache = palloc(sizeof(CircTreeGeomCache));
+       memset(cache, 0, sizeof(CircTreeGeomCache));
+       return (GeomCache*)cache;
+}
+
+static GeomCacheMethods CircTreeCacheMethods =
+{
+       CIRC_CACHE_ENTRY,
+       CircTreeBuilder,
+       CircTreeFreer,
+       CircTreeAllocator
+};
+
+CircTreeGeomCache*
+GetCircTreeGeomCache(FunctionCallInfoData* fcinfo, const GSERIALIZED* g1, const GSERIALIZED* g2)
+{
+       return (CircTreeGeomCache*)GetGeomCache(fcinfo, &CircTreeCacheMethods, g1, g2);
+}
+
diff --git a/postgis/geography_measurement_trees.h b/postgis/geography_measurement_trees.h
new file mode 100644 (file)
index 0000000..7ecd261
--- /dev/null
@@ -0,0 +1,24 @@
+#include "liblwgeom_internal.h"
+#include "lwgeodetic_tree.h"
+#include "lwgeom_cache.h"
+
+/*
+* Specific tree types include all the generic slots and 
+* their own slots for their trees. We put the implementation
+* for the CircTreeGeomCache here because we can't shove
+* the PgSQL specific bits of the code (fcinfo) back into
+* liblwgeom, where most of the circtree logic lives.
+*/
+typedef struct {
+       int                         type;       // <GeomCache>
+       GSERIALIZED*                geom1;      // 
+       GSERIALIZED*                geom2;      // 
+       size_t                      geom1_size; // 
+       size_t                      geom2_size; // 
+       int32                       argnum;     // </GeomCache>
+       CIRC_NODE*                  index;
+} CircTreeGeomCache;
+
+
+
+CircTreeGeomCache* GetCircTreeGeomCache(FunctionCallInfoData* fcinfo, const GSERIALIZED* g1, const GSERIALIZED* g2);