PostGIS  2.5.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  *
6  * PostGIS is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * PostGIS is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with PostGIS. If not, see <http://www.gnu.org/licenses/>.
18  *
19  **********************************************************************
20  *
21  * Copyright 2008 Paul Ramsey <pramsey@cleverelephant.ca>
22  *
23  **********************************************************************/
24 
25 
26 #ifndef LWGEOM_GEOS_PREPARED_H_
27 #define LWGEOM_GEOS_PREPARED_H_ 1
28 
29 #include "postgres.h"
30 #include "fmgr.h"
31 #include "miscadmin.h"
32 #include "utils/hsearch.h"
33 #include "utils/memutils.h"
34 #include "access/hash.h"
35 
36 #include "lwgeom_pg.h"
37 #include "liblwgeom.h"
38 #include "lwgeom_geos.h"
39 #include "lwgeom_cache.h"
40 
41 /*
42 * Cache structure. We use GSERIALIZED as keys so no transformations
43 * are needed before we memcmp them with other keys. We store the
44 * size to avoid having to calculate the size every time.
45 * The argnum gives the number of function arguments we are caching.
46 * Intersects requires that both arguments be checked for cacheability,
47 * while Contains only requires that the containing argument be checked.
48 * Both the Geometry and the PreparedGeometry have to be cached,
49 * because the PreparedGeometry contains a reference to the geometry.
50 *
51 * Note that the first 6 entries are part of the common GeomCache
52 * structure and have to remain in order to allow the overall caching
53 * system to share code (the cache checking code is common between
54 * prepared geometry, circtrees, recttrees, and rtrees).
55 */
56 typedef struct {
57  GeomCache gcache;
58  MemoryContext context_statement;
59  MemoryContext context_callback;
60  const GEOSPreparedGeometry* prepared_geom;
61  const GEOSGeometry* geom;
63 
64 
65 /*
66 ** Get the current cache, given the input geometries.
67 ** Function will create cache if none exists, and prepare geometries in
68 ** cache if necessary, or pull an existing cache if possible.
69 **
70 ** If you are only caching one argument (e.g., in contains) supply 0 as the
71 ** value for pg_geom2.
72 */
73 PrepGeomCache *GetPrepGeomCache(FunctionCallInfo fcinfo, GSERIALIZED *pg_geom1, GSERIALIZED *pg_geom2);
74 
75 #endif /* LWGEOM_GEOS_PREPARED_H_ */
This library is the generic geometry handling section of PostGIS.
PrepGeomCache * GetPrepGeomCache(FunctionCallInfo fcinfo, GSERIALIZED *pg_geom1, GSERIALIZED *pg_geom2)
Given a couple potential geometries and a function call context, return a prepared structure for one ...
const GEOSPreparedGeometry * prepared_geom
MemoryContext context_statement
const GEOSGeometry * geom
MemoryContext context_callback