Created
April 29, 2016 15:36
-
-
Save connormanning/d62122189ead6cdf6634ca57b3b4e9da to your computer and use it in GitHub Desktop.
PDAL getSpatialReference
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <pdal/PointTable.hpp> | |
#include <pdal/Reader.hpp> | |
#include <pdal/StageFactory.hpp> | |
namespace | |
{ | |
const std::string path("/Users/connor/data/autzen-full.laz"); | |
pdal::StageFactory factory; | |
} | |
pdal::Reader* makeReader(const std::string f) | |
{ | |
const std::string driver(factory.inferReaderDriver(f)); | |
if (driver.empty()) throw std::runtime_error("No driver - " + f); | |
pdal::Reader* reader( | |
static_cast<pdal::Reader*>(factory.createStage(driver))); | |
if (!reader) throw std::runtime_error("No reader - " + f); | |
pdal::Options options; | |
options.add(pdal::Option("filename", f)); | |
reader->setOptions(options); | |
return reader; | |
} | |
int main() | |
{ | |
if (pdal::Reader* reader = makeReader(path)) | |
{ | |
std::cout << "\nBare reader: " << | |
reader->getSpatialReference().getWKT() << std::endl; | |
} | |
else throw std::runtime_error("No reader"); | |
if (pdal::Reader* reader = makeReader(path)) | |
{ | |
pdal::PointTable table; | |
reader->prepare(table); | |
std::cout << "\nPrepared: " << | |
reader->getSpatialReference().getWKT() << std::endl; | |
} | |
else throw std::runtime_error("No reader"); | |
if (pdal::Reader* reader = makeReader(path)) | |
{ | |
reader->preview(); | |
std::cout << "\nPreviewed: " << | |
reader->getSpatialReference().getWKT() << std::endl; | |
} | |
else throw std::runtime_error("No reader"); | |
/* | |
if (pdal::Reader* reader = makeReader(path)) | |
{ | |
// Error - initialize is a private member of pdal::Stage. | |
reader->initialize(); | |
std::cout << "\nInitialized: " << | |
reader->getSpatialReference().getWKT() << std::endl; | |
} | |
else throw std::runtime_error("No reader"); | |
*/ | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ g++ -std=c++11 prepare.cpp -lpdalcpp && ./a.out | |
Bare reader: | |
Prepared: PROJCS["NAD_1983_HARN_Lambert_Conformal_Conic",GEOGCS["GCS_North_American_1983_HARN",DATUM["NAD83_High_Accuracy_Reference_Network",SPHEROID["GRS 1980",6378137,298.2572221010002,AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","6152"]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic_2SP"],PARAMETER["standard_parallel_1",43],PARAMETER["standard_parallel_2",45.5],PARAMETER["latitude_of_origin",41.75],PARAMETER["central_meridian",-120.5],PARAMETER["false_easting",1312335.958005249],PARAMETER["false_northing",0],UNIT["foot",0.3048,AUTHORITY["EPSG","9002"]]] | |
Previewed: PROJCS["NAD_1983_HARN_Lambert_Conformal_Conic",GEOGCS["GCS_North_American_1983_HARN",DATUM["NAD83_High_Accuracy_Reference_Network",SPHEROID["GRS 1980",6378137,298.2572221010002,AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","6152"]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic_2SP"],PARAMETER["standard_parallel_1",43],PARAMETER["standard_parallel_2",45.5],PARAMETER["latitude_of_origin",41.75],PARAMETER["central_meridian",-120.5],PARAMETER["false_easting",1312335.958005249],PARAMETER["false_northing",0],UNIT["foot",0.3048,AUTHORITY["EPSG","9002"]]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment