135{
136 GEOSGeometry *g1, *gn, *gm;
139 int pn, ln, np, nl;
140
142 lwerror(
"Noding geometries of dimension != 1 is unsupported");
143 return NULL;
144 }
145
148 if ( ! g1 ) {
150 return NULL;
151 }
152
154 if ( ! ep ) {
155 GEOSGeom_destroy(g1);
156 lwerror(
"Error extracting unique endpoints from input");
157 return NULL;
158 }
159
160 gn = GEOSNode(g1);
161 GEOSGeom_destroy(g1);
162 if ( ! gn ) {
165 return NULL;
166 }
168
169 nl = GEOSGetNumGeometries(gn);
170 if ( nl > 1 )
171 {
172 gm = GEOSLineMerge(gn);
173 GEOSGeom_destroy(gn);
174 if ( ! gm ) {
177 return NULL;
178 }
180 gn = gm;
181
183 GEOSGeom_destroy(gn);
184 if ( ! lines ) {
186 lwerror(
"Error during GEOS2LWGEOM");
187 return NULL;
188 }
189 }
190 else if ( nl == 1 )
191 {
192 const GEOSGeometry *gc = GEOSGetGeometryN(gn, 0);
194 GEOSGeom_destroy(gn);
195 if ( ! lines ) {
197 lwerror(
"Error during GEOS2LWGEOM");
198 return NULL;
199 }
200 }
201 else
202 {
203
205 GEOSGeom_destroy(gn);
206 if ( ! lines ) {
208 lwerror(
"Error during GEOS2LWGEOM");
209 return NULL;
210 }
213 }
214
215
216
217
218
219
220
221
222
223
224
228
230 for (pn=0; pn<np; ++pn) {
231
233
235 for (ln=0; ln<nl; ++ln) {
236
238
240
242
244
245 break;
246 }
247
248
249
250
254 while (nl > ln+1) {
256 --nl;
257 }
262 } else {
264
269 }
270
271
274
275 break;
276 }
277
278 }
279
282
285}
char lwgeom_geos_errmsg[LWGEOM_GEOS_ERRMSG_MAXSIZE]
GEOSGeometry * LWGEOM2GEOS(const LWGEOM *lwgeom, uint8_t autofix)
void lwgeom_geos_error(const char *fmt,...)
void(*) LWGEOM GEOS2LWGEOM)(const GEOSGeometry *geom, uint8_t want3d)
#define LWDEBUGGEOS(level, geom, msg)
void lwgeom_set_srid(LWGEOM *geom, int32_t srid)
Set the SRID on an LWGEOM For collections, only the parent gets an SRID, all the children get SRID_UN...
void lwgeom_free(LWGEOM *geom)
#define FLAGS_GET_Z(flags)
int lwgeom_dimension(const LWGEOM *geom)
For an LWGEOM, returns 0 for points, 1 for lines, 2 for polygons, 3 for volume, and the max dimension...
int lwgeom_is_collection(const LWGEOM *lwgeom)
Determine whether a LWGEOM contains sub-geometries or not This basically just checks that the struct ...
#define FLAGS_GET_M(flags)
void lwcollection_free(LWCOLLECTION *col)
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int32_t srid, char hasz, char hasm)
LWCOLLECTION * lwcollection_clone_deep(const LWCOLLECTION *lwgeom)
Deep clone LWCOLLECTION object.
int lwline_split_by_point_to(const LWLINE *ln, const LWPOINT *pt, LWMLINE *to)
Split a line by a point and push components to the provided multiline.
void lwcollection_reserve(LWCOLLECTION *col, uint32_t ngeoms)
Ensure the collection can hold at least up to ngeoms geometries.
static LWGEOM * lwgeom_extract_unique_endpoints(const LWGEOM *lwg)
static const LWGEOM * lwgeom_subgeom(const LWGEOM *g, int n)
static int lwgeom_ngeoms(const LWGEOM *n)
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.