Skip to content

Commit

Permalink
Fix mvt polygon orientation (#86555) (#86849)
Browse files Browse the repository at this point in the history
This commit forks the method we use in JTSAdapter to generate the vector tile feature containing the right logic
for polygon orientation.
  • Loading branch information
iverase committed May 17, 2022
1 parent 5a3b700 commit 9cdc41c
Show file tree
Hide file tree
Showing 6 changed files with 521 additions and 7 deletions.
6 changes: 6 additions & 0 deletions docs/changelog/86555.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 86555
summary: Fix mvt polygon orientation
area: Geo
type: bug
issues:
- 86560
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,14 @@ private static byte[] box(int minX, int maxX, int minY, int maxY) throws IOExcep
commands[2] = BitUtil.zigZagEncode(minY);
commands[3] = encodeCommand(LINETO, 3);
// 1
commands[4] = BitUtil.zigZagEncode(maxX - minX);
commands[5] = BitUtil.zigZagEncode(0);
commands[4] = BitUtil.zigZagEncode(0);
commands[5] = BitUtil.zigZagEncode(maxY - minY);
// 2
commands[6] = BitUtil.zigZagEncode(0);
commands[7] = BitUtil.zigZagEncode(maxY - minY);
commands[6] = BitUtil.zigZagEncode(maxX - minX);
commands[7] = BitUtil.zigZagEncode(0);
// 3
commands[8] = BitUtil.zigZagEncode(minX - maxX);
commands[9] = BitUtil.zigZagEncode(0);
commands[8] = BitUtil.zigZagEncode(0);
commands[9] = BitUtil.zigZagEncode(minY - maxY);
// close
commands[10] = encodeCommand(CLOSEPATH, 1);
return writeCommands(commands, 3, 11);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mapbox-vector-tile (https://github.com/wdtinc/mapbox-vector-tile-java), with modifications
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public List<byte[]> getFeatures(Geometry geometry) {
// convert coordinates to MVT geometry
convertToMvtGeometry(flatGeometries, sequenceFilter);
// MVT geometry to MVT feature
final List<VectorTile.Tile.Feature> features = JtsAdapter.toFeatures(flatGeometries, layerProps, userDataIgnoreConverter);
final List<VectorTile.Tile.Feature> features = PatchedJtsAdapter.toFeatures(flatGeometries, layerProps, userDataIgnoreConverter);
final List<byte[]> byteFeatures = new ArrayList<>(features.size());
features.forEach(f -> byteFeatures.add(f.toByteArray()));
return byteFeatures;
Expand Down

0 comments on commit 9cdc41c

Please sign in to comment.