13#include <geos/util/TopologyException.h>
15#include "IException.h"
16#include "LimitPolygonSeeder.h"
17#include "PolygonTools.h"
50 std::vector<geos::geom::Point *> points;
53 const geos::geom::Envelope *polyBoundBox = multiPoly->getEnvelopeInternal();
68 if(fabs(polyBoundBox->getMaxX() - polyBoundBox->getMinX()) > fabs((polyBoundBox->getMaxY() - polyBoundBox->getMinY()))) {
77 double xSpacing = (polyBoundBox->getMaxX() - polyBoundBox->getMinX()) / (xSteps);
78 double ySpacing = (polyBoundBox->getMaxY() - polyBoundBox->getMinY()) / (ySteps);
80 double realMinX = polyBoundBox->getMinX() + xSpacing / 2;
81 double realMinY = polyBoundBox->getMinY() + ySpacing / 2;
82 double maxY = polyBoundBox->getMaxY();
83 double maxX = polyBoundBox->getMaxX();
85 for(
double y = realMinY; y < maxY; y += ySpacing) {
86 for(
double x = realMinX; x < maxX; x += xSpacing) {
87 geos::geom::Geometry *gridSquarePolygon =
GetMultiPolygon(x - xSpacing / 2.0, y - ySpacing / 2,
88 x + xSpacing / 2.0, y + ySpacing / 2, *multiPoly);
90 geos::geom::Point *centroid = gridSquarePolygon->getCentroid().release();
92 delete gridSquarePolygon;
93 if(centroid->isEmpty())
continue;
95 double gridCenterX = centroid->getX();
96 double gridCenterY = centroid->getY();
99 geos::geom::Coordinate c(gridCenterX, gridCenterY);
100 points.push_back(Isis::globalFactory->createPoint(c).release());
122 double dMaxX,
double dMaxY,
123 const geos::geom::MultiPolygon &orig) {
124 geos::geom::CoordinateSequence *points =
new geos::geom::CoordinateSequence();
126 points->add(geos::geom::Coordinate(dMinX, dMinY));
127 points->add(geos::geom::Coordinate(dMaxX, dMinY));
128 points->add(geos::geom::Coordinate(dMaxX, dMaxY));
129 points->add(geos::geom::Coordinate(dMinX, dMaxY));
130 points->add(geos::geom::Coordinate(dMinX, dMinY));
132 std::unique_ptr<geos::geom::Polygon> poly = Isis::globalFactory->createPolygon(Isis::globalFactory->createLinearRing(*points));
133 geos::geom::Geometry *overlap = poly->intersection(&orig).release();
164 QString msg =
"PVL for LimitPolygonSeeder must contain [MajorAxisPoints] in [";
177 QString msg =
"PVL for LimitPolygonSeeder must contain [MinorAxisPoints] in [";
183 QString msg =
"Improper format for PolygonSeeder PVL [" + pvl.
fileName() +
"]";
@ User
A type of error that could only have occurred due to a mistake on the user's part (e....
Adds specific functionality to C++ strings.
Seed points using a grid.
int p_majorAxisPts
Number of points to place on major axis.
LimitPolygonSeeder(Pvl &pvl)
Construct a LimitPolygonSeeder algorithm.
int p_minorAxisPts
Number of points to place on minor axis.
virtual PvlGroup PluginParameters(QString grpName)
Plugin parameters.
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.
virtual void Parse(Pvl &pvl)
Parse the LimitPolygonSeeder spicific parameters from the PVL.
std::vector< geos::geom::Point * > Seed(const geos::geom::MultiPolygon *mp)
Seed a polygon with points.
This class is used as the base class for all PolygonSeeder objects.
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.
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...
bool hasKeyword(const QString &name) const
Check to see if a keyword exists.
QString fileName() const
Returns the filename used to initialise the Pvl object.
void addKeyword(const PvlKeyword &keyword, const InsertMode mode=Append)
Add a keyword to the container.
void deleteKeyword(const QString &name)
Remove a specified keyword.
Contains multiple PvlContainers.
Container for cube-like labels.
A single keyword-value pair.
@ Traverse
Search child objects.
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
This is free and unencumbered software released into the public domain.
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.