@@ -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 }
0 commit comments