in baremaps-core/src/main/java/org/apache/baremaps/vectortile/VectorTileDecoder.java [206:244]
protected Geometry decodePoint(List<Integer> encoding) {
List<Coordinate> coordinates = new ArrayList<>();
// Iterate over the commands and parameters
int i = 0;
while (i < encoding.size()) {
int value = encoding.get(i);
int command = command(value);
int count = count(value);
// Increment the index to the first parameter
i++;
// Iterate over the parameters
int length = count * 2;
for (int j = 0; j < length; j += 2) {
// Decode the parameters and move the cursor
cx += parameter(encoding.get(i + j));
cy += parameter(encoding.get(i + j + 1));
// Add the coordinate to the list
if (command == MOVE_TO) {
coordinates.add(new Coordinate(cx, cy));
}
}
// Increment the index to the next command
i += length;
}
// Build the final geometry
if (coordinates.size() == 1) {
return GEOMETRY_FACTORY.createPoint(coordinates.get(0));
} else if (coordinates.size() > 1) {
return GEOMETRY_FACTORY.createMultiPointFromCoords(coordinates.toArray(new Coordinate[0]));
} else {
throw new IllegalStateException("No coordinates found.");
}
}