Skip to content

Commit

Permalink
call OSRImportFromProj4() in locale "C" (fixes #1120)
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@8592 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Jun 4, 2008
1 parent 1f1bb58 commit 3e3d160
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
15 changes: 12 additions & 3 deletions src/core/qgsspatialrefsys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
{
Expand Down
7 changes: 6 additions & 1 deletion src/plugins/grass/qgsgrassnewmapset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 3e3d160

Please sign in to comment.