~ubuntu-branches/debian/sid/gdal/sid

« back to all changes in this revision

Viewing changes to ogr/ogrsf_frmts/mitab/mitab_spatialref.cpp

  • Committer: Package Import Robot
  • Author(s): Francesco Paolo Lovergine
  • Date: 2012-05-07 15:04:42 UTC
  • mfrom: (5.5.16 experimental)
  • Revision ID: package-import@ubuntu.com-20120507150442-2eks97loeh6rq005
Tags: 1.9.0-1
* Ready for sid, starting transition.
* All symfiles updated to latest builds.
* Added dh_numpy call in debian/rules to depend on numpy ABI.
* Policy bumped to 3.9.3, no changes required.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/**********************************************************************
2
 
 * $Id: mitab_spatialref.cpp,v 1.49 2009-10-15 16:16:37 fwarmerdam Exp $
 
2
 * $Id: mitab_spatialref.cpp,v 1.55 2011-06-11 00:35:00 fwarmerdam Exp $
3
3
 *
4
4
 * Name:     mitab_spatialref.cpp
5
5
 * Project:  MapInfo TAB Read/Write library
30
30
 **********************************************************************
31
31
 *
32
32
 * $Log: mitab_spatialref.cpp,v $
 
33
 * Revision 1.55  2011-06-11 00:35:00  fwarmerdam
 
34
 * add support for reading google mercator (#4115)
 
35
 *
 
36
 * Revision 1.54  2010-10-07 18:46:26  aboudreault
 
37
 * Fixed bad use of atof when locale setting doesn't use . for float (GDAL bug #3775)
 
38
 *
 
39
 * Revision 1.53  2010-09-07 16:48:08  aboudreault
 
40
 * Removed incomplete patch for affine params support in mitab. (bug 1155)
 
41
 *
 
42
 * Revision 1.52  2010-07-08 17:21:12  aboudreault
 
43
 * Put back New_Zealand Datum in asDatumInfoList
 
44
 *
 
45
 * Revision 1.51  2010-07-07 19:00:15  aboudreault
 
46
 * Cleanup Win32 Compile Warnings (GDAL bug #2930)
 
47
 *
 
48
 * Revision 1.50  2010-07-05 17:20:14  aboudreault
 
49
 * Added Krovak projection suppoprt (bug 2230)
 
50
 *
33
51
 * Revision 1.49  2009-10-15 16:16:37  fwarmerdam
34
52
 * add the default EPSG/OGR name for new zealand datums (gdal #3187)
35
53
 *
360
378
{150, "Hartebeesthoek94",           0, 0,    0,   0,    0, 0, 0, 0, 0},
361
379
{151, "ATS77",                      51, 0, 0, 0, 0, 0, 0, 0, 0},
362
380
{152, "JGD2000",                    0, 0, 0, 0, 0, 0, 0, 0, 0},
 
381
{157, "WGS_1984",                   54,0, 0, 0, 0, 0, 0, 0, 0}, // Google merc
363
382
{1000,"DHDN_Potsdam_Rauenberg",     10,582,  105, 414, -1.04, -0.35, 3.08, 8.3, 0},
364
383
{1001,"Pulkovo_1942",               3, 24,   -123, -94, -0.02, 0.25, 0.13, 1.1, 0},
365
384
{1002,"NTF_Paris_Meridian",         30,-168, -60, 320, 0, 0, 0, 0, 2.337229166667},
377
396
{1014,"Russia_SK95",                52, 24.82,-131.21,-82.66,0,0,-0.16,-0.12, 0},
378
397
{1015,"Tokyo",                      10, -146.414, 507.337, 680.507,0,0,0,0,0},
379
398
{1016,"Finnish_KKJ",                4, -96.062, -82.428, -121.754, -4.801, -0.345, 1.376, 1.496, 0},
 
399
{1017,"Xian 1980",                                      53, 24, -123, -94, -0.02, -0.25, 0.13, 1.1, 0},
 
400
{1018,"Lithuanian Pulkovo 1942",        4, -40.59527, -18.54979, -69.33956, -2.508, -1.8319, 2.6114, -4.2991, 0},
 
401
{1019,"Belgian 1972 7 Parameter",   4, -99.059, 53.322, -112.486, -0.419, 0.83, -1.885, 0.999999, 0},
 
402
{1020,"S-JTSK with Ferro prime meridian", 10, 589, 76, 480, 0, 0, 0, 0, -17.666666666667}, 
380
403
 
381
404
{-1, NULL,                          0, 0, 0, 0, 0, 0, 0, 0, 0}
382
405
};
441
464
{ 1,"WGS 72",                                   6378135.0,      298.26},
442
465
{28,"WGS 84",                                   6378137.0,      298.257223563},
443
466
{29,"WGS 84 (MAPINFO Datum 0)",                 6378137.01,     298.257223563},
 
467
{54,"WGS 84 (MAPINFO Datum 157)",               6378137.01,     298.257223563},
444
468
{-1,NULL,                                       0.0,            0.0}
445
469
};
446
470
 
573
597
        break;
574
598
    }
575
599
 
576
 
    dfConv = atof(pszUnitsConv);
 
600
    dfConv = CPLAtof(pszUnitsConv);
577
601
 
578
602
    /*-----------------------------------------------------------------
579
603
     * Transform them into an OGRSpatialReference.
870
894
                               sTABProj.adProjParams[3] );
871
895
        break;
872
896
 
 
897
     /*--------------------------------------------------------------
 
898
      * Krovak
 
899
      *-------------------------------------------------------------*/
 
