locationtech / jts

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

Use CoordinateSequence instead of Coordinate arrays #188

Open dr-jts opened 7 years ago

dr-jts commented 7 years ago

To improve the performance of using non-array based CoordinateSequenceimplementations the JTS core should be changed to using coordinate access based on CoordinateSequence accessors, instead of forcing the creation of Coordinate arrays.

Some places where this is needed:

See also:

FObermaier commented 7 years ago

All usages of org.locationtech.jts.geom.CoordinateArrays class (here) potentially benefit from a utility class that works on org.locationtech.jts.geom.CoordinateSequence instead of org.locationtech.jts.geom.Coordinate[]. This would have to be extended.

Not explicitly performance, but making the [WKT|WKB]Reader classes not work on org.locationtech.jts.geom.Coordinate[] can help to improve handling of measure ordinate values. I have an implementation using a CoordinateBuffer class at hand.

dr-jts commented 7 years ago

Good recommendations @FObermaier .

What is the nature of your CoordinateBuffer class?

FObermaier commented 7 years ago

What is the nature of your CoordinateBuffer class?

It encapsulates an ArrayList to store 3DM coordinate values. You can add ordinate values calling add2d, add3d, add2dm, add3dm functions. While adding the following is taken care of:

You can have a look at it here.