Skip to content

Commit f9462da

Browse files
authored
Fix goto locator to support leading NESW (#6041)
1 parent 26af4d3 commit f9462da

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

src/core/locator/gotolocatorfilter.cpp

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,30 @@ void GotoLocatorFilter::fetchResults( const QString &string, const QgsLocatorCon
9393
if ( !match.hasMatch() )
9494
{
9595
// Check if the string is a pair of degree minute second
96-
separatorRx = QRegularExpression( QStringLiteral( "^((?:([-+nsew])\\s*)?\\d{1,3}(?:[^0-9.]+[0-5]?\\d)?[^0-9.]+[0-5]?\\d(?:[\\.\\%1]\\d+)?[^0-9.,]*[-+nsew]?)[,\\s]+((?:([-+nsew])\\s*)?\\d{1,3}(?:[^0-9.]+[0-5]?\\d)?[^0-9.]+[0-5]?\\d(?:[\\.\\%1]\\d+)?[^0-9.,]*[-+nsew]?)$" )
97-
.arg( locale.decimalPoint() ) );
96+
const QString dmsRx = QStringLiteral( "\\d{1,3}(?:[^0-9.]+[0-5]?\\d)?[^0-9.]+[0-5]?\\d(?:[\\.\\%1]\\d+)?" ).arg( locale.decimalPoint() );
97+
separatorRx = QRegularExpression( QStringLiteral(
98+
"^("
99+
"(\\s*%1[^0-9.,]*[-+NSEWnsew]?)[,\\s]+(%1[^0-9.,]*[-+NSEWnsew]?)"
100+
")|("
101+
"((?:([-+NSEWnsew])\\s*)%1[^0-9.,]*)[,\\s]+((?:([-+NSEWnsew])\\s*)%1[^0-9.,]*)"
102+
")$" )
103+
.arg( dmsRx ) );
104+
98105
match = separatorRx.match( string.trimmed() );
99106
if ( match.hasMatch() )
100107
{
101108
posIsWgs84 = true;
102109
bool isEasting = false;
103-
firstNumber = QgsCoordinateUtils::dmsToDecimal( match.captured( 1 ), &firstOk, &isEasting );
104-
secondNumber = QgsCoordinateUtils::dmsToDecimal( match.captured( 3 ), &secondOk );
110+
if ( !match.captured( 1 ).isEmpty() )
111+
{
112+
firstNumber = QgsCoordinateUtils::dmsToDecimal( match.captured( 2 ), &firstOk, &isEasting );
113+
secondNumber = QgsCoordinateUtils::dmsToDecimal( match.captured( 3 ), &secondOk );
114+
}
115+
else
116+
{
117+
firstNumber = QgsCoordinateUtils::dmsToDecimal( match.captured( 5 ), &firstOk, &isEasting );
118+
secondNumber = QgsCoordinateUtils::dmsToDecimal( match.captured( 7 ), &secondOk );
119+
}
105120
// normalize to northing (i.e. Y) first
106121
if ( isEasting )
107122
std::swap( firstNumber, secondNumber );

0 commit comments

Comments
 (0)