900
      case 32:
 
901
        m_poSpatialRef->SetKrovak( sTABProj.adProjParams[1],   // dfCenterLat
 
902
                                   sTABProj.adProjParams[0],   // dfCenterLong
 
903
                                   sTABProj.adProjParams[3],   // dfAzimuth
 
904
                                   sTABProj.adProjParams[2],   // dfPseudoStdParallelLat
 
905
                                   1.0,                                      // dfScale
 
906
                                   sTABProj.adProjParams[4],   // dfFalseEasting
 
907
                                   sTABProj.adProjParams[5] ); // dfFalseNorthing
 
908
        break;
 
909
 
873
910
      default:
874
911
        break;
875
912
    }
887
924
        poUnits->AddChild( new OGR_SRSNode( pszUnitsConv ) );
888
925
    }
889
926
 
890
 
#ifdef MITAB_AFFINE_PARAMS  // See MITAB bug 1155
891
 
    /*-----------------------------------------------------------------
892
 
     * Collect affine definitions. (Added by Encom 2003)
893
 
     *----------------------------------------------------------------*/
894
 
    if( sTABProj.nAffineFlag==1 && m_poSpatialRef->GetRoot() != NULL )
895
 
    {
896
 
        m_poSpatialRef->nAffineFlag = 1;
897
 
        m_poSpatialRef->nAffineUnit = sTABProj.nAffineUnits;
898
 
        m_poSpatialRef->dAffineParamA = sTABProj.dAffineParamA;
899
 
        m_poSpatialRef->dAffineParamB = sTABProj.dAffineParamB;
900
 
        m_poSpatialRef->dAffineParamC = sTABProj.dAffineParamC;
901
 
        m_poSpatialRef->dAffineParamD = sTABProj.dAffineParamD;
902
 
        m_poSpatialRef->dAffineParamE = sTABProj.dAffineParamE;
903
 
        m_poSpatialRef->dAffineParamF = sTABProj.dAffineParamF;
904
 
    }
905
 
    else
906
 
    {
907
 
        m_poSpatialRef->nAffineFlag = 0;
908
 
    }
909
 
#endif // MITAB_AFFINE_PARAMS
910
 
 
911
927
    /*-----------------------------------------------------------------
912
928
     * Local (nonearth) coordinate systems have no Geographic relationship
913
929
     * so we just return from here. 
961
977
            && sTABProj.adDatumParams[4] == 0.0 )
962
978
        {
963
979
            sprintf( szDatumName,
964
 
                     "MIF 999,%d,%.4g,%.4g,%.4g",
 
980
                     "MIF 999,%d,%.15g,%.15g,%.15g", 
965
981
                     sTABProj.nEllipsoidId,
966
982
                     sTABProj.dDatumShiftX, 
967
983
                     sTABProj.dDatumShiftY, 
970
986
        else
971
987
        {
972
988
            sprintf( szDatumName,
973
 
                     "MIF 9999,%d,%.4g,%.4g,%.4g,%.15g,%.15g,%.15g,%.15g,%.15g",
 
989
                     "MIF 9999,%d,%.15g,%.15g,%.15g,%.15g,%.15g,%.15g,%.15g,%.15g",
974
990
                     sTABProj.nEllipsoidId,
975
991
                     sTABProj.dDatumShiftX, 
976
992
                     sTABProj.dDatumShiftY, 
1039
1055
                               pszSpheroidName,
1040
1056
                               dfSemiMajor, dfInvFlattening,
1041
1057
                               pszPMName, dfPMOffset,
1042
 
                               SRS_UA_DEGREE, atof(SRS_UA_DEGREE_CONV));
 
1058
                               SRS_UA_DEGREE, CPLAtof(SRS_UA_DEGREE_CONV));
1043
1059
 
1044
1060
    if( psDatumInfo != NULL )
1045
1061
    {
1052
1068
                                    psDatumInfo->dfDatumParm3 );
1053
1069
    }
1054
1070
 
 
1071
    /*-----------------------------------------------------------------
 
1072
     * Special case for Google Mercator (datum=157, ellipse=54, gdal #4115)
 
1073
     *----------------------------------------------------------------*/
 
1074
    if( sTABProj.nProjId == 10 
 
1075
        && sTABProj.nDatumId == 157
 
1076
        && sTABProj.nEllipsoidId == 54 )
 
