PostGIS  3.7.0dev-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 #pragma once
26 
27 #include "postgres.h"
28 #include "fmgr.h"
29 #include "miscadmin.h"
30 #include "utils/hsearch.h"
31 #include "utils/memutils.h"
32 #include "access/hash.h"
33 
34 #include "lwgeom_pg.h"
35 #include "liblwgeom.h"
36 #include "lwgeom_geos.h"
37 #include "lwgeom_cache.h"
38 
39 /*
40  * Cache structure. The common components used across all
41  * caches are in the GeomCache. That contains SHARED_GSERIALIZED
42  * and the argnum that indicates which argument we are caching
43  * prepared geometry for.
44  * The argnum gives the number of function arguments we are caching.
45  * Intersects requires that both arguments be checked for cacheability,
46  * while Contains only requires that the containing argument be checked.
47  * Both the Geometry and the PreparedGeometry have to be cached,
48  * because the PreparedGeometry contains a reference to the geometry.
49  */
50 typedef struct {
51  GeomCache gcache;
52  MemoryContext context_statement;
53  MemoryContext context_callback;
54  const GEOSPreparedGeometry* prepared_geom;
55  const GEOSGeometry* geom;
57 
58 
59 /*
60  * Get the current cache, given the input geometries.
61  * Function will create cache if none exists, and prepare geometries in
62  * cache if necessary, or pull an existing cache if possible.
63  *
64  * If you are only caching one argument (e.g., in contains) supply 0 as the
65  * value for pg_geom2.
66  */
67 PrepGeomCache *GetPrepGeomCache(FunctionCallInfo fcinfo, SHARED_GSERIALIZED *pg_geom1, SHARED_GSERIALIZED *pg_geom2);
68 
This library is the generic geometry handling section of PostGIS.
PrepGeomCache * GetPrepGeomCache(FunctionCallInfo fcinfo, SHARED_GSERIALIZED *pg_geom1, SHARED_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