Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the java decoder tests #168

Merged
merged 7 commits into from
Jun 21, 2024

Conversation

springmeyer
Copy link
Collaborator

Currently we support both a "Non-vectorized (aka sequential)" decoding path and a "Vectorized" decoding path. In the future we can and should consolidate to just one (vectorized), but for the moment we need to keep two because the JS decoder is targeting the non-vectorized path.

With that in mind we need to ensure we are testing the non-vectorized java decoder.

So, this PR makes improvements to the decoder tests to:

  • Test both decoding paths as much as possible
  • The non-vectorized path has more issues, so temporary accommodations are made to allow tests to pass by asserting on expected errors (this gets the code running at least until we can fix its behavior)
  • It is not going to be obvious in the diff, but this also starts testing some tiles which used to fail in the vectorized path, but no longer do (after Fix non-vectorized LineString decoding #158 was fixed)
  • Finally, by asserting on the number of expected errors returned for known failures, this starts allowing the tests to iterate through more features during the comparison which ensures the tests are not hiding additional errors behind other asserts which fail

@springmeyer springmeyer requested a review from mactrem June 20, 2024 19:17
assertEquals(mvtFeature.id(), mltFeature.id());

var mltGeometry = mltFeature.geometry();
var mvtGeometry = mvtFeature.geometry();
assertEquals(mvtGeometry, mltGeometry);
if (!mvtGeometry.toString().equals(mltGeometry.toString())) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you get any additonal error with this change?
The Geometry classes used for the equlity tests are from the JTS Topology Suite library, which does proper geometry equality comparison based on the specific geometry types and is battle tested :) Since we are provding no tolerance values for the current equality comparision we are also not safe for floating point rounding errors like in the String variant but we could introduce a value for this to be more robust.
By using toString JTS converts it to WKT.
What are your thoughts on this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I also tried with if (!mvtGeometry.equals(mltGeometry)) { and I get 7 exceptions like:

MltDecoderTest > Decode OMT Tiles > com.mlt.decoder.MltDecoderTest.decodeOMTTiles(String)[13] FAILED
    org.locationtech.jts.geom.TopologyException: side location conflict [ (2639.311475409836, 3217.967213114754, NaN) ]
        at app//org.locationtech.jts.geomgraph.EdgeEndStar.propagateSideLabels(EdgeEndStar.java:289)
        at app//org.locationtech.jts.geomgraph.EdgeEndStar.computeLabelling(EdgeEndStar.java:125)
        at app//org.locationtech.jts.operation.relate.RelateComputer.labelNodeEdges(RelateComputer.java:325)
        at app//org.locationtech.jts.operation.relate.RelateComputer.computeIM(RelateComputer.java:125)
        at app//org.locationtech.jts.operation.relate.RelateOp.getIntersectionMatrix(RelateOp.java:109)
        at app//org.locationtech.jts.operation.relate.RelateOp.relate(RelateOp.java:54)
        at app//org.locationtech.jts.geom.Geometry.relate(Geometry.java:1035)
        at app//org.locationtech.jts.geom.Geometry.equalsTopo(Geometry.java:1089)
        at app//org.locationtech.jts.geom.Geometry.equals(Geometry.java:1057)
        at app//com.mlt.TestUtils.compareTilesSequential(TestUtils.java:93)
        at app//com.mlt.decoder.MltDecoderTest.testTile(MltDecoderTest.java:158)
        at app//com.mlt.decoder.MltDecoderTest.decodeOMTTiles(MltDecoderTest.java:122)

Do you also see that locally?

Try changing from:

assertEquals(mvtGeometry, mltGeometry);

To:

import static org.junit.jupiter.api.Assertions.assertTrue;
assertTrue(mvtGeometry.equals(mltGeometry), "MVTGeom != MLTGeom");

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now in this PR I've reverted this custom handling: [cb75bdc](https://github.com/maplibre/maplibre-tile-spec/pull/168/commits/cb75bdc075ceec0d37dcfdf227177c657d41c42e)

Let's discuss larger issue at #178

return Stream.of(
Triple.of(2, 2, 2),
Triple.of(3, 4, 5),
Triple.of(4, 8, 10),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My thoughts on this were -> by using int values ​​we can dynamically change the file name, e.g. change the separator of xyz in an easy way as i have tiles lying around that have different separators.
This change is ok for me, but maybe we can agree on a common file naming structure for all tiles so using "_" or "-" for example

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, okay. Yes, how about we standardize on - as the separator? z-x-y.mvt? I can make the change in this PR to rename any non-conforming tiles. Does that sound good?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can make the change in this PR to rename any non-conforming tiles. Does that sound good?

Actually, it's a rather large change to do the renaming. I'd like to do in a followup PR instead of this one as it will require updating JS side as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ticketed at #179 to ensure we agree and then I can get a PR going after.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good

@springmeyer springmeyer mentioned this pull request Jun 21, 2024
3 tasks
return Stream.of(
Triple.of(2, 2, 2),
Triple.of(3, 4, 5),
Triple.of(4, 8, 10),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good

@springmeyer springmeyer merged commit f8ddd5f into maplibre:main Jun 21, 2024
8 checks passed
@springmeyer springmeyer deleted the java-decoder-test-update branch June 21, 2024 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants