Isis 3 Programmer Reference
Isis::PolygonTools Class Reference

Provides various tools to work with geos multipolygons. More...

#include <PolygonTools.h>

Collaboration diagram for Isis::PolygonTools:
Collaboration graph

Static Public Member Functions

static geos::geom::MultiPolygon * LatLonToXY (const geos::geom::MultiPolygon &lonLatPoly, TProjection *proj)
 This method will return a geos::geom::MultiPolygon which contains the X/Y coordinates of the LonLat polygon.
 
static geos::geom::MultiPolygon * XYToLatLon (const geos::geom::MultiPolygon &xYPoly, TProjection *proj)
 This method will return a geos::geom::MultiPolygon which contains the (Lon,Lat) coordinates of the XY polygon.
 
static geos::geom::MultiPolygon * LatLonToSampleLine (const geos::geom::MultiPolygon &lonLatPoly, UniversalGroundMap *ugm)
 This method will return a geos::geom::MultiPolygon which contains the sample/line coordinates of the Lat/Lon polygon.
 
static geos::geom::MultiPolygon * CopyMultiPolygon (const geos::geom::MultiPolygon *mpolygon)
 This static method will create a deep copy of a geos::geom::MultiPolygon.
 
static geos::geom::MultiPolygon * CopyMultiPolygon (const geos::geom::MultiPolygon &mpolygon)
 This static method will create a deep copy of a geos::geom::MultiPolygon.
 
static geos::geom::MultiPolygon * Despike (const geos::geom::Geometry *geom)
 This method attempts to convert the geom to a MultiPolygon and then despike it.
 
static geos::geom::MultiPolygon * Despike (const geos::geom::MultiPolygon *multiPoly)
 Create a new multipolygon without the spikes associated with some versions of the geos package.
 
static geos::geom::LinearRing * Despike (const geos::geom::LineString *linearRing)
 Create a new LinearRing from a LineString without the spikes associated with some versions of the geos package.
 
static geos::geom::MultiPolygon * To180 (geos::geom::MultiPolygon *poly360)
 Convert polygon coordinates from 360 system to 180.
 
static QString ToGML (const geos::geom::MultiPolygon *mpolygon, QString idString=QString("0"), QString schema=QString(""))
 Return the polygon with gml header.
 
static QString GMLSchema ()
 Return the gml schema.
 
static double Thickness (const geos::geom::MultiPolygon *mpolygon)
 Calculates the thickness of a polygon using: thickness = area / max(Xextent,Yextent)**2 The provided polygon SHOULD be an XY polygon, not a lat/lon polygon, but this is not enforced.
 
static geos::geom::Geometry * Intersect (const geos::geom::Geometry *geom1, const geos::geom::Geometry *geom2)
 This applies the geos Intersect operator.
 
static geos::geom::Geometry * Difference (const geos::geom::Geometry *geom1, const geos::geom::Geometry *geom2)
 This method is used to subtract two polygons.
 
static geos::geom::MultiPolygon * MakeMultiPolygon (const geos::geom::Geometry *geom)
 Make a geos::geom::MultiPolygon out of the components of the argument.
 
static QString GetGeometryName (const geos::geom::Geometry *geom)
 This method returns the name of the type of geometry passed in.
 
static bool Equal (const geos::geom::MultiPolygon *poly1, const geos::geom::MultiPolygon *poly2)
 
static bool Equal (const geos::geom::Polygon *poly1, const geos::geom::Polygon *poly2)
 
static bool Equal (const geos::geom::LineString *lineString1, const geos::geom::LineString *lineString2)
 
static bool Equal (const geos::geom::Coordinate &coord1, const geos::geom::Coordinate &coord2)
 
static bool Equal (const double d1, const double d2)
 
static geos::geom::MultiPolygon * FixSeam (const geos::geom::MultiPolygon *poly)
 
static geos::geom::MultiPolygon * FixSeam (const geos::geom::Polygon *polyA, const geos::geom::Polygon *polyB)
 
