USGS

Isis 3.0 Developer's Reference (API)

Home

PolygonTools.h

Go to the documentation of this file.
00001 #ifndef Polygontools_h
00002 #define Polygontools_h
00003 
00025 #include "geos/geom/GeometryFactory.h"
00026 #include "geos/geom/MultiPolygon.h"
00027 #include "geos/geom/CoordinateSequence.h"
00028 
00029 namespace Isis {
00030 
00059   class UniversalGroundMap;
00060   class Projection;
00061 
00062   static geos::geom::GeometryFactory globalFactory;
00063 
00126   class PolygonTools {
00127 
00128     public:
00129       PolygonTools();
00130       ~PolygonTools();
00131 
00132       static geos::geom::MultiPolygon *LatLonToXY(
00133         const geos::geom::MultiPolygon &lonLatPoly, Projection *proj);
00134 
00135       static geos::geom::MultiPolygon *XYToLatLon(
00136         const geos::geom::MultiPolygon &xYPoly, Projection *proj);
00137 
00138       static geos::geom::MultiPolygon *LatLonToSampleLine(
00139         const geos::geom::MultiPolygon &lonLatPoly, UniversalGroundMap *ugm);
00140 
00141       // Return a deep copy of a multpolygon
00142       static geos::geom::MultiPolygon *CopyMultiPolygon(const geos::geom::MultiPolygon *mpolygon);
00143       static geos::geom::MultiPolygon *CopyMultiPolygon(const geos::geom::MultiPolygon &mpolygon);
00144 
00145       static geos::geom::MultiPolygon *Despike(const geos::geom::Geometry *geom);
00146       static geos::geom::MultiPolygon *Despike(const geos::geom::MultiPolygon *multiPoly);
00147       static geos::geom::LinearRing *Despike(const geos::geom::LineString *linearRing);
00148 
00149       //  Return polygon in -180/180 coordinated system and merge split polys
00150       static geos::geom::MultiPolygon *To180(geos::geom::MultiPolygon *poly360);
00151 
00152       //Return a polygon in GML format
00153       static std::string ToGML(const geos::geom::MultiPolygon *mpolygon, std::string idString = "0");
00154 
00155       //Return the thickness of a polygon
00156       static double Thickness(const geos::geom::MultiPolygon *mpolygon);
00157 
00158       static geos::geom::Geometry *Intersect(const geos::geom::Geometry *geom1, const geos::geom::Geometry *geom2);
00159       static geos::geom::Geometry *Difference(const geos::geom::Geometry *geom1, const geos::geom::Geometry *geom2);
00160 
00161       static geos::geom::MultiPolygon *MakeMultiPolygon(const geos::geom::Geometry *geom);
00162 
00163       static std::string GetGeometryName(const geos::geom::Geometry *geom);
00164 
00165       static bool Equal(const geos::geom::MultiPolygon *poly1, const geos::geom::MultiPolygon *poly2);
00166       static bool Equal(const geos::geom::Polygon *poly1, const geos::geom::Polygon *poly2);
00167       static bool Equal(const geos::geom::LineString *lineString1, const geos::geom::LineString *lineString2);
00168       static bool Equal(const geos::geom::Coordinate &coord1, const geos::geom::Coordinate &coord2);
00169       static bool Equal(const double d1, const double d2);
00170     private:
00171       geos::geom::MultiPolygon *p_polygons;
00172 
00174       static bool IsSpiked(geos::geom::Coordinate first, geos::geom::Coordinate middle, geos::geom::Coordinate last);
00176       static bool TestSpiked(geos::geom::Coordinate first, geos::geom::Coordinate middle, geos::geom::Coordinate last);
00177 
00178       static geos::geom::Geometry     *FixGeometry(const geos::geom::Geometry *geom);
00179       static geos::geom::MultiPolygon *FixGeometry(const geos::geom::MultiPolygon *poly);
00180       static geos::geom::Polygon      *FixGeometry(const geos::geom::Polygon *poly);
00181       static geos::geom::LinearRing   *FixGeometry(const geos::geom::LinearRing *ring);
00182 
00183     public:
00184       static geos::geom::MultiPolygon *FixSeam(const geos::geom::MultiPolygon *poly);
00185       static geos::geom::MultiPolygon *FixSeam(const geos::geom::Polygon *polyA,
00186                                                const geos::geom::Polygon *polyB);
00187       
00188       static geos::geom::Geometry     *ReducePrecision(const geos::geom::Geometry *geom, unsigned int precision);
00189       static geos::geom::MultiPolygon *ReducePrecision(const geos::geom::MultiPolygon *poly, unsigned int precision);
00190       static geos::geom::Polygon      *ReducePrecision(const geos::geom::Polygon *poly, unsigned int precision);
00191       static geos::geom::LinearRing   *ReducePrecision(const geos::geom::LinearRing *ring, unsigned int precision);
00192       static geos::geom::Coordinate   *ReducePrecision(const geos::geom::Coordinate *coord, unsigned int precision);
00193       static double ReducePrecision(double num, unsigned int precision);
00194 
00195     private:
00196 
00197       static geos::geom::Geometry *Operate(const geos::geom::Geometry *geom1, const geos::geom::Geometry *geom2, unsigned int opcode);
00198 
00199       static int DecimalPlace(double);
00200   };
00201 };
00202 
00203 #endif
00204