From de90df56b2d3b7728695a5718155b2050e4023c4 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Mon, 19 May 2014 22:59:40 +0200 Subject: [PATCH] Add datum mapping between EPSG/authority codes and the MapInfo definitions. Falls back to old behaviour of name/string matching (http://trac.osgeo.org/gdal/ticket/481) --- mitab/mitab.h | 1 + mitab/mitab_coordsys.cpp | 19 +- mitab/mitab_spatialref.cpp | 392 +++++++++++++++++++------------------ 3 files changed, 218 insertions(+), 194 deletions(-) diff --git a/mitab/mitab.h b/mitab/mitab.h index 38db4f6..1e035be 100644 --- a/mitab/mitab.h +++ b/mitab/mitab.h @@ -1894,6 +1894,7 @@ GBool MITABExtractCoordSysBounds( const char * pszCoordSys, int MITABCoordSys2TABProjInfo(const char * pszCoordSys, TABProjInfo *psProj); typedef struct { + int nDatumEPSGCode; int nMapInfoDatumID; const char *pszOGCDatumName; int nEllipsoid; diff --git a/mitab/mitab_coordsys.cpp b/mitab/mitab_coordsys.cpp index eb3a934..2bd6cc4 100644 --- a/mitab/mitab_coordsys.cpp +++ b/mitab/mitab_coordsys.cpp @@ -1145,6 +1145,15 @@ char *MITABSpatialRef2CoordSys( OGRSpatialReference * poSR ) double adfDatumParm[8] = {0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0}; int nEllipsoid=0; + int nDatumEPSGCode = -1; + const char *pszDatumAuthority = poSR->GetAuthorityName("DATUM"); + const char *pszDatumCode = poSR->GetAuthorityCode("DATUM"); + + if (pszDatumCode && pszDatumAuthority && EQUAL(pszDatumAuthority, "EPSG")) + { + nDatumEPSGCode = atoi(pszDatumCode); + } + const char *pszWKTDatum = poSR->GetAttrValue("DATUM"); if( pszWKTDatum == NULL ) @@ -1202,8 +1211,9 @@ char *MITABSpatialRef2CoordSys( OGRSpatialReference * poSR ) } /*----------------------------------------------------------------- - * We have a "real" datum name. Try to look it up and get the - * parameters. If we don't find it just use WGS84. + * We have a "real" datum name, and possibly an EPSG code for the + * datum. Try to look it up (using EPSG code first) and get the + * parameters. If we don't find it with either just use WGS84. *----------------------------------------------------------------*/ else { @@ -1211,7 +1221,8 @@ char *MITABSpatialRef2CoordSys( OGRSpatialReference * poSR ) for( i = 0; asDatumInfoList[i].nMapInfoDatumID != -1; i++ ) { - if( EQUAL(pszWKTDatum,asDatumInfoList[i].pszOGCDatumName) ) + if ( (nDatumEPSGCode > 0 && asDatumInfoList[i].nDatumEPSGCode == nDatumEPSGCode) || + EQUAL(pszWKTDatum,asDatumInfoList[i].pszOGCDatumName) ) { nDatum = asDatumInfoList[i].nMapInfoDatumID; break; @@ -1221,7 +1232,7 @@ char *MITABSpatialRef2CoordSys( OGRSpatialReference * poSR ) if( nDatum == 0 ) nDatum = 104; /* WGS84 */ } - + /*----------------------------------------------------------------- * Translate the units *----------------------------------------------------------------*/ diff --git a/mitab/mitab_spatialref.cpp b/mitab/mitab_spatialref.cpp index 4c9f643..a5a5823 100644 --- a/mitab/mitab_spatialref.cpp +++ b/mitab/mitab_spatialref.cpp @@ -213,195 +213,196 @@ /* -------------------------------------------------------------------- */ /* This table was automatically generated by doing translations */ /* between mif and tab for each datum, and extracting the */ -/* parameters from the tab file. The OGC names were added */ -/* afterwards and may be incomplete or inaccurate. */ +/* parameters from the tab file. The EPSG codes and OGC names */ +/* were added afterwards and may be incomplete or inaccurate. */ /* -------------------------------------------------------------------- */ + MapInfoDatumInfo asDatumInfoList[] = { -{104, "WGS_1984", 28,0, 0, 0, 0, 0, 0, 0, 0}, -{74, "North_American_Datum_1983", 0, 0, 0, 0, 0, 0, 0, 0, 0}, - -{0, "", 29, 0, 0, 0, 0, 0, 0, 0, 0}, // Datum ignore - -{1, "Adindan", 6, -162, -12, 206, 0, 0, 0, 0, 0}, -{2, "Afgooye", 3, -43, -163, 45, 0, 0, 0, 0, 0}, -{3, "Ain_el_Abd_1970", 4, -150, -251, -2, 0, 0, 0, 0, 0}, -{4, "Anna_1_Astro_1965", 2, -491, -22, 435, 0, 0, 0, 0, 0}, -{5, "Arc_1950", 15,-143, -90, -294,0, 0, 0, 0, 0}, -{6, "Arc_1960", 6, -160, -8, -300,0, 0, 0, 0, 0}, -{7, "Ascension_Islands", 4, -207, 107, 52, 0, 0, 0, 0, 0}, -{8, "Astro_Beacon_E", 4, 145, 75, -272,0, 0, 0, 0, 0}, -{9, "Astro_B4_Sorol_Atoll", 4, 114, -116, -333,0, 0, 0, 0, 0}, -{10, "Astro_Dos_71_4", 4, -320, 550, -494,0, 0, 0, 0, 0}, -{11, "Astronomic_Station_1952", 4, 124, -234, -25, 0, 0, 0, 0, 0}, -{12, "Australian_Geodetic_Datum_66",2, -133, -48, 148, 0, 0, 0, 0, 0}, -{13, "Australian_Geodetic_Datum_84",2, -134, -48, 149, 0, 0, 0, 0, 0}, -{14, "Bellevue_Ign", 4, -127, -769, 472, 0, 0, 0, 0, 0}, -{15, "Bermuda_1957", 7, -73, 213, 296, 0, 0, 0, 0, 0}, -{16, "Bogota", 4, 307, 304, -318,0, 0, 0, 0, 0}, -{17, "Campo_Inchauspe", 4, -148, 136, 90, 0, 0, 0, 0, 0}, -{18, "Canton_Astro_1966", 4, 298, -304, -375,0, 0, 0, 0, 0}, -{19, "Cape", 6, -136, -108, -292,0, 0, 0, 0, 0}, -{20, "Cape_Canaveral", 7, -2, 150, 181, 0, 0, 0, 0, 0}, -{21, "Carthage", 6, -263, 6, 431, 0, 0, 0, 0, 0}, -{22, "Chatham_1971", 4, 175, -38, 113, 0, 0, 0, 0, 0}, -{23, "Chua", 4, -134, 229, -29, 0, 0, 0, 0, 0}, -{24, "Corrego_Alegre", 4, -206, 172, -6, 0, 0, 0, 0, 0}, -{25, "Batavia", 10,-377,681, -50, 0, 0, 0, 0, 0}, -{26, "Dos_1968", 4, 230, -199, -752,0, 0, 0, 0, 0}, -{27, "Easter_Island_1967", 4, 211, 147, 111, 0, 0, 0, 0, 0}, -{28, "European_Datum_1950", 4, -87, -98, -121,0, 0, 0, 0, 0}, -{29, "European_Datum_1979", 4, -86, -98, -119,0, 0, 0, 0, 0}, -{30, "Gandajika_1970", 4, -133, -321, 50, 0, 0, 0, 0, 0}, -{31, "New_Zealand_GD49", 4, 84, -22, 209, 0, 0, 0, 0, 0}, -{31, "New_Zealand_Geodetic_Datum_1949",4,84, -22, 209, 0, 0, 0, 0, 0}, -{32, "GRS_67", 21,0, 0, 0, 0, 0, 0, 0, 0}, -{33, "GRS_80", 0, 0, 0, 0, 0, 0, 0, 0, 0}, -{34, "Guam_1963", 7, -100, -248, 259, 0, 0, 0, 0, 0}, -{35, "Gux_1_Astro", 4, 252, -209, -751,0, 0, 0, 0, 0}, -{36, "Hito_XVIII_1963", 4, 16, 196, 93, 0, 0, 0, 0, 0}, -{37, "Hjorsey_1955", 4, -73, 46, -86, 0, 0, 0, 0, 0}, -{38, "Hong_Kong_1963", 4, -156, -271, -189,0, 0, 0, 0, 0}, -{39, "Hu_Tzu_Shan", 4, -634, -549, -201,0, 0, 0, 0, 0}, -{40, "Indian_Thailand_Vietnam", 11,214, 836, 303, 0, 0, 0, 0, 0}, -{41, "Indian_Bangladesh", 11,289, 734, 257, 0, 0, 0, 0, 0}, -{42, "Ireland_1965", 13,506, -122, 611, 0, 0, 0, 0, 0}, -{43, "ISTS_073_Astro_1969", 4, 208, -435, -229,0, 0, 0, 0, 0}, -{44, "Johnston_Island_1961", 4, 191, -77, -204,0, 0, 0, 0, 0}, -{45, "Kandawala", 11,-97, 787, 86, 0, 0, 0, 0, 0}, -{46, "Kerguyelen_Island", 4, 145, -187, 103, 0, 0, 0, 0, 0}, -{47, "Kertau", 17,-11, 851, 5, 0, 0, 0, 0, 0}, -{48, "L_C_5_Astro", 7, 42, 124, 147, 0, 0, 0, 0, 0}, -{49, "Liberia_1964", 6, -90, 40, 88, 0, 0, 0, 0, 0}, -{50, "Luzon_Phillippines", 7, -133, -77, -51, 0, 0, 0, 0, 0}, -{51, "Luzon_Mindanao_Island", 7, -133, -79, -72, 0, 0, 0, 0, 0}, -{52, "Mahe_1971", 6, 41, -220, -134,0, 0, 0, 0, 0}, -{53, "Marco_Astro", 4, -289, -124, 60, 0, 0, 0, 0, 0}, -{54, "Massawa", 10,639, 405, 60, 0, 0, 0, 0, 0}, -{55, "Merchich", 16,31, 146, 47, 0, 0, 0, 0, 0}, -{56, "Midway_Astro_1961", 4, 912, -58, 1227,0, 0, 0, 0, 0}, -{57, "Minna", 6, -92, -93, 122, 0, 0, 0, 0, 0}, -{58, "Nahrwan_Masirah_Island", 6, -247, -148, 369, 0, 0, 0, 0, 0}, -{59, "Nahrwan_Un_Arab_Emirates", 6, -249, -156, 381, 0, 0, 0, 0, 0}, -{60, "Nahrwan_Saudi_Arabia", 6, -231, -196, 482, 0, 0, 0, 0, 0}, -{61, "Naparima_1972", 4, -2, 374, 172, 0, 0, 0, 0, 0}, -{62, "NAD_1927", 7, -8, 160, 176, 0, 0, 0, 0, 0}, -{62, "North_American_Datum_1927", 7, -8, 160, 176, 0, 0, 0, 0, 0}, -{63, "NAD_27_Alaska", 7, -5, 135, 172, 0, 0, 0, 0, 0}, -{64, "NAD_27_Bahamas", 7, -4, 154, 178, 0, 0, 0, 0, 0}, -{65, "NAD_27_San_Salvador", 7, 1, 140, 165, 0, 0, 0, 0, 0}, -{66, "NAD_27_Canada", 7, -10, 158, 187, 0, 0, 0, 0, 0}, -{67, "NAD_27_Canal_Zone", 7, 0, 125, 201, 0, 0, 0, 0, 0}, -{68, "NAD_27_Caribbean", 7, -7, 152, 178, 0, 0, 0, 0, 0}, -{69, "NAD_27_Central_America", 7, 0, 125, 194, 0, 0, 0, 0, 0}, -{70, "NAD_27_Cuba", 7, -9, 152, 178, 0, 0, 0, 0, 0}, -{71, "NAD_27_Greenland", 7, 11, 114, 195, 0, 0, 0, 0, 0}, -{72, "NAD_27_Mexico", 7, -12, 130, 190, 0, 0, 0, 0, 0}, -{73, "NAD_27_Michigan", 8, -8, 160, 176, 0, 0, 0, 0, 0}, -{75, "Observatorio_1966", 4, -425, -169, 81, 0, 0, 0, 0, 0}, -{76, "Old_Egyptian", 22,-130, 110, -13, 0, 0, 0, 0, 0}, -{77, "Old_Hawaiian", 7, 61, -285, -181,0, 0, 0, 0, 0}, -{78, "Oman", 6, -346, -1, 224, 0, 0, 0, 0, 0}, -{79, "OSGB_1936", 9, 375, -111, 431, 0, 0, 0, 0, 0}, -{80, "Pico_De_Las_Nieves", 4, -307, -92, 127, 0, 0, 0, 0, 0}, -{81, "Pitcairn_Astro_1967", 4, 185, 165, 42, 0, 0, 0, 0, 0}, -{82, "Provisional_South_American", 4, -288, 175, -376,0, 0, 0, 0, 0}, -{83, "Puerto_Rico", 7, 11, 72, -101,0, 0, 0, 0, 0}, -{84, "Qatar_National", 4, -128, -283, 22, 0, 0, 0, 0, 0}, -{85, "Qornoq", 4, 164, 138, -189, 0, 0, 0, 0, 0}, -{86, "Reunion", 4, 94, -948,-1262,0, 0, 0, 0, 0}, -{87, "Monte_Mario", 4, -225, -65, 9, 0, 0, 0, 0, 0}, -{88, "Santo_Dos", 4, 170, 42, 84, 0, 0, 0, 0, 0}, -{89, "Sao_Braz", 4, -203, 141, 53, 0, 0, 0, 0, 0}, -{90, "Sapper_Hill_1943", 4, -355, 16, 74, 0, 0, 0, 0, 0}, -{91, "Schwarzeck", 14,616, 97, -251, 0, 0, 0, 0, 0}, -{92, "South_American_Datum_1969", 24,-57, 1, -41, 0, 0, 0, 0, 0}, -{93, "South_Asia", 19,7, -10, -26, 0, 0, 0, 0, 0}, -{94, "Southeast_Base", 4, -499, -249,314, 0, 0, 0, 0, 0}, -{95, "Southwest_Base", 4, -104, 167, -38, 0, 0, 0, 0, 0}, -{96, "Timbalai_1948", 11,-689, 691, -46, 0, 0, 0, 0, 0}, -{97, "Tokyo", 10,-128, 481, 664, 0, 0, 0, 0, 0}, -{98, "Tristan_Astro_1968", 4, -632, 438, -609, 0, 0, 0, 0, 0}, -{99, "Viti_Levu_1916", 6, 51, 391, -36, 0, 0, 0, 0, 0}, -{100, "Wake_Entiwetok_1960", 23,101, 52, -39, 0, 0, 0, 0, 0}, -{101, "WGS_60", 26,0, 0, 0, 0, 0, 0, 0, 0}, -{102, "WGS_66", 27,0, 0, 0, 0, 0, 0, 0, 0}, -{103, "WGS_1972", 1, 0, 8, 10, 0, 0, 0, 0, 0}, -{104, "WGS_1984", 28,0, 0, 0, 0, 0, 0, 0, 0}, -{105, "Yacare", 4, -155, 171, 37, 0, 0, 0, 0, 0}, -{106, "Zanderij", 4, -265, 120, -358, 0, 0, 0, 0, 0}, -{107, "NTF", 30,-168, -60, 320, 0, 0, 0, 0, 0}, -{108, "European_Datum_1987", 4, -83, -96, -113, 0, 0, 0, 0, 0}, -{109, "Netherlands_Bessel", 10,593, 26, 478, 0, 0, 0, 0, 0}, -{110, "Belgium_Hayford", 4, 81, 120, 129, 0, 0, 0, 0, 0}, -{111, "NWGL_10", 1, -1, 15, 1, 0, 0, 0, 0, 0}, -{112, "Rikets_koordinatsystem_1990",10,498, -36, 568, 0, 0, 0, 0, 0}, -{113, "Lisboa_DLX", 4, -303, -62, 105, 0, 0, 0, 0, 0}, -{114, "Melrica_1973_D73", 4, -223, 110, 37, 0, 0, 0, 0, 0}, -{115, "Euref_98", 0, 0, 0, 0, 0, 0, 0, 0, 0}, -{116, "GDA94", 0, 0, 0, 0, 0, 0, 0, 0, 0}, -{117, "NZGD2000", 0, 0, 0, 0, 0, 0, 0, 0, 0}, -{117, "New_Zealand_Geodetic_Datum_2000",0,0, 0, 0, 0, 0, 0, 0, 0}, -{118, "America_Samoa", 7, -115, 118, 426, 0, 0, 0, 0, 0}, -{119, "Antigua_Astro_1965", 6, -270, 13, 62, 0, 0, 0, 0, 0}, -{120, "Ayabelle_Lighthouse", 6, -79, -129, 145, 0, 0, 0, 0, 0}, -{121, "Bukit_Rimpah", 10,-384, 664, -48, 0, 0, 0, 0, 0}, -{122, "Estonia_1937", 10,374, 150, 588, 0, 0, 0, 0, 0}, -{123, "Dabola", 6, -83, 37, 124, 0, 0, 0, 0, 0}, -{124, "Deception_Island", 6, 260, 12, -147, 0, 0, 0, 0, 0}, -{125, "Fort_Thomas_1955", 6, -7, 215, 225, 0, 0, 0, 0, 0}, -{126, "Graciosa_base_1948", 4, -104, 167, -38, 0, 0, 0, 0, 0}, -{127, "Herat_North", 4, -333, -222,114, 0, 0, 0, 0, 0}, -{128, "Hermanns_Kogel", 10,682, -203, 480, 0, 0, 0, 0, 0}, -{129, "Indian", 50,283, 682, 231, 0, 0, 0, 0, 0}, -{130, "Indian_1954", 11,217, 823, 299, 0, 0, 0, 0, 0}, -{131, "Indian_1960", 11,198, 881, 317, 0, 0, 0, 0, 0}, -{132, "Indian_1975", 11,210, 814, 289, 0, 0, 0, 0, 0}, -{133, "Indonesian_Datum_1974", 4, -24, -15, 5, 0, 0, 0, 0, 0}, -{134, "ISTS061_Astro_1968", 4, -794, 119, -298, 0, 0, 0, 0, 0}, -{135, "Kusaie_Astro_1951", 4, 647, 1777, -1124,0, 0, 0, 0, 0}, -{136, "Leigon", 6, -130, 29, 364, 0, 0, 0, 0, 0}, -{137, "Montserrat_Astro_1958", 6, 174, 359, 365, 0, 0, 0, 0, 0}, -{138, "Mporaloko", 6, -74, -130, 42, 0, 0, 0, 0, 0}, -{139, "North_Sahara_1959", 6, -186, -93, 310, 0, 0, 0, 0, 0}, -{140, "Observatorio_Met_1939", 4, -425, -169,81, 0, 0, 0, 0, 0}, -{141, "Point_58", 6, -106, -129,165, 0, 0, 0, 0, 0}, -{142, "Pointe_Noire", 6, -148, 51, -291, 0, 0, 0, 0, 0}, -{143, "Porto_Santo_1936", 4, -499, -249,314, 0, 0, 0, 0, 0}, -{144, "Selvagem_Grande_1938", 4, -289, -124,60, 0, 0, 0, 0, 0}, -{145, "Sierra_Leone_1960", 6, -88, 4, 101, 0, 0, 0, 0, 0}, -{146, "S_JTSK_Ferro", 10, 589, 76, 480, 0, 0, 0, 0, 0}, -{147, "Tananarive_1925", 4, -189, -242,-91, 0, 0, 0, 0, 0}, -{148, "Voirol_1874", 6, -73, -247,227, 0, 0, 0, 0, 0}, -{149, "Virol_1960", 6, -123, -206,219, 0, 0, 0, 0, 0}, -{150, "Hartebeesthoek94", 0, 0, 0, 0, 0, 0, 0, 0, 0}, -{151, "ATS77", 51, 0, 0, 0, 0, 0, 0, 0, 0}, -{152, "JGD2000", 0, 0, 0, 0, 0, 0, 0, 0, 0}, -{157, "WGS_1984", 54,0, 0, 0, 0, 0, 0, 0, 0}, // Google merc -{1000,"DHDN_Potsdam_Rauenberg", 10,582, 105, 414, -1.04, -0.35, 3.08, 8.3, 0}, -{1001,"Pulkovo_1942", 3, 24, -123, -94, -0.02, 0.25, 0.13, 1.1, 0}, -{1002,"NTF_Paris_Meridian", 30,-168, -60, 320, 0, 0, 0, 0, 2.337229166667}, -{1003,"Switzerland_CH_1903", 10,660.077,13.551, 369.344, 0.804816, 0.577692, 0.952236, 5.66,0}, -{1004,"Hungarian_Datum_1972", 21,-56, 75.77, 15.31, -0.37, -0.2, -0.21, -1.01, 0}, -{1005,"Cape_7_Parameter", 28,-134.73,-110.92, -292.66, 0, 0, 0, 1, 0}, -{1006,"AGD84_7_Param_Aust", 2, -117.763,-51.51, 139.061, -0.292, -0.443, -0.277, -0.191, 0}, -{1007,"AGD66_7_Param_ACT", 2, -129.193,-41.212, 130.73, -0.246, -0.374, -0.329, -2.955, 0}, -{1008,"AGD66_7_Param_TAS", 2, -120.271,-64.543, 161.632, -0.2175, 0.0672, 0.1291, 2.4985, 0}, -{1009,"AGD66_7_Param_VIC_NSW", 2, -119.353,-48.301, 139.484, -0.415, -0.26, -0.437, -0.613, 0}, -{1010,"NZGD_7_Param_49", 4, 59.47, -5.04, 187.44, -0.47, 0.1, -1.024, -4.5993, 0}, -{1011,"Rikets_Tri_7_Param_1990", 10,419.3836, 99.3335, 591.3451, -0.850389, -1.817277, 7.862238, -0.99496, 0}, -{1012,"Russia_PZ90", 52, -1.08,-0.27,-0.9,0, 0, -0.16,-0.12, 0}, -{1013,"Russia_SK42", 52, 23.92,-141.27,-80.9, 0, -0.35,-0.82, -0.12, 0}, -{1014,"Russia_SK95", 52, 24.82,-131.21,-82.66,0,0,-0.16,-0.12, 0}, -{1015,"Tokyo", 10, -146.414, 507.337, 680.507,0,0,0,0,0}, -{1016,"Finnish_KKJ", 4, -96.062, -82.428, -121.754, -4.801, -0.345, 1.376, 1.496, 0}, -{1017,"Xian 1980", 53, 24, -123, -94, -0.02, -0.25, 0.13, 1.1, 0}, -{1018,"Lithuanian Pulkovo 1942", 4, -40.59527, -18.54979, -69.33956, -2.508, -1.8319, 2.6114, -4.2991, 0}, -{1019,"Belgian 1972 7 Parameter", 4, -99.059, 53.322, -112.486, -0.419, 0.83, -1.885, 0.999999, 0}, -{1020,"S-JTSK with Ferro prime meridian", 10, 589, 76, 480, 0, 0, 0, 0, -17.666666666667}, - -{-1, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0} +{ 0, 104, "WGS_1984", 28,0, 0, 0, 0, 0, 0, 0, 0}, +{ 6269, 74, "North_American_Datum_1983", 0, 0, 0, 0, 0, 0, 0, 0, 0}, + +{ 0, 0, "", 29, 0, 0, 0, 0, 0, 0, 0, 0}, // Datum ignore + +{ 6201, 1, "Adindan", 6, -162, -12, 206, 0, 0, 0, 0, 0}, +{ 6205, 2, "Afgooye", 3, -43, -163, 45, 0, 0, 0, 0, 0}, +{ 6204, 3, "Ain_el_Abd_1970", 4, -150, -251, -2, 0, 0, 0, 0, 0}, +{ 0, 4, "Anna_1_Astro_1965", 2, -491, -22, 435, 0, 0, 0, 0, 0}, +{ 6209, 5, "Arc_1950", 15,-143, -90, -294,0, 0, 0, 0, 0}, +{ 6210, 6, "Arc_1960", 6, -160, -8, -300,0, 0, 0, 0, 0}, +{ 0, 7, "Ascension_Islands", 4, -207, 107, 52, 0, 0, 0, 0, 0}, +{ 0, 8, "Astro_Beacon_E", 4, 145, 75, -272,0, 0, 0, 0, 0}, +{ 0, 9, "Astro_B4_Sorol_Atoll", 4, 114, -116, -333,0, 0, 0, 0, 0}, +{ 0, 10, "Astro_Dos_71_4", 4, -320, 550, -494,0, 0, 0, 0, 0}, +{ 0, 11, "Astronomic_Station_1952", 4, 124, -234, -25, 0, 0, 0, 0, 0}, +{ 6202, 12, "Australian_Geodetic_Datum_66",2, -133, -48, 148, 0, 0, 0, 0, 0}, +{ 6203, 13, "Australian_Geodetic_Datum_84",2, -134, -48, 149, 0, 0, 0, 0, 0}, +{ 0, 14, "Bellevue_Ign", 4, -127, -769, 472, 0, 0, 0, 0, 0}, +{ 6216, 15, "Bermuda_1957", 7, -73, 213, 296, 0, 0, 0, 0, 0}, +{ 6218, 16, "Bogota", 4, 307, 304, -318,0, 0, 0, 0, 0}, +{ 6221, 17, "Campo_Inchauspe", 4, -148, 136, 90, 0, 0, 0, 0, 0}, +{ 0, 18, "Canton_Astro_1966", 4, 298, -304, -375,0, 0, 0, 0, 0}, +{ 6222, 19, "Cape", 6, -136, -108, -292,0, 0, 0, 0, 0}, +{ 6717, 20, "Cape_Canaveral", 7, -2, 150, 181, 0, 0, 0, 0, 0}, +{ 6223, 21, "Carthage", 6, -263, 6, 431, 0, 0, 0, 0, 0}, +{ 6672, 22, "Chatham_1971", 4, 175, -38, 113, 0, 0, 0, 0, 0}, +{ 6224, 23, "Chua", 4, -134, 229, -29, 0, 0, 0, 0, 0}, +{ 6225, 24, "Corrego_Alegre", 4, -206, 172, -6, 0, 0, 0, 0, 0}, +{ 6211, 25, "Batavia", 10,-377,681, -50, 0, 0, 0, 0, 0}, +{ 0, 26, "Dos_1968", 4, 230, -199, -752,0, 0, 0, 0, 0}, +{ 6719, 27, "Easter_Island_1967", 4, 211, 147, 111, 0, 0, 0, 0, 0}, +{ 6230, 28, "European_Datum_1950", 4, -87, -98, -121,0, 0, 0, 0, 0}, +{ 6668, 29, "European_Datum_1979", 4, -86, -98, -119,0, 0, 0, 0, 0}, +{ 6233, 30, "Gandajika_1970", 4, -133, -321, 50, 0, 0, 0, 0, 0}, +{ 6272, 31, "New_Zealand_GD49", 4, 84, -22, 209, 0, 0, 0, 0, 0}, +{ 6272, 31, "New_Zealand_Geodetic_Datum_1949",4,84, -22, 209, 0, 0, 0, 0, 0}, +{ 0, 32, "GRS_67", 21,0, 0, 0, 0, 0, 0, 0, 0}, +{ 0, 33, "GRS_80", 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{ 6675, 34, "Guam_1963", 7, -100, -248, 259, 0, 0, 0, 0, 0}, +{ 0, 35, "Gux_1_Astro", 4, 252, -209, -751,0, 0, 0, 0, 0}, +{ 6254, 36, "Hito_XVIII_1963", 4, 16, 196, 93, 0, 0, 0, 0, 0}, +{ 6658, 37, "Hjorsey_1955", 4, -73, 46, -86, 0, 0, 0, 0, 0}, +{ 6738, 38, "Hong_Kong_1963", 4, -156, -271, -189,0, 0, 0, 0, 0}, +{ 6236, 39, "Hu_Tzu_Shan", 4, -634, -549, -201,0, 0, 0, 0, 0}, +{ 0, 40, "Indian_Thailand_Vietnam", 11,214, 836, 303, 0, 0, 0, 0, 0}, +{ 0, 41, "Indian_Bangladesh", 11,289, 734, 257, 0, 0, 0, 0, 0}, +{ 0, 42, "Ireland_1965", 13,506, -122, 611, 0, 0, 0, 0, 0}, +{ 0, 43, "ISTS_073_Astro_1969", 4, 208, -435, -229,0, 0, 0, 0, 0}, +{ 6725, 44, "Johnston_Island_1961", 4, 191, -77, -204,0, 0, 0, 0, 0}, +{ 6244, 45, "Kandawala", 11,-97, 787, 86, 0, 0, 0, 0, 0}, +{ 0, 46, "Kerguyelen_Island", 4, 145, -187, 103, 0, 0, 0, 0, 0}, +{ 6245, 47, "Kertau", 17,-11, 851, 5, 0, 0, 0, 0, 0}, +{ 0, 48, "L_C_5_Astro", 7, 42, 124, 147, 0, 0, 0, 0, 0}, +{ 6251, 49, "Liberia_1964", 6, -90, 40, 88, 0, 0, 0, 0, 0}, +{ 0, 50, "Luzon_Phillippines", 7, -133, -77, -51, 0, 0, 0, 0, 0}, +{ 0, 51, "Luzon_Mindanao_Island", 7, -133, -79, -72, 0, 0, 0, 0, 0}, +{ 6256, 52, "Mahe_1971", 6, 41, -220, -134,0, 0, 0, 0, 0}, +{ 0, 53, "Marco_Astro", 4, -289, -124, 60, 0, 0, 0, 0, 0}, +{ 6262, 54, "Massawa", 10,639, 405, 60, 0, 0, 0, 0, 0}, +{ 6261, 55, "Merchich", 16,31, 146, 47, 0, 0, 0, 0, 0}, +{ 0, 56, "Midway_Astro_1961", 4, 912, -58, 1227,0, 0, 0, 0, 0}, +{ 6263, 57, "Minna", 6, -92, -93, 122, 0, 0, 0, 0, 0}, +{ 0, 58, "Nahrwan_Masirah_Island", 6, -247, -148, 369, 0, 0, 0, 0, 0}, +{ 0, 59, "Nahrwan_Un_Arab_Emirates", 6, -249, -156, 381, 0, 0, 0, 0, 0}, +{ 0, 60, "Nahrwan_Saudi_Arabia", 6, -231, -196, 482, 0, 0, 0, 0, 0}, +{ 6271, 61, "Naparima_1972", 4, -2, 374, 172, 0, 0, 0, 0, 0}, +{ 6267, 62, "NAD_1927", 7, -8, 160, 176, 0, 0, 0, 0, 0}, +{ 6267, 62, "North_American_Datum_1927", 7, -8, 160, 176, 0, 0, 0, 0, 0}, +{ 0, 63, "NAD_27_Alaska", 7, -5, 135, 172, 0, 0, 0, 0, 0}, +{ 0, 64, "NAD_27_Bahamas", 7, -4, 154, 178, 0, 0, 0, 0, 0}, +{ 0, 65, "NAD_27_San_Salvador", 7, 1, 140, 165, 0, 0, 0, 0, 0}, +{ 0, 66, "NAD_27_Canada", 7, -10, 158, 187, 0, 0, 0, 0, 0}, +{ 0, 67, "NAD_27_Canal_Zone", 7, 0, 125, 201, 0, 0, 0, 0, 0}, +{ 0, 68, "NAD_27_Caribbean", 7, -7, 152, 178, 0, 0, 0, 0, 0}, +{ 0, 69, "NAD_27_Central_America", 7, 0, 125, 194, 0, 0, 0, 0, 0}, +{ 0, 70, "NAD_27_Cuba", 7, -9, 152, 178, 0, 0, 0, 0, 0}, +{ 0, 71, "NAD_27_Greenland", 7, 11, 114, 195, 0, 0, 0, 0, 0}, +{ 0, 72, "NAD_27_Mexico", 7, -12, 130, 190, 0, 0, 0, 0, 0}, +{ 0, 73, "NAD_27_Michigan", 8, -8, 160, 176, 0, 0, 0, 0, 0}, +{ 0, 75, "Observatorio_1966", 4, -425, -169, 81, 0, 0, 0, 0, 0}, +{ 0, 76, "Old_Egyptian", 22,-130, 110, -13, 0, 0, 0, 0, 0}, +{ 6135, 77, "Old_Hawaiian", 7, 61, -285, -181,0, 0, 0, 0, 0}, +{ 0, 78, "Oman", 6, -346, -1, 224, 0, 0, 0, 0, 0}, +{ 6277, 79, "OSGB_1936", 9, 375, -111, 431, 0, 0, 0, 0, 0}, +{ 0, 80, "Pico_De_Las_Nieves", 4, -307, -92, 127, 0, 0, 0, 0, 0}, +{ 6729, 81, "Pitcairn_Astro_1967", 4, 185, 165, 42, 0, 0, 0, 0, 0}, +{ 6248, 82, "Provisional_South_American", 4, -288, 175, -376,0, 0, 0, 0, 0}, +{ 6139, 83, "Puerto_Rico", 7, 11, 72, -101,0, 0, 0, 0, 0}, +{ 6614, 84, "Qatar_National", 4, -128, -283, 22, 0, 0, 0, 0, 0}, +{ 6287, 85, "Qornoq", 4, 164, 138, -189, 0, 0, 0, 0, 0}, +{ 6627, 86, "Reunion", 4, 94, -948,-1262,0, 0, 0, 0, 0}, +{ 6265, 87, "Monte_Mario", 4, -225, -65, 9, 0, 0, 0, 0, 0}, +{ 0, 88, "Santo_Dos", 4, 170, 42, 84, 0, 0, 0, 0, 0}, +{ 0, 89, "Sao_Braz", 4, -203, 141, 53, 0, 0, 0, 0, 0}, +{ 6292, 90, "Sapper_Hill_1943", 4, -355, 16, 74, 0, 0, 0, 0, 0}, +{ 6293, 91, "Schwarzeck", 14,616, 97, -251, 0, 0, 0, 0, 0}, +{ 6618, 92, "South_American_Datum_1969", 24,-57, 1, -41, 0, 0, 0, 0, 0}, +{ 0, 93, "South_Asia", 19,7, -10, -26, 0, 0, 0, 0, 0}, +{ 0, 94, "Southeast_Base", 4, -499, -249,314, 0, 0, 0, 0, 0}, +{ 0, 95, "Southwest_Base", 4, -104, 167, -38, 0, 0, 0, 0, 0}, +{ 6298, 96, "Timbalai_1948", 11,-689, 691, -46, 0, 0, 0, 0, 0}, +{ 6301, 97, "Tokyo", 10,-128, 481, 664, 0, 0, 0, 0, 0}, +{ 0, 98, "Tristan_Astro_1968", 4, -632, 438, -609, 0, 0, 0, 0, 0}, +{ 6731, 99, "Viti_Levu_1916", 6, 51, 391, -36, 0, 0, 0, 0, 0}, +{ 0, 100, "Wake_Entiwetok_1960", 23,101, 52, -39, 0, 0, 0, 0, 0}, +{ 0, 101, "WGS_60", 26,0, 0, 0, 0, 0, 0, 0, 0}, +{ 6760, 102, "WGS_66", 27,0, 0, 0, 0, 0, 0, 0, 0}, +{ 6322, 103, "WGS_1972", 1, 0, 8, 10, 0, 0, 0, 0, 0}, +{ 6326, 104, "WGS_1984", 28,0, 0, 0, 0, 0, 0, 0, 0}, +{ 6309, 105, "Yacare", 4, -155, 171, 37, 0, 0, 0, 0, 0}, +{ 6311, 106, "Zanderij", 4, -265, 120, -358, 0, 0, 0, 0, 0}, +{ 0, 107, "NTF", 30,-168, -60, 320, 0, 0, 0, 0, 0}, +{ 6231, 108, "European_Datum_1987", 4, -83, -96, -113, 0, 0, 0, 0, 0}, +{ 0, 109, "Netherlands_Bessel", 10,593, 26, 478, 0, 0, 0, 0, 0}, +{ 0, 110, "Belgium_Hayford", 4, 81, 120, 129, 0, 0, 0, 0, 0}, +{ 0, 111, "NWGL_10", 1, -1, 15, 1, 0, 0, 0, 0, 0}, +{ 6124, 112, "Rikets_koordinatsystem_1990",10,498, -36, 568, 0, 0, 0, 0, 0}, +{ 0, 113, "Lisboa_DLX", 4, -303, -62, 105, 0, 0, 0, 0, 0}, +{ 0, 114, "Melrica_1973_D73", 4, -223, 110, 37, 0, 0, 0, 0, 0}, +{ 0, 115, "Euref_98", 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{ 0, 116, "GDA94", 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{ 6167, 117, "NZGD2000", 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{ 6167, 117, "New_Zealand_Geodetic_Datum_2000",0,0, 0, 0, 0, 0, 0, 0, 0}, +{ 6169, 118, "America_Samoa", 7, -115, 118, 426, 0, 0, 0, 0, 0}, +{ 0, 119, "Antigua_Astro_1965", 6, -270, 13, 62, 0, 0, 0, 0, 0}, +{ 6713, 120, "Ayabelle_Lighthouse", 6, -79, -129, 145, 0, 0, 0, 0, 0}, +{ 6219, 121, "Bukit_Rimpah", 10,-384, 664, -48, 0, 0, 0, 0, 0}, +{ 0, 122, "Estonia_1937", 10,374, 150, 588, 0, 0, 0, 0, 0}, +{ 6155, 123, "Dabola", 6, -83, 37, 124, 0, 0, 0, 0, 0}, +{ 6736, 124, "Deception_Island", 6, 260, 12, -147, 0, 0, 0, 0, 0}, +{ 0, 125, "Fort_Thomas_1955", 6, -7, 215, 225, 0, 0, 0, 0, 0}, +{ 0, 126, "Graciosa_base_1948", 4, -104, 167, -38, 0, 0, 0, 0, 0}, +{ 6255, 127, "Herat_North", 4, -333, -222,114, 0, 0, 0, 0, 0}, +{ 0, 128, "Hermanns_Kogel", 10,682, -203, 480, 0, 0, 0, 0, 0}, +{ 6240, 129, "Indian", 50,283, 682, 231, 0, 0, 0, 0, 0}, +{ 6239, 130, "Indian_1954", 11,217, 823, 299, 0, 0, 0, 0, 0}, +{ 6131, 131, "Indian_1960", 11,198, 881, 317, 0, 0, 0, 0, 0}, +{ 6240, 132, "Indian_1975", 11,210, 814, 289, 0, 0, 0, 0, 0}, +{ 6238, 133, "Indonesian_Datum_1974", 4, -24, -15, 5, 0, 0, 0, 0, 0}, +{ 0, 134, "ISTS061_Astro_1968", 4, -794, 119, -298, 0, 0, 0, 0, 0}, +{ 0, 135, "Kusaie_Astro_1951", 4, 647, 1777, -1124,0, 0, 0, 0, 0}, +{ 6250, 136, "Leigon", 6, -130, 29, 364, 0, 0, 0, 0, 0}, +{ 0, 137, "Montserrat_Astro_1958", 6, 174, 359, 365, 0, 0, 0, 0, 0}, +{ 6266, 138, "Mporaloko", 6, -74, -130, 42, 0, 0, 0, 0, 0}, +{ 0, 139, "North_Sahara_1959", 6, -186, -93, 310, 0, 0, 0, 0, 0}, +{ 0, 140, "Observatorio_Met_1939", 4, -425, -169,81, 0, 0, 0, 0, 0}, +{ 6620, 141, "Point_58", 6, -106, -129,165, 0, 0, 0, 0, 0}, +{ 6282, 142, "Pointe_Noire", 6, -148, 51, -291, 0, 0, 0, 0, 0}, +{ 6615, 143, "Porto_Santo_1936", 4, -499, -249,314, 0, 0, 0, 0, 0}, +{ 6616, 144, "Selvagem_Grande_1938", 4, -289, -124,60, 0, 0, 0, 0, 0}, +{ 0, 145, "Sierra_Leone_1960", 6, -88, 4, 101, 0, 0, 0, 0, 0}, +{ 6156, 146, "S_JTSK_Ferro", 10, 589, 76, 480, 0, 0, 0, 0, 0}, +{ 6297, 147, "Tananarive_1925", 4, -189, -242,-91, 0, 0, 0, 0, 0}, +{ 0, 148, "Voirol_1874", 6, -73, -247,227, 0, 0, 0, 0, 0}, +{ 0, 149, "Virol_1960", 6, -123, -206,219, 0, 0, 0, 0, 0}, +{ 6148, 150, "Hartebeesthoek94", 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{ 6122, 151, "ATS77", 51, 0, 0, 0, 0, 0, 0, 0, 0}, +{ 6612, 152, "JGD2000", 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{ 0, 157, "WGS_1984", 54, 0, 0, 0, 0, 0, 0, 0, 0}, // Google merc +{ 0, 1000,"DHDN_Potsdam_Rauenberg", 10,582, 105, 414, -1.04, -0.35, 3.08, 8.3, 0}, +{ 6284, 1001,"Pulkovo_1942", 3, 24, -123, -94, -0.02, 0.25, 0.13, 1.1, 0}, +{ 6275, 1002,"NTF_Paris_Meridian", 30,-168, -60, 320, 0, 0, 0, 0, 2.337229166667}, +{ 0, 1003,"Switzerland_CH_1903", 10,660.077,13.551, 369.344, 0.804816, 0.577692, 0.952236, 5.66,0}, +{ 6237, 1004,"Hungarian_Datum_1972", 21,-56, 75.77, 15.31, -0.37, -0.2, -0.21, -1.01, 0}, +{ 0, 1005,"Cape_7_Parameter", 28,-134.73,-110.92, -292.66, 0, 0, 0, 1, 0}, +{ 6203, 1006,"AGD84_7_Param_Aust", 2, -117.763,-51.51, 139.061, -0.292, -0.443, -0.277, -0.191, 0}, +{ 0, 1007,"AGD66_7_Param_ACT", 2, -129.193,-41.212, 130.73, -0.246, -0.374, -0.329, -2.955, 0}, +{ 0, 1008,"AGD66_7_Param_TAS", 2, -120.271,-64.543, 161.632, -0.2175, 0.0672, 0.1291, 2.4985, 0}, +{ 0, 1009,"AGD66_7_Param_VIC_NSW", 2, -119.353,-48.301, 139.484, -0.415, -0.26, -0.437, -0.613, 0}, +{ 6272, 1010,"NZGD_7_Param_49", 4, 59.47, -5.04, 187.44, -0.47, 0.1, -1.024, -4.5993, 0}, +{ 0, 1011,"Rikets_Tri_7_Param_1990", 10,419.3836, 99.3335, 591.3451, -0.850389, -1.817277, 7.862238, -0.99496, 0}, +{ 0, 1012,"Russia_PZ90", 52, -1.08,-0.27,-0.9,0, 0, -0.16,-0.12, 0}, +{ 0, 1013,"Russia_SK42", 52, 23.92,-141.27,-80.9, 0, -0.35,-0.82, -0.12, 0}, +{ 0, 1014,"Russia_SK95", 52, 24.82,-131.21,-82.66,0,0,-0.16,-0.12, 0}, +{ 6301, 1015,"Tokyo", 10, -146.414, 507.337, 680.507,0,0,0,0,0}, +{ 0, 1016,"Finnish_KKJ", 4, -96.062, -82.428, -121.754, -4.801, -0.345, 1.376, 1.496, 0}, +{ 6610, 1017,"Xian 1980", 53, 24, -123, -94, -0.02, -0.25, 0.13, 1.1, 0}, +{ 0, 1018,"Lithuanian Pulkovo 1942", 4, -40.59527, -18.54979, -69.33956, -2.508, -1.8319, 2.6114, -4.2991, 0}, +{ 0, 1019,"Belgian 1972 7 Parameter", 4, -99.059, 53.322, -112.486, -0.419, 0.83, -1.885, 0.999999, 0}, +{ 6818, 1020,"S-JTSK with Ferro prime meridian", 10, 589, 76, 480, 0, 0, 0, 0, -17.666666666667}, + +{ -1, -1, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0} }; /* -------------------------------------------------------------------- */ @@ -1440,14 +1441,23 @@ int TABFile::SetSpatialRef(OGRSpatialReference *poSpatialRef) const char *pszWKTDatum = poSpatialRef->GetAttrValue("DATUM"); MapInfoDatumInfo *psDatumInfo = NULL; + int nDatumEPSGCode = -1; + const char *pszDatumAuthority = poSpatialRef->GetAuthorityName("DATUM"); + const char *pszDatumCode = poSpatialRef->GetAuthorityCode("DATUM"); + + if (pszDatumCode && pszDatumAuthority && EQUAL(pszDatumAuthority, "EPSG")) + { + nDatumEPSGCode = atoi(pszDatumCode); + } + /*----------------------------------------------------------------- - * Default to WGS83 if we have no datum at all. + * Default to WGS84 if we have no datum at all. *----------------------------------------------------------------*/ if( pszWKTDatum == NULL ) { psDatumInfo = asDatumInfoList+0; /* WGS 84 */ } - + /*----------------------------------------------------------------- * We know the MIF datum number, and need to look it up to * translate into datum parameters. @@ -1506,8 +1516,9 @@ int TABFile::SetSpatialRef(OGRSpatialReference *poSpatialRef) } /*----------------------------------------------------------------- - * We have a "real" datum name. Try to look it up and get the - * parameters. If we don't find it just use WGS84. + * We have a "real" datum name, and possibly an EPSG code for the + * datum. Try to look it up (using EPSG code first) and get the + * parameters. If we don't find it with either just use WGS84. *----------------------------------------------------------------*/ else { @@ -1515,7 +1526,8 @@ int TABFile::SetSpatialRef(OGRSpatialReference *poSpatialRef) for( i = 0; asDatumInfoList[i].nMapInfoDatumID != -1; i++ ) { - if( EQUAL(pszWKTDatum,asDatumInfoList[i].pszOGCDatumName) ) + if ( (nDatumEPSGCode > 0 && asDatumInfoList[i].nDatumEPSGCode == nDatumEPSGCode) || + EQUAL(pszWKTDatum,asDatumInfoList[i].pszOGCDatumName) ) { psDatumInfo = asDatumInfoList + i; break;