locationtech / jts

The JTS Topology Suite is a Java library for creating and manipulating vector geometry.
Other
1.96k stars 440 forks source link

GeometryCollection constructor #651

Closed juliusfriedman closed 3 years ago

juliusfriedman commented 3 years ago

See also: https://github.com/NetTopologySuite/NetTopologySuite/issues/451

I find that the GeometryCollection lacks the constructor providing the GeometryFactory.

Would you please kindly explain why that is so?

Thank you for your time.

dr-jts commented 3 years ago

This constructor takes a GeometryFactory.

Is this because you want to create an empty GeometryCollection? If so, why not pass an empty Geometry array?

In any case, it is discouraged to use raw constructors. There is a GeometryFactory.createGeometryCollection() method for creating empty collections.

juliusfriedman commented 3 years ago

The identify of the array is questionable, it must come from somewhere and if I have that in my hand and yet its also in the constructor then the identity becomes shared, The empty array would need to be allocated. I implement non homogenous geometry with a specific factory requirement for precision. This has complications.

Having a single factory always create the empty collection prevents me from having a reasonable left handed sentinel, although its arguable the concept alone could be sentinelized.

To be direct its more for implementing special types of collections which store either geography, geometry or idiomatically.

Thank you for your time and your library.