static geos::geom::Geometry * ReducePrecision (const geos::geom::Geometry *geom, unsigned int precision)
 This method reduces the precision of the geometry to precision significant figures.
 
static geos::geom::MultiPolygon * ReducePrecision (const geos::geom::MultiPolygon *poly, unsigned int precision)
 This method reduces the precision of the MultiPolygon to precision significant figures.
 
static geos::geom::Polygon * ReducePrecision (const geos::geom::Polygon *poly, unsigned int precision)
 This method reduces the precision of the Polygon to precision significant figures.
 
static geos::geom::LinearRing * ReducePrecision (const geos::geom::LinearRing *ring, unsigned int precision)
 This method reduces the precision of the LinearRing to precision significant figures.
 
static geos::geom::Coordinate * ReducePrecision (const geos::geom::Coordinate *coord, unsigned int precision)
 This method reduces the precision of the coordinate to precision significant figures.
 
static double ReducePrecision (double num, unsigned int precision)
 This method will reduce the decimal precision of the inputted num to precision decimal places.
 
static geos::geom::MultiPolygon * FixPolePolygon (const geos::geom::MultiPolygon *polePolygon, UniversalGroundMap *ugm)
 
static geos::geom::MultiPolygon * SplitPolygonOn360 (const geos::geom::Polygon *inPoly)
 If the cube crosses the 0/360 boundary and does not include a pole, this will divide the polygon into multiple polygons (one for each time the polygon crosses the boundry and back).
 

Static Private Member Functions

static bool IsSpiked (geos::geom::Coordinate first, geos::geom::Coordinate middle, geos::geom::Coordinate last)
 Returns true if the middle point is spiked.
 
static bool TestSpiked (geos::geom::Coordinate first, geos::geom::Coordinate middle, geos::geom::Coordinate last)
 Used by IsSpiked to directionally test (first/last matter) the spike.
 
static geos::geom::Geometry * FixGeometry (const geos::geom::Geometry *geom)
 This method attempts to seek out known problems with geometries and repair them.
 
static geos::geom::MultiPolygon * FixGeometry (const geos::geom::MultiPolygon *poly)
 This applies the LinearRing FixGeometry method to all of the interior and exterior rings in the multipolygon.
 
static geos::geom::Polygon * FixGeometry (const geos::geom::Polygon *poly)
 
static geos::geom::LinearRing * FixGeometry (const geos::geom::LinearRing *ring)
 One problem we know of seems to happen when two points are right on top of each other.
 
static geos::geom::Geometry * Operate (const geos::geom::Geometry *geom1, const geos::geom::Geometry *geom2, unsigned int opcode)
 
static int DecimalPlace (double)
 This returns the location of the decimal place in the number.
 

Private Attributes

geos::geom::MultiPolygon * p_polygons
 

Detailed Description

Provides various tools to work with geos multipolygons.

This class provides methods to that work with geos multipolygons. This includes functions to convert from one coordinate system to another and to copy multipolygons.

Author
2006-08-07 Stuart Sides
History

2006-08-07 Stuart Sides - Original version

2007-05-04 Robert Sucharski - Moved the method to output WKT from ImagePlygon class to this class. Also added method to output GML format.

2007-11-09 Tracie Sucharski - Remove ToWKT method, geos now has a method (toString) to return a WKT string. Added To180 method which converts polygon coordinates from 0/360 system to -180/180 system. If polygon was split because it crossed the 0/360 seam, the two polys coordinates are converted then merged.

2008-06-18 Steven Koechle - Fixed Documentation Errors

2008-08-18 Steven Lambright - Updated to work with geos3.0.0 instead of geos2. Mostly namespace changes.

2008-11-10 Christopher Austin - Added Thickness()

2008-11-25 Steven Koechle - Moved Despike Methods from ImageOverlapSet to PolygonTools

2008-12-01 Steven Lambright - Changed the Despike algorithm to be in more methods to clean it up, added the middle point to beginning/end of line tests to keep more data. Added "IsSpiked" and "TestSpiked."

