Skip to content

Commit

Permalink
fix goto locator to support leading NESW
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids authored Feb 25, 2025
1 parent 14e30a3 commit 1d6fa60
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/core/locator/gotolocatorfilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,31 @@ 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 );
Expand Down

0 comments on commit 1d6fa60

Please sign in to comment.