|
Isis 3.0 Object Programmers' Reference |
Home |
#include <PolygonTools.h>
Collaboration diagram for Isis::PolygonTools:

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.
For internal use only.
Definition at line 122 of file PolygonTools.h.
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") |
| 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::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 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) |
| This method tests for spikes. | |
| 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 |
| 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.
| mpolygon | The multipolygon to be copied. |
Definition at line 368 of file PolygonTools.cpp.
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.
| mpolygon | The multipolygon to be copied. |
Definition at line 346 of file PolygonTools.cpp.
References Isis::globalFactory.
Referenced by Isis::InterestOperator::SetClipPolygon(), Isis::Chip::SetClipPolygon(), and Isis::ImageOverlap::SetPolygon().
| int Isis::PolygonTools::DecimalPlace | ( | double | num | ) | [static, private] |
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
| num | The number to find the decimal place in |
Definition at line 1233 of file PolygonTools.cpp.
Referenced by Equal(), FixGeometry(), and ReducePrecision().
| 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.
| 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. |
Definition at line 711 of file PolygonTools.cpp.
References Isis::globalFactory, and IsSpiked().
| 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.
| multiPoly | The original geos::geom::MultiPolygon to be despiked. |
Definition at line 606 of file PolygonTools.cpp.
References _FILEINFO_, Despike(), e, FixGeometry(), g, Isis::globalFactory, Isis::iException::Message(), and poly().
| 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.
| geom |
Definition at line 586 of file PolygonTools.cpp.
References MakeMultiPolygon().
Referenced by Despike(), Isis::ImageOverlapSet::DespikeLonLatOverlaps(), Isis::ImageOverlapSet::FindAllOverlaps(), Isis::ImageOverlapSet::FindImageOverlaps(), LatLonToSampleLine(), LatLonToXY(), ReducePrecision(), Isis::ImageOverlapSet::SetPolygon(), 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.
| geom1 | ||
| geom2 |
Definition at line 1261 of file PolygonTools.cpp.
References _FILEINFO_, e, Isis::iException::Message(), and Operate().
Referenced by Isis::ImageOverlapSet::FindAllOverlaps().
| geos::geom::LinearRing * Isis::PolygonTools::FixGeometry | ( | const geos::geom::LinearRing * | ring | ) | [static, private] |
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.
| ring | An invalid linear ring |
Definition at line 1133 of file PolygonTools.cpp.
References _FILEINFO_, DecimalPlace(), difference(), Isis::globalFactory, and Isis::iException::Message().
| geos::geom::MultiPolygon * Isis::PolygonTools::FixGeometry | ( | const geos::geom::MultiPolygon * | poly | ) | [static, private] |
This applies the LinearRing FixGeometry method to all of the interior and exterior rings in the multipolygon.
See FixGeometry(LinearRing) for more explanation.
| poly | An invalid multipolygon |
Definition at line 1051 of file PolygonTools.cpp.
References FixGeometry(), and Isis::globalFactory.
| geos::geom::Geometry * Isis::PolygonTools::FixGeometry | ( | const geos::geom::Geometry * | geom | ) | [static, private] |
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.
| geom | The geometry to be fixed |
Definition at line 1023 of file PolygonTools.cpp.
References _FILEINFO_, GetGeometryName(), MakeMultiPolygon(), and Isis::iException::Message().
Referenced by Despike(), FixGeometry(), and Operate().
| 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).
| geom | The geometry to test which type it really is |
Definition at line 1576 of file PolygonTools.cpp.
Referenced by FixGeometry(), and 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.
| geom1 | First geometry to intersect | |
| geom2 | Second geometry to intersect |
Definition at line 898 of file PolygonTools.cpp.
References _FILEINFO_, e, Isis::iException::Message(), and Operate().
Referenced by Isis::ImageOverlapSet::FindAllOverlaps(), and Isis::ImagePolygon::Fix360Poly().
| bool Isis::PolygonTools::IsSpiked | ( | geos::geom::Coordinate | first, | |
| geos::geom::Coordinate | middle, | |||
| geos::geom::Coordinate | last | |||
| ) | [static, private] |
Returns true if the middle point is spiked.
| first | ||
| middle | ||
| last |
Definition at line 786 of file PolygonTools.cpp.
References TestSpiked().
Referenced by Despike().
| 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).
| lonLatPolygon | A multipolygon in (Lon,Lat order) | |
| ugm | The UniversalGroundMap to be used to convert the Lons and Lat to Samples and Lines |
Definition at line 254 of file PolygonTools.cpp.
References _FILEINFO_, Despike(), e, g, Isis::globalFactory, Isis::UniversalGroundMap::Line(), Isis::iException::Message(), poly(), 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).
| lonLatPolygon | A multipolygon in (Lon,Lat) order | |
| projection | The projection to be used to convert the Lons and Lat to X and Y |
Definition at line 60 of file PolygonTools.cpp.
References _FILEINFO_, Despike(), e, g, Isis::globalFactory, Isis::iException::Message(), poly(), Isis::Projection::SetGround(), Isis::Projection::XCoord(), and Isis::Projection::YCoord().
Referenced by Isis::StripPolygonSeeder::Seed(), Isis::LimitPolygonSeeder::Seed(), Isis::GridPolygonSeeder::SeedGrid(), and Isis::GridPolygonSeeder::SeedSubGrid().
| 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.
| geom | The geometry to be converted into a multipolygon |
Definition at line 1294 of file PolygonTools.cpp.
References Isis::globalFactory.
Referenced by Despike(), Isis::ImageOverlapSet::FindAllOverlaps(), Isis::ImageOverlapSet::FindImageOverlaps(), Isis::ImagePolygon::Fix360Poly(), FixGeometry(), Operate(), ReducePrecision(), and Isis::ImageOverlapSet::SetPolygon().
| 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.
| num | The original number | |
| precision | The new precision |
Definition at line 1551 of file PolygonTools.cpp.
References DecimalPlace().
| 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.
| coord | The coordinate to reduce precision on | |
| precision | The precision to reduce to |
Definition at line 1533 of file PolygonTools.cpp.
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.
| ring | The linear ring to reduce precision on | |
| precision | The precision to reduce to |
Definition at line 1469 of file PolygonTools.cpp.
References _FILEINFO_, Despike(), e, Isis::globalFactory, Isis::iException::Message(), 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.
| poly | The polygon to reduce precision on | |
| precision | The precision to reduce to |
Definition at line 1408 of file PolygonTools.cpp.
References _FILEINFO_, e, Isis::globalFactory, Isis::iException::Message(), 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.
| poly | The MultiPolygon to reduce precision on | |
| precision | The precision to reduce to |
Definition at line 1378 of file PolygonTools.cpp.
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.
| geom | The geometry to reduce precision on | |
| precision | The precision to reduce to |
Definition at line 1349 of file PolygonTools.cpp.
References _FILEINFO_, GetGeometryName(), MakeMultiPolygon(), and Isis::iException::Message().
Referenced by Operate(), and ReducePrecision().
| bool Isis::PolygonTools::TestSpiked | ( | geos::geom::Coordinate | first, | |
| geos::geom::Coordinate | middle, | |||
| geos::geom::Coordinate | last | |||
| ) | [static, private] |
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).
| first | ||
| middle | ||
| last |
Definition at line 818 of file PolygonTools.cpp.
References Isis::globalFactory, line, poly(), and tolerance.
Referenced by IsSpiked().
| 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.
| mpolygon | The XY polygon to calculate the thickness of |
Definition at line 564 of file PolygonTools.cpp.
| geos::geom::MultiPolygon * Isis::PolygonTools::To180 | ( | geos::geom::MultiPolygon * | poly360 | ) | [static] |
Convert polygon coordinates from 360 system to 180.
If polygon is split into 2 polygons due to crossing the 360 boundary, convert the polygon less than 360 to 180, then union together to merge the polygons. If the polygon was one poly, but crosses the -180/180 boundary after it's converted, then we need to split it up to 2 polygons before we return the multipolygon.
| [in] | poly360 | (geos::geom::MultiPolygon) polys split by 360 boundary |
Definition at line 446 of file PolygonTools.cpp.
References Isis::globalFactory.
Referenced by Qisis::MosaicItem::reproject().
| 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).
| xYPolygon | A multipolygon in (X,Y) order | |
| projection | The projection to be used to convert the Xs and Ys to Lon and Lats |
Definition at line 164 of file PolygonTools.cpp.
References _FILEINFO_, Despike(), e, g, Isis::globalFactory, Isis::Projection::Latitude(), Isis::Projection::Longitude(), Isis::iException::Message(), poly(), and Isis::Projection::SetWorld().