Skip to content

Commit 9d98258

Browse files
committed
format, always orient MVT geom after processing
1 parent a78bfe4 commit 9d98258

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

src/spatial/modules/geos/geos_module.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -327,9 +327,6 @@ struct ST_AsMVTGeom {
327327
const auto &blob = geom_data[geom_idx];
328328
auto geom = lstate.Deserialize(blob);
329329

330-
// Orient polygons in place
331-
geom.orient_polygons(true);
332-
333330
// Compute bounds
334331
const auto extent = bind_data.extent;
335332

@@ -363,10 +360,14 @@ struct ST_AsMVTGeom {
363360
const auto transformed = geom.get_transformed(affine_matrix);
364361

365362
// Snap to grid (round coordinates to integers)
366-
const auto snapped = transformed.get_gridded(1.0);
363+
auto snapped = transformed.get_gridded(1.0);
367364

368365
// Should we clip? if not, return the snapped geometry
369366
if (!bind_data.clip) {
367+
368+
// But first orient in place
369+
snapped.orient_polygons(true);
370+
370371
res_data[out_idx] = lstate.Serialize(result, snapped);
371372
continue;
372373
}
@@ -385,7 +386,10 @@ struct ST_AsMVTGeom {
385386
}
386387

387388
// Snap again to clean up any potential issues from clipping
388-
const auto cleaned_clipped = clipped.get_gridded(1.0);
389+
auto cleaned_clipped = clipped.get_gridded(1.0);
390+
391+
// Also orient the polygons in place
392+
cleaned_clipped.orient_polygons(true);
389393

390394
res_data[out_idx] = lstate.Serialize(result, cleaned_clipped);
391395
}

src/spatial/modules/mvt/mvt_module.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -609,15 +609,15 @@ class MVTFeatureBuilder {
609609
const auto y = CastDouble(cursor.Read<double>());
610610
cursor.Skip(vertex_space); // Skip z and m if present
611611

612-
if (vertex_idx == 0) {
613-
geometry.push_back((1 & 0x7) | (1 << 3)); // MoveTo, 1 part
614-
geometry.push_back(protozero::encode_zigzag32(x - cursor_x));
615-
geometry.push_back(protozero::encode_zigzag32(y - cursor_y));
616-
geometry.push_back((2 & 0x7) | ((vertex_count - 1) << 3)); // LineTo, part count
617-
} else {
618-
geometry.push_back(protozero::encode_zigzag32(x - cursor_x));
619-
geometry.push_back(protozero::encode_zigzag32(y - cursor_y));
620-
}
612+
if (vertex_idx == 0) {
613+
geometry.push_back((1 & 0x7) | (1 << 3)); // MoveTo, 1 part
614+
geometry.push_back(protozero::encode_zigzag32(x - cursor_x));
615+
geometry.push_back(protozero::encode_zigzag32(y - cursor_y));
616+
geometry.push_back((2 & 0x7) | ((vertex_count - 1) << 3)); // LineTo, part count
617+
} else {
618+
geometry.push_back(protozero::encode_zigzag32(x - cursor_x));
619+
geometry.push_back(protozero::encode_zigzag32(y - cursor_y));
620+
}
621621

622622
cursor_x = x;
623623
cursor_y = y;

0 commit comments

Comments
 (0)