[geos-devel] createEmptyGeometry() createsinstance ofGeometryCollection

Mateusz Łoskot mateusz at loskot.net
Thu Mar 30 17:49:38 EST 2006


Martin Davis wrote:
> This isn't a question of what Geometry.isEmpty() returns.  In fact, 
> isEmpty behaves exactly the way you mention - it checks whether there
>  are any points in the Geometry, and returns false if not.

OK, now I see that even Point is implemented on base of sequence of
points. I give up :-)

> The issue is: what should a method return when it needs to return an 
> empty geometry, but there is no guide about what type of geometry to 
> return?

Empty geometry does not need any additional type like EmptyGeometry.
Every type of geometry can represent empty geometry.

> For instance, if you run line.intersect(polygon), and they don't 
> actually intersect, what should be returned?  JTS adopts the 
> convention that an empty GeometryCollection is returned.  Otherwise, 
> it would have to choose a particular type to return, and this might 
> be misleading.

Yes, it should choose particular type depending on input types.
E.g. intersection of two envelopes should produce new envelope.
If those envelopes do not intersect, then empty envelop is returned.

> Actually reviewing this has exposed a minor but probably bad design 
> decision in JTS: empty buffers currently return an empty GC, whereas 
> they should return an empty Polygon (to maintain the exit condition 
> that buffer always returns a polygonal object).

Yes, I think so.

Please, understand my point. I'm not an expert, I'm just learning,
reading and analyzing, and I'm trying to understand the situation and
make it better if there is any room for improvements.
I'm thankful you are discussing those issues what helps in my better
understanding!

Cheers
-- 
Mateusz Łoskot
http://mateusz.loskot.net



More information about the geos-devel mailing list