Official websites use .gov
A .gov website belongs to an official government organization in the United States.

Secure .gov websites use HTTPS
A lock ( ) or https:// means you’ve safely connected to the .gov website. Share sensitive information only on official, secure websites.

Isis 3 Programmer Reference
PolygonSeeder.cpp
1
5
6/* SPDX-License-Identifier: CC0-1.0 */
7#include "PolygonSeeder.h"
8
9#include "IException.h"
10#include "LeastSquares.h"
11#include "Plugin.h"
12#include "PolygonTools.h"
13#include "PolynomialBivariate.h"
14#include "LeastSquares.h"
15#include "FileName.h"
16#include "ProjectionFactory.h"
17#include "Pvl.h"
18#include "PvlGroup.h"
19
20
21namespace Isis {
31 invalidInput = NULL;
32 invalidInput = new Pvl(pvl);
33
34 p_algorithmName = "Unknown";
35
36 Parse(pvl);
37 }
38
39
54
55
60 if(invalidInput) {
61 delete invalidInput;
62 invalidInput = NULL;
63 }
64 }
65
66
85 void PolygonSeeder::Parse(Pvl &pvl) {
86
87 QString errorSpot;
88
89 try {
90 // Get info from Algorithm group
91 errorSpot = "Algorithm";
92 PvlGroup &algo = pvl.findGroup("PolygonSeederAlgorithm", Pvl::Traverse);
93
94 // algo is such a cool name for a PvlGroup that it begs to be out done
95 PvlGroup &invalgo = invalidInput->findGroup("PolygonSeederAlgorithm",
96 Pvl::Traverse);
97
98 // Set the algorithm name
99 errorSpot = "Name";
100 p_algorithmName = (QString) algo["Name"];
101
102 if(invalgo.hasKeyword("Name"))
103 invalgo.deleteKeyword("Name");
104
105 // Set the minimum thickness (Area / max(extent X, extent Y)**2
106 errorSpot = "MinimumThickness";
107 p_minimumThickness = 0.0;
108 if(algo.hasKeyword("MinimumThickness")) {
109 p_minimumThickness = (double) algo["MinimumThickness"];
110 }
111
112 if(invalgo.hasKeyword("MinimumThickness"))
113 invalgo.deleteKeyword("MinimumThickness");
114
115 // Set the minimum area
116 errorSpot = "MinimumArea";
117 p_minimumArea = 0.0;
118 if(algo.hasKeyword("MinimumArea")) {
119 p_minimumArea = (double) algo["MinimumArea"];
120 }
121
122 if(invalgo.hasKeyword("MinimumArea"))
123 invalgo.deleteKeyword("MinimumArea");
124 }
125 catch(IException &e) {
126 QString msg = "Improper format for PolygonSeeder PVL [";
127 msg += pvl.fileName() + "]. Location [" + errorSpot + "]";
128 throw IException(IException::User, msg, _FILEINFO_);
129 }
130
131 return;
132 }
133
134
146 QString PolygonSeeder::StandardTests(const geos::geom::MultiPolygon *xymp,
147 const geos::geom::Envelope *xyBoundBox) {
148 if(xymp->getArea() < MinimumArea()) {
149 QString msg = "Polygon did not meet the minimum area of [";
150 msg += toString(MinimumArea()) + "]";
151 return msg;
152 }
153
154 double thickness =
155 xymp->getArea() /
156 pow(std::max(xyBoundBox->getWidth(), xyBoundBox->getHeight()), 2.0);
157 if(thickness < MinimumThickness()) {
158 QString msg = "Polygon did not meet the minimum thickness ratio of [";
159 msg += toString(MinimumThickness()) + "]";
160 return msg;
161 }
162
163 return "";
164 }
165
172 QString PolygonSeeder::Algorithm() const {
173 return p_algorithmName;
174 }
175
186
187
196 return p_minimumArea;
197 }
198
210 PvlGroup PolygonSeeder::PluginParameters(QString grpName) {
211 PvlGroup pluginInfo(grpName);
212
213 PvlKeyword name("Name", p_algorithmName);
214 PvlKeyword minThickness("MinimumThickness", toString(p_minimumThickness));
215 PvlKeyword minArea("MinimumArea", toString(p_minimumArea));
216
217 pluginInfo.addKeyword(name);
218 pluginInfo.addKeyword(minThickness);
219 pluginInfo.addKeyword(minArea);
220
221 return pluginInfo;
222 }
223
224
232 return *invalidInput;
233 }
234
250
251 return *this;
252 }
253
254}
Pvl InvalidInput()
This method returns a copy of the Pvl passed in by the constructor (from a def file probably) minus w...
virtual void Parse(Pvl &pvl)
Initialize parameters in the PolygonSeeder class using a PVL specification.
Pvl * invalidInput
The Pvl passed in by the constructor minus what was used.
QString StandardTests(const geos::geom::MultiPolygon *multiPoly, const geos::geom::Envelope *polyBoundBox)
Check the polygon to see if it meets standard criteria.
virtual PvlGroup PluginParameters(QString grpName)
Plugin parameters.
virtual ~PolygonSeeder()
Destroys the PolygonSeeder object.
double p_minimumThickness
The value for the 'MinimumThickness' Keyword in the PolygonSeederAlgorithm group of the Pvl that is p...
QString p_algorithmName
The value for the 'Name' Keyword in the PolygonSeederAlgorithm group of the Pvl that is passed into t...
PolygonSeeder(Pvl &pvl)
Create PolygonSeeder object.
double MinimumArea()
Return the minimum allowed area of the polygon.
double MinimumThickness()
Return the minimum allowed thickness of the polygon.
QString Algorithm() const
The name of the algorithm, read from the Name Keyword in the PolygonSeeder Pvl passed into the constr...
double p_minimumArea
The value for the 'MinimumArea' Keyword in the PolygonSeederAlgorithm group of the Pvl that is passed...
const PolygonSeeder & operator=(const PolygonSeeder &other)
Assignment operator.
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
QString toString(const LinearAlgebra::Vector &vector, int precision)
A global function to format LinearAlgebra::Vector as a QString with the given precision.