mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-03 00:02:25 -05:00
Use a more flexible coordinate detection approach
This commit is contained in:
parent
182167fcfc
commit
8d7f090789
@ -731,18 +731,14 @@ void QgsGotoLocatorFilter::fetchResults( const QString &string, const QgsLocator
|
|||||||
const QgsCoordinateReferenceSystem wgs84Crs( QStringLiteral( "EPSG:4326" ) );
|
const QgsCoordinateReferenceSystem wgs84Crs( QStringLiteral( "EPSG:4326" ) );
|
||||||
|
|
||||||
// Coordinates such as 106.8468,-6.3804
|
// Coordinates such as 106.8468,-6.3804
|
||||||
QStringList coordinates = string.split( ' ' );
|
QRegularExpression separatorRx( QStringLiteral( "^([0-9\\-\\.]*)[\\s\\,]*([0-9\\-\\.]*)$" ) );
|
||||||
if ( coordinates.size() != 2 )
|
QRegularExpressionMatch match = separatorRx.match( string.trimmed() );
|
||||||
{
|
if ( match.hasMatch() )
|
||||||
coordinates = string.split( ',' );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( coordinates.size() == 2 )
|
|
||||||
{
|
{
|
||||||
bool okX = false;
|
bool okX = false;
|
||||||
bool okY = false;
|
bool okY = false;
|
||||||
double posX = coordinates.at( 0 ).toDouble( &okX );
|
double posX = match.captured( 1 ).toDouble( &okX );
|
||||||
double posY = coordinates.at( 1 ).toDouble( &okY );
|
double posY = match.captured( 2 ).toDouble( &okY );
|
||||||
|
|
||||||
if ( okX && okY )
|
if ( okX && okY )
|
||||||
{
|
{
|
||||||
@ -847,7 +843,7 @@ void QgsGotoLocatorFilter::fetchResults( const QString &string, const QgsLocator
|
|||||||
if ( !okX && !okY )
|
if ( !okX && !okY )
|
||||||
{
|
{
|
||||||
QRegularExpression locationRx( QStringLiteral( "google.*\\/@([0-9\\-\\.\\,]*)z" ) );
|
QRegularExpression locationRx( QStringLiteral( "google.*\\/@([0-9\\-\\.\\,]*)z" ) );
|
||||||
QRegularExpressionMatch match = locationRx.match( string );
|
match = locationRx.match( string );
|
||||||
if ( match.hasMatch() )
|
if ( match.hasMatch() )
|
||||||
{
|
{
|
||||||
QStringList params = match.captured( 1 ).split( ',' );
|
QStringList params = match.captured( 1 ).split( ',' );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user