File failed to load: https://isis.astrogeology.usgs.gov/6.0.0/Object/assets/jax/output/NativeMML/config.js
Isis 3 Programmer Reference
PolygonSeeder.cpp
1 
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 
21 namespace Isis {
31  invalidInput = NULL;
32  invalidInput = new Pvl(pvl);
33 
34  p_algorithmName = "Unknown";
35 
36  Parse(pvl);
37  }
38 
39 
53  }
54 
55 
60  if(invalidInput) {
61  delete invalidInput;
62  invalidInput = NULL;
63  }
64  }
65 
66 
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",
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 
184  return p_minimumThickness;
185  }
186 
187 
196  return p_minimumArea;
197  }
198 
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 }
Isis::PolygonSeeder::p_minimumArea
double p_minimumArea
The value for the 'MinimumArea' Keyword in the PolygonSeederAlgorithm group of the Pvl that is passed...
Definition: PolygonSeeder.h:89
Isis::PvlObject::findGroup
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
Definition: PvlObject.h:129
Isis::PolygonSeeder::p_algorithmName
QString p_algorithmName
The value for the 'Name' Keyword in the PolygonSeederAlgorithm group of the Pvl that is passed into t...
Definition: PolygonSeeder.h:82
Isis::PvlKeyword
A single keyword-value pair.
Definition: PvlKeyword.h:82
Isis::PvlContainer::addKeyword
void addKeyword(const PvlKeyword &keyword, const InsertMode mode=Append)
Add a keyword to the container.
Definition: PvlContainer.cpp:202
Isis::PolygonSeeder::PluginParameters
virtual PvlGroup PluginParameters(QString grpName)
Plugin parameters.
Definition: PolygonSeeder.cpp:210
Isis::PvlContainer::hasKeyword
bool hasKeyword(const QString &name) const
Check to see if a keyword exists.
Definition: PvlContainer.cpp:159
Isis::Pvl
Container for cube-like labels.
Definition: Pvl.h:119
Isis::PolygonSeeder::MinimumArea
double MinimumArea()
Return the minimum allowed area of the polygon.
Definition: PolygonSeeder.cpp:195
Isis::toString
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition: IString.cpp:211
Isis::PvlObject::Traverse
@ Traverse
Search child objects.
Definition: PvlObject.h:158
Isis::PolygonSeeder::MinimumThickness
double MinimumThickness()
Return the minimum allowed thickness of the polygon.
Definition: PolygonSeeder.cpp:183
Isis::PvlGroup
Contains multiple PvlContainers.
Definition: PvlGroup.h:41
Isis::PolygonSeeder::invalidInput
Pvl * invalidInput
The Pvl passed in by the constructor minus what was used.
Definition: PolygonSeeder.h:78
Isis::PolygonSeeder::operator=
const PolygonSeeder & operator=(const PolygonSeeder &other)
Assignment operator.
Definition: PolygonSeeder.cpp:246
Isis::PvlContainer::fileName
QString fileName() const
Returns the filename used to initialise the Pvl object.
Definition: PvlContainer.h:232
Isis::PolygonSeeder::~PolygonSeeder
virtual ~PolygonSeeder()
Destroys the PolygonSeeder object.
Definition: PolygonSeeder.cpp:59
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::PolygonSeeder::Parse
virtual void Parse(Pvl &pvl)
Initialize parameters in the PolygonSeeder class using a PVL specification.
Definition: PolygonSeeder.cpp:85
Isis::PvlContainer::deleteKeyword
void deleteKeyword(const QString &name)
Remove a specified keyword.
Definition: PvlContainer.cpp:97
Isis::PolygonSeeder::Algorithm
QString Algorithm() const
The name of the algorithm, read from the Name Keyword in the PolygonSeeder Pvl passed into the constr...
Definition: PolygonSeeder.cpp:172
Isis::PolygonSeeder::StandardTests
QString StandardTests(const geos::geom::MultiPolygon *multiPoly, const geos::geom::Envelope *polyBoundBox)
Check the polygon to see if it meets standard criteria.
Definition: PolygonSeeder.cpp:146
Isis::PolygonSeeder::PolygonSeeder
PolygonSeeder(Pvl &pvl)
Create PolygonSeeder object.
Definition: PolygonSeeder.cpp:30
Isis::PolygonSeeder::p_minimumThickness
double p_minimumThickness
The value for the 'MinimumThickness' Keyword in the PolygonSeederAlgorithm group of the Pvl that is p...
Definition: PolygonSeeder.h:85
Isis::PolygonSeeder::InvalidInput
Pvl InvalidInput()
This method returns a copy of the Pvl passed in by the constructor (from a def file probably) minus w...
Definition: PolygonSeeder.cpp:231
Isis::PolygonSeeder
This class is used as the base class for all PolygonSeeder objects.
Definition: PolygonSeeder.h:47
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::IException::User
@ User
A type of error that could only have occurred due to a mistake on the user's part (e....
Definition: IException.h:126

U.S. Department of the Interior | U.S. Geological Survey
ISIS | Privacy & Disclaimers | Astrogeology Research Program
To contact us, please post comments and questions on the USGS Astrogeology Discussion Board
To report a bug, or suggest a feature go to: ISIS Github
File Modified: 07/13/2023 15:17:02