1 //----------------------------------------------------------------------------
2 //
3 // License:  See top level LICENSE.txt file.
4 //
5 // File: ossim-foo.cpp
6 //
7 // Author:  David Burken
8 //
9 // Description: Contains application definition "ossim-foo" app.
10 //
11 // NOTE:  This is supplied for simple quick test. DO NOT checkin your test to
12 //        the svn repository.  Simply edit ossim-foo.cpp and run your test.
13 //        After completion you can do a "svn revert foo.cpp" if you want to
14 //        keep your working repository up to snuff.
15 //
16 // $Id: ossim-gsoc1.cpp 23420 2015-07-12 11:58:34Z dburken $
17 //----------------------------------------------------------------------------
18 
19 // ossim includes:  These are here just to save time/typing...
20 #include <ossim/init/ossimInit.h>
21 #include <ossim/point_cloud/ossimPointCloudImageHandler.h>
22 #include <ossim/point_cloud/ossimGenericPointCloudHandler.h>
23 #include <vector>
24 #include <ossim/base/ossimStringProperty.h>
25 #include <ossim/base/ossimKeywordNames.h>
26 #include <ossim/imaging/ossimTiffWriter.h>
27 
28 using namespace std;
29 
main(int argc,char * argv[])30 int main(int argc, char *argv[])
31 {
32    ossimInit::instance()->initialize(argc, argv);
33 
34    // TODO: Read your ECEF points from your input file here:
35    vector<ossimEcefPoint> ecef_points; // Need to fill this vector array
36 
37    ossimEcefPoint Pt1( 4347158.78960514, 848070.80152498, 4573989.32558993);
38    ossimEcefPoint Pt2( 4347158.78960514, 853070.80152498, 4573927.96772204);
39    ossimEcefPoint Pt3( 4347158.78960514, 858070.80152498, 4573866.60985415);
40    ossimEcefPoint Pt4( 4352158.78960514, 848070.80152498, 4569848.07121407);
41    ossimEcefPoint Pt5( 4352158.78960514, 853070.80152498, 4569786.71334618);
42    ossimEcefPoint Pt6( 4352158.78960514, 858070.80152498, 4569725.35547829);
43    ossimEcefPoint Pt7( 4357158.78960514, 848070.80152498, 4565706.81683821);
44    ossimEcefPoint Pt8( 4357158.78960514, 853070.80152498, 4565645.45897032);
45    ossimEcefPoint Pt9( 4357158.78960514, 858070.80152498, 4565584.10110243);
46 
47    ecef_points.push_back(Pt1);
48    ecef_points.push_back(Pt2);
49    ecef_points.push_back(Pt3);
50    ecef_points.push_back(Pt4);
51    ecef_points.push_back(Pt5);
52    ecef_points.push_back(Pt6);
53    ecef_points.push_back(Pt7);
54    ecef_points.push_back(Pt8);
55    ecef_points.push_back(Pt9);
56 
57    ossimRefPtr<ossimGenericPointCloudHandler> pc_handler =
58       new ossimGenericPointCloudHandler(ecef_points);
59 
60    ossimRefPtr<ossimPointCloudImageHandler> ih =  new ossimPointCloudImageHandler;
61    ih->setCurrentEntry((ossim_uint32)ossimPointCloudImageHandler::HIGHEST);
62    ih->setPointCloudHandler(pc_handler.get());
63 
64    // TODO: This sets the resolution of the output file. There is a default value computed but you
65    // may either adjust it or set it manually here:
66    ossimDpt gsd;
67    ih->getGSD(gsd, 0);
68    ossimString gsdstr = ossimString::toString((gsd.x + gsd.y)/2.0); // I use 1/6th of default
69    ossimRefPtr<ossimProperty> gsd_prop =
70          new ossimStringProperty(ossimKeywordNames::METERS_PER_PIXEL_KW, gsdstr);
71    ih->setProperty(gsd_prop);
72 
73    // Set up the writer:
74    ossimRefPtr<ossimTiffWriter> tif_writer =  new ossimTiffWriter();
75    tif_writer->setGeotiffFlag(true);
76 
77    ossimFilename outfile ("output.tif");
78    tif_writer->setFilename(outfile);
79    if (tif_writer.valid())
80    {
81       tif_writer->connectMyInputTo(0, ih.get());
82       tif_writer->execute();
83    }
84 
85    cout << "Output written to <"<<outfile<<">"<<endl;
86    tif_writer->close();
87    tif_writer = 0;
88    ih = 0;
89    pc_handler = 0;
90    return 0;
91 }
92