Skip to content
Permalink
Browse files

call OSRImportFromProj4() in locale "C" (fixes #1120)

git-svn-id: http://svn.osgeo.org/qgis/trunk@8592 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef
jef committed Jun 4, 2008
1 parent d54861a commit 2b3bb91e6662878787ce5d131179fe435d0696bc
Showing with 18 additions and 4 deletions.
  1. +12 −3 src/core/qgsspatialrefsys.cpp
  2. +6 −1 src/plugins/grass/qgsgrassnewmapset.cpp
@@ -228,7 +228,10 @@ bool QgsSpatialRefSys::loadFromDb(QString db, QString field, long id)
mGeoFlag = (geo == 0 ? false : true);
setMapUnits();
mIsValidFlag = true;
OSRImportFromProj4( mSRS, (const char *)proj4String.toLatin1() );
const char *oldlocale = setlocale(LC_ALL, NULL);
setlocale(LC_ALL, "C");
OSRImportFromProj4( mSRS, proj4String.toLatin1().constData() );
setlocale(LC_ALL, oldlocale);
}
else
{
@@ -408,7 +411,10 @@ bool QgsSpatialRefSys::createFromProj4 (const QString theProj4String)
if (!myRecord.empty())
{
// Success! We have found the proj string by swapping the lat_1 and lat_2
OSRImportFromProj4(mSRS, (const char *)theProj4StringModified.toLatin1() );
const char *oldlocale = setlocale(LC_ALL, NULL);
setlocale(LC_ALL, "C");
OSRImportFromProj4(mSRS, theProj4StringModified.toLatin1().constData() );
setlocale(LC_ALL, oldlocale);
mySrsId=myRecord["srs_id"].toLong();
QgsDebugMsg("QgsSpatialRefSys::createFromProj4 proj4string match search for srsid returned srsid: " + QString::number(mySrsId));
if (mySrsId > 0)
@@ -658,7 +664,10 @@ void QgsSpatialRefSys::setDescription (QString theDescription)
}
void QgsSpatialRefSys::setProj4String (QString theProj4String)
{
mIsValidFlag = OSRImportFromProj4(mSRS, (const char *)theProj4String.toLatin1())==OGRERR_NONE;
const char *oldlocale = setlocale(LC_ALL, NULL);
setlocale(LC_ALL, "C");
mIsValidFlag = OSRImportFromProj4(mSRS, theProj4String.toLatin1().constData() )==OGRERR_NONE;
setlocale(LC_ALL, oldlocale);
}
void QgsSpatialRefSys::setGeographicFlag (bool theGeoFlag)
{
@@ -473,7 +473,12 @@ void QgsGrassNewMapset::setGrassProjection()
OGRSpatialReferenceH hSRS = NULL;
hSRS = OSRNewSpatialReference(NULL);
int errcode;
if ( (errcode = OSRImportFromProj4(hSRS, proj4.ascii())) != OGRERR_NONE) {
const char *oldlocale = setlocale(LC_ALL, NULL);
setlocale(LC_ALL, "C");
errcode = OSRImportFromProj4(hSRS, proj4.ascii());
setlocale(LC_ALL, oldlocale);
if ( errcode!=OGRERR_NONE )
{
std::cerr << "OGR can't parse PROJ.4-style parameter string:\n" << proj4.ascii()
<< "\nOGR Error code was " << errcode << std::endl;

0 comments on commit 2b3bb91

Please sign in to comment.
You can’t perform that action at this time.