Fix GPS coordinate searches returning OSM elements

Simply let a loction search match take priority over an ID pattern
match
This commit is contained in:
SilentSpike
2020-09-15 20:45:28 +01:00
parent 8ecada3b79
commit 42f0b3dcd1
+14 -13
View File
@@ -122,19 +122,6 @@ export function uiFeatureList(context) {
if (!q) return result;
var idMatch = q.match(/(?:^|\W)(node|way|relation|[nwr])\W?0*([1-9]\d*)(?:\W|$)/i);
if (idMatch) {
var elemType = idMatch[1].charAt(0);
var elemId = idMatch[2];
result.push({
id: elemType + elemId,
geometry: elemType === 'n' ? 'point' : elemType === 'w' ? 'line' : 'relation',
type: elemType === 'n' ? t('inspector.node') : elemType === 'w' ? t('inspector.way') : t('inspector.relation'),
name: elemId
});
}
var locationMatch = sexagesimal.pair(q.toUpperCase()) || q.match(/^(-?\d+\.?\d*)\s+(-?\d+\.?\d*)$/);
if (locationMatch) {
@@ -148,6 +135,20 @@ export function uiFeatureList(context) {
});
}
// A location search takes priority over an ID search
var idMatch = !locationMatch && q.match(/(?:^|\W)(node|way|relation|[nwr])\W?0*([1-9]\d*)(?:\W|$)/i);
if (idMatch) {
var elemType = idMatch[1].charAt(0);
var elemId = idMatch[2];
result.push({
id: elemType + elemId,
geometry: elemType === 'n' ? 'point' : elemType === 'w' ? 'line' : 'relation',
type: elemType === 'n' ? t('inspector.node') : elemType === 'w' ? t('inspector.way') : t('inspector.relation'),
name: elemId
});
}
var allEntities = graph.entities;
var localResults = [];
for (var id in allEntities) {