2008-12-10 Steven Koechle - Moved MakeMultiPolygon Method from ImageOverlapSet to PolygonTools

2008-12-12 Steven Lambright - Bug fixes, cleaned up Despike/MakeMultiPolygon

2008-12-12 Steven Lambright - Renamed methods, polygon conversion methods now throw an iException if they fail, updated Despike(...)'s algorithm

2008-12-19 Steven Lambright - updated Despike(...)'s algorithm

2008-12-19 Steven Lambright - Added error to Despike (empty or invalid result).

2009-01-16 Steven Koechle - Fixed Memory Leak in LatLonToSampleLine method

2009-01-23 Steven Lambright - Added precision reduction algorithms and made the Difference and Intersect operators work in a more generic way by calling the new method Operate(...).

2009-01-28 Steven Lambright - Fixed memory leaks

2009-02-02 Stacy Alley - updated the To180 method to handle 360 multi polys that cross the -180/180 boundry. We need to return >1 polygon for these type of cases.

2009-01-28 Steven Lambright - Fixed bug in Operate(...) method when reducing precision

2009-06-09 Steven Lambright - Added a check to Equal(double,double). This never caused a problem but could have.

2011-05-31 Steven Lambright - Improved To180 (not finished). The remaining work is to remove the 0 seam from the polygons.

2013-02-26 Stuart Sides - Modified the output of GML and GML schema

2013-08-12 Stuart Sides - Added SplitPolygonOn360 and FixPolePolygon methods. Code was extracted from the ImagePolygon class. References #1604.

2017-08-18 Tyler Wilson, Summer Stapleton, Ian Humphrey - Changed auto_ptr references to unique_ptr so that this class compiles with no warnings for C++14. References #4809.

Definition at line 120 of file PolygonTools.h.

Member Function Documentation

◆ CopyMultiPolygon() [1/2]

geos::geom::MultiPolygon * Isis::PolygonTools::CopyMultiPolygon ( const geos::geom::MultiPolygon & mpolygon)
static

This static method will create a deep copy of a geos::geom::MultiPolygon.

The caller assumes responsibility for the memory associated with the new polygon.

Parameters
mpolygonThe multipolygon to be copied.
Returns
Returns a pointer to a multipolygon which is a deep copy of the input multipolygon. This is necessary because at the time of writing the geos package does not create multipolygons when copying. It produdes geometryCollections

Definition at line 375 of file PolygonTools.cpp.

◆ CopyMultiPolygon() [2/2]

geos::geom::MultiPolygon * Isis::PolygonTools::CopyMultiPolygon ( const geos::geom::MultiPolygon * mpolygon)
static

This static method will create a deep copy of a geos::geom::MultiPolygon.

The caller assumes responsibility for the memory associated with the new polygon.

Parameters
mpolygonThe multipolygon to be copied.
Returns
Returns a pointer to a multipolygon which is a deep copy of the input multipolygon. This is necessary because at the time of writing the geos package does not create multipolygons when copying. It produdes geometryCollections

Definition at line 353 of file PolygonTools.cpp.

Referenced by Isis::Chip::SetClipPolygon(), Isis::InterestOperator::SetClipPolygon(), Isis::ImageOverlap::SetPolygon(), and Isis::ImageOverlap::SetPolygon().

◆ DecimalPlace()

int Isis::PolygonTools::DecimalPlace ( double num)
staticprivate

This returns the location of the decimal place in the number.

This method is used as a helper method for FixGeometry(...), to help figure out how close two numbers are in significant figures.

1.0 = decimal place 1, .1 = decimal place 0, 10.0 = decimal place 2

Parameters
numThe number to find the decimal place in
Returns
int The decimal place relative to the first significant digit

Definition at line 1309 of file PolygonTools.cpp.

Referenced by FixGeometry(), and ReducePrecision().

◆ Despike() [1/3]

