Isis 3.0 Object Programmers' Reference
Home
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
PolygonSeeder.cpp
1
#include "
PolygonSeeder.h
"
2
3
#include "
IException.h
"
4
#include "
LeastSquares.h
"
5
#include "
Plugin.h
"
6
#include "
PolygonTools.h
"
7
#include "
PolynomialBivariate.h
"
8
#include "
LeastSquares.h
"
9
#include "
FileName.h
"
10
#include "
ProjectionFactory.h
"
11
#include "
Pvl.h
"
12
#include "
PvlGroup.h
"
13
14
15
namespace
Isis {
24
PolygonSeeder::PolygonSeeder
(
Pvl
&pvl) {
25
invalidInput
= NULL;
26
invalidInput
=
new
Pvl
(pvl);
27
28
p_algorithmName
=
"Unknown"
;
29
30
Parse
(pvl);
31
}
32
33
43
PolygonSeeder::PolygonSeeder
(
const
PolygonSeeder
&other) {
44
p_algorithmName
= other.
p_algorithmName
;
45
p_minimumThickness
= other.
p_minimumThickness
;
46
p_minimumArea
= other.
p_minimumArea
;
47
}
48
49
53
PolygonSeeder::~PolygonSeeder
() {
54
if
(
invalidInput
) {
55
delete
invalidInput
;
56
invalidInput
= NULL;
57
}
58
}
59
60
79
void
PolygonSeeder::Parse
(
Pvl
&pvl) {
80
81
QString errorSpot;
82
83
try
{
84
// Get info from Algorithm group
85
errorSpot =
"Algorithm"
;
86
PvlGroup
&algo = pvl.
findGroup
(
"PolygonSeederAlgorithm"
,
Pvl::Traverse
);
87
88
// algo is such a cool name for a PvlGroup that it begs to be out done
89
PvlGroup
&invalgo =
invalidInput
->
findGroup
(
"PolygonSeederAlgorithm"
,
90
Pvl::Traverse
);
91
92
// Set the algorithm name
93
errorSpot =
"Name"
;
94
p_algorithmName
= (QString) algo[
"Name"
];
95
96
if
(invalgo.
hasKeyword
(
"Name"
))
97
invalgo.
deleteKeyword
(
"Name"
);
98
99
// Set the minimum thickness (Area / max(extent X, extent Y)**2
100
errorSpot =
"MinimumThickness"
;
101
p_minimumThickness
= 0.0;
102
if
(algo.
hasKeyword
(
"MinimumThickness"
)) {
103
p_minimumThickness
= (double) algo[
"MinimumThickness"
];
104
}
105
106
if
(invalgo.
hasKeyword
(
"MinimumThickness"
))
107
invalgo.
deleteKeyword
(
"MinimumThickness"
);
108
109
// Set the minimum area
110
errorSpot =
"MinimumArea"
;
111
p_minimumArea
= 0.0;
112
if
(algo.
hasKeyword
(
"MinimumArea"
)) {
113
p_minimumArea
= (double) algo[
"MinimumArea"
];
114
}
115
116
if
(invalgo.
hasKeyword
(
"MinimumArea"
))
117
invalgo.
deleteKeyword
(
"MinimumArea"
);
118
}
119
catch
(
IException
&e) {
120
QString msg =
"Improper format for PolygonSeeder PVL ["
;
121
msg += pvl.
fileName
() +
"]. Location ["
+ errorSpot +
"]"
;
122
throw
IException
(
IException::User
, msg,
_FILEINFO_
);
123
}
124
125
return
;
126
}
127
128
140
QString
PolygonSeeder::StandardTests
(
const
geos::geom::MultiPolygon *xymp,
141
const
geos::geom::Envelope *xyBoundBox) {
142
if
(xymp->getArea() <
MinimumArea
()) {
143
QString msg =
"Polygon did not meet the minimum area of ["
;
144
msg +=
toString
(
MinimumArea
()) +
"]"
;
145
return
msg;
146
}
147
148
double
thickness =
149
xymp->getArea() /
150
pow(std::max(xyBoundBox->getWidth(), xyBoundBox->getHeight()), 2.0);
151
if
(thickness <
MinimumThickness
()) {
152
QString msg =
"Polygon did not meet the minimum thickness ratio of ["
;
153
msg +=
toString
(
MinimumThickness
()) +
"]"
;
154
return
msg;
155
}
156
157
return
""
;
158
}
159
166
QString
PolygonSeeder::Algorithm
()
const
{
167
return
p_algorithmName
;
168
}
169
177
double
PolygonSeeder::MinimumThickness
() {
178
return
p_minimumThickness
;
179
}
180
181
189
double
PolygonSeeder::MinimumArea
() {
190
return
p_minimumArea
;
191
}
192
204
PvlGroup
PolygonSeeder::PluginParameters
(QString grpName) {
205
PvlGroup
pluginInfo(grpName);
206
207
PvlKeyword
name(
"Name"
,
p_algorithmName
);
208
PvlKeyword
minThickness(
"MinimumThickness"
,
toString
(
p_minimumThickness
));
209
PvlKeyword
minArea(
"MinimumArea"
,
toString
(
p_minimumArea
));
210
211
pluginInfo.
addKeyword
(name);
212
pluginInfo.
addKeyword
(minThickness);
213
pluginInfo.
addKeyword
(minArea);
214
215
return
pluginInfo;
216
}
217
218
225
Pvl
PolygonSeeder::InvalidInput
() {
226
return
*
invalidInput
;
227
}
228
240
const
PolygonSeeder
&
PolygonSeeder::operator=
(
const
PolygonSeeder
&other) {
241
p_algorithmName
= other.
p_algorithmName
;
242
p_minimumThickness
= other.
p_minimumThickness
;
243
p_minimumArea
= other.
p_minimumArea
;
244
245
return
*
this
;
246
}
247
248
}