PostGIS  3.3.9dev-r@@SVN_REVISION@@

◆ GBOX2GEOS()

GEOSGeometry* GBOX2GEOS ( const GBOX box)

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

363 {
364  GEOSGeometry* envelope;
365  GEOSGeometry* ring;
366  GEOSCoordSequence* seq = GEOSCoordSeq_create(5, 2);
367  if (!seq) return NULL;
368 
369 #if POSTGIS_GEOS_VERSION < 30800
370  GEOSCoordSeq_setX(seq, 0, box->xmin);
371  GEOSCoordSeq_setY(seq, 0, box->ymin);
372 
373  GEOSCoordSeq_setX(seq, 1, box->xmax);
374  GEOSCoordSeq_setY(seq, 1, box->ymin);
375 
376  GEOSCoordSeq_setX(seq, 2, box->xmax);
377  GEOSCoordSeq_setY(seq, 2, box->ymax);
378 
379  GEOSCoordSeq_setX(seq, 3, box->xmin);
380  GEOSCoordSeq_setY(seq, 3, box->ymax);
381 
382  GEOSCoordSeq_setX(seq, 4, box->xmin);
383  GEOSCoordSeq_setY(seq, 4, box->ymin);
384 #else
385  GEOSCoordSeq_setXY(seq, 0, box->xmin, box->ymin);
386  GEOSCoordSeq_setXY(seq, 1, box->xmax, box->ymin);
387  GEOSCoordSeq_setXY(seq, 2, box->xmax, box->ymax);
388  GEOSCoordSeq_setXY(seq, 3, box->xmin, box->ymax);
389  GEOSCoordSeq_setXY(seq, 4, box->xmin, box->ymin);
390 #endif
391 
392  ring = GEOSGeom_createLinearRing(seq);
393  if (!ring)
394  {
395  GEOSCoordSeq_destroy(seq);
396  return NULL;
397  }
398 
399  envelope = GEOSGeom_createPolygon(ring, NULL, 0);
400  if (!envelope)
401  {
402  GEOSGeom_destroy(ring);
403  return NULL;
404  }
405 
406  return envelope;
407 }
double ymax
Definition: liblwgeom.h:372
double xmax
Definition: liblwgeom.h:370
double ymin
Definition: liblwgeom.h:371
double xmin
Definition: liblwgeom.h:369

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

Referenced by lwgeom_voronoi_diagram().

Here is the caller graph for this function: