From b9d67aff9ea9c94499324f0662bd961af2ffef82 Mon Sep 17 00:00:00 2001 From: Denis Rouzaud Date: Tue, 25 Feb 2025 08:25:26 +0100 Subject: [PATCH] [locator] fix goto to support leading NESW --- .../kadasalternategotolocatorfilter.cpp | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/kadas/gui/search/kadasalternategotolocatorfilter.cpp b/kadas/gui/search/kadasalternategotolocatorfilter.cpp index 015da901..88a34f4b 100644 --- a/kadas/gui/search/kadasalternategotolocatorfilter.cpp +++ b/kadas/gui/search/kadasalternategotolocatorfilter.cpp @@ -118,15 +118,32 @@ void KadasAlternateGotoLocatorFilter::fetchResults( const QString &string, const 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() ) { + qDebug() << match.captured( 1 ) << match.captured( 2 ) << match.captured( 3 ) << match.captured( 4 ) << match.captured( 5 ) << match.captured( 6 ) << match.captured( 7 ) << match.captured( 8 ); + 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 );