[QGIS Commit] r15361 - trunk/qgis/src/core
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Sun Mar 6 08:52:21 EST 2011
Author: jef
Date: 2011-03-06 05:52:21 -0800 (Sun, 06 Mar 2011)
New Revision: 15361
Modified:
trunk/qgis/src/core/qgscoordinatereferencesystem.cpp
Log:
be less restrictive on interpreting CRSes
Modified: trunk/qgis/src/core/qgscoordinatereferencesystem.cpp
===================================================================
--- trunk/qgis/src/core/qgscoordinatereferencesystem.cpp 2011-03-06 13:38:20 UTC (rev 15360)
+++ trunk/qgis/src/core/qgscoordinatereferencesystem.cpp 2011-03-06 13:52:21 UTC (rev 15361)
@@ -302,7 +302,18 @@
//now that we have the proj4string, delegate to createFromProj4 so
// that we can try to fill in the remaining class members...
//create from Proj will set the isValidFlag
- createFromProj4( QString( proj4src ) );
+ if ( !createFromProj4( proj4src ) )
+ {
+ CPLFree( proj4src );
+
+ // try fixed up version
+ OSRFixup( mCRS );
+
+ OSRExportToProj4( mCRS, &proj4src );
+
+ createFromProj4( proj4src );
+ }
+
CPLFree( proj4src );
return mIsValidFlag;
@@ -324,42 +335,36 @@
// +proj=lcc +lat_1=46.8 +lat_0=46.8 +lon_0=2.337229166666664 +k_0=0.99987742
// +x_0=600000 +y_0=2200000 +a=6378249.2 +b=6356515.000000472 +units=m +no_defs
//
+ QgsDebugMsg( "proj4: " + theProj4String );
mIsValidFlag = false;
- QRegExp myProjRegExp( "\\+proj=\\S+" );
- int myStart = 0;
- int myLength = 0;
- myStart = myProjRegExp.indexIn( theProj4String, myStart );
+ QRegExp myProjRegExp( "\\+proj=(\\S+)" );
+ int myStart = myProjRegExp.indexIn( theProj4String );
if ( myStart == -1 )
{
- QgsDebugMsg( "error proj string supplied has no +proj argument" );
+ QgsDebugMsg( "proj string supplied has no +proj argument" );
return mIsValidFlag;
}
- else
- {
- myLength = myProjRegExp.matchedLength();
- }
- mProjectionAcronym = theProj4String.mid( myStart + PROJ_PREFIX_LEN, myLength - PROJ_PREFIX_LEN );
+ mProjectionAcronym = myProjRegExp.cap( 1 );
- QRegExp myEllipseRegExp( "\\+ellps=\\S+" );
- myStart = 0;
- myLength = 0;
- myStart = myEllipseRegExp.indexIn( theProj4String, myStart );
- if ( myStart != -1 )
+ QRegExp myEllipseRegExp( "\\+ellps=(\\S+)" );
+ myStart = myEllipseRegExp.indexIn( theProj4String );
+ if ( myStart == -1 )
{
- myLength = myEllipseRegExp.matchedLength();
- mEllipsoidAcronym = theProj4String.mid( myStart + ELLPS_PREFIX_LEN, myLength - ELLPS_PREFIX_LEN );
+ QgsDebugMsg( "proj string supplied has no +ellps argument" );
+ mEllipsoidAcronym = "";
}
+ else
+ {
+ mEllipsoidAcronym = myEllipseRegExp.cap( 1 );
+ }
- QRegExp myAxisRegExp( "\\+a=\\S+" );
- myStart = 0;
- myLength = 0;
- myStart = myAxisRegExp.indexIn( theProj4String, myStart );
- if ( myStart == -1 && mEllipsoidAcronym.isNull() )
+ QRegExp myAxisRegExp( "\\+a=(\\S+)" );
+ myStart = myAxisRegExp.indexIn( theProj4String );
+ if ( myStart == -1 )
{
- QgsDebugMsg( "proj string supplied has no +ellps or +a argument" );
- return mIsValidFlag;
+ QgsDebugMsg( "proj string supplied has no +a argument" );
}
/*
More information about the QGIS-commit
mailing list