Isis Developer Reference
ImagePolygon.h
Go to the documentation of this file.
1 #ifndef ImagePolygon_h
2 #define ImagePolygon_h
3 
8 /* SPDX-License-Identifier: CC0-1.0 */
9 
10 #include <string>
11 #include <sstream>
12 #include <vector>
13 
14 #include "IException.h"
15 #include "Cube.h"
16 #include "Brick.h"
17 #include "Blob.h"
18 #include "Camera.h"
19 #include "Projection.h"
20 #include "UniversalGroundMap.h"
21 #include "Blob.h"
22 #include "geos/geom/Coordinate.h"
23 #include "geos/geom/MultiPolygon.h"
24 #include "geos/geom/CoordinateSequence.h"
25 
26 namespace Isis {
27 
153  class ImagePolygon {
154 
155  public:
156  ImagePolygon();
157  ImagePolygon(Blob &blob);
158  ~ImagePolygon();
159 
160  void Create(Cube &cube, int sinc = 1, int linc = 1,
161  int ss = 1, int sl = 1, int ns = 0, int nl = 0, int band = 1,
162  bool increasePrecision = false);
163 
164  void Create(std::vector<std::vector<double>> polyCoordinates);
165 
166  Camera * initCube(Cube &cube, int ss = 1, int sl = 1,
167  int ns = 0, int nl = 0, int band = 1);
168 
174  void Emission(double emission) {
175  p_emission = emission;
176  }
182  void Incidence(double incidence) {
183  p_incidence = incidence;
184  }
185 
192  void EllipsoidLimb(bool ellip) {
193  p_ellipsoid = ellip;
194  }
195 
205  void SubpixelAccuracy(int div) {
206  p_subpixelAccuracy = div;
207  }
208 
210  geos::geom::MultiPolygon *Polys() {
211  return p_polygons;
212  };
213 
215  std::string polyStr() const {
216  return p_polyStr;
217  };
218 
219  double validSampleDim();
220  double validLineDim();
221 
223  int getSinc() const {
224  return p_sampinc;
225  }
226 
228  int getLinc() const {
229  return p_lineinc;
230  }
231 
232  int numVertices() const {
233  return p_pts->size();
234  }
235 
236  Blob toBlob() const;
237 
238  private:
239  // Please do not add new polygon manipulation methods to this class.
240  // Polygon manipulation should be done in the PolygonTools class.
241  bool SetImage(const double sample, const double line);
242 
243  geos::geom::Coordinate FindFirstPoint();
244  void WalkPoly();
245  geos::geom::Coordinate FindNextPoint(geos::geom::Coordinate *currentPoint,
246  geos::geom::Coordinate lastPoint,
247  int recursionDepth = 0);
248 
249  double DistanceSquared(const geos::geom::Coordinate *p1, const geos::geom::Coordinate *p2);
250 
251  void MoveBackInsideImage(double &sample, double &line, double sinc, double linc);
252  bool InsideImage(double sample, double line);
253  void Fix360Poly();
254  void FixPolePoly(std::vector<geos::geom::Coordinate> *crossingPoints);
255 
256  bool IsLimb();
257  geos::geom::Coordinate FindBestPoint(geos::geom::Coordinate *currentPoint,
258  geos::geom::Coordinate newPoint,
259  geos::geom::Coordinate lastPoint);
260  geos::geom::Coordinate FixCornerSkip(geos::geom::Coordinate *currentPoint,
261  geos::geom::Coordinate newPoint);
262 
263  void FindSubpixel(std::vector<geos::geom::Coordinate> & points);
264 
265  void calcImageBorderCoordinates();
266 
267  Cube *p_cube;
268  bool p_isProjected;
269 
270  Brick *p_brick;
271 
272  geos::geom::CoordinateSequence *p_pts;
273 
274  geos::geom::MultiPolygon *p_polygons;
275 
276  std::string p_polyStr;
277 
278  UniversalGroundMap *p_gMap;
279 
280  geos::geom::Coordinate *m_leftCoord;
281  geos::geom::Coordinate *m_rightCoord;
282  geos::geom::Coordinate *m_topCoord;
283  geos::geom::Coordinate *m_botCoord;
284 
285  int p_cubeStartSamp;
286  int p_cubeStartLine;
287  int p_cubeSamps;
288  int p_cubeLines;
289 
290  int p_sampinc;
291  int p_lineinc;
292 
293  double p_emission;
294  double p_incidence;
295  bool p_ellipsoid;
296 
297  int p_subpixelAccuracy;
298 
299  };
300 };
301 
302 #endif
Isis::ImagePolygon::ImagePolygon
ImagePolygon()
Constructs a Polygon object, setting the polygon name.
Definition: ImagePolygon.cpp:40
Isis::ImagePolygon::Incidence
void Incidence(double incidence)
Set the maximum incidence angle ( light contacting the planet )
Definition: ImagePolygon.h:182
Isis::Brick::SetBasePosition
void SetBasePosition(const int start_sample, const int start_line, const int start_band)
This method is used to set the base position of the shape buffer.
Definition: Brick.h:120
Isis::ImagePolygon::~ImagePolygon
~ImagePolygon()
Destroys the Polygon object.
Definition: ImagePolygon.cpp:86
Isis::Cube::fileName
virtual QString fileName() const
Returns the opened cube's filename.
Definition: Cube.cpp:1563
Cube.h
Isis::UniversalGroundMap
Universal Ground Map.
Definition: UniversalGroundMap.h:69
Isis::ImagePolygon::validSampleDim
double validSampleDim()
Retuns the maximum valid sample width of the cube set with either initCube() or Create()
Definition: ImagePolygon.cpp:555
Isis::IException::print
void print() const
Prints a string representation of this exception to stderr.
Definition: IException.cpp:445
Isis::UniversalGroundMap::UniversalLatitude
double UniversalLatitude() const
Returns the universal latitude of the camera model or projection.
Definition: UniversalGroundMap.cpp:247
Isis::ImagePolygon::validLineDim
double validLineDim()
Retuns the maximum valid line width of the cube set with either initCube() or Create()
Definition: ImagePolygon.cpp:570
Isis::ImagePolygon::numVertices
int numVertices() const
Definition: ImagePolygon.h:232
Isis::Blob::setData
void setData(const char *buffer, int nbytes)
Set the data stored in the BLOB.
Definition: Blob.cpp:382
Isis::Cube::read
void read(Blob &blob, const std::vector< PvlKeyword > keywords=std::vector< PvlKeyword >()) const
This method will read data from the specified Blob object.
Definition: Cube.cpp:807
SpecialPixel.h
Isis::Camera::Sample
virtual double Sample() const
Returns the current sample number.
Definition: Camera.cpp:2690
Isis::IException::Unknown
@ Unknown
A type of error that cannot be classified as any of the other error types.
Definition: IException.h:118
Isis::ImagePolygon::toBlob
Blob toBlob() const
Serialize the ImagePolygon to a Blob.
Definition: ImagePolygon.cpp:1347
Isis::ImagePolygon::initCube
Camera * initCube(Cube &cube, int ss=1, int sl=1, int ns=0, int nl=0, int band=1)
Create a Polygon from given cube.
Definition: ImagePolygon.cpp:121
Isis::ImagePolygon::polyStr
std::string polyStr() const
Return a geos Multipolygon.
Definition: ImagePolygon.h:215
Isis::IsNullPixel
bool IsNullPixel(const double d)
Returns if the input pixel is null.
Definition: SpecialPixel.h:235
Isis::Pvl
Container for cube-like labels.
Definition: Pvl.h:119
Isis::ImagePolygon::Create
void Create(Cube &cube, int sinc=1, int linc=1, int ss=1, int sl=1, int ns=0, int nl=0, int band=1, bool increasePrecision=false)
Create a Polygon from given cube.
Definition: ImagePolygon.cpp:217
Isis::globalFactory
static geos::geom::GeometryFactory::Ptr globalFactory
Definition: PolygonTools.h:51
Isis::ImagePolygon
Create cube polygons, read/write polygons to blobs.
Definition: ImagePolygon.h:153
Isis::UniversalGroundMap::Camera
Isis::Camera * Camera() const
Return the camera associated with the ground map (NULL implies none)
Definition: UniversalGroundMap.h:136
Isis::Camera
Definition: Camera.h:236
Isis::ImagePolygon::getSinc
int getSinc() const
Return the sample increment used the create this polygon.
Definition: ImagePolygon.h:223
Isis::Brick
Buffer for containing a three dimensional section of an image.
Definition: Brick.h:45
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
IString.h
Isis::Sensor::IgnoreElevationModel
void IgnoreElevationModel(bool ignore)
This allows you to ignore the cube elevation model and use the ellipse.
Definition: Sensor.cpp:60
Isis::IException::append
void append(const IException &exceptionSource)
Appends the given exception (and its list of previous exceptions) to this exception's causational exc...
Definition: IException.cpp:409
Isis::Projection::WorldY
virtual double WorldY() const
This returns the world Y coordinate provided SetGround, SetCoordinate, SetUniversalGround,...
Definition: Projection.cpp:544
Isis::ImagePolygon::SubpixelAccuracy
void SubpixelAccuracy(int div)
The subpixel accuracy to use.
Definition: ImagePolygon.h:205
Isis::Cube::lineCount
int lineCount() const
Definition: Cube.cpp:1734
_FILEINFO_
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:24
Isis::Blob::getBuffer
char * getBuffer()
Get the internal data buff of the Blob.
Definition: Blob.cpp:546
Isis::ImagePolygon::Emission
void Emission(double emission)
Set the maximum emission angle ( light refleted to camera )
Definition: ImagePolygon.h:174
Blob.h
Isis::Cube::sampleCount
int sampleCount() const
Definition: Cube.cpp:1807
Isis::ImagePolygon::getLinc
int getLinc() const
Return the line increment used the create this polygon.
Definition: ImagePolygon.h:228
Isis::Projection::WorldX
virtual double WorldX() const
This returns the world X coordinate provided SetGround, SetCoordinate, SetUniversalGround,...
Definition: Projection.cpp:524
Isis::Cube
IO Handler for Isis Cubes.
Definition: Cube.h:167
Isis::IException
Isis exception class.
Definition: IException.h:91
ASSERT
#define ASSERT(x)
Definition: IsisDebug.h:134
UniversalGroundMap.h
Isis::Sensor::IncidenceAngle
virtual double IncidenceAngle() const
Returns the incidence angle in degrees.
Definition: Sensor.cpp:335
Camera.h
Isis::Null
const double Null
Value for an Isis Null pixel.
Definition: SpecialPixel.h:95
Isis::Blob::Size
int Size() const
Accessor method that returns the number of bytes in the blob data.
Definition: Blob.cpp:142
Isis::Camera::BasicMapping
void BasicMapping(Pvl &map)
Writes the basic mapping group to the specified Pvl.
Definition: Camera.cpp:1356
Isis::UniversalGroundMap::Projection
Isis::Projection * Projection() const
Return the projection associated with the ground map (NULL implies none)
Definition: UniversalGroundMap.h:131
Brick.h
Isis::Cube::camera
Camera * camera()
Return a camera associated with the cube.
Definition: Cube.cpp:1451
IException.h
Isis::IException::Programmer
@ Programmer
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:146
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::Cube::pixelType
PixelType pixelType() const
Definition: Cube.cpp:1758
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
Projection.h
Isis::UniversalGroundMap::SetImage
bool SetImage(double sample, double line)
Returns whether the sample/line postion was set successfully in the camera model or projection.
Definition: UniversalGroundMap.cpp:233
Isis::ImagePolygon::EllipsoidLimb
void EllipsoidLimb(bool ellip)
If a limb is detected, use un ellipsoid shape model if true.
Definition: ImagePolygon.h:192
Isis::Sensor::EmissionAngle
virtual double EmissionAngle() const
Returns the emission angle in degrees.
Definition: Sensor.cpp:324
Isis::Camera::Line
virtual double Line() const
Returns the current line number.
Definition: Camera.cpp:2710
PolygonTools.h
IsisDebug.h
Isis::Blob
Definition: Blob.h:51
Isis::Camera::HasProjection
bool HasProjection()
Checks to see if the camera object has a projection.
Definition: Camera.cpp:2638
Isis::Cube::projection
Projection * projection()
Definition: Cube.cpp:1794
Isis::ImagePolygon::Polys
geos::geom::MultiPolygon * Polys()
Return a geos Multipolygon.
Definition: ImagePolygon.h:210
Isis::UniversalGroundMap::UniversalLongitude
double UniversalLongitude() const
Returns the universal longitude of the camera model or projection.
Definition: UniversalGroundMap.cpp:270
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
ImagePolygon.h
Isis::IException::User
@ User
A type of error that could only have occurred due to a mistake on the user's part (e....
Definition: IException.h:126
Isis::UniversalGroundMap::SetBand
void SetBand(const int band)
Set the image band number.
Definition: UniversalGroundMap.cpp:72