wdtinc / mapbox-vector-tile-java

Java Mapbox Vector Tile Library for Encoding/Decoding

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issues with parsing polygons

boldtrn opened this issue · comments

commented

I just started test your library and saw there seems to be an issue with parsing Polygons.

When I try to read a polygon the outer and inner rings seem to be switched and many polygons are not accepted because the library thinks that the polygon has no outer ring. The problem seems to be created in MvtReader#classifyRings when running CGAlgorithms.signedArea(r.getCoordinates()).

For example have a look at this tile. The first polygon is a water polygon that has no inner, just an outer. Same thing happens for Mapzen mvt, they also provide a nice geojson debugging version of the tile, where you can see that it's just a big simple polygon.

commented

BTW: The code at this point actually looks correct. Maybe the coordinates get mixed up before the actual call or maybe there is a bug in CGAlgorithms?

Hey @boldtrn thank you for posting the issue. I'm looking at the android legacy pull request tonight but I should be able to get a look at this one some time tomorrow.

@boldtrn By any chance did you try

// Allow negative-area exterior rings with classifier
JtsMvt jtsMvt = MvtReader.loadMvt(
        Paths.get("path/to/your.mvt"),
        geomFactory,
        new TagKeyValueMapConverter(),
        MvtReader.RING_CLASSIFIER_V1);

? (Using the RING_CLASSIFIER_V1) ?

commented

Thanks, using MvtReader.RING_CLASSIFIER_V1 fixes my issue :). I missed that in the docu. Sorry for creating an issue.

No problem at all. I want to do a pass on the doc's to make some things a bit more clear. RING_CLASSIFIER_V1 mimics that mapbox code.

commented

RING_CLASSIFIER_V1 mimics that mapbox code.

Ah ok, I am not familiar with the Mapbox code. Thanks for the explanation.