Isis 3.0 Programmer Reference
Back | Home
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 
61  class UniversalGroundMap;
62  class TProjection;
63 
64  static geos::geom::GeometryFactory globalFactory;
65 
130  class PolygonTools {
131 
132  public:
133  PolygonTools();
134  ~PolygonTools();
135 
136  static geos::geom::MultiPolygon *LatLonToXY(
137  const geos::geom::MultiPolygon &lonLatPoly, TProjection *proj);
138 
139  static geos::geom::MultiPolygon *XYToLatLon(
140  const geos::geom::MultiPolygon &xYPoly, TProjection *proj);
141 
142  static geos::geom::MultiPolygon *LatLonToSampleLine(
143  const geos::geom::MultiPolygon &lonLatPoly, UniversalGroundMap *ugm);
144 
145  // Return a deep copy of a multpolygon
146  static geos::geom::MultiPolygon *CopyMultiPolygon(const geos::geom::MultiPolygon *mpolygon);
147  static geos::geom::MultiPolygon *CopyMultiPolygon(const geos::geom::MultiPolygon &mpolygon);
148 
149  static geos::geom::MultiPolygon *Despike(const geos::geom::Geometry *geom);
150  static geos::geom::MultiPolygon *Despike(const geos::geom::MultiPolygon *multiPoly);
151  static geos::geom::LinearRing *Despike(const geos::geom::LineString *linearRing);
152 
153  // Return polygon in -180/180 coordinated system and merge split polys
154  static geos::geom::MultiPolygon *To180(geos::geom::MultiPolygon *poly360);
155 
156  //Return a polygon in GML format
157  static QString ToGML(const geos::geom::MultiPolygon *mpolygon,
158  QString idString = QString("0"),
159  QString schema = QString(""));
160 
161  //Return the GML schema for a polygon
162  static QString GMLSchema();
163 
164  //Return the thickness of a polygon
165  static double Thickness(const geos::geom::MultiPolygon *mpolygon);
166 
167  static geos::geom::Geometry *Intersect(const geos::geom::Geometry *geom1,
168  const geos::geom::Geometry *geom2);
169  static geos::geom::Geometry *Difference(const geos::geom::Geometry *geom1,
170  const geos::geom::Geometry *geom2);
171 
172  static geos::geom::MultiPolygon *MakeMultiPolygon(const geos::geom::Geometry *geom);
173 
174  static QString GetGeometryName(const geos::geom::Geometry *geom);
175 
176  static bool Equal(const geos::geom::MultiPolygon *poly1,
177  const geos::geom::MultiPolygon *poly2);
178  static bool Equal(const geos::geom::Polygon *poly1, const geos::geom::Polygon *poly2);
179  static bool Equal(const geos::geom::LineString *lineString1,
180  const geos::geom::LineString *lineString2);
181  static bool Equal(const geos::geom::Coordinate &coord1, const geos::geom::Coordinate &coord2);
182  static bool Equal(const double d1, const double d2);
183 
184  static geos::geom::MultiPolygon *FixSeam(const geos::geom::MultiPolygon *poly);
185  static geos::geom::MultiPolygon *FixSeam(const geos::geom::Polygon *polyA,
186  const geos::geom::Polygon *polyB);
187 
188  static geos::geom::Geometry *ReducePrecision(const geos::geom::Geometry *geom,
189  unsigned int precision);
190  static geos::geom::MultiPolygon *ReducePrecision(const geos::geom::MultiPolygon *poly,
191  unsigned int precision);
192  static geos::geom::Polygon *ReducePrecision(const geos::geom::Polygon *poly,
193  unsigned int precision);
194  static geos::geom::LinearRing *ReducePrecision(const geos::geom::LinearRing *ring,
195  unsigned int precision);
196  static geos::geom::Coordinate *ReducePrecision(const geos::geom::Coordinate *coord,
197  unsigned int precision);
198  static double ReducePrecision(double num, unsigned int precision);
199 
200  static geos::geom::MultiPolygon *FixPolePolygon(const geos::geom::MultiPolygon *polePolygon,
201  UniversalGroundMap *ugm);
202  static geos::geom::MultiPolygon *SplitPolygonOn360(const geos::geom::Polygon *inPoly);
203 
204 
205  private:
207  static bool IsSpiked(geos::geom::Coordinate first,
208  geos::geom::Coordinate middle, geos::geom::Coordinate last);
210  static bool TestSpiked(geos::geom::Coordinate first, geos::geom::Coordinate middle,
211  geos::geom::Coordinate last);
212 
213  static geos::geom::Geometry *FixGeometry(const geos::geom::Geometry *geom);
214  static geos::geom::MultiPolygon *FixGeometry(const geos::geom::MultiPolygon *poly);
215  static geos::geom::Polygon *FixGeometry(const geos::geom::Polygon *poly);
216  static geos::geom::LinearRing *FixGeometry(const geos::geom::LinearRing *ring);
217 
218  static geos::geom::Geometry *Operate(const geos::geom::Geometry *geom1,
219  const geos::geom::Geometry *geom2, unsigned int opcode);
220 
221  static int DecimalPlace(double);
222 
223  geos::geom::MultiPolygon *p_polygons;
224 
225  };
226 };
227 
228 #endif
229 
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 * To180(geos::geom::MultiPolygon *poly360)
Convert polygon coordinates from 360 system to 180.
static int DecimalPlace(double)
This returns the location of the decimal place in the number.
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 ...
Universal Ground Map.
static QString GMLSchema()
Return the gml schema.
Base class for Map TProjections.
Definition: TProjection.h:178
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 double Thickness(const geos::geom::MultiPolygon *mpolygon)
Calculates the thickness of a polygon using: thickness = area / max(Xextent,Yextent)**2 The provided ...
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 * 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...
static geos::geom::Geometry * Intersect(const geos::geom::Geometry *geom1, const geos::geom::Geometry *geom2)
This applies the geos Intersect operator.
Provides various tools to work with geos multipolygons.
Definition: PolygonTools.h:130
static QString GetGeometryName(const geos::geom::Geometry *geom)
This method returns the name of the type of geometry passed in.
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 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 QString ToGML(const geos::geom::MultiPolygon *mpolygon, QString idString=QString("0"), QString schema=QString(""))
Return the polygon with gml header.
static bool IsSpiked(geos::geom::Coordinate first, geos::geom::Coordinate middle, geos::geom::Coordinate last)
Returns true if the middle point is spiked.
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 * 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...
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...

U.S. Department of the Interior | U.S. Geological Survey
ISIS | Privacy & Disclaimers | Astrogeology Research Program
To contact us, please post comments and questions on the ISIS Support Center
File Modified: 07/12/2023 23:25:58