mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-15 05:30:35 +02:00
matchTags - don't calculcate valid locations unless needed
mismatched_geometry - small optimization
This commit is contained in:
+20
-10
@@ -208,11 +208,8 @@ export function presetIndex() {
|
||||
let address;
|
||||
let best = -1;
|
||||
let match;
|
||||
|
||||
let matchCandidates = [];
|
||||
let validLocations;
|
||||
if (Array.isArray(loc)) {
|
||||
validLocations = locationManager.locationsAt(loc);
|
||||
}
|
||||
|
||||
for (let k in tags) {
|
||||
// If any part of an address is present, allow fallback to "Address" preset - #4353
|
||||
@@ -225,13 +222,11 @@ export function presetIndex() {
|
||||
|
||||
for (let i = 0; i < keyMatches.length; i++) {
|
||||
const candidate = keyMatches[i];
|
||||
|
||||
// discard candidate preset if location is not valid at `loc`
|
||||
if (validLocations && candidate.locationSetID) {
|
||||
if (!validLocations[candidate.locationSetID]) continue;
|
||||
}
|
||||
|
||||
const score = candidate.matchScore(tags);
|
||||
if (score === -1){
|
||||
continue;
|
||||
}
|
||||
matchCandidates.push({score, candidate});
|
||||
if (score > best) {
|
||||
best = score;
|
||||
match = candidate;
|
||||
@@ -239,6 +234,21 @@ export function presetIndex() {
|
||||
}
|
||||
}
|
||||
|
||||
if (match && match.locationSetID && Array.isArray(loc)){
|
||||
validLocations = locationManager.locationsAt(loc);
|
||||
if (!validLocations[match.locationSetID]){
|
||||
matchCandidates.sort((a, b) => (a.score < b.score) ? 1 : -1);
|
||||
for (let i = 0; i < matchCandidates.length; i++){
|
||||
const candidateScore = matchCandidates[i];
|
||||
if (!candidateScore.candidate.locationSetID || validLocations[candidateScore.candidate.locationSetID]){
|
||||
match = candidateScore.candidate;
|
||||
best = candidateScore.score;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (address && (!match || match.isFallback())) {
|
||||
match = address;
|
||||
}
|
||||
|
||||
@@ -220,8 +220,9 @@ export function validationMismatchedGeometry() {
|
||||
|
||||
if (sourceGeom === 'area') targetGeoms.unshift('line');
|
||||
|
||||
var asSource = presetManager.match(entity, graph);
|
||||
|
||||
var targetGeom = targetGeoms.find(nodeGeom => {
|
||||
var asSource = presetManager.matchTags(entity.tags, sourceGeom);
|
||||
var asTarget = presetManager.matchTags(entity.tags, nodeGeom);
|
||||
if (!asSource || !asTarget ||
|
||||
asSource === asTarget ||
|
||||
|
||||
Reference in New Issue
Block a user