geos::geom::MultiPolygon * Isis::PolygonTools::Despike ( const geos::geom::Geometry * geom)
static

This method attempts to convert the geom to a MultiPolygon and then despike it.

This method does not take ownership of the argument geom. The ownership of the return value is given to the caller.

Parameters
geom
Returns
geos::geom::MultiPolygon*

Definition at line 641 of file PolygonTools.cpp.

References Despike(), and MakeMultiPolygon().

Referenced by Despike(), Despike(), Isis::ImageOverlapSet::DespikeLonLatOverlaps(), Isis::ProcessPolygons::FillPolygon(), Isis::ImageOverlapSet::FindAllOverlaps(), Isis::ImageOverlapSet::FindImageOverlaps(), LatLonToSampleLine(), LatLonToXY(), ReducePrecision(), Isis::ImageOverlapSet::SetPolygon(), and XYToLatLon().

◆ Despike() [2/3]

geos::geom::LinearRing * Isis::PolygonTools::Despike ( const geos::geom::LineString * lineString)
static

Create a new LinearRing from a LineString without the spikes associated with some versions of the geos package.

These "spikes" are created when intersections and differences are calculated.

Parameters
lineStringThe original geos::geom::lineString to be despiked. This can be the lineString associated with the outside of a polygon or one of its holes.
Returns
A pointer to a LinearRing. If the despiking causes the number of unique verticies to fall below 3, an empty LinearRing will be returned.

Definition at line 765 of file PolygonTools.cpp.

References IsSpiked().

◆ Despike() [3/3]

geos::geom::MultiPolygon * Isis::PolygonTools::Despike ( const geos::geom::MultiPolygon * multiPoly)
static

Create a new multipolygon without the spikes associated with some versions of the geos package.

This method does not take ownership of the argument multiPoly. The ownership of the return value is given to the caller.

Parameters
multiPolyThe original geos::geom::MultiPolygon to be despiked.

Definition at line 662 of file PolygonTools.cpp.

References Despike(), FixGeometry(), and Isis::IException::Programmer.

◆ Difference()

geos::geom::Geometry * Isis::PolygonTools::Difference ( const geos::geom::Geometry * geom1,
const geos::geom::Geometry * geom2 )
static

This method is used to subtract two polygons.

Parameters
geom1
geom2
Returns
geos::geom::Geometry*

Definition at line 1337 of file PolygonTools.cpp.

References Isis::IException::Programmer.

Referenced by Isis::ImageOverlapSet::FindAllOverlaps().

◆ Equal() [1/5]

bool Isis::PolygonTools::Equal ( const double d1,
const double d2 )
static

Definition at line 1952 of file PolygonTools.cpp.

◆ Equal() [2/5]

bool Isis::PolygonTools::Equal ( const geos::geom::Coordinate & coord1,
const geos::geom::Coordinate & coord2 )
static

Definition at line 1941 of file PolygonTools.cpp.

◆ Equal() [3/5]

bool Isis::PolygonTools::Equal ( const geos::geom::LineString * lineString1,
const geos::geom::LineString * lineString2 )
static

Definition at line 1910 of file PolygonTools.cpp.

◆ Equal() [4/5]

bool Isis::PolygonTools::Equal ( const geos::geom::MultiPolygon * poly1,
const geos::geom::MultiPolygon * poly2 )
static

Definition at line 1836 of file PolygonTools.cpp.

◆ Equal() [5/5]

bool Isis::PolygonTools::Equal ( const geos::geom::Polygon * poly1,
const geos::geom::Polygon * poly2 )
static

Definition at line 1869 of file PolygonTools.cpp.

◆ FixGeometry() [1/4]

geos::geom::Geometry * Isis::PolygonTools::FixGeometry ( const geos::geom::Geometry * geom)
staticprivate

This method attempts to seek out known problems with geometries and repair them.

Currently the only known problem is when two points lie on top of each other, which is a result of various operations. Currently only LinearRings and MultiPolygons are supported.

Parameters
geomThe geometry to be fixed
Returns
geos::geom::Geometry* A fixed geometry.

Definition at line 1095 of file PolygonTools.cpp.

References FixGeometry(), GetGeometryName(), MakeMultiPolygon(), and Isis::IException::Programmer.

Referenced by Despike(), FixGeometry(), and FixGeometry().

◆ FixGeometry() [2/4]

geos::geom::LinearRing * Isis::PolygonTools::FixGeometry ( const geos::geom::LinearRing * ring)
staticprivate

One problem we know of seems to happen when two points are right on top of each other.

We're going to look for those points and remove them, then see if the linear ring is valid. Assumes input fails its isValid() test.

Point end up on top of each other for two (2) known reasons. First, Despike removes a spike that simply went back and forth. Second, the geos Intersect operator can return invalid polygons because of this problem. Every geometry thus far is being broken down into LinearRings and this method cleans those up.

Parameters
ringAn invalid linear ring
Returns
geos::geom::LinearRing* A possibly valid linear ring

Definition at line 1209 of file PolygonTools.cpp.

References DecimalPlace(), and Isis::IException::Programmer.

◆ FixGeometry() [3/4]

geos::geom::MultiPolygon * Isis::PolygonTools::FixGeometry ( const geos::geom::MultiPolygon * poly)
staticprivate

This applies the LinearRing FixGeometry method to all of the interior and exterior rings in the multipolygon.

See FixGeometry(LinearRing) for more explanation.

Parameters
polyAn invalid multipolygon
Returns
geos::geom::MultiPolygon* A possibly valid multipolygon

Definition at line 1123 of file PolygonTools.cpp.

References FixGeometry().

◆ FixGeometry() [4/4]

geos::geom::Polygon * Isis::PolygonTools::FixGeometry ( const geos::geom::Polygon * poly)
staticprivate

Definition at line 1146 of file PolygonTools.cpp.

◆ FixSeam() [1/2]

geos::geom::MultiPolygon * Isis::PolygonTools::FixSeam ( const geos::geom::MultiPolygon * poly)
static

Definition at line 1504 of file PolygonTools.cpp.

◆ FixSeam() [2/2]

geos::geom::MultiPolygon * Isis::PolygonTools::FixSeam ( const geos::geom::Polygon * polyA,
const geos::geom::Polygon * polyB )
static

Definition at line 1428 of file PolygonTools.cpp.

◆ GetGeometryName()

QString Isis::PolygonTools::GetGeometryName ( const geos::geom::Geometry * geom)
static

This method returns the name of the type of geometry passed in.

This is useful for error reporting (i.e. Geometry Type [...] not supported).

Parameters
geomThe geometry to test which type it really is
Returns
QString

Definition at line 1812 of file PolygonTools.cpp.

Referenced by FixGeometry(), and ReducePrecision().

◆ GMLSchema()

QString Isis::PolygonTools::GMLSchema ( )
static

Return the gml schema.

Returns
QString Returns the polygon with lon,lat lon,lat format vertices and GML header

Definition at line 460 of file PolygonTools.cpp.

◆ Intersect()

geos::geom::Geometry * Isis::PolygonTools::Intersect ( const geos::geom::Geometry * geom1,
const geos::geom::Geometry * geom2 )
static

This applies the geos Intersect operator.

Due to "BinaryOp.h" having implementations in it, only one Isis object may perform these operations. If that file is included anywhere else in Isis, the library will not build! Please use this method to intersect two geometries. If the geometry is a linear ring or multi polygon, corrections may be applied if the geos intersection operator fails.

Parameters
geom1First geometry to intersect
geom2Second geometry to intersect
Returns
geos::geom::Geometry* geom1 intersected with geom2

Definition at line 966 of file PolygonTools.cpp.

References Isis::IException::Programmer.

Referenced by Isis::ImageOverlapSet::FindAllOverlaps(), Isis::InterestOperator::FindOverlapByImageFootPrint(), Isis::ImagePolygon::Fix360Poly(), SplitPolygonOn360(), and To180().

◆ IsSpiked()

bool Isis::PolygonTools::IsSpiked ( geos::geom::Coordinate first,
geos::geom::Coordinate middle,
geos::geom::Coordinate last )
staticprivate

Returns true if the middle point is spiked.

Parameters
first
middle
last
Returns
bool Returns true if middle point is spiked

Definition at line 852 of file PolygonTools.cpp.

References TestSpiked().

Referenced by Despike().

◆ LatLonToSampleLine()

geos::geom::MultiPolygon * Isis::PolygonTools::LatLonToSampleLine ( const geos::geom::MultiPolygon & lonLatPolygon,
UniversalGroundMap * ugm )
static

This method will return a geos::geom::MultiPolygon which contains the sample/line coordinates of the Lat/Lon polygon.

The Lat/Lon polygon must have coordinates (x direction, y direction) or (Lon,Lat).

Parameters
lonLatPolygonA multipolygon in (Lon,Lat order)
ugmThe UniversalGroundMap to be used to convert the Lons and Lat to Samples and Lines
Returns
Returns a multipolygon which is the result of converting the input multipolygon from (Lon,Lat) to (Sample,Line).

Definition at line 244 of file PolygonTools.cpp.

References Despike(), Isis::IException::Programmer, and Isis::IException::Unknown.

Referenced by Isis::InterestOperator::InterestByPoint().

◆ LatLonToXY()

geos::geom::MultiPolygon * Isis::PolygonTools::LatLonToXY ( const geos::geom::MultiPolygon & lonLatPolygon,
TProjection * projection )
static

This method will return a geos::geom::MultiPolygon which contains the X/Y coordinates of the LonLat polygon.

The Lat/Lon polygon must have coordinates (x direction, y direction) or (Lon,Lat).

Parameters
lonLatPolygonA multipolygon in (Lon,Lat) order
projectionThe projection to be used to convert the Lons and Lat to X and Y
Returns
Returns a multipolygon which is the result of converting the input multipolygon from (Lon,Lat) to (X,Y).

Definition at line 46 of file PolygonTools.cpp.

References Despike(), Isis::IException::Programmer, Isis::TProjection::SetGround(), Isis::Projection::XCoord(), and Isis::Projection::YCoord().

◆ MakeMultiPolygon()

geos::geom::MultiPolygon * Isis::PolygonTools::MakeMultiPolygon ( const geos::geom::Geometry * geom)
static

Make a geos::geom::MultiPolygon out of the components of the argument.

Create a new geos::geom::MultiPolygon out of the general geometry that is passed in. This can be useful after an intersection or some other operator on two MultiPolygons. The result of the operator is often a collection of different geometries such as points, lines, polygons... This member extracts all polygons and multipolygons into a new multipolygon. The original geometry is deleted. The resulting multipolygon is not necessarily valid.

Parameters
geomThe geometry to be converted into a multipolygon

Definition at line 1372 of file PolygonTools.cpp.

References MakeMultiPolygon().

Referenced by Isis::Chip::Chip(), Isis::Image::createFootprint(), Isis::Shape::createFootprint(), Despike(), Isis::Image::XmlHandler::endElement(), Isis::ProcessPolygons::FillPolygon(), Isis::ImageOverlapSet::FindAllOverlaps(), Isis::ImageOverlapSet::FindImageOverlaps(), Isis::InterestOperator::FindOverlapByImageFootPrint(), Isis::ImagePolygon::Fix360Poly(), FixGeometry(), Isis::UniversalGroundMap::GroundRange(), Isis::ImageOverlap::ImageOverlap(), Isis::ImagePolygon::ImagePolygon(), Isis::Image::initQuickFootprint(), MakeMultiPolygon(), Isis::Chip::operator=(), ReducePrecision(), Isis::ImageOverlapSet::SetPolygon(), SplitPolygonOn360(), and To180().

◆ Operate()

geos::geom::Geometry * Isis::PolygonTools::Operate ( const geos::geom::Geometry * geom1,
const geos::geom::Geometry * geom2,
unsigned int opcode )
staticprivate

Definition at line 987 of file PolygonTools.cpp.

◆ ReducePrecision() [1/6]

geos::geom::Coordinate * Isis::PolygonTools::ReducePrecision ( const geos::geom::Coordinate * coord,
unsigned int precision )
static

This method reduces the precision of the coordinate to precision significant figures.

Parameters
coordThe coordinate to reduce precision on
precisionThe precision to reduce to
Returns
geos::geom::Coordinate* The lower precision coordinate

Definition at line 1762 of file PolygonTools.cpp.

References ReducePrecision().

◆ ReducePrecision() [2/6]

geos::geom::Geometry * Isis::PolygonTools::ReducePrecision ( const geos::geom::Geometry * geom,
unsigned int precision )
static

This method reduces the precision of the geometry to precision significant figures.

Parameters
geomThe geometry to reduce precision on
precisionThe precision to reduce to
Returns
geos::geom::Geometry* The lower precision geometry

Definition at line 1564 of file PolygonTools.cpp.

References GetGeometryName(), MakeMultiPolygon(), Isis::IException::Programmer, and ReducePrecision().

Referenced by ReducePrecision(), ReducePrecision(), ReducePrecision(), ReducePrecision(), and ReducePrecision().

◆ ReducePrecision() [3/6]

geos::geom::LinearRing * Isis::PolygonTools::ReducePrecision ( const geos::geom::LinearRing * ring,
unsigned int precision )
static

This method reduces the precision of the LinearRing to precision significant figures.

Parameters
ringThe linear ring to reduce precision on
precisionThe precision to reduce to
Returns
geos::geom::LinearRing* The lower precision linear ring

Definition at line 1696 of file PolygonTools.cpp.

References Despike(), Isis::IException::Programmer, and ReducePrecision().

◆ ReducePrecision() [4/6]

geos::geom::MultiPolygon * Isis::PolygonTools::ReducePrecision ( const geos::geom::MultiPolygon * poly,
unsigned int precision )
static

This method reduces the precision of the MultiPolygon to precision significant figures.

Parameters
polyThe MultiPolygon to reduce precision on
precisionThe precision to reduce to
Returns
geos::geom::MultiPolygon* The lower precision MultiPolygon

Definition at line 1598 of file PolygonTools.cpp.

References ReducePrecision().

◆ ReducePrecision() [5/6]

geos::geom::Polygon * Isis::PolygonTools::ReducePrecision ( const geos::geom::Polygon * poly,
unsigned int precision )
static

This method reduces the precision of the Polygon to precision significant figures.

Parameters
polyThe polygon to reduce precision on
precisionThe precision to reduce to
Returns
geos::geom::Polygon* The lower precision polygon

Definition at line 1632 of file PolygonTools.cpp.

References Isis::IException::Programmer, and ReducePrecision().

◆ ReducePrecision() [6/6]

double Isis::PolygonTools::ReducePrecision ( double num,
unsigned int precision )
static

This method will reduce the decimal precision of the inputted num to precision decimal places.

Parameters
numThe original number
precisionThe new precision
Returns
double The reduced precision number

Definition at line 1781 of file PolygonTools.cpp.

References DecimalPlace().

◆ SplitPolygonOn360()

geos::geom::MultiPolygon * Isis::PolygonTools::SplitPolygonOn360 ( const geos::geom::Polygon * inPoly)
static

If the cube crosses the 0/360 boundary and does not include a pole, this will divide the polygon into multiple polygons (one for each time the polygon crosses the boundry and back).

These polygons are put into a geos Multipolygon. If the cube does not cross the 0/360 boundary then the returned Multipolygon will contain a single Polygon.

Parameters
polygonprojection The projection to be used to convert the Xs and Ys to Lon and Lats
Returns
Returns a pointer to a multipolygon which is the result of splitting the input parameter polygon every where it crosses the 0/360 longitude boundry. The caller assumes responsibility for deleting the returned multipolygon

