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 (C) 2015 Sandro Santilli <strk@kbt.io>
22  *
23  **********************************************************************/
24 
25 
26 #ifndef LIBLWGEOM_TOPO_INTERNAL_H
27 #define LIBLWGEOM_TOPO_INTERNAL_H 1
28 
29 #include "../postgis_config.h"
30 
31 #include "liblwgeom.h"
32 #include "liblwgeom_topo.h"
33 
34 /************************************************************************
35  *
36  * Generic SQL handler
37  *
38  ************************************************************************/
39 
40 struct LWT_BE_IFACE_T
41 {
42   const LWT_BE_DATA *data;
43   const LWT_BE_CALLBACKS *cb;
44 };
45 
46 const char* lwt_be_lastErrorMessage(const LWT_BE_IFACE* be);
47 
48 LWT_BE_TOPOLOGY * lwt_be_loadTopologyByName(LWT_BE_IFACE *be, const char *name);
49 
50 int lwt_be_freeTopology(LWT_TOPOLOGY *topo);
51 
52 LWT_ISO_NODE *lwt_be_getNodeWithinDistance2D(LWT_TOPOLOGY *topo,
53 					     LWPOINT *pt,
54 					     double dist,
55 					     uint64_t *numelems,
56 					     int fields,
57 					     int64_t limit);
58 
59 LWT_ISO_NODE *lwt_be_getNodeById(LWT_TOPOLOGY *topo, const LWT_ELEMID *ids, uint64_t *numelems, int fields);
60 
61 int lwt_be_ExistsCoincidentNode(LWT_TOPOLOGY* topo, LWPOINT* pt);
62 int lwt_be_insertNodes(LWT_TOPOLOGY *topo, LWT_ISO_NODE *node, uint64_t numelems);
63 
64 int lwt_be_ExistsEdgeIntersectingPoint(LWT_TOPOLOGY* topo, LWPOINT* pt);
65 
66 LWT_ELEMID lwt_be_getNextEdgeId(LWT_TOPOLOGY* topo);
67 LWT_ISO_EDGE *lwt_be_getEdgeById(LWT_TOPOLOGY *topo, const LWT_ELEMID *ids, uint64_t *numelems, int fields);
68 LWT_ISO_EDGE *lwt_be_getEdgeWithinDistance2D(LWT_TOPOLOGY *topo,
69 					     const LWPOINT *pt,
70 					     double dist,
71 					     uint64_t *numelems,
72 					     int fields,
73 					     int64_t limit);
74 int lwt_be_insertEdges(LWT_TOPOLOGY *topo, LWT_ISO_EDGE *edge, uint64_t numelems);
75 int
76 lwt_be_updateEdges(LWT_TOPOLOGY* topo, const LWT_ISO_EDGE* sel_edge, int sel_fields, const LWT_ISO_EDGE* upd_edge, int upd_fields, const LWT_ISO_EDGE* exc_edge, int exc_fields);
77 int
78 lwt_be_deleteEdges(LWT_TOPOLOGY* topo, const LWT_ISO_EDGE* sel_edge, int sel_fields);
79 
80 int lwt_be_updateTopoGeomEdgeSplit(LWT_TOPOLOGY* topo, LWT_ELEMID split_edge, LWT_ELEMID new_edge1, LWT_ELEMID new_edge2);
81 
82 
83 /************************************************************************
84  *
85  * Internal objects
86  *
87  ************************************************************************/
88 
89 struct LWT_TOPOLOGY_T
90 {
91   const LWT_BE_IFACE *be_iface;
92   LWT_BE_TOPOLOGY *be_topo;
93   int32_t srid;
94   double precision;
95   int hasZ;
96 };
97 
98 #endif /* LIBLWGEOM_TOPO_INTERNAL_H */
99