jts
jts copied to clipboard
Suggestions for CoordinateArraySequenceFactory
The CoordinateSequence.create(int size, int dimension)
implementation still cuts off at dimension == 3
:
https://github.com/locationtech/jts/blob/8d433caaf37d0dd965af95608c23acbb9dbdb566/modules/core/src/main/java/org/locationtech/jts/geom/impl/CoordinateArraySequenceFactory.java#L71-L80
Shouldn't it allow a dimension
of 4 and automatically set measures = 1
?
The CoordinateSequence.create(int size, int dimension)
implementation allows a dimension
of 4, but shouldn't it, in that case, enforce a measure
value of 1?
https://github.com/locationtech/jts/blob/8d433caaf37d0dd965af95608c23acbb9dbdb566/modules/core/src/main/java/org/locationtech/jts/geom/impl/CoordinateArraySequenceFactory.java#L82-L98
Thanks! Discussed in todays meeting...
-
create(size, dimension): the behaviour is correct, it rounds the requested dimension down as required. The measure (unspecified) is 0.
-
create(size,simension,measure): you have found a logic bug. We need to fix so dimension 4 is only available when measure is 1.
Discussion did look at the tradeoff between throwing an exception (early failure) vs carrying on with an assumption. For now we are adjusting the clipping the requested dimensions + measures as best we can in order to continue.
Writing a test case to make this clear as part of PR.
@FObermaier are you in position to make a PR?
@FObermaier let us know if https://github.com/locationtech/jts/commit/83b684f0a93ce1034bd4f40b6bba3c73745357bc knocks this out. If it does, it'd be great to close this issue.
IMHO it is a unnecessary limitation to clip dimension
to 3 when using the old factory without the measure
parameter. CoordinateArraySequence
can cope with 4 dimensions and the CoordinateSequence.Create
javadoc states If the requested dimension is larger than the CoordinateSequence implementation can provide, then a sequence of maximum possible dimension should be created. This is not what the current solution does.
https://github.com/locationtech/jts/blob/8e2f394b3b55bfba64ab605ad26652482c1ceb51/modules/core/src/main/java/org/locationtech/jts/geom/CoordinateSequenceFactory.java#L43-L56
If I'd request a sequence like that, I would use the CoordianteSequence.getOrdinate(index, 3)
or CoordinateSequence.setOrdinate(index, 3, value)
to work with it and not rely on CoordinateSequence.getM(index)
. I wouldn't even care how that fourth dimension value was stored.
The most recent suggestion from @dr-jts was asking if enforceArrayConsistency check could be removed from CoordinateSequenceArray.
This is addressed by https://github.com/locationtech/jts/pull/584