370{
371 GEOSGeometry* envelope;
372 GEOSGeometry* ring;
373 GEOSCoordSequence* seq = GEOSCoordSeq_create(5, 2);
374 if (!seq) return NULL;
375
376 GEOSCoordSeq_setXY(seq, 0, box->
xmin, box->
ymin);
377 GEOSCoordSeq_setXY(seq, 1, box->
xmax, box->
ymin);
378 GEOSCoordSeq_setXY(seq, 2, box->
xmax, box->
ymax);
379 GEOSCoordSeq_setXY(seq, 3, box->
xmin, box->
ymax);
380 GEOSCoordSeq_setXY(seq, 4, box->
xmin, box->
ymin);
381
382 ring = GEOSGeom_createLinearRing(seq);
383 if (!ring)
384 {
385 GEOSCoordSeq_destroy(seq);
386 return NULL;
387 }
388
389 envelope = GEOSGeom_createPolygon(ring, NULL, 0);
390 if (!envelope)
391 {
392 GEOSGeom_destroy(ring);
393 return NULL;
394 }
395
396 return envelope;
397}