OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
dem-test.cpp
Go to the documentation of this file.
1 //---
2 //
3 // License: MIT
4 //
5 // File: ossim-foo.cpp
6 //
7 // Description: Contains application definition "ossim-foo" app.
8 //
9 // NOTE: This is supplied for simple quick test. DO NOT checkin your test to
10 // the svn repository. Simply edit ossim-foo.cpp and run your test.
11 // After completion you can do a "git checkout -- ossimfoo.cpp" if
12 // you want to keep your working repository up to snuff.
13 //
14 // $Id$
15 //---
16 
17 // System includes:
18 #include <cmath>
19 #include <memory>
20 #include <sstream>
21 #include <iostream>
26 #include <ossim/base/ossimDpt.h>
27 #include <ossim/base/ossimDrect.h>
29 #include <ossim/base/ossimIrect.h>
30 #include <ossim/base/ossimNotify.h>
47 #include <ossim/init/ossimInit.h>
49 #include <ossim/base/Thread.h>
52 #include<json/json.h>
53 #include <dem/src/ossimDemTool.h>
54 
55 using namespace std;
56 
57 int main(int argc, char *argv[])
58 {
59  int returnCode = 0;
60 
61  ossimArgumentParser ap(&argc, argv);
64 
65  if (argc < 3)
66  {
67  cout<<"\nUsage: "<<argv[0]<<"<image-A> <image-B>\n"<<endl;
68  exit(0);
69  }
70 
71  try
72  {
73  ossimFilename imageA (argv[1]);
74  ossimFilename imageB (argv[2]);
75 
76  Json::Value rootJson;
77  rootJson["algorithm"] = "omg";
78  rootJson["method"] = "generate";
79  rootJson["filename"] = "dem-test-output.tif";
80  rootJson["postSpacing"] = 1.0;
81  rootJson["postSpacingUnits"] = "meters";
82 
83  Json::Value imagesJson;
84  Json::Value imageAJson;
85  imageAJson["filename"] = imageA.string();
86  imagesJson[0] = imageAJson;
87  Json::Value imageBJson;
88  imageBJson["filename"] = imageB.string();
89  imagesJson[1] = imageBJson;
90 
91  Json::Value pbJson;
92  pbJson["images"] = imagesJson;
93  rootJson["photoblock"] = pbJson;
94 
95  cout<<"Input JSON:\n"<<rootJson<<endl;
96 
97  ossimDemTool demTool;
98  demTool.loadJSON(rootJson);
99 
100  demTool.execute();
101  }
102  catch(const ossimException& e)
103  {
104  ossimNotify(ossimNotifyLevel_WARN) << e.what() << std::endl;
105  returnCode = 1;
106  }
107  catch( ... )
108  {
110  << argv[0] <<" caught unhandled exception!" << std::endl;
111  returnCode = 1;
112  }
113 
114  return returnCode;
115 }
int main(int argc, char *argv[])
Definition: dem-test.cpp:57
void initialize(int &argc, char **argv)
Definition: ossimInit.cpp:119
void addOptions(ossimArgumentParser &parser)
Definition: ossimInit.cpp:100
bool execute() override
Writes product to output file if applicable.
virtual const char * what() const
Returns the error message.
static ossimInit * instance()
Definition: ossimInit.cpp:89
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
void loadJSON(const Json::Value &json) override
Reads processing params from JSON object provided.
const std::string & string() const
Definition: ossimString.h:414