PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ GBOX2GEOS()

GEOSGeometry* GBOX2GEOS ( const GBOX box)

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

385 {
386  GEOSGeometry* envelope;
387  GEOSGeometry* ring;
388  GEOSCoordSequence* seq = GEOSCoordSeq_create(5, 2);
389  if (!seq) return NULL;
390 
391 #if POSTGIS_GEOS_VERSION < 30800
392  GEOSCoordSeq_setX(seq, 0, box->xmin);
393  GEOSCoordSeq_setY(seq, 0, box->ymin);
394 
395  GEOSCoordSeq_setX(seq, 1, box->xmax);
396  GEOSCoordSeq_setY(seq, 1, box->ymin);
397 
398  GEOSCoordSeq_setX(seq, 2, box->xmax);
399  GEOSCoordSeq_setY(seq, 2, box->ymax);
400 
401  GEOSCoordSeq_setX(seq, 3, box->xmin);
402  GEOSCoordSeq_setY(seq, 3, box->ymax);
403 
404  GEOSCoordSeq_setX(seq, 4, box->xmin);
405  GEOSCoordSeq_setY(seq, 4, box->ymin);
406 #else
407  GEOSCoordSeq_setXY(seq, 0, box->xmin, box->ymin);
408  GEOSCoordSeq_setXY(seq, 1, box->xmax, box->ymin);
409  GEOSCoordSeq_setXY(seq, 2, box->xmax, box->ymax);
410  GEOSCoordSeq_setXY(seq, 3, box->xmin, box->ymax);
411  GEOSCoordSeq_setXY(seq, 4, box->xmin, box->ymin);
412 #endif
413 
414  ring = GEOSGeom_createLinearRing(seq);
415  if (!ring)
416  {
417  GEOSCoordSeq_destroy(seq);
418  return NULL;
419  }
420 
421  envelope = GEOSGeom_createPolygon(ring, NULL, 0);
422  if (!envelope)
423  {
424  GEOSGeom_destroy(ring);
425  return NULL;
426  }
427 
428  return envelope;
429 }
double ymax
Definition: liblwgeom.h:357
double xmax
Definition: liblwgeom.h:355
double ymin
Definition: liblwgeom.h:356
double xmin
Definition: liblwgeom.h:354

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

Referenced by lwgeom_voronoi_diagram().

Here is the caller graph for this function: