USGS

Isis 3.0 Developer's Reference (API)

Home

Isis::PolygonTools Class Reference
[Utility]

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

#include <PolygonTools.h>

List of all members.

Public Member Functions

 PolygonTools ()
 ~PolygonTools ()

Static Public Member Functions

static geos::geom::MultiPolygon * LatLonToXY (const geos::geom::MultiPolygon &lonLatPoly, Projection *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, Projection *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 std::string ToGML (const geos::geom::MultiPolygon *mpolygon, std::string idString="0")
 Write out the polygon with gml header.
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 std::string 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.

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

Constructor & Destructor Documentation

Isis::PolygonTools::PolygonTools (  ) 
Isis::PolygonTools::~PolygonTools (  ) 

Member Function Documentation

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:
mpolygon The 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

References Isis::globalFactory.

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:
mpolygon The 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

References Isis::globalFactory.

Referenced by Isis::Chip::SetClipPolygon().

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:
lineString The 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.

References Isis::globalFactory.

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:
multiPoly The original geos::geom::MultiPolygon to be despiked.

References _FILEINFO_, Isis::iException::Clear(), Despike(), g, Isis::globalFactory, Isis::iException::Message(), poly(), and Isis::iException::Programmer.

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*

References MakeMultiPolygon().

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

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*

References _FILEINFO_, Isis::iException::Message(), and Isis::iException::Programmer.

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

bool Isis::PolygonTools::Equal ( const double  d1,
const double  d2 
) [static]
bool Isis::PolygonTools::Equal ( const geos::geom::Coordinate &  coord1,
const geos::geom::Coordinate &  coord2 
) [static]

References Equal().

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

References Equal().

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

References Equal().

bool Isis::PolygonTools::Equal ( const geos::geom::MultiPolygon *  poly1,
const geos::geom::MultiPolygon *  poly2 
) [static]
geos::geom::MultiPolygon * Isis::PolygonTools::FixSeam ( const geos::geom::Polygon *  polyA,
const geos::geom::Polygon *  polyB 
) [static]
geos::geom::MultiPolygon * Isis::PolygonTools::FixSeam ( const geos::geom::MultiPolygon *  poly  )  [static]

References Isis::globalFactory, and size.

Referenced by To180().

std::string 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:
geom The geometry to test which type it really is
Returns:
std::string

Referenced by ReducePrecision().

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:
geom1 First geometry to intersect
geom2 Second geometry to intersect
Returns:
geos::geom::Geometry* geom1 intersected with geom2

References _FILEINFO_, Isis::iException::Message(), and Isis::iException::Programmer.

Referenced by Isis::ImageOverlapSet::FindAllOverlaps(), and To180().

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:
lonLatPolygon A multipolygon in (Lon,Lat order)
ugm The 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).

References _FILEINFO_, Despike(), g, Isis::globalFactory, Isis::UniversalGroundMap::Line(), Isis::iException::Message(), poly(), Isis::iException::Programmer, Isis::UniversalGroundMap::Sample(), and Isis::UniversalGroundMap::SetUniversalGround().

geos::geom::MultiPolygon * Isis::PolygonTools::LatLonToXY ( const geos::geom::MultiPolygon &  lonLatPolygon,
Projection 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:
lonLatPolygon A multipolygon in (Lon,Lat) order
projection The 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).

References _FILEINFO_, Despike(), g, Isis::globalFactory, Isis::iException::Message(), poly(), Isis::iException::Programmer, Isis::Projection::SetGround(), Isis::Projection::XCoord(), and Isis::Projection::YCoord().

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:
geom The geometry to be converted into a multipolygon

References Isis::globalFactory.

Referenced by Despike(), Isis::ImageOverlapSet::FindAllOverlaps(), Isis::ImageOverlapSet::FindImageOverlaps(), FixSeam(), ReducePrecision(), and To180().

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:
num The original number
precision The new precision
Returns:
double The reduced precision number
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:
coord The coordinate to reduce precision on
precision The precision to reduce to
Returns:
geos::geom::Coordinate* The lower precision coordinate

References ReducePrecision().

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:
ring The linear ring to reduce precision on
precision The precision to reduce to
Returns:
geos::geom::LinearRing* The lower precision linear ring

References _FILEINFO_, Isis::iException::Clear(), Despike(), Isis::globalFactory, Isis::iException::Message(), Isis::iException::Programmer, and ReducePrecision().

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:
poly The polygon to reduce precision on
precision The precision to reduce to
Returns:
geos::geom::Polygon* The lower precision polygon

References _FILEINFO_, Isis::globalFactory, Isis::iException::Message(), Isis::iException::Programmer, and ReducePrecision().

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:
poly The MultiPolygon to reduce precision on
precision The precision to reduce to
Returns:
geos::geom::MultiPolygon* The lower precision MultiPolygon

References Isis::globalFactory, and ReducePrecision().

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:
geom The geometry to reduce precision on
precision The precision to reduce to
Returns:
geos::geom::Geometry* The lower precision geometry

References _FILEINFO_, GetGeometryName(), MakeMultiPolygon(), Isis::iException::Message(), and Isis::iException::Programmer.

Referenced by FixSeam(), and ReducePrecision().

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:
mpolygon The XY polygon to calculate the thickness of
Returns:
double The thikness of the provided polygon

References x, and y.

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

References _FILEINFO_, FixSeam(), Isis::globalFactory, Intersect(), MakeMultiPolygon(), Isis::iException::Message(), and Isis::iException::Programmer.

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

string Isis::PolygonTools::ToGML ( const geos::geom::MultiPolygon *  mpolygon,
std::string  idString = "0" 
) [static]

Write out the polygon with gml header.

Parameters:
[in] mpolygon Polygon with lat/lon vertices
idString mpolygon's Id
Returns:
istrean Returns the polygon with lon,lat lon,lat format vertices and GML header
geos::geom::MultiPolygon * Isis::PolygonTools::XYToLatLon ( const geos::geom::MultiPolygon &  xYPolygon,
Projection 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:
xYPolygon A multipolygon in (X,Y) order
projection The 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).

References _FILEINFO_, Despike(), g, Isis::globalFactory, Isis::Projection::Latitude(), Isis::Projection::Longitude(), Isis::iException::Message(), poly(), Isis::iException::Programmer, and Isis::Projection::SetWorld().


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