Skip to content

Commit 9cdc41c

Browse files
authored
Fix mvt polygon orientation (#86555) (#86849)
This commit forks the method we use in JTSAdapter to generate the vector tile feature containing the right logic for polygon orientation.
1 parent 5a3b700 commit 9cdc41c

File tree

6 files changed

+521
-7
lines changed

6 files changed

+521
-7
lines changed

docs/changelog/86555.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 86555
2+
summary: Fix mvt polygon orientation
3+
area: Geo
4+
type: bug
5+
issues:
6+
- 86560

server/src/main/java/org/elasticsearch/common/geo/SimpleFeatureFactory.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,14 @@ private static byte[] box(int minX, int maxX, int minY, int maxY) throws IOExcep
160160
commands[2] = BitUtil.zigZagEncode(minY);
161161
commands[3] = encodeCommand(LINETO, 3);
162162
// 1
163-
commands[4] = BitUtil.zigZagEncode(maxX - minX);
164-
commands[5] = BitUtil.zigZagEncode(0);
163+
commands[4] = BitUtil.zigZagEncode(0);
164+
commands[5] = BitUtil.zigZagEncode(maxY - minY);
165165
// 2
166-
commands[6] = BitUtil.zigZagEncode(0);
167-
commands[7] = BitUtil.zigZagEncode(maxY - minY);
166+
commands[6] = BitUtil.zigZagEncode(maxX - minX);
167+
commands[7] = BitUtil.zigZagEncode(0);
168168
// 3
169-
commands[8] = BitUtil.zigZagEncode(minX - maxX);
170-
commands[9] = BitUtil.zigZagEncode(0);
169+
commands[8] = BitUtil.zigZagEncode(0);
170+
commands[9] = BitUtil.zigZagEncode(minY - maxY);
171171
// close
172172
commands[10] = encodeCommand(CLOSEPATH, 1);
173173
return writeCommands(commands, 3, 11);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
mapbox-vector-tile (https://github.com/wdtinc/mapbox-vector-tile-java), with modifications

x-pack/plugin/vector-tile/src/main/java/org/elasticsearch/xpack/vectortile/feature/FeatureFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public List<byte[]> getFeatures(Geometry geometry) {
125125
// convert coordinates to MVT geometry
126126
convertToMvtGeometry(flatGeometries, sequenceFilter);
127127
// MVT geometry to MVT feature
128-
final List<VectorTile.Tile.Feature> features = JtsAdapter.toFeatures(flatGeometries, layerProps, userDataIgnoreConverter);
128+
final List<VectorTile.Tile.Feature> features = PatchedJtsAdapter.toFeatures(flatGeometries, layerProps, userDataIgnoreConverter);
129129
final List<byte[]> byteFeatures = new ArrayList<>(features.size());
130130
features.forEach(f -> byteFeatures.add(f.toByteArray()));
131131
return byteFeatures;

0 commit comments

Comments
 (0)