Fix issue with extracting relations

This commit is contained in:
Quincy Morgan
2020-06-28 14:46:49 -04:00
parent e7df76d730
commit 0c95b12964
2 changed files with 7 additions and 5 deletions
+5 -2
View File
@@ -45,7 +45,10 @@ export function actionExtract(entityID) {
var keysToRetain = ['area'];
var buildingKeysToRetain = ['architect', 'building', 'height', 'layer'];
var centroid = d3_geoCentroid(entity.asGeoJSON(graph));
var extractedLoc = d3_geoCentroid(entity.asGeoJSON(graph));
if (!extractedLoc || !isFinite(extractedLoc[0]) || !isFinite(extractedLoc[1])) {
extractedLoc = entity.extent(graph).center();
}
var isBuilding = entity.tags.building && entity.tags.building !== 'no';
@@ -87,7 +90,7 @@ export function actionExtract(entityID) {
entityTags.area = 'yes';
}
var replacement = osmNode({ loc: centroid, tags: pointTags });
var replacement = osmNode({ loc: extractedLoc, tags: pointTags });
graph = graph.replace(replacement);
extractedNodeID = replacement.id;
+2 -3
View File
@@ -21,10 +21,9 @@ export function operationExtract(context, selectedIDs) {
if (entity.type === 'node' && graph.parentWays(entity).length === 0) return;
var geometry = graph.geometry(entityID);
if (geometry === 'area' || geometry === 'line') {
if (entity.type !== 'node') {
var preset = presetManager.match(entity, graph);
// only allow extraction from ways/multipolygons if the preset supports points
// only allow extraction from ways/relations if the preset supports points
if (preset.geometry.indexOf('point') === -1) return;
}