Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Show both lat/lon and lon/lat variations in dropdown when searching coordinates #10725

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 32 additions & 8 deletions modules/ui/feature_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,38 @@ 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
});
var latLon = [Number(locationMatch[0]), Number(locationMatch[1])];
var lonLat = [latLon[1], latLon[0]]; // Swap the order

var isLatLonValid = latLon[0] >= -90 && latLon[0] <= 90;
var isLonLatValid = lonLat[0] >= -90 && lonLat[0] <= 90;

if (isLatLonValid && isLonLatValid) {
result.push({
id: latLon[0] + '/' + latLon[1],
geometry: 'point',
type: t('inspector.location'),
name: dmsCoordinatePair([latLon[1], latLon[0]]),
location: latLon
});

result.push({
id: lonLat[0] + '/' + lonLat[1],
geometry: 'point',
type: t('inspector.location'),
name: dmsCoordinatePair([lonLat[1], lonLat[0]]),
location: lonLat
});
} else {
// If one order is invalid, only push the valid one
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
Expand Down
Loading