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