mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-14 21:28:11 +02:00
Fix issue where extracting points could results in off placements (close #8246)
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
|
||||
import { geoCentroid as d3_geoCentroid } from 'd3-geo';
|
||||
import geojsonRewind from '@mapbox/geojson-rewind';
|
||||
import { geoPath as d3_geoPath } from 'd3-geo';
|
||||
|
||||
import { osmNode } from '../osm/node';
|
||||
|
||||
export function actionExtract(entityID) {
|
||||
export function actionExtract(entityID, projection) {
|
||||
|
||||
var extractedNodeID;
|
||||
|
||||
@@ -47,8 +46,8 @@ export function actionExtract(entityID) {
|
||||
var keysToRetain = ['area'];
|
||||
var buildingKeysToRetain = ['architect', 'building', 'height', 'layer'];
|
||||
|
||||
// d3_geoCentroid is wrong for counterclockwise-wound polygons, so wind them clockwise
|
||||
var extractedLoc = d3_geoCentroid(geojsonRewind(Object.assign({}, entity.asGeoJSON(graph)), true));
|
||||
var extractedLoc = d3_geoPath(projection).centroid(entity.asGeoJSON(graph));
|
||||
extractedLoc = extractedLoc && projection.invert(extractedLoc);
|
||||
if (!extractedLoc || !isFinite(extractedLoc[0]) || !isFinite(extractedLoc[1])) {
|
||||
extractedLoc = entity.extent(graph).center();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user