OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Macros | Functions
plugin-test.cpp File Reference
#include "../src/ossimPdalFileReader.h"
#include "../src/ossimRialtoReader.h"
#include <ossim/init/ossimInit.h>
#include <ossim/base/ossimStringProperty.h>
#include <ossim/base/ossimKeywordNames.h>
#include <assert.h>
#include <ossim/point_cloud/ossimPointCloudImageHandler.h>
#include <ossim/imaging/ossimTiffWriter.h>
#include <pdal/pdal.hpp>
#include <pdal/util/Bounds.hpp>
#include <pdal/LasWriter.hpp>
#include <pdal/FauxReader.hpp>

Go to the source code of this file.

Macros

#define TEST_READER   false
 

Functions

int usage (char *app_name)
 
bool writeRaster (ossimPdalReader *reader, const char *test)
 
bool test_rialto (const ossimFilename &fname)
 
bool test_pdal (const ossimFilename &fname)
 
bool genlas (const ossimFilename &fname)
 
int main (int argc, char **argv)
 

Macro Definition Documentation

◆ TEST_READER

#define TEST_READER   false

Definition at line 22 of file plugin-test.cpp.

Function Documentation

◆ genlas()

bool genlas ( const ossimFilename fname)

Definition at line 99 of file plugin-test.cpp.

References ossimString::string().

Referenced by main().

100 {
101  cout << "Generating file <"<<fname<<">"<<endl;
102 
103  FauxReader reader;
104  Options roptions;
105  BOX3D bbox(-0.001, -0.001, -100.0, 0.001, 0.001, 100.0);
106  roptions.add("bounds", bbox);
107  roptions.add("num_points", 11);
108  roptions.add("mode", "ramp");
109  reader.setOptions(roptions);
110 
111  LasWriter writer;
112  Options woptions;
113  woptions.add("filename", fname.string());
114  woptions.add("a_srs", "EPSG:4326"); // causes core dump when ossimInit::initialize() called on startup
115  woptions.add("scale_x", 0.0000001);
116  woptions.add("scale_y", 0.0000001);
117  writer.setOptions(woptions);
118  writer.setInput(reader);
119 
120  PointTable wtable;
121  writer.prepare(wtable);
122  writer.execute(wtable);
123 
124  return true;
125 }
const std::string & string() const
Definition: ossimString.h:414

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 127 of file plugin-test.cpp.

References ossimString::downcase(), ossimString::empty(), genlas(), test_pdal(), test_rialto(), and usage().

128 {
129  // TODO: Figure out why program core-dumps on exit when this line is included and genlas test is
130  // run. Determined problem to be in GDAL's OGRSpatialReference::SetFromUserInput() called from
131  // PDAL's SpatialReference::setFromUserInput() called when EPSG option is set:
132  //ossimInit::instance()->initialize(argc, argv);
133 
134  if (argc == 1)
135  return usage(argv[0]);
136 
137  ossimFilename fname;
138  if (argc > 2)
139  fname = argv[2];
140 
141  ossimString test_name (argv[1]);
142  bool passed = false;
143  if (test_name.downcase() == "rialto")
144  {
145  if (fname.empty())
146  fname = "autzen.gpkg";
147  passed = test_rialto(fname);
148  }
149  else if (test_name.downcase() == "pdal")
150  {
151  if (fname.empty())
152  fname = "autzen.las";
153  passed = test_pdal(fname);
154  }
155  else if (test_name.downcase() == "genlas")
156  {
157  if (fname.empty())
158  fname = "ramp.las";
159  passed = genlas(fname);
160  }
161  else
162  return usage(argv[0]);
163 
164  if (passed)
165  return 0;
166  return 1;
167 }
int usage(char *app_name)
Definition: plugin-test.cpp:26
bool test_rialto(const ossimFilename &fname)
Definition: plugin-test.cpp:63
bool genlas(const ossimFilename &fname)
Definition: plugin-test.cpp:99
bool test_pdal(const ossimFilename &fname)
Definition: plugin-test.cpp:83
bool empty() const
Definition: ossimString.h:411

◆ test_pdal()

bool test_pdal ( const ossimFilename fname)

Definition at line 83 of file plugin-test.cpp.

References ossimRefPtr< T >::get(), ossimPointCloudHandler::getBounds(), ossimPdalFileReader::open(), and writeRaster().

Referenced by main().

