diff --git a/src/centroid/index.js b/src/centroid/index.js old mode 100644 new mode 100755 index 6b26ca86b0..036cfafabf --- a/src/centroid/index.js +++ b/src/centroid/index.js @@ -27,7 +27,7 @@ function centroid(geojson, options) { xSum += coord[0]; ySum += coord[1]; len++; - }); + }, true); return point([xSum / len, ySum / len], options.properties); } diff --git a/src/centroid/test/in/polygon2.geojson b/src/centroid/test/in/polygon2.geojson new file mode 100644 index 0000000000..a96e1c417b --- /dev/null +++ b/src/centroid/test/in/polygon2.geojson @@ -0,0 +1,8 @@ +{ + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [[[-1, -1], [1, -1], [1, 1], [-1, 1], [-1, -1]]] + } +} diff --git a/src/centroid/test/out/imbalanced-polygon.geojson b/src/centroid/test/out/imbalanced-polygon.geojson old mode 100644 new mode 100755 index a8d9325f2e..5f397e9da7 --- a/src/centroid/test/out/imbalanced-polygon.geojson +++ b/src/centroid/test/out/imbalanced-polygon.geojson @@ -9,8 +9,8 @@ "geometry": { "type": "Point", "coordinates": [ - 4.851914405822754, - 45.78098812633097 + 4.851791984156558, + 45.78143055383553 ] } }, diff --git a/src/centroid/test/out/polygon.geojson b/src/centroid/test/out/polygon.geojson old mode 100644 new mode 100755 index bdd2010e8b..c2b430e812 --- a/src/centroid/test/out/polygon.geojson +++ b/src/centroid/test/out/polygon.geojson @@ -9,8 +9,8 @@ "geometry": { "type": "Point", "coordinates": [ - 4.839177131652832, - 45.76256007199914 + 4.841194152832031, + 45.75807143030368 ] } }, diff --git a/src/centroid/test/out/polygon2.geojson b/src/centroid/test/out/polygon2.geojson new file mode 100644 index 0000000000..83882787bf --- /dev/null +++ b/src/centroid/test/out/polygon2.geojson @@ -0,0 +1,49 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": { + "marker-symbol": "circle" + }, + "geometry": { + "type": "Point", + "coordinates": [ + 0, + 0 + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + -1, + -1 + ], + [ + 1, + -1 + ], + [ + 1, + 1 + ], + [ + -1, + 1 + ], + [ + -1, + -1 + ] + ] + ] + } + } + ] +}