Loading [MathJax]/jax/output/NativeMML/config.js
Isis Developer Reference
PolygonTools.h
Go to the documentation of this file.
1 #ifndef Polygontools_h
2 #define Polygontools_h
3 
8 /* SPDX-License-Identifier: CC0-1.0 */
9 #include <geos/geom/GeometryFactory.h>
10 #include <geos/geom/MultiPolygon.h>
11 #include <geos/geom/CoordinateSequence.h>
12 
13 #include <QString>
14 
15 namespace Isis {
16 
47  class UniversalGroundMap;
48  class TProjection;
49 
50 
51  static geos::geom::GeometryFactory::Ptr globalFactory = geos::geom::GeometryFactory::create();
52 
120  class PolygonTools {
121 
122  public:
125 
126  static geos::geom::MultiPolygon *LatLonToXY(
127  const geos::geom::MultiPolygon &lonLatPoly, TProjection *proj);
128 
129  static geos::geom::MultiPolygon *XYToLatLon(
130  const geos::geom::MultiPolygon &xYPoly, TProjection *proj);
131 
132  static geos::geom::MultiPolygon *LatLonToSampleLine(
133  const geos::geom::MultiPolygon &lonLatPoly, UniversalGroundMap *ugm);
134 
135  // Return a deep copy of a multpolygon
136  static geos::geom::MultiPolygon *CopyMultiPolygon(const geos::geom::MultiPolygon *mpolygon);
137  static geos::geom::MultiPolygon *CopyMultiPolygon(const geos::geom::MultiPolygon &mpolygon);
138 
139  static geos::geom::MultiPolygon *Despike(const geos::geom::Geometry *geom);
140  static geos::geom::MultiPolygon *Despike(const geos::geom::MultiPolygon *multiPoly);
141  static geos::geom::LinearRing *Despike(const geos::geom::LineString *linearRing);
142 
143  // Return polygon in -180/180 coordinated system and merge split polys
144  static geos::geom::MultiPolygon *To180(geos::geom::MultiPolygon *poly360);
145 
146  //Return a polygon in GML format
147  static QString ToGML(const geos::geom::MultiPolygon *mpolygon,
148  QString idString = QString("0"),
149  QString schema = QString(""));
150 
151  //Return the GML schema for a polygon
152  static QString GMLSchema();
153 
154  //Return the thickness of a polygon
155  static double Thickness(const geos::geom::MultiPolygon *mpolygon);
156 
157  static geos::geom::Geometry *Intersect(const geos::geom::Geometry *geom1,
158  const geos::geom::Geometry *geom2);
159  static geos::geom::Geometry *Difference(const geos::geom::Geometry *geom1,
160  const geos::geom::Geometry *geom2);
161 
162  static geos::geom::MultiPolygon *MakeMultiPolygon(const geos::geom::Geometry *geom);
163 
164  static QString GetGeometryName(const geos::geom::Geometry *geom);
165 
166  static bool Equal(const geos::geom::MultiPolygon *poly1,
167  const geos::geom::MultiPolygon *poly2);
168  static bool Equal(const geos::geom::Polygon *poly1, const geos::geom::Polygon *poly2);
169  static bool Equal(const geos::geom::LineString *lineString1,
170  const geos::geom::LineString *lineString2);
171  static bool Equal(const geos::geom::Coordinate &coord1, const geos::geom::Coordinate &coord2);
172  static bool Equal(const double d1, const double d2);
173 
174  static geos::geom::MultiPolygon *FixSeam(const geos::geom::MultiPolygon *poly);
175  static geos::geom::MultiPolygon *FixSeam(const geos::geom::Polygon *polyA,
176  const geos::geom::Polygon *polyB);
177 
178  static geos::geom::Geometry *ReducePrecision(const geos::geom::Geometry *geom,
179  unsigned int precision);
180  static geos::geom::MultiPolygon *ReducePrecision(const geos::geom::MultiPolygon *poly,
181  unsigned int precision);
182  static geos::geom::Polygon *ReducePrecision(const geos::geom::Polygon *poly,
183  unsigned int precision);
184  static geos::geom::LinearRing *ReducePrecision(const geos::geom::LinearRing *ring,
185  unsigned int precision);
186  static geos::geom::Coordinate *ReducePrecision(const geos::geom::Coordinate *coord,
187  unsigned int precision);
188  static double ReducePrecision(double num, unsigned int precision);
189 
190  static geos::geom::MultiPolygon *FixPolePolygon(const geos::geom::MultiPolygon *polePolygon,
191  UniversalGroundMap *ugm);
192  static geos::geom::MultiPolygon *SplitPolygonOn360(const geos::geom::Polygon *inPoly);
193 
194 
195  private:
197  static bool IsSpiked(geos::geom::Coordinate first,
198  geos::geom::Coordinate middle, geos::geom::Coordinate last);
200  static bool TestSpiked(geos::geom::Coordinate first, geos::geom::Coordinate middle,
201  geos::geom::Coordinate last);
202 
203  static geos::geom::Geometry *FixGeometry(const geos::geom::Geometry *geom);
204  static geos::geom::MultiPolygon *FixGeometry(const geos::geom::MultiPolygon *poly);
205  static geos::geom::Polygon *FixGeometry(const geos::geom::Polygon *poly);
206  static geos::geom::LinearRing *FixGeometry(const geos::geom::LinearRing *ring);
207 
208  static geos::geom::Geometry *Operate(const geos::geom::Geometry *geom1,
209  const geos::geom::Geometry *geom2, unsigned int opcode);
210 
211  static int DecimalPlace(double);
212 
213  geos::geom::MultiPolygon *p_polygons;
214 
215  };
216 };
217 
218 #endif
219 
ProjectionFactory.h
Isis::UniversalGroundMap
Universal Ground Map.
Definition: UniversalGroundMap.h:69
Isis::PolygonTools::To180
static geos::geom::MultiPolygon * To180(geos::geom::MultiPolygon *poly360)
Convert polygon coordinates from 360 system to 180.
Definition: PolygonTools.cpp:527
Isis::UniversalGroundMap::Sample
double Sample() const
Returns the current line value of the camera model or projection.
Definition: UniversalGroundMap.cpp:200
Isis::PolygonTools::ReducePrecision
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:1564
Isis::PolygonTools::LatLonToXY
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:47
Isis::PolygonTools
Provides various tools to work with geos multipolygons.
Definition: PolygonTools.h:120
SpecialPixel.h
Isis::PolygonTools::PolygonTools
PolygonTools()
Isis::PolygonTools::GetGeometryName
static QString GetGeometryName(const geos::geom::Geometry *geom)
This method returns the name of the type of geometry passed in.
Definition: PolygonTools.cpp:1811
Isis::PolygonTools::Thickness
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:624
Isis::TProjection::Longitude
virtual double Longitude() const
This returns a longitude with correct longitude direction and domain as specified in the label object...
Definition: TProjection.cpp:823
Isis::globalFactory
static geos::geom::GeometryFactory::Ptr globalFactory
Definition: PolygonTools.h:51
Isis::PolygonTools::XYToLatLon
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:153
Isis::PolygonTools::FixSeam
static geos::geom::MultiPolygon * FixSeam(const geos::geom::MultiPolygon *poly)
Definition: PolygonTools.cpp:1503
Isis::PolygonTools::Intersect
static geos::geom::Geometry * Intersect(const geos::geom::Geometry *geom1, const geos::geom::Geometry *geom2)
This applies the geos Intersect operator.
Definition: PolygonTools.cpp:964
Isis::IException::what
const char * what() const
Returns a string representation of this exception in its current state.
Definition: IException.cpp:375
_FILEINFO_
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:24
Isis::TProjection::Latitude
virtual double Latitude() const
This returns a latitude with correct latitude type as specified in the label object.
Definition: TProjection.cpp:811
Isis::PolygonTools::Difference
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:1334
Isis::TProjection
Base class for Map TProjections.
Definition: TProjection.h:166
Isis::PolygonTools::CopyMultiPolygon
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:354
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::Projection::SetWorld
virtual bool SetWorld(const double x, const double y)
This method is used to set a world coordinate.
Definition: Projection.cpp:497
UniversalGroundMap.h
TProjection.h
Isis::PolygonTools::~PolygonTools
~PolygonTools()
Isis::PolygonTools::Equal
static bool Equal(const geos::geom::MultiPolygon *poly1, const geos::geom::MultiPolygon *poly2)
Definition: PolygonTools.cpp:1835
Isis::TProjection::SetGround
virtual bool SetGround(const double lat, const double lon)
This method is used to set the latitude/longitude (assumed to be of the correct LatitudeType,...
Definition: TProjection.cpp:760
Isis::PolygonTools::MakeMultiPolygon
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:1369
std
Namespace for the standard library.
Isis::PolygonTools::ToGML
static QString ToGML(const geos::geom::MultiPolygon *mpolygon, QString idString=QString("0"), QString schema=QString(""))
Return the polygon with gml header.
Definition: PolygonTools.cpp:394
Isis::PolygonTools::Despike
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:646
Isis::PolygonTools::LatLonToSampleLine
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:245
Isis::UniversalGroundMap::SetUniversalGround
bool SetUniversalGround(double lat, double lon)
Returns whether the lat/lon position was set successfully in the camera model or projection.
Definition: UniversalGroundMap.cpp:102
Isis::PolygonTools::SplitPolygonOn360
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:1996
Isis::IString
Adds specific functionality to C++ strings.
Definition: IString.h:165
PolygonTools.h
Isis::Projection::YCoord
double YCoord() const
This returns the projection Y provided SetGround, SetCoordinate, SetUniversalGround,...
Definition: Projection.cpp:400
Isis::PolygonTools::GMLSchema
static QString GMLSchema()
Return the gml schema.
Definition: PolygonTools.cpp:461
Isis::UniversalGroundMap::Line
double Line() const
Returns the current line value of the camera model or projection.
Definition: UniversalGroundMap.cpp:214
Isis::PolygonTools::FixPolePolygon
static geos::geom::MultiPolygon * FixPolePolygon(const geos::geom::MultiPolygon *polePolygon, UniversalGroundMap *ugm)
Isis::Projection::XCoord
double XCoord() const
This returns the projection X provided SetGround, SetCoordinate, SetUniversalGround,...
Definition: Projection.cpp:387
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16

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 USGS Astrogeology Discussion Board
To report a bug, or suggest a feature go to: ISIS Github
File Modified: 07/13/2023 15:12:07