Isis 3 Developer Reference
PolygonTools.h
Go to the documentation of this file.
1 #ifndef Polygontools_h
2 #define Polygontools_h
3 
25 #include <geos/geom/GeometryFactory.h>
26 #include <geos/geom/MultiPolygon.h>
27 #include <geos/geom/CoordinateSequence.h>
28 
29 #include <QString>
30 
31 namespace Isis {
32 
63  class UniversalGroundMap;
64  class TProjection;
65 
66  static geos::geom::GeometryFactory globalFactory;
67 
135  class PolygonTools {
136 
137  public:
138  PolygonTools();
139  ~PolygonTools();
140 
141  static geos::geom::MultiPolygon *LatLonToXY(
142  const geos::geom::MultiPolygon &lonLatPoly, TProjection *proj);
143 
144  static geos::geom::MultiPolygon *XYToLatLon(
145  const geos::geom::MultiPolygon &xYPoly, TProjection *proj);
146 
147  static geos::geom::MultiPolygon *LatLonToSampleLine(
148  const geos::geom::MultiPolygon &lonLatPoly, UniversalGroundMap *ugm);
149 
150  // Return a deep copy of a multpolygon
151  static geos::geom::MultiPolygon *CopyMultiPolygon(const geos::geom::MultiPolygon *mpolygon);
152  static geos::geom::MultiPolygon *CopyMultiPolygon(const geos::geom::MultiPolygon &mpolygon);
153 
154  static geos::geom::MultiPolygon *Despike(const geos::geom::Geometry *geom);
155  static geos::geom::MultiPolygon *Despike(const geos::geom::MultiPolygon *multiPoly);
156  static geos::geom::LinearRing *Despike(const geos::geom::LineString *linearRing);
157 
158  // Return polygon in -180/180 coordinated system and merge split polys
159  static geos::geom::MultiPolygon *To180(geos::geom::MultiPolygon *poly360);
160 
161  //Return a polygon in GML format
162  static QString ToGML(const geos::geom::MultiPolygon *mpolygon,
163  QString idString = QString("0"),
164  QString schema = QString(""));
165 
166  //Return the GML schema for a polygon
167  static QString GMLSchema();
168 
169  //Return the thickness of a polygon
170  static double Thickness(const geos::geom::MultiPolygon *mpolygon);
171 
172  static geos::geom::Geometry *Intersect(const geos::geom::Geometry *geom1,
173  const geos::geom::Geometry *geom2);
174  static geos::geom::Geometry *Difference(const geos::geom::Geometry *geom1,
175  const geos::geom::Geometry *geom2);
176 
177  static geos::geom::MultiPolygon *MakeMultiPolygon(const geos::geom::Geometry *geom);
178 
179  static QString GetGeometryName(const geos::geom::Geometry *geom);
180 
181  static bool Equal(const geos::geom::MultiPolygon *poly1,
182  const geos::geom::MultiPolygon *poly2);
183  static bool Equal(const geos::geom::Polygon *poly1, const geos::geom::Polygon *poly2);
184  static bool Equal(const geos::geom::LineString *lineString1,
185  const geos::geom::LineString *lineString2);
186  static bool Equal(const geos::geom::Coordinate &coord1, const geos::geom::Coordinate &coord2);
187  static bool Equal(const double d1, const double d2);
188 
189  static geos::geom::MultiPolygon *FixSeam(const geos::geom::MultiPolygon *poly);
190  static geos::geom::MultiPolygon *FixSeam(const geos::geom::Polygon *polyA,
191  const geos::geom::Polygon *polyB);
192 
193  static geos::geom::Geometry *ReducePrecision(const geos::geom::Geometry *geom,
194  unsigned int precision);
195  static geos::geom::MultiPolygon *ReducePrecision(const geos::geom::MultiPolygon *poly,
196  unsigned int precision);
197  static geos::geom::Polygon *ReducePrecision(const geos::geom::Polygon *poly,
198  unsigned int precision);
199  static geos::geom::LinearRing *ReducePrecision(const geos::geom::LinearRing *ring,
200  unsigned int precision);
201  static geos::geom::Coordinate *ReducePrecision(const geos::geom::Coordinate *coord,
202  unsigned int precision);
203  static double ReducePrecision(double num, unsigned int precision);
204 
205  static geos::geom::MultiPolygon *FixPolePolygon(const geos::geom::MultiPolygon *polePolygon,
206  UniversalGroundMap *ugm);
207  static geos::geom::MultiPolygon *SplitPolygonOn360(const geos::geom::Polygon *inPoly);
208 
209 
210  private:
212  static bool IsSpiked(geos::geom::Coordinate first,
213  geos::geom::Coordinate middle, geos::geom::Coordinate last);
215  static bool TestSpiked(geos::geom::Coordinate first, geos::geom::Coordinate middle,
216  geos::geom::Coordinate last);
217 
218  static geos::geom::Geometry *FixGeometry(const geos::geom::Geometry *geom);
219  static geos::geom::MultiPolygon *FixGeometry(const geos::geom::MultiPolygon *poly);
220  static geos::geom::Polygon *FixGeometry(const geos::geom::Polygon *poly);
221  static geos::geom::LinearRing *FixGeometry(const geos::geom::LinearRing *ring);
222 
223  static geos::geom::Geometry *Operate(const geos::geom::Geometry *geom1,
224  const geos::geom::Geometry *geom2, unsigned int opcode);
225 
226  static int DecimalPlace(double);
227 
228  geos::geom::MultiPolygon *p_polygons;
229 
230  };
231 };
232 
233 #endif
234 
static geos::geom::MultiPolygon * CopyMultiPolygon(const geos::geom::MultiPolygon *mpolygon)
This static method will create a deep copy of a geos::geom::MultiPolygon.
Definition: PolygonTools.cpp:370
static geos::geom::MultiPolygon * To180(geos::geom::MultiPolygon *poly360)
Convert polygon coordinates from 360 system to 180.
Definition: PolygonTools.cpp:543
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 ...
Definition: PolygonTools.cpp:261
Universal Ground Map.
Definition: UniversalGroundMap.h:85
static QString GMLSchema()
Return the gml schema.
Definition: PolygonTools.cpp:477
static geos::geom::MultiPolygon * FixSeam(const geos::geom::MultiPolygon *poly)
Definition: PolygonTools.cpp:1519
Base class for Map TProjections.
Definition: TProjection.h:182
static geos::geom::MultiPolygon * Despike(const geos::geom::Geometry *geom)
This method attempts to convert the geom to a MultiPolygon and then despike it.
Definition: PolygonTools.cpp:662
static geos::geom::MultiPolygon * FixPolePolygon(const geos::geom::MultiPolygon *polePolygon, UniversalGroundMap *ugm)
static double Thickness(const geos::geom::MultiPolygon *mpolygon)
Calculates the thickness of a polygon using: thickness = area / max(Xextent,Yextent)**2 The provided ...
Definition: PolygonTools.cpp:640
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.
Definition: PolygonTools.cpp:1580
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 p...
Definition: PolygonTools.cpp:63
static geos::geom::Geometry * Intersect(const geos::geom::Geometry *geom1, const geos::geom::Geometry *geom2)
This applies the geos Intersect operator.
Definition: PolygonTools.cpp:980
Provides various tools to work with geos multipolygons.
Definition: PolygonTools.h:135
static QString GetGeometryName(const geos::geom::Geometry *geom)
This method returns the name of the type of geometry passed in.
Definition: PolygonTools.cpp:1827
static geos::geom::Geometry * Difference(const geos::geom::Geometry *geom1, const geos::geom::Geometry *geom2)
This method is used to subtract two polygons.
Definition: PolygonTools.cpp:1350
static geos::geom::MultiPolygon * MakeMultiPolygon(const geos::geom::Geometry *geom)
Make a geos::geom::MultiPolygon out of the components of the argument.
Definition: PolygonTools.cpp:1385
static QString ToGML(const geos::geom::MultiPolygon *mpolygon, QString idString=QString("0"), QString schema=QString(""))
Return the polygon with gml header.
Definition: PolygonTools.cpp:410
static bool Equal(const geos::geom::MultiPolygon *poly1, const geos::geom::MultiPolygon *poly2)
Definition: PolygonTools.cpp:1851
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
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...
Definition: PolygonTools.cpp:2012
static geos::geom::GeometryFactory globalFactory
Definition: PolygonTools.h:64
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...
Definition: PolygonTools.cpp:169