JTS defines a concept of a null Envelope object state for precisely this reason.

The reason for returning a null Envelope object rather than null is that in my 
experience most callers of getEnvelopeInternal want something they can test 
against.  If null was returned calling code would need a special check for 
every call.

This is the same reason that empty Geometries are defined.  Often it simplifies 
code if there is something there, rather than null.

Martin Davis, Senior Technical Architect
Vivid Solutions Inc.      www.vividsolutions.com
Suite #1A-2328 Government Street Victoria, B.C. V8T 5G5
Phone: (250) 385 6040 - Local 308 Fax: (250) 385 6046


> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of 
> Mateusz Loskot
> Sent: March 30, 2006 10:14 PM
> To: GEOS Development List
> Subject: [geos-devel] Envelope of empty Polygon
> 
> 
> Hi,
> 
> I'm bringing next subject to discuss.
> 
> The main question is what should be returned by getEnvelope() 
> called on empty polygon?
> 
> Here is simple use case:
> 
> GeometryFactory factory(...);
> //...
> 
> // create empty polygon
> Polygon* poly = factory.createPolygon();
> 
> // request for its envelope
> Geometry* geo = 0;
> geo = poly->getEnvelope();
> geo->isEmpty(); // <--- THE PROBLEM
> 
> 
> As I revealed, when exterior ring is empty geometry,
> getEnvelope() returns or creates instance of envelope object. 
> This object is initialized by Envelope::setToNull(). So, 
> returned envelope for empty polygon has following 
> coordinates: minx = -1.0 maxx = 0.0 miny = -1.0 maxx = 0.0
> 
> Is this correct behaviour?
> Is empty polygon assumed to return non-empty envelope as above?
> 
> Cheers
> -- 
> Mateusz Łoskot
> http://mateusz.loskot.net 
> _______________________________________________
> geos-devel mailing list
> geos-devel@geos.refractions.net 
> http://geos.refractions.net/mailman/listinfo/geos-devel
> 
_______________________________________________
geos-devel mailing list
geos-devel@geos.refractions.net
http://geos.refractions.net/mailman/listinfo/geos-devel

Reply via email to