fix #1141 by fixing #1120 differently.

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
This commit is contained in:
jef 2008-07-12 09:18:52 +00:00
parent 26833c5a3d
commit f3f933d0d6
3 changed files with 16 additions and 16 deletions

View File

@ -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
{
@ -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)
@ -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)
{

View File

@ -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()

View File

@ -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 )
{
@ -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();
}
@ -1276,7 +1276,7 @@ QgsSpatialRefSys QgsGrassProvider::getSRS()
free ( wkt);
}
setlocale(LC_ALL, oldlocale);
setlocale(LC_NUMERIC, oldlocale);
QgsSpatialRefSys srs;
srs.createFromWkt(WKT);