Definition at line 1997 of file PolygonTools.cpp.

References Intersect(), MakeMultiPolygon(), and Isis::IException::Unknown.

Referenced by Isis::ProcessGroundPolygons::Rasterize(), and Isis::PixelFOV::splitIfov().

◆ TestSpiked()

bool Isis::PolygonTools::TestSpiked ( geos::geom::Coordinate first,
geos::geom::Coordinate middle,
geos::geom::Coordinate last )
staticprivate

Used by IsSpiked to directionally test (first/last matter) the spike.

This method tests for spikes.

The first/last coordinate matter. If the line between the first point and middle point are the base of a triangle, with the last point as the tip, then if the base of this triangle is substantially larger than the height we have a spike (fig A). If the middle point is near the edges of the triangle, however, this is valid data (fig B/C).

(A) (B) (C) 1 1 1-2 | | | | | | 3-| | | | | | | | | 2 2-3 3

*1 is start, 2 is middle, 3 is end

Spikes are a problem because when we convert from lat/lons to meters the points get shifted relative to each other (lower points might be shifted more right then higher points, for example).

Parameters
first
middle
last
Returns
bool Returns true if middle point spiked given this first/last pt

Definition at line 886 of file PolygonTools.cpp.

Referenced by IsSpiked().

◆ Thickness()

double Isis::PolygonTools::Thickness ( const geos::geom::MultiPolygon * mpolygon)
static

Calculates the thickness of a polygon using: thickness = area / max(Xextent,Yextent)**2 The provided polygon SHOULD be an XY polygon, not a lat/lon polygon, but this is not enforced.

Parameters
mpolygonThe XY polygon to calculate the thickness of
Returns
double The thikness of the provided polygon

Definition at line 619 of file PolygonTools.cpp.

◆ To180()

geos::geom::MultiPolygon * Isis::PolygonTools::To180 ( geos::geom::MultiPolygon * poly360)
static

Convert polygon coordinates from 360 system to 180.

Parameters
[in]poly360(geos::geom::MultiPolygon)poly split by 360 boundary
Returns
geos::geom::MultiPolygon Returns a 180 multi-polygon

Definition at line 526 of file PolygonTools.cpp.

References Intersect(), MakeMultiPolygon(), and Isis::IException::Programmer.

Referenced by Isis::MosaicSceneItem::reproject().

◆ ToGML()

QString Isis::PolygonTools::ToGML ( const geos::geom::MultiPolygon * mpolygon,
QString idString = QString("0"),
QString schema = QString("") )
static

Return the polygon with gml header.

Parameters
[in]mpolygonPolygon with lat/lon vertices
idStringmpolygon's Id
Returns
QString Returns the polygon with lon,lat lon,lat format vertices and GML header

Definition at line 393 of file PolygonTools.cpp.

◆ XYToLatLon()

geos::geom::MultiPolygon * Isis::PolygonTools::XYToLatLon ( const geos::geom::MultiPolygon & xYPolygon,
TProjection * projection )
static

This method will return a geos::geom::MultiPolygon which contains the (Lon,Lat) coordinates of the XY polygon.

The Lat/Lon polygon will have coordinates (x direction, y direction) or (Lon,Lat).

Parameters
xYPolygonA multipolygon in (X,Y) order
projectionThe projection to be used to convert the Xs and Ys to Lon and Lats
Returns
Returns a multipolygon which is the result of converting the input multipolygon from (X,Y) to (Lon,Lat).

Definition at line 152 of file PolygonTools.cpp.

References Despike(), Isis::TProjection::Latitude(), Isis::TProjection::Longitude(), Isis::IException::Programmer, and Isis::Projection::SetWorld().

Member Data Documentation

◆ p_polygons

geos::geom::MultiPolygon* Isis::PolygonTools::p_polygons
private

Definition at line 213 of file PolygonTools.h.


The documentation for this class was generated from the following files: