Skip to content

Commit

Permalink
MITAB: swap StdParallel1 and stdParallel2 if necessary on LCC project…
Browse files Browse the repository at this point in the history
…ions (mapgears/mitab#1)

git-svn-id: https://svn.osgeo.org/gdal/trunk/gdal@27527 f0d54148-0727-0410-94bb-9a71ac55c965
  • Loading branch information
rouault committed Jul 14, 2014
1 parent 352bebd commit d326695
Show file tree
Hide file tree
Showing 3 changed files with 499 additions and 16 deletions.
7 changes: 4 additions & 3 deletions ogr/ogrsf_frmts/mitab/mitab_bounds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
* bounds lookups
*----------------------------------------------------------------*/
static MapInfoBoundsInfo **gpapsExtBoundsList = NULL;
static MapInfoBoundsInfo gasBoundsList[] = {
static const MapInfoBoundsInfo gasBoundsList[] = {
{{1, 0xff, 0xff, {0,0,0,0,0,0}, 0,0,0,0, {0,0,0,0,0}}, -1000, -1000, 1000, 1000}, /* Lat/Lon */

{{2, 29, 0, {-85.5,13,0,0,0,0}, 0,0,0,0, {0,0,0,0,0}}, -18500.7190263237, -4067.43878447928, 30025.7571082958, 4067.43878447928},
Expand Down Expand Up @@ -1053,7 +1053,8 @@ GBool MITABLookupCoordSysBounds(TABProjInfo *psCS,
double &dXMax, double &dYMax)
{
GBool bFound = FALSE;
MapInfoBoundsInfo *psList, **ppsList;
const MapInfoBoundsInfo *psList;
MapInfoBoundsInfo **ppsList;

/*-----------------------------------------------------------------
* Lookup table...
Expand Down Expand Up @@ -1100,7 +1101,7 @@ GBool MITABLookupCoordSysBounds(TABProjInfo *psCS,
psList = gasBoundsList;
for( ; !bFound && psList->sProj.nProjId!=0xff; psList++)
{
TABProjInfo *p = &(psList->sProj);
const TABProjInfo *p = &(psList->sProj);

if (p->nProjId == psCS->nProjId &&
(p->nUnitsId == 0xff || p->nUnitsId == psCS->nUnitsId) &&
Expand Down
48 changes: 43 additions & 5 deletions ogr/ogrsf_frmts/mitab/mitab_coordsys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@
#include "mitab.h"
#include "mitab_utils.h"

extern MapInfoDatumInfo asDatumInfoList[];
extern MapInfoSpheroidInfo asSpheroidInfoList[];
extern const MapInfoDatumInfo asDatumInfoList[];
extern const MapInfoSpheroidInfo asSpheroidInfoList[];

/************************************************************************/
/* GetMIFParm() */
Expand Down Expand Up @@ -650,6 +650,17 @@ OGRSpatialReference *MITABCoordSys2SpatialRef( const char * pszCoordSys )
GetMIFParm( papszNextField, 5, 0.0 )); // dfFalseNorthing
break;

/*--------------------------------------------------------------
* Equidistant Cylindrical / Equirectangular
*-------------------------------------------------------------*/
case 33:
poSR->SetEquirectangular(
GetMIFParm( papszNextField, 1, 0.0 ),
GetMIFParm( papszNextField, 0, 0.0 ),
GetMIFParm( papszNextField, 2, 0.0 ),
GetMIFParm( papszNextField, 3, 0.0 ) );
break;

default:
break;
}
Expand Down Expand Up @@ -683,7 +694,7 @@ OGRSpatialReference *MITABCoordSys2SpatialRef( const char * pszCoordSys )
/* Find the datum, and collect it's parameters if possible. */
/* -------------------------------------------------------------------- */
int iDatum;
MapInfoDatumInfo *psDatumInfo = NULL;
const MapInfoDatumInfo *psDatumInfo = NULL;

for( iDatum = 0; asDatumInfoList[iDatum].nMapInfoDatumID != -1; iDatum++ )
{
Expand Down Expand Up @@ -786,7 +797,9 @@ OGRSpatialReference *MITABCoordSys2SpatialRef( const char * pszCoordSys )
CPLAtof(SRS_UA_DEGREE_CONV) );

poSR->SetTOWGS84( adfDatumParm[0], adfDatumParm[1], adfDatumParm[2],
-adfDatumParm[3], -adfDatumParm[4], -adfDatumParm[5],
adfDatumParm[3] == 0.0 ? 0.0 : -adfDatumParm[3],
adfDatumParm[4] == 0.0 ? 0.0 : -adfDatumParm[4],
adfDatumParm[5] == 0.0 ? 0.0 : -adfDatumParm[5],
adfDatumParm[6] );

/*-----------------------------------------------------------------
Expand All @@ -798,6 +811,21 @@ OGRSpatialReference *MITABCoordSys2SpatialRef( const char * pszCoordSys )
poSR->SetNode( "PROJCS", "WGS 84 / Pseudo-Mercator" );
poSR->SetExtension( "PROJCS", "PROJ4", "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs" );
}

/*-----------------------------------------------------------------
* Special case for France Lambert-93
*----------------------------------------------------------------*/
if( nBaseProjection == 3
&& nDatum == 33
&& nEllipsoid == 0
&& poSR->GetProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0) == 3.0
&& poSR->GetProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0) == 46.5 )
{
poSR->SetNode( "PROJCS", "RGF93 / Lambert-93" );
poSR->SetNode( "PROJCS|GEOGCS", "RGF93");
poSR->SetNode( "PROJCS|GEOGCS|DATUM", "Reseau_Geodesique_Francais_1993");
}

/* -------------------------------------------------------------------- */
/* Report on translation. */
/* -------------------------------------------------------------------- */
Expand Down Expand Up @@ -1139,6 +1167,16 @@ char *MITABSpatialRef2CoordSys( OGRSpatialReference * poSR )
nParmCount = 6;
}

else if( EQUAL(pszProjection,SRS_PT_EQUIRECTANGULAR) )
{
nProjection = 33;
parms[0] = poSR->GetProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0);
parms[1] = poSR->GetProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0);
parms[2] = poSR->GetProjParm(SRS_PP_FALSE_EASTING,0.0);
parms[3] = poSR->GetProjParm(SRS_PP_FALSE_NORTHING,0.0);
nParmCount = 4;
}

/* ==============================================================
* Translate Datum and Ellipsoid
* ============================================================== */
Expand Down Expand Up @@ -1507,7 +1545,7 @@ int MITABCoordSys2TABProjInfo(const char * pszCoordSys, TABProjInfo *psProj)
* Find the datum, and collect it's parameters if possible.
*----------------------------------------------------------------*/
int iDatum;
MapInfoDatumInfo *psDatumInfo = NULL;
const MapInfoDatumInfo *psDatumInfo = NULL;

for(iDatum=0; asDatumInfoList[iDatum].nMapInfoDatumID != -1; iDatum++)
{
Expand Down
Loading

0 comments on commit d326695

Please sign in to comment.