Skip to content

Commit

Permalink
fix(VectorTileParser): clock wise polygon wasn't calculated.
Browse files Browse the repository at this point in the history
  • Loading branch information
gchoqueux committed Mar 30, 2022
1 parent 09e047a commit 135ee7a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Parser/VectorTileParser.js
Expand Up @@ -17,7 +17,8 @@ const firstPoint = new Vector2();
// Draw polygon with canvas doesn't need to classify however it is necessary for meshs.
function vtFeatureToFeatureGeometry(vtFeature, feature, classify = false) {
let geometry = feature.bindNewGeometry();
classify = classify && (feature.type === FEATURE_TYPES.POLYGON);
const isPolygon = feature.type === FEATURE_TYPES.POLYGON;
classify = classify && isPolygon;

geometry.properties = vtFeature.properties;
const pbf = vtFeature._pbf;
Expand Down Expand Up @@ -62,15 +63,15 @@ function vtFeatureToFeatureGeometry(vtFeature, feature, classify = false) {
if (count == 1) {
firstPoint.set(x, y);
lastPoint.set(x, y);
} else if (classify && count > 1) {
} else if (isPolygon && count > 1) {
sum += (lastPoint.x - x) * (lastPoint.y + y);
lastPoint.set(x, y);
}
} else if (cmd === 7) {
if (count) {
count++;
geometry.pushCoordinatesValues(feature, firstPoint.x, firstPoint.y);
if (classify) {
if (isPolygon) {
sum += (lastPoint.x - firstPoint.x) * (lastPoint.y + firstPoint.y);
}
}
Expand Down

0 comments on commit 135ee7a

Please sign in to comment.