Add polylines with geographic coordinates (#3547)

Co-authored-by: Bart Louwers <bart@emeel.net>
This commit is contained in:
Adrian Cojocaru
2025-06-24 19:15:40 +03:00
committed by GitHub
parent 32302a4c19
commit aaaf55a549

View File

@@ -519,8 +519,23 @@ util::SimpleIdentity CustomDrawableLayerHost::Interface::addPolyline(const LineS
switch (shaderType) {
case LineShaderType::Classic: {
// TODO: build classic polyline with Geo coordinates
return util::SimpleIdentity::Empty;
// build classic polyline with Geo coordinates
if (!updateBuilder(BuilderType::LineClassic, "custom-lines", lineShaderDefault())) {
return util::SimpleIdentity::Empty;
}
// geographic coordinates require tile {0, 0, 0}
setTileID({0, 0, 0});
constexpr int32_t zoom = 0;
GeometryCoordinates tileCoordinates;
for (const auto& coord : coordinates) {
const auto point = Projection::project(LatLng(coord.y, coord.x), zoom);
tileCoordinates.push_back(Point<int16_t>(static_cast<int16_t>(point.x * mbgl::util::EXTENT),
static_cast<int16_t>(point.y * mbgl::util::EXTENT)));
}
builder->addPolyline(tileCoordinates, lineOptions.geometry);
} break;
case LineShaderType::WideVector: {