1077
    {
 
1078
        m_poSpatialRef->SetNode( "PROJCS", "WGS 84 / Pseudo-Mercator" );
 
1079
        m_poSpatialRef->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" );
 
1080
    }
 
1081
 
1055
1082
    return m_poSpatialRef;
1056
1083
}
1057
1084
 
1118
1145
    sTABProj.adDatumParams[3] = 0.0;
1119
1146
    sTABProj.adDatumParams[4] = 0.0;
1120
1147
 
1121
 
    // Encom 2003
1122
1148
    sTABProj.nAffineFlag   = 0;
1123
1149
    sTABProj.nAffineUnits  = 7;
1124
1150
    sTABProj.dAffineParamA = 0.0;
1127
1153
    sTABProj.dAffineParamD = 0.0;
1128
1154
    sTABProj.dAffineParamE = 0.0;
1129
1155
    sTABProj.dAffineParamF = 0.0;
1130
 
    
 
1156
 
1131
1157
    /*-----------------------------------------------------------------
1132
1158
     * Get the linear units and conversion.
1133
1159
     *----------------------------------------------------------------*/
1397
1423
        parms[3] = poSpatialRef->GetProjParm(SRS_PP_FALSE_NORTHING,0.0);
1398
1424
    }
1399
1425
 
 
1426
   else if( EQUAL(pszProjection,SRS_PT_KROVAK) )
 
1427
   {
 
1428
        sTABProj.nProjId = 32;
 
1429
        parms[0] = poSpatialRef->GetProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0);
 
1430
        parms[1] = poSpatialRef->GetProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0);
 
1431
        parms[2] = poSpatialRef->GetProjParm(SRS_PP_PSEUDO_STD_PARALLEL_1,0.0);
 
1432
        parms[3] = poSpatialRef->GetProjParm(SRS_PP_AZIMUTH,0.0);
 
1433
        parms[4] = poSpatialRef->GetProjParm(SRS_PP_FALSE_EASTING,0.0);
 
1434
        parms[5] = poSpatialRef->GetProjParm(SRS_PP_FALSE_NORTHING,0.0);
 
1435
   }
 
1436
 
1400
1437
    /* ==============================================================
1401
1438
     * Translate Datum and Ellipsoid
1402
1439
     * ============================================================== */
1447
1484
 
1448
1485
        if( CSLCount(papszFields) >= 5 )
1449
1486
        {
1450
 
            sTABProj.nEllipsoidId = atoi(papszFields[1]);
 
1487
            sTABProj.nEllipsoidId = (GByte)atoi(papszFields[1]);
1451
1488
            sTABProj.dDatumShiftX = atof(papszFields[2]);
1452
1489
            sTABProj.dDatumShiftY = atof(papszFields[3]);
1453
1490
            sTABProj.dDatumShiftZ = atof(papszFields[4]);
1491
1528
 
1492
1529
    if( psDatumInfo != NULL )
1493
1530
    {
1494
 
        sTABProj.nEllipsoidId = psDatumInfo->nEllipsoid;
1495
 
        sTABProj.nDatumId = psDatumInfo->nMapInfoDatumID;
 
1531
        sTABProj.nEllipsoidId = (GByte)psDatumInfo->nEllipsoid;
 
1532
        sTABProj.nDatumId = (GInt16)psDatumInfo->nMapInfoDatumID;
1496
1533
        sTABProj.dDatumShiftX = psDatumInfo->dfShiftX;
1497
1534
        sTABProj.dDatumShiftY = psDatumInfo->dfShiftY;
1498
1535
        sTABProj.dDatumShiftZ = psDatumInfo->dfShiftZ;
1513
1550
    else if( dfLinearConv == 0.0254 || EQUAL(pszLinearUnits,"Inch")
1514
1551
             || EQUAL(pszLinearUnits,"IINCH") )
1515
1552
        sTABProj.nUnitsId = 2;
1516
 
    else if( dfLinearConv == atof(SRS_UL_FOOT_CONV)
 
1553
    else if( dfLinearConv == CPLAtof(SRS_UL_FOOT_CONV)
1517
1554
             || EQUAL(pszLinearUnits,SRS_UL_FOOT) )
1518
1555
        sTABProj.nUnitsId = 3;
1519
1556
    else if( EQUAL(pszLinearUnits,"YARD") || EQUAL(pszLinearUnits,"IYARD") 
1525
1562
        sTABProj.nUnitsId = 6;
1526
1563
    else if( dfLinearConv == 1.0 )
1527
1564
        sTABProj.nUnitsId = 7;
1528
 
    else if( dfLinearConv == atof(SRS_UL_US_FOOT_CONV)
 
1565
    else if( dfLinearConv == CPLAtof(SRS_UL_US_FOOT_CONV)
1529
1566
             || EQUAL(pszLinearUnits,SRS_UL_US_FOOT) )
1530
1567
        sTABProj.nUnitsId = 8;
1531
1568
    else if( EQUAL(pszLinearUnits,SRS_UL_NAUTICAL_MILE) )