PostGIS 3.0.6dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ GBOX2GEOS()

GEOSGeometry * GBOX2GEOS ( const GBOX box)

Definition at line 342 of file liblwgeom/lwgeom_geos.c.

343{
344 GEOSGeometry* envelope;
345 GEOSGeometry* ring;
346 GEOSCoordSequence* seq = GEOSCoordSeq_create(5, 2);
347 if (!seq) return NULL;
348
349#if POSTGIS_GEOS_VERSION < 38
350 GEOSCoordSeq_setX(seq, 0, box->xmin);
351 GEOSCoordSeq_setY(seq, 0, box->ymin);
352
353 GEOSCoordSeq_setX(seq, 1, box->xmax);
354 GEOSCoordSeq_setY(seq, 1, box->ymin);
355
356 GEOSCoordSeq_setX(seq, 2, box->xmax);
357 GEOSCoordSeq_setY(seq, 2, box->ymax);
358
359 GEOSCoordSeq_setX(seq, 3, box->xmin);
360 GEOSCoordSeq_setY(seq, 3, box->ymax);
361
362 GEOSCoordSeq_setX(seq, 4, box->xmin);
363 GEOSCoordSeq_setY(seq, 4, box->ymin);
364#else
365 GEOSCoordSeq_setXY(seq, 0, box->xmin, box->ymin);
366 GEOSCoordSeq_setXY(seq, 1, box->xmax, box->ymin);
367 GEOSCoordSeq_setXY(seq, 2, box->xmax, box->ymax);
368 GEOSCoordSeq_setXY(seq, 3, box->xmin, box->ymax);
369 GEOSCoordSeq_setXY(seq, 4, box->xmin, box->ymin);
370#endif
371
372 ring = GEOSGeom_createLinearRing(seq);
373 if (!ring)
374 {
375 GEOSCoordSeq_destroy(seq);
376 return NULL;
377 }
378
379 envelope = GEOSGeom_createPolygon(ring, NULL, 0);
380 if (!envelope)
381 {
382 GEOSGeom_destroy(ring);
383 return NULL;
384 }
385
386 return envelope;
387}
double ymax
Definition liblwgeom.h:343
double xmax
Definition liblwgeom.h:341
double ymin
Definition liblwgeom.h:342
double xmin
Definition liblwgeom.h:340

References GBOX::xmax, GBOX::xmin, GBOX::ymax, and GBOX::ymin.

Referenced by lwgeom_voronoi_diagram().

Here is the caller graph for this function: