00001 /************************************************************************************ 00002 TerraLib - a library for developing GIS applications. 00003 Copyright © 2001-2004 INPE and Tecgraf/PUC-Rio. 00004 00005 This code is part of the TerraLib library. 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Lesser General Public 00008 License as published by the Free Software Foundation; either 00009 version 2.1 of the License, or (at your option) any later version. 00010 00011 You should have received a copy of the GNU Lesser General Public 00012 License along with this library. 00013 00014 The authors reassure the license terms regarding the warranties. 00015 They specifically disclaim any warranties, including, but not limited to, 00016 the implied warranties of merchantability and fitness for a particular purpose. 00017 The library provided hereunder is on an "as is" basis, and the authors have no 00018 obligation to provide maintenance, support, updates, enhancements, or modifications. 00019 In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct, 00020 indirect, special, incidental, or consequential damages arising out of the use 00021 of this library and its documentation. 00022 *************************************************************************************/ 00023 /* 00024 This file showns an example of how to convert coordinates from a projection to another. 00025 00026 Author: Lubia Vinhas 00027 */ 00028 00029 #include "../../src/terralib/kernel/TeProjection.h" 00030 #include <iostream> 00031 00032 int main() 00033 { 00034 TeDatum dSAD69 = TeDatumFactory::make("SAD69"); // SAD69 Spheroid 00035 00036 TeDatum dWGS84 = TeDatumFactory::make("WGS84"); // WGS84 Spheroid 00037 00038 TeUtm* pUTM = new TeUtm(dSAD69,-45.0*TeCDR); // Origin latitude of -45.0 00039 // TeCDR means "Convert to Degrees from Radians" 00040 00041 TePolyconic* pPolyconic = new TePolyconic(dWGS84,-45.0*TeCDR); // Origin latitude of -45.0 00042 // TeCDR means "Converte Degrees from Radians" 00043 TeCoord2D pt1(340033.47, 7391306.21); // Original coordinate in UTM 00044 00045 // Conversion from the UTM to the Polyconic projection 00046 pUTM->setDestinationProjection(pPolyconic); 00047 00048 TeCoord2D ll = pUTM->PC2LL(pt1); // Convert to Lat Long 00049 TeCoord2D pt2 = pPolyconic->LL2PC(ll); // Convert to output projection 00050 00051 printf("UTM -> Polyconic \n"); 00052 printf("(%.4f, %.4f) -> ",pt1.x(), pt1.y()); 00053 printf("(%.4f, %.4f) \n",pt2.x(), pt2.y()); 00054 00055 // Conversion from the Polyconic to the UTM projection 00056 pPolyconic->setDestinationProjection(pUTM); 00057 ll = pPolyconic->PC2LL(pt2); 00058 pt1 = pUTM->LL2PC(ll); 00059 00060 printf("\nPolyconic -> UTM \n"); 00061 printf("(%.4f, %.4f) -> ",pt2.x(), pt2.y()); 00062 printf("(%.4f, %.4f) \n",pt1.x(), pt1.y()); 00063 00064 cout << "\nPress Enter\n" ; 00065 cout.flush(); 00066 getchar(); 00067 return 0; 00068 }
1.5.3