29 #include <geos/util/TopologyException.h> 66 std::vector<geos::geom::Point *> points;
69 const geos::geom::Envelope *polyBoundBox = multiPoly->getEnvelopeInternal();
84 if(fabs(polyBoundBox->getMaxX() - polyBoundBox->getMinX()) > fabs((polyBoundBox->getMaxY() - polyBoundBox->getMinY()))) {
93 double xSpacing = (polyBoundBox->getMaxX() - polyBoundBox->getMinX()) / (xSteps);
94 double ySpacing = (polyBoundBox->getMaxY() - polyBoundBox->getMinY()) / (ySteps);
96 double realMinX = polyBoundBox->getMinX() + xSpacing / 2;
97 double realMinY = polyBoundBox->getMinY() + ySpacing / 2;
98 double maxY = polyBoundBox->getMaxY();
99 double maxX = polyBoundBox->getMaxX();
101 for(
double y = realMinY; y < maxY; y += ySpacing) {
102 for(
double x = realMinX; x < maxX; x += xSpacing) {
103 geos::geom::Geometry *gridSquarePolygon =
GetMultiPolygon(x - xSpacing / 2.0, y - ySpacing / 2,
104 x + xSpacing / 2.0, y + ySpacing / 2, *multiPoly);
106 geos::geom::Point *centroid = gridSquarePolygon->getCentroid();
108 delete gridSquarePolygon;
109 if(centroid == NULL)
continue;
111 double gridCenterX = centroid->getX();
112 double gridCenterY = centroid->getY();
115 geos::geom::Coordinate c(gridCenterX, gridCenterY);
116 points.push_back(Isis::globalFactory.createPoint(c));
138 double dMaxX,
double dMaxY,
139 const geos::geom::MultiPolygon &orig) {
140 geos::geom::CoordinateSequence *points =
new geos::geom::CoordinateArraySequence();
142 points->add(geos::geom::Coordinate(dMinX, dMinY));
143 points->add(geos::geom::Coordinate(dMaxX, dMinY));
144 points->add(geos::geom::Coordinate(dMaxX, dMaxY));
145 points->add(geos::geom::Coordinate(dMinX, dMaxY));
146 points->add(geos::geom::Coordinate(dMinX, dMinY));
148 geos::geom::Polygon *poly = Isis::globalFactory.createPolygon(Isis::globalFactory.createLinearRing(points), NULL);
149 geos::geom::Geometry *overlap = poly->intersection(&orig);
180 QString msg =
"PVL for LimitPolygonSeeder must contain [MajorAxisPoints] in [";
193 QString msg =
"PVL for LimitPolygonSeeder must contain [MinorAxisPoints] in [";
199 QString msg =
"Improper format for PolygonSeeder PVL [" + pvl.
fileName() +
"]";
bool hasKeyword(const QString &name) const
Check to see if a keyword exists.
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
Seed points using a grid.
QString Algorithm() const
The name of the algorithm, read from the Name Keyword in the PolygonSeeder Pvl passed into the constr...
Pvl * invalidInput
The Pvl passed in by the constructor minus what was used.
This class is used as the base class for all PolygonSeeder objects.
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
void addKeyword(const PvlKeyword &keyword, const InsertMode mode=Append)
Add a keyword to the container.
virtual PvlGroup PluginParameters(QString grpName)
Plugin parameters.
Contains multiple PvlContainers.
#define _FILEINFO_
Macro for the filename and line number.
LimitPolygonSeeder(Pvl &pvl)
Construct a LimitPolygonSeeder algorithm.
A type of error that could only have occurred due to a mistake on the user's part (e...
A single keyword-value pair.
virtual void Parse(Pvl &pvl)
Parse the LimitPolygonSeeder spicific parameters from the PVL.
virtual void Parse(Pvl &pvl)
Initialize parameters in the PolygonSeeder class using a PVL specification.
Container for cube-like labels.
QString StandardTests(const geos::geom::MultiPolygon *multiPoly, const geos::geom::Envelope *polyBoundBox)
Check the polygon to see if it meets standard criteria.
std::vector< geos::geom::Point * > Seed(const geos::geom::MultiPolygon *mp)
Seed a polygon with points.
double MinimumThickness()
Return the minimum allowed thickness of the polygon.
int p_minorAxisPts
Number of points to place on minor axis.
QString fileName() const
Returns the filename used to initialise the Pvl object.
double MinimumArea()
Return the minimum allowed area of the polygon.
int p_majorAxisPts
Number of points to place on major axis.
Adds specific functionality to C++ strings.
Namespace for ISIS/Bullet specific routines.
geos::geom::Geometry * GetMultiPolygon(double dMinX, double dMinY, double dMaxX, double dMaxY, const geos::geom::MultiPolygon &orig)
This method returns the overlap between the x/y range specified and the "orig" polygon.
Isis::PolygonSeeder * LimitPolygonSeederPlugin(Isis::Pvl &pvl)
Create a LimitPolygonSeeder object.
void deleteKeyword(const QString &name)
Remove a specified keyword.