#include <TeDatum.h>
Definition at line 143 of file TeDatum.h.
Static Public Member Functions | |
| static TeDatumMap & | getDatumMap () |
| static void | loadDatumMap () |
| static TeDatum | make (const std::string &name) |
| Builds a datum from a TerraLib name. | |
| static TeDatum | makeFromEPSGCode (const std::string epsgCode) |
| Builds a datum from its EPSG code. | |
| static TeDatum | makeFromWKT (const std::string wktDatumDescription) |
| Builds a datum from its OGC's WKT description. | |
Static Protected Attributes | |
| static TeDatumMap | _datumMap |
| TeDatumMap & TeDatumFactory::getDatumMap | ( | ) | [static] |
Definition at line 499 of file TeDatum.cpp.
References _datumMap, and loadDatumMap().
Referenced by findDatum(), TeDatabase::insertDatum(), TeDatabase::loadDatumSet(), TeDatabase::populateDatumTable(), and TeDatabase::updateDatum().
00500 { 00501 loadDatumMap(); 00502 return _datumMap; 00503 }
| void TeDatumFactory::loadDatumMap | ( | ) | [static] |
Definition at line 459 of file TeDatum.cpp.
References _datumMap, DATUM_ERROR, datumList, ellipsoidList, SphParam::flt, NUMDATUM, NUMSPH, and SphParam::rd.
Referenced by getDatumMap().
00460 { 00461 if(!_datumMap.empty()) 00462 return; 00463 00464 // Step 1 - Read the initial Spheroids - Put in a Map 00465 SphMap sphMap; 00466 SphParam sphPar; 00467 int i, k = 0; 00468 for(i = 0; i < NUMSPH; ++i) 00469 { 00470 string name = ellipsoidList[k++]; 00471 sphPar.rd = atof (ellipsoidList [k++]); 00472 sphPar.flt = atof (ellipsoidList [k++]); 00473 sphMap[name] = sphPar; 00474 } 00475 00476 // Step 2 - Read the initial Datum List - Put in a static map 00477 k = 0; 00478 for(i = 0; i < NUMDATUM; ++i) 00479 { 00480 std::string name = datumList[k++]; 00481 00482 std::string sphname = datumList[k++]; 00483 00484 double dx = atof(datumList [k++]); 00485 double dy = atof(datumList [k++]); 00486 double dz = atof(datumList [k++]); 00487 00488 SphMap::iterator it = sphMap.find (sphname); 00489 if(it == sphMap.end()) 00490 throw TeException (DATUM_ERROR); 00491 else 00492 sphPar = (*it).second; 00493 00494 TeDatum d(name, sphPar.rd, sphPar.flt, dx, dy, dz); 00495 _datumMap[name] = d; 00496 } 00497 }
| static TeDatum TeDatumFactory::make | ( | const std::string & | name | ) | [static] |
Referenced by TeGTM::getDatum(), TeDecoderTIFF::getGeoTIFF(), main(), TeProjectionFactory::make(), makeFromEPSGCode(), makeFromWKT(), TeRasterParams::readParametersFile(), TeDecoderMrSID::readProjection(), TeTin::saveTINdb(), TeTin::saveVertexTINdb(), TeCheckBoxConsistency(), TeImportSPR(), TeMIFProjectionDatum(), TeReadMIFProjection(), and testCoverage().
| TeDatum TeDatumFactory::makeFromEPSGCode | ( | const std::string | epsgCode | ) | [static] |
Definition at line 304 of file TeDatum.cpp.
References make().
Referenced by TeProjectionFactory::make(), and makeFromWKT().
00305 { 00306 string dname; 00307 if (epsgCode == "6224") 00308 { 00309 dname = "Astro-Chua"; 00310 } 00311 else if (epsgCode == "6225") 00312 { 00313 dname = "CorregoAlegre"; 00314 } 00315 else if (epsgCode == "6240") 00316 { 00317 dname = "Indian"; 00318 } 00319 else if (epsgCode == "6609") 00320 { 00321 dname = "NAD27"; 00322 } 00323 else if (epsgCode == "6152") 00324 { 00325 dname = "NAD83"; 00326 } 00327 else if (epsgCode == "6326") 00328 { 00329 dname = "WGS84"; 00330 } 00331 else if (epsgCode == "6618") 00332 { 00333 dname = "SAD69"; 00334 } 00335 else if (epsgCode == "6208") 00336 { 00337 dname = "Aratu"; 00338 } 00339 else 00340 { 00341 dname = "Spherical"; 00342 } 00343 TeDatum dat = TeDatumFactory::make(dname); 00344 return dat; 00345 }
| TeDatum TeDatumFactory::makeFromWKT | ( | const std::string | wktDatumDescription | ) | [static] |
Definition at line 347 of file TeDatum.cpp.
References TeDatum::dx_, TeDatum::dy_, TeDatum::dz_, TeDatum::flattening(), make(), makeFromEPSGCode(), TeDatum::name(), TeDatum::radius(), TeTrim(), and tokenizeWKT().
Referenced by TeGetTeProjectionFromWKT().
00348 { 00349 TeDatum dat; 00350 vector<string> tokens; 00351 char* wktchar = new char[wktDatumDescription.size()]; 00352 strcpy(wktchar,wktDatumDescription.c_str()); 00353 if (!tokenizeWKT((char **) &wktchar, tokens)) 00354 { 00355 return dat; 00356 } 00357 unsigned int i =0; 00358 while (i<tokens.size() && tokens[i] != "DATUM") 00359 ++i; 00360 00361 if (i== tokens.size()) 00362 return dat; 00363 ++i; 00364 00365 map<string,string> ewktToTeDatum; 00366 ewktToTeDatum["D_Chua"] = "Astro-Chua"; 00367 ewktToTeDatum["D_Corrego_Alegre"] = "CorregoAlegre"; 00368 ewktToTeDatum["D_Indian_1975"] = "Indian"; 00369 ewktToTeDatum["D_North_American_1927"] = "NAD27"; 00370 ewktToTeDatum["D_North_American_1983"] = "NAD83"; 00371 ewktToTeDatum["D_South_American_1969"] = "SAD69"; 00372 ewktToTeDatum["D_WGS_1984"] = "WGS84"; 00373 ewktToTeDatum["D_Aratu"] = "Aratu"; 00374 // lets the ESRI's WKT format 00375 TeTrim(tokens[i]); 00376 map<string,string>::iterator it = ewktToTeDatum.find(tokens[i]); 00377 if (it != ewktToTeDatum.end()) 00378 { 00379 dat = TeDatumFactory::make(it->second); 00380 return dat; 00381 } 00382 00383 map<string,string> wktToTeDatum; 00384 wktToTeDatum["Chua"] = "Astro-Chua"; 00385 wktToTeDatum["Corrego_Alegre"] = "CorregoAlegre"; 00386 wktToTeDatum["Indian_1975"] = "Indian"; 00387 wktToTeDatum["North_American_Datum_1927"] = "NAD27"; 00388 wktToTeDatum["North_American_Datum_1983"] = "NAD83"; 00389 wktToTeDatum["South_American_Datum_1969"] = "SAD69"; 00390 wktToTeDatum["Unknown"] = "Spherical"; 00391 wktToTeDatum["WGS_1984"] = "WGS84"; 00392 wktToTeDatum["Aratu"] = "Aratu"; 00393 00394 // lets try OGC's SFS WKT format 00395 it = wktToTeDatum.find(tokens[i]); 00396 if (it != wktToTeDatum.end()) 00397 { 00398 dat = TeDatumFactory::make(it->second); 00399 return dat; 00400 } 00401 00402 // lets try EPSG authority codes 00403 unsigned int is = i; 00404 while (i<tokens.size() && tokens[i] != "AUTHORITY") 00405 ++i; 00406 if (i== tokens.size()) 00407 return dat; 00408 ++i; 00409 if (tokens[i]=="EPSG") 00410 { 00411 ++i; 00412 dat = TeDatumFactory::makeFromEPSGCode(tokens[i]); 00413 return dat; 00414 } 00415 00416 // so let's try according to the parameters 00417 i = is; 00418 dat.name(tokens[i]); 00419 while (i<tokens.size() && tokens[i] != "SPHEROID") 00420 ++i; 00421 if (i== tokens.size()) 00422 return dat; 00423 ++i; ++i; 00424 dat.radius(atof(tokens[i].c_str())); 00425 ++i; 00426 dat.flattening(1/atof(tokens[i].c_str())); 00427 ++i; 00428 if (tokens[i] == "TOWGS84" && i<tokens.size()) 00429 { 00430 ++i; 00431 double dx = (atof(tokens[i].c_str())); 00432 ++i; 00433 double dy = (atof(tokens[i].c_str())); 00434 ++i; 00435 double dz = (atof(tokens[i].c_str())); 00436 ++i; 00437 ++i; 00438 ++i; 00439 ++i; 00440 //if ( dx==0.0 && dy== 0 && dz == 0.0) 00441 //{ 00442 // dat = TeDatum("WGS84",6378137,0.003352811,66.87,-4.37,38.52); 00443 //} 00444 //// this is a SAD69 00445 //else if (dx == -66.87 && dy == 4.37 && dz == -38.52) 00446 //{ 00447 // dat = TeDatum("SAD69",6378160,0.003352892,0.0,0.0,0.0); 00448 //} 00449 //else 00450 //{ 00451 dat.dx_ = dx; 00452 dat.dy_ = dy; 00453 dat.dz_ = dz; 00454 //} 00455 } 00456 return dat; 00457 }
TeDatumMap TeDatumFactory::_datumMap [static, protected] |
1.5.3