PostGIS  2.2.7dev-r@@SVN_REVISION@@
lwgeom_geos_prepared.h
Go to the documentation of this file.
1 /**********************************************************************
2  *
3  * PostGIS - Spatial Types for PostgreSQL
4  * http://postgis.net
5  * Copyright 2008 Paul Ramsey <pramsey@cleverelephant.ca>
6  *
7  * This is free software; you can redistribute and/or modify it under
8  * the terms of the GNU General Public Licence. See the COPYING file.
9  *
10  **********************************************************************/
11 
12 #ifndef LWGEOM_GEOS_PREPARED_H_
13 #define LWGEOM_GEOS_PREPARED_H_ 1
14 
15 #include "postgres.h"
16 #include "fmgr.h"
17 #include "miscadmin.h"
18 #include "utils/hsearch.h"
19 #include "utils/memutils.h"
20 #include "access/hash.h"
21 
22 #include "lwgeom_pg.h"
23 #include "liblwgeom.h"
24 #include "lwgeom_geos.h"
25 
26 /*
27 * Cache structure. We use GSERIALIZED as keys so no transformations
28 * are needed before we memcmp them with other keys. We store the
29 * size to avoid having to calculate the size every time.
30 * The argnum gives the number of function arguments we are caching.
31 * Intersects requires that both arguments be checked for cacheability,
32 * while Contains only requires that the containing argument be checked.
33 * Both the Geometry and the PreparedGeometry have to be cached,
34 * because the PreparedGeometry contains a reference to the geometry.
35 *
36 * Note that the first 6 entries are part of the common GeomCache
37 * structure and have to remain in order to allow the overall caching
38 * system to share code (the cache checking code is common between
39 * prepared geometry, circtrees, recttrees, and rtrees).
40 */
41 typedef struct {
42  int type; // <GeomCache>
45  size_t geom1_size; //
46  size_t geom2_size; //
47  int32 argnum; // </GeomCache>
48  MemoryContext context_statement;
49  MemoryContext context_callback;
50  const GEOSPreparedGeometry* prepared_geom;
51  const GEOSGeometry* geom;
53 
54 
55 /*
56 ** Get the current cache, given the input geometries.
57 ** Function will create cache if none exists, and prepare geometries in
58 ** cache if necessary, or pull an existing cache if possible.
59 **
60 ** If you are only caching one argument (e.g., in contains) supply 0 as the
61 ** value for pg_geom2.
62 */
63 PrepGeomCache *GetPrepGeomCache(FunctionCallInfoData *fcinfo, GSERIALIZED *pg_geom1, GSERIALIZED *pg_geom2);
64 
65 #endif /* LWGEOM_GEOS_PREPARED_H_ */
unsigned int int32
Definition: shpopen.c:273
GSERIALIZED * geom2
const GEOSPreparedGeometry * prepared_geom
GSERIALIZED * geom1
MemoryContext context_statement
const GEOSGeometry * geom
MemoryContext context_callback
PrepGeomCache * GetPrepGeomCache(FunctionCallInfoData *fcinfo, GSERIALIZED *pg_geom1, GSERIALIZED *pg_geom2)
Given a couple potential geometries and a function call context, return a prepared structure for one ...
This library is the generic geometry handling section of PostGIS.