Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | Last revision Both sides next revision | ||
wiki:documentation:devguide:srs_module [2016/01/20 10:15] lubia [Coordinate Transformation] |
wiki:documentation:devguide:srs_module [2016/01/20 11:00] lubia [Coordinate Transformation] |
||
---|---|---|---|
Line 39: | Line 39: | ||
{ | { | ||
// ... | // ... | ||
- | // requesting a pointer to a converter | + | te::srs::Converter converter; |
- | std::auto_ptr<te::srs::Converter> converter(new te::srs::Converter()); | + | |
- | converter->setSourceSRS(4326); // the SRS id for geographic coordinates over a WGS84 datum | + | converter.setSourceSRID(4326); // the SRS id for geographic coordinates over a WGS84 datum |
- | converter->setTargetSRS(31985); // the SRS id for projected coordinates of UTM / WGS84 datum, Zone 17 South | + | converter.setTargetSRID(32723); // the SRS id for projected coordinates of UTM / WGS84 datum, Zone 23 South |
// Converting a single coordinate | // Converting a single coordinate | ||
- | double llX = -45.5; | + | double llX = -45.0; |
- | double llY = -23.0; | + | double llY = 0.0; |
double xyX; | double xyX; | ||
double xyY; | double xyY; | ||
- | converter->convert(llX,llY,xyX,xyY); | + | converter.convert(llX,llY,xyX,xyY); |
- | converter->invert(xyX,xyY,llX,llY); | + | |
- | // Converting a list of coordinates | + | std::cout.precision(10); |
- | double* xs = new double[3]; | + | std::cout << "EPSG:4326 (" << llX << "," << llY << ") => "; |
- | double* ys = new double[3]; | + | std::cout << "EPSG:32723 (" << xyX << "," << xyY << ")\n"; |
- | xs[0] = -45.5; | + | llX = -44.0; |
- | xs[1] = -45.6; | + | llY = 0.0; |
- | xs[2] = -45.7; | + | converter.convert(llX,llY,xyX,xyY); |
- | ys[0] = -23.0; | + | std::cout.precision(10); |
- | ys[1] = -23.1; | + | std::cout << "EPSG:4326 (" << llX << "," << llY << ") => "; |
- | ys[2] = -23.2; | + | std::cout << "EPSG:32723 (" << xyX << "," << xyY << ")\n"; |
- | + | ||
- | converter->convert(xs,ys,3,1); | + | |
// ... | // ... | ||
} | } |