Closed bettdouglas closed 3 years ago
Hi @bettdouglas , is there an existing JTS test to reproduce it? I can't find it and would rather use the original jts testcases where possible.
I just created a testcase with your example in jts:
GeometryFactory gf = new GeometryFactory();
Coordinate[] coordinates = new Coordinate[] {
new Coordinate(1.0,2.0),
new Coordinate(3.0,4.0)
};
LineString line= gf.createLineString(coordinates);
int dimension = line.getCoordinateSequence().getDimension();
System.out.println(dimension);
This returns 3, same as the dart version.
@bettdouglas , the example you refer to uses: CoordinateXY, not Coordinate Do the same with dart_jts, and the result is the same. Closing this here.
Ok. So when one is sure there are two coordinates use CoordinateXY instead of Coordinate? I don't know much Java, just basics
Just tried that. Same issue here
test('preserve dimension 2d', () {
final gf = GeometryFactory.defaultPrecision();
final line= gf.createLineString([
CoordinateXY.fromXY(1,2),
CoordinateXY.fromXY(3,4),
]);
expect(line.getCoordinateSequence().getDimension(), 2);
final densifiedLine = densify(line, 0.1) as LineString;
expect(densifiedLine.getCoordinateSequence().getDimension(), 2);
});
Tried this (where you signalled the error):
final gf = GeometryFactory.defaultPrecision();
final line = gf.createLineString([
CoordinateXY.fromXY(1, 2),
CoordinateXY.fromXY(3, 4),
]);
var coordinateSequence = line.getCoordinateSequence();
var dimension = coordinateSequence.getDimension();
expect(dimension, 2);
And this passes properly. If you have an issue later, then that is probably in your code somewhere. Make sure you use the right coordinate class.
Anyways, it really depends on you what you need to use. The most used is Coordinate, even if it has a 3rd dimension, which is mostly not used.
Just tried that. Same issue here
test('preserve dimension 2d', () { final gf = GeometryFactory.defaultPrecision(); final line= gf.createLineString([ CoordinateXY.fromXY(1,2), CoordinateXY.fromXY(3,4), ]); expect(line.getCoordinateSequence().getDimension(), 2); final densifiedLine = densify(line, 0.1) as LineString; expect(densifiedLine.getCoordinateSequence().getDimension(), 2); });
Okay, I wasn't keen enough. The test was failing on last test
@moovida thanks for this
@moovida I've tried finding out where the bug causing the dimension preservation test case to fail, but I cannot figure out where it is.
If you have some time and wanna assist, look at it here https://github.com/bettdouglas/dart_jts.git
Also I couldn't find any Class tests for GeometryTransformer, the way there is for Densifier. Could you point me to it if you find it?
Hi, I'm trying to port some GeometryTransformer code from java jts here.
However, some test case fails to pass concerning line.getCoordinateSequence().
Am I missing something or