84 {
85  cout << "Testing pdal with <"<<fname<<">"<<endl;
86 
88  reader->open(fname);
89 
90  ossimGrect bounds;
91  reader->getBounds(bounds);
92  cout <<"bounds = "<<bounds<<endl;
93 
94  writeRaster(reader.get(), "pdal");
95 
96  return 0;
97 }
virtual void getBounds(ossimGrect &bounds) const
bool writeRaster(ossimPdalReader *reader, const char *test)
Definition: plugin-test.cpp:32
virtual bool open(const ossimFilename &fname)
Accepts the name of a point cloud file.

◆ test_rialto()

bool test_rialto ( const ossimFilename fname)

Definition at line 63 of file plugin-test.cpp.

References ossimRefPtr< T >::get(), ossimRialtoReader::getBlock(), ossimPointCloudHandler::getBounds(), ossimRialtoReader::open(), and writeRaster().

Referenced by main().

64 {
65  cout << "Testing rialto with <"<<fname<<">"<<endl;
66 
68  reader->open(fname);
69 
70  ossimGrect bounds;
71  reader->getBounds(bounds);
72  cout <<"bounds = "<<bounds<<endl;
73 
74  ossimPointBlock pointBlock;
75  reader->getBlock(bounds, pointBlock);
76 
77  writeRaster(reader.get(), "rialto");
78 
79  return true;
80 }
virtual bool open(const ossimFilename &fname)
Accepts filename of Rialto database file.
virtual void getBounds(ossimGrect &bounds) const
bool writeRaster(ossimPdalReader *reader, const char *test)
Definition: plugin-test.cpp:32
virtual void getBlock(const ossimGrect &bounds, ossimPointBlock &block) const
Fetches the block of points inside the block bounds.

◆ usage()

int usage ( char *  app_name)

Definition at line 26 of file plugin-test.cpp.

Referenced by main().

27 {
28  cout << "\nUsage: "<<app_name<<" <pdal|rialto|genlas> [filename]\n" << endl;
29  return 1;
30 }

◆ writeRaster()

bool writeRaster ( ossimPdalReader reader,
const char *  test 
)

Definition at line 32 of file plugin-test.cpp.

References ossimConnectableObject::connectMyInputTo(), ossimImageFileWriter::execute(), ossimRefPtr< T >::get(), ossimPointCloudImageHandler::getGSD(), ossimPointCloudImageHandler::HIGHEST, ossimKeywordNames::METERS_PER_PIXEL_KW, ossimPointCloudImageHandler::setCurrentEntry(), ossimImageFileWriter::setFilename(), ossimTiffWriter::setGeotiffFlag(), ossimPointCloudImageHandler::setPointCloudHandler(), ossimPointCloudImageHandler::setProperty(), ossimString::toString(), ossimRefPtr< T >::valid(), ossimDpt::x, and ossimDpt::y.

Referenced by test_pdal(), and test_rialto().

33 {
36  ih->setPointCloudHandler(reader);
37 
38  ossimDpt gsd;
39  ih->getGSD(gsd, 0);
40  ossimString gsdstr = ossimString::toString((gsd.x + gsd.y)/6.0);
43  ih->setProperty(gsd_prop);
44 
45  // Set up the writer:
47  tif_writer->setGeotiffFlag(true);
48 
49  ossimFilename outfile (test);
50  outfile += "-OUTPUT.tif";
51  tif_writer->setFilename(outfile);
52  if (tif_writer.valid())
53  {
54  tif_writer->connectMyInputTo(0, ih.get());
55  tif_writer->execute();
56  }
57 
58  cout << "Output written to <"<<outfile<<">"<<endl;
59  return true;
60 }
bool valid() const
Definition: ossimRefPtr.h:75
double y
Definition: ossimDpt.h:165
Class used for rendering point cloud data into a raster tile.
static ossimString toString(bool aValue)
Numeric to string methods.
bool setPointCloudHandler(ossimPointCloudHandler *pch)
Permits backdoor for setting the input point cloud handler object.
void getGSD(ossimDpt &gsd, ossim_uint32 resLevel) const
Get the GSD for resLevel.
virtual void setGeotiffFlag(bool flag)
unsigned int ossim_uint32
virtual ossim_int32 connectMyInputTo(ossimConnectableObject *inputObject, bool makeOutputConnection=true, bool createEventFlag=true)
Will try to connect this objects input to the passed in object.
bool setCurrentEntry(ossim_uint32 entryIdx) override
void setProperty(ossimRefPtr< ossimProperty > property) override
The reader properties are: – the GSD ("meters_per_pixel") which overrides computed nominal GSD – th...
virtual void setFilename(const ossimFilename &file)
static const char * METERS_PER_PIXEL_KW
double x
Definition: ossimDpt.h:164
virtual bool execute()
Calls: writeFile() writeMetaDataFiles()