diff --git a/src/core/locator/gotolocatorfilter.cpp b/src/core/locator/gotolocatorfilter.cpp index 52e71120eb..cb796c2fb6 100644 --- a/src/core/locator/gotolocatorfilter.cpp +++ b/src/core/locator/gotolocatorfilter.cpp @@ -93,15 +93,30 @@ void GotoLocatorFilter::fetchResults( const QString &string, const QgsLocatorCon if ( !match.hasMatch() ) { // Check if the string is a pair of degree minute second - 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]?)$" ) - .arg( locale.decimalPoint() ) ); + const QString dmsRx = QStringLiteral( "\\d{1,3}(?:[^0-9.]+[0-5]?\\d)?[^0-9.]+[0-5]?\\d(?:[\\.\\%1]\\d+)?" ).arg( locale.decimalPoint() ); + separatorRx = QRegularExpression( QStringLiteral( + "^(" + "(\\s*%1[^0-9.,]*[-+NSEWnsew]?)[,\\s]+(%1[^0-9.,]*[-+NSEWnsew]?)" + ")|(" + "((?:([-+NSEWnsew])\\s*)%1[^0-9.,]*)[,\\s]+((?:([-+NSEWnsew])\\s*)%1[^0-9.,]*)" + ")$" ) + .arg( dmsRx ) ); + match = separatorRx.match( string.trimmed() ); if ( match.hasMatch() ) { posIsWgs84 = true; bool isEasting = false; - firstNumber = QgsCoordinateUtils::dmsToDecimal( match.captured( 1 ), &firstOk, &isEasting ); - secondNumber = QgsCoordinateUtils::dmsToDecimal( match.captured( 3 ), &secondOk ); + if ( !match.captured( 1 ).isEmpty() ) + { + firstNumber = QgsCoordinateUtils::dmsToDecimal( match.captured( 2 ), &firstOk, &isEasting ); + secondNumber = QgsCoordinateUtils::dmsToDecimal( match.captured( 3 ), &secondOk ); + } + else + { + firstNumber = QgsCoordinateUtils::dmsToDecimal( match.captured( 5 ), &firstOk, &isEasting ); + secondNumber = QgsCoordinateUtils::dmsToDecimal( match.captured( 7 ), &secondOk ); + } // normalize to northing (i.e. Y) first if ( isEasting ) std::swap( firstNumber, secondNumber );