mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-20 07:25:15 +02:00
Show both lat/lon and lon/lat when searching coordinates (#10725)
This commit is contained in:
committed by
GitHub
parent
c292ac788e
commit
f7fc707159
@@ -38,6 +38,7 @@ _Breaking developer changes, which may affect downstream projects or sites that
|
||||
# Unreleased (2.32.0-dev)
|
||||
|
||||
#### :sparkles: Usability & Accessibility
|
||||
* Also show search result for coordinates in `lon/lat` order in search results ([#10720], thanks [@Deeptanshu-sankhwar])
|
||||
#### :scissors: Operations
|
||||
#### :camera: Street-Level
|
||||
#### :white_check_mark: Validation
|
||||
@@ -54,9 +55,11 @@ _Breaking developer changes, which may affect downstream projects or sites that
|
||||
#### :hammer: Development
|
||||
|
||||
[#10003]: https://github.com/openstreetmap/iD/pull/10003
|
||||
[#10720]: https://github.com/openstreetmap/iD/issues/10720
|
||||
[#10747]: https://github.com/openstreetmap/iD/issues/10747
|
||||
[#10748]: https://github.com/openstreetmap/iD/issues/10748
|
||||
[@hlfan]: https://github.com/hlfan
|
||||
[@Deeptanshu-sankhwar]: https://github.com/Deeptanshu-sankhwar
|
||||
|
||||
|
||||
# 2.31.1
|
||||
|
||||
@@ -127,14 +127,32 @@ export function uiFeatureList(context) {
|
||||
var locationMatch = sexagesimal.pair(q.toUpperCase()) || dmsMatcher(q);
|
||||
|
||||
if (locationMatch) {
|
||||
var loc = [Number(locationMatch[0]), Number(locationMatch[1])];
|
||||
result.push({
|
||||
id: loc[0] + '/' + loc[1],
|
||||
geometry: 'point',
|
||||
type: t('inspector.location'),
|
||||
name: dmsCoordinatePair([loc[1], loc[0]]),
|
||||
location: loc
|
||||
});
|
||||
const latLon = [Number(locationMatch[0]), Number(locationMatch[1])];
|
||||
const lonLat = [latLon[1], latLon[0]]; // also try swapped order
|
||||
|
||||
const isLatLonValid = latLon[0] >= -90 && latLon[0] <= 90 && latLon[1] >= -180 && latLon[1] <= 180;
|
||||
let isLonLatValid = lonLat[0] >= -90 && lonLat[0] <= 90 && lonLat[1] >= -180 && lonLat[1] <= 180;
|
||||
isLonLatValid &&= !q.match(/[NSEW]/i);
|
||||
isLonLatValid &&= lonLat[0] !== lonLat[1];
|
||||
|
||||
if (isLatLonValid) {
|
||||
result.push({
|
||||
id: latLon[0] + '/' + latLon[1],
|
||||
geometry: 'point',
|
||||
type: t('inspector.location'),
|
||||
name: dmsCoordinatePair([latLon[1], latLon[0]]),
|
||||
location: latLon
|
||||
});
|
||||
}
|
||||
if (isLonLatValid) {
|
||||
result.push({
|
||||
id: lonLat[0] + '/' + lonLat[1],
|
||||
geometry: 'point',
|
||||
type: t('inspector.location'),
|
||||
name: dmsCoordinatePair([lonLat[1], lonLat[0]]),
|
||||
location: lonLat
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// A location search takes priority over an ID search
|
||||
|
||||
Reference in New Issue
Block a user