Skip to content

Commit

Permalink
fix #1141 by fixing #1120 differently.
Browse files Browse the repository at this point in the history
I still don't see why r8592 has an effect, except calling OSRImportFromProj4()
in locale "C".  Just setting LC_NUMERIC probably resolves the side effects
leading to #1141 without reopening #1120.

But there might be - even more subtle - side effects left - watch out.



git-svn-id: http://svn.osgeo.org/qgis/trunk@8759 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Jul 12, 2008
1 parent 26833c5 commit f3f933d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
18 changes: 9 additions & 9 deletions src/core/qgsspatialrefsys.cpp
Expand Up @@ -228,10 +228,10 @@ bool QgsSpatialRefSys::loadFromDb(QString db, QString field, long id)
mGeoFlag = (geo == 0 ? false : true);
setMapUnits();
mIsValidFlag = true;
const char *oldlocale = setlocale(LC_ALL, NULL);
setlocale(LC_ALL, "C");
const char *oldlocale = setlocale(LC_NUMERIC, NULL);
setlocale(LC_NUMERIC, "C");
OSRImportFromProj4( mSRS, proj4String.toLatin1().constData() );
setlocale(LC_ALL, oldlocale);
setlocale(LC_NUMERIC, oldlocale);
}
else
{
Expand Down Expand Up @@ -411,10 +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
const char *oldlocale = setlocale(LC_ALL, NULL);
setlocale(LC_ALL, "C");
const char *oldlocale = setlocale(LC_NUMERIC, NULL);
setlocale(LC_NUMERIC, "C");
OSRImportFromProj4(mSRS, theProj4StringModified.toLatin1().constData() );
setlocale(LC_ALL, oldlocale);
setlocale(LC_NUMERIC, oldlocale);
mySrsId=myRecord["srs_id"].toLong();
QgsDebugMsg("QgsSpatialRefSys::createFromProj4 proj4string match search for srsid returned srsid: " + QString::number(mySrsId));
if (mySrsId > 0)
Expand Down Expand Up @@ -664,10 +664,10 @@ void QgsSpatialRefSys::setDescription (QString theDescription)
}
void QgsSpatialRefSys::setProj4String (QString theProj4String)
{
const char *oldlocale = setlocale(LC_ALL, NULL);
setlocale(LC_ALL, "C");
const char *oldlocale = setlocale(LC_NUMERIC, NULL);
setlocale(LC_NUMERIC, "C");
mIsValidFlag = OSRImportFromProj4(mSRS, theProj4String.toLatin1().constData() )==OGRERR_NONE;
setlocale(LC_ALL, oldlocale);
setlocale(LC_NUMERIC, oldlocale);
}
void QgsSpatialRefSys::setGeographicFlag (bool theGeoFlag)
{
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/grass/qgsgrassnewmapset.cpp
Expand Up @@ -473,10 +473,10 @@ void QgsGrassNewMapset::setGrassProjection()
OGRSpatialReferenceH hSRS = NULL;
hSRS = OSRNewSpatialReference(NULL);
int errcode;
const char *oldlocale = setlocale(LC_ALL, NULL);
setlocale(LC_ALL, "C");
const char *oldlocale = setlocale(LC_NUMERIC, NULL);
setlocale(LC_NUMERIC, "C");
errcode = OSRImportFromProj4(hSRS, proj4.ascii());
setlocale(LC_ALL, oldlocale);
setlocale(LC_NUMERIC, oldlocale);
if ( errcode!=OGRERR_NONE )
{
std::cerr << "OGR can't parse PROJ.4-style parameter string:\n" << proj4.ascii()
Expand Down
8 changes: 4 additions & 4 deletions src/providers/grass/qgsgrassprovider.cpp
Expand Up @@ -1253,8 +1253,8 @@ QgsSpatialRefSys QgsGrassProvider::getSRS()
QgsGrass::resetError();
QgsGrass::setLocation ( mGisdbase, mLocation );

char *oldlocale = setlocale(LC_ALL, NULL);
setlocale(LC_ALL, "C");
const char *oldlocale = setlocale(LC_NUMERIC, NULL);
setlocale(LC_NUMERIC, "C");

if ( setjmp(QgsGrass::fatalErrorEnv()) == 0 )
{
Expand All @@ -1263,7 +1263,7 @@ QgsSpatialRefSys QgsGrassProvider::getSRS()
QgsGrass::clearErrorEnv();

if ( QgsGrass::getError() == QgsGrass::FATAL ) {
setlocale(LC_ALL, oldlocale);
setlocale(LC_NUMERIC, oldlocale);
QgsDebugMsg(QString("Cannot get default window: %1").arg(QgsGrass::getErrorMessage()));
return QgsSpatialRefSys();
}
Expand All @@ -1276,7 +1276,7 @@ QgsSpatialRefSys QgsGrassProvider::getSRS()
free ( wkt);
}

setlocale(LC_ALL, oldlocale);
setlocale(LC_NUMERIC, oldlocale);

QgsSpatialRefSys srs;
srs.createFromWkt(WKT);
Expand Down

0 comments on commit f3f933d

Please sign in to comment.