Isis 3 Programmer Reference
ImagePolygon.h
Go to the documentation of this file.
1 #ifndef ImagePolygon_h
2 #define ImagePolygon_h
3 
25 #include <string>
26 #include <sstream>
27 #include <vector>
28 
29 #include "IException.h"
30 #include "Cube.h"
31 #include "Brick.h"
32 #include "Camera.h"
33 #include "Projection.h"
34 #include "UniversalGroundMap.h"
35 #include "Blob.h"
36 #include "geos/geom/Coordinate.h"
37 #include "geos/geom/MultiPolygon.h"
38 #include "geos/geom/CoordinateSequence.h"
39 
40 namespace Isis {
41 
167  class ImagePolygon : public Isis::Blob {
168 
169  public:
170  ImagePolygon();
171  ~ImagePolygon();
172 
173  void Create(Cube &cube, int sinc = 1, int linc = 1,
174  int ss = 1, int sl = 1, int ns = 0, int nl = 0, int band = 1,
175  bool increasePrecision = false);
176 
177  Camera * initCube(Cube &cube, int ss = 1, int sl = 1,
178  int ns = 0, int nl = 0, int band = 1);
179 
185  void Emission(double emission) {
186  p_emission = emission;
187  }
193  void Incidence(double incidence) {
194  p_incidence = incidence;
195  }
196 
203  void EllipsoidLimb(bool ellip) {
204  p_ellipsoid = ellip;
205  }
206 
216  void SubpixelAccuracy(int div) {
217  p_subpixelAccuracy = div;
218  }
219 
221  geos::geom::MultiPolygon *Polys() {
222  return p_polygons;
223  };
224 
225  double validSampleDim();
226  double validLineDim();
227 
229  int getSinc() const {
230  return p_sampinc;
231  }
232 
234  int getLinc() const {
235  return p_lineinc;
236  }
237 
238  protected:
239  void ReadData(std::istream &is);
240  void WriteInit();
241  void WriteData(std::fstream &os);
242 
243  private:
244  // Please do not add new polygon manipulation methods to this class.
245  // Polygon manipulation should be done in the PolygonTools class.
246  bool SetImage(const double sample, const double line);
247 
248  geos::geom::Coordinate FindFirstPoint();
249  void WalkPoly();
250  geos::geom::Coordinate FindNextPoint(geos::geom::Coordinate *currentPoint,
251  geos::geom::Coordinate lastPoint,
252  int recursionDepth = 0);
253 
254  double DistanceSquared(const geos::geom::Coordinate *p1, const geos::geom::Coordinate *p2);
255 
256  void MoveBackInsideImage(double &sample, double &line, double sinc, double linc);
257  bool InsideImage(double sample, double line);
258  void Fix360Poly();
259  void FixPolePoly(std::vector<geos::geom::Coordinate> *crossingPoints);
260 
261  bool IsLimb();
262  geos::geom::Coordinate FindBestPoint(geos::geom::Coordinate *currentPoint,
263  geos::geom::Coordinate newPoint,
264  geos::geom::Coordinate lastPoint);
265  geos::geom::Coordinate FixCornerSkip(geos::geom::Coordinate *currentPoint,
266  geos::geom::Coordinate newPoint);
267 
268  void FindSubpixel(std::vector<geos::geom::Coordinate> & points);
269 
271 
274 
276 
277  geos::geom::CoordinateSequence *p_pts;
278 
279  geos::geom::MultiPolygon *p_polygons;
280 
281  std::string p_polyStr;
282 
284 
285  geos::geom::Coordinate *m_leftCoord;
286  geos::geom::Coordinate *m_rightCoord;
287  geos::geom::Coordinate *m_topCoord;
288  geos::geom::Coordinate *m_botCoord;
289 
294 
295  int p_sampinc;
296  int p_lineinc;
297 
298  double p_emission;
299  double p_incidence;
300  bool p_ellipsoid;
301 
303 
304  };
305 };
306 
307 #endif
308 
double validSampleDim()
Retuns the maximum valid sample width of the cube set with either initCube() or Create() ...
geos::geom::Coordinate FindFirstPoint()
Finds the first point that projects in an image.
ImagePolygon()
Constructs a Polygon object, setting the polygon name.
double validLineDim()
Retuns the maximum valid line width of the cube set with either initCube() or Create() ...
geos::geom::Coordinate FixCornerSkip(geos::geom::Coordinate *currentPoint, geos::geom::Coordinate newPoint)
Looks at the next possible point relative to the lasts and attempts to adjust the point outward to gr...
geos::geom::Coordinate * m_rightCoord
The cube&#39;s right-most valid coord.
Definition: ImagePolygon.h:286
geos::geom::Coordinate * m_topCoord
The cube&#39;s top-most valid coord.
Definition: ImagePolygon.h:287
bool InsideImage(double sample, double line)
This returns true if sample/line are inside the cube.
int p_subpixelAccuracy
The subpixel accuracy to use.
Definition: ImagePolygon.h:302
Universal Ground Map.
int p_cubeLines
The number of lines in the cube.
Definition: ImagePolygon.h:293
Buffer for containing a three dimensional section of an image.
Definition: Brick.h:61
bool p_ellipsoid
Uses an ellipsoid if a limb is detected.
Definition: ImagePolygon.h:300
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.
bool p_isProjected
True when the provided cube is projected.
Definition: ImagePolygon.h:273
int getSinc() const
Return the sample increment used the create this polygon.
Definition: ImagePolygon.h:229
geos::geom::Coordinate * m_leftCoord
The cube&#39;s left-most valid coord.
Definition: ImagePolygon.h:285
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.
double p_emission
The maximum emission angle to consider valid.
Definition: ImagePolygon.h:298
Cube * p_cube
The cube provided.
Definition: ImagePolygon.h:272
Create cube polygons, read/write polygons to blobs.
Definition: ImagePolygon.h:167
void WalkPoly()
Walks the image finding its lon lat polygon and stores it to p_pts.
UniversalGroundMap * p_gMap
The cube&#39;s ground map.
Definition: ImagePolygon.h:283
Brick * p_brick
Used to check for valid DNs.
Definition: ImagePolygon.h:275
geos::geom::Coordinate * m_botCoord
The cube&#39;s bot-most valid coord.
Definition: ImagePolygon.h:288
void SubpixelAccuracy(int div)
The subpixel accuracy to use.
Definition: ImagePolygon.h:216
geos::geom::Coordinate FindNextPoint(geos::geom::Coordinate *currentPoint, geos::geom::Coordinate lastPoint, int recursionDepth=0)
Finds the next point on the image using a left hand rule walking algorithm.
double DistanceSquared(const geos::geom::Coordinate *p1, const geos::geom::Coordinate *p2)
Calculates the distance squared between two coordinates.
int p_lineinc
The increment for walking along the polygon in the line direcction.
Definition: ImagePolygon.h:296
void Emission(double emission)
Set the maximum emission angle ( light refleted to camera )
Definition: ImagePolygon.h:185
std::string p_polyStr
The string representation of the polygon.
Definition: ImagePolygon.h:281
void WriteInit()
Initializes for writing polygon to cube blob.
bool SetImage(const double sample, const double line)
Sets the sample/line values of the cube to get lat/lon values.
void ReadData(std::istream &is)
Reads Multipolygon from cube blob.
int p_cubeStartLine
The the line of the first valid point in the cube.
Definition: ImagePolygon.h:291
geos::geom::MultiPolygon * p_polygons
The multipolygon of the image.
Definition: ImagePolygon.h:279
double p_incidence
The maximum incidence angle to consider valid.
Definition: ImagePolygon.h:299
int p_cubeStartSamp
The the sample of the first valid point in the cube.
Definition: ImagePolygon.h:290
void FixPolePoly(std::vector< geos::geom::Coordinate > *crossingPoints)
If the cube crosses the 0/360 boundary and contains a pole, Some points are added to allow the polygo...
int getLinc() const
Return the line increment used the create this polygon.
Definition: ImagePolygon.h:234
bool IsLimb()
Returns True when the input image is a limb image.
int p_cubeSamps
The number of samples in the cube.
Definition: ImagePolygon.h:292
void Fix360Poly()
If the cube crosses the 0/360 boundary and does not include a pole, the polygon is separated into mul...
void WriteData(std::fstream &os)
Writes polygon to cube blob.
void calcImageBorderCoordinates()
Calculates the four border points, particularly for validSampleDim() and validLineDim() ...
void EllipsoidLimb(bool ellip)
If a limb is detected, use un ellipsoid shape model if true.
Definition: ImagePolygon.h:203
void MoveBackInsideImage(double &sample, double &line, double sinc, double linc)
This method ensures sample/line after sinc/linc have been applied is inside the image.
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
geos::geom::Coordinate FindBestPoint(geos::geom::Coordinate *currentPoint, geos::geom::Coordinate newPoint, geos::geom::Coordinate lastPoint)
While walking the image in sample/line space, this function finds the best valid point between the fi...
geos::geom::CoordinateSequence * p_pts
The sequence of coordinates that compose the boundry of the image.
Definition: ImagePolygon.h:277
void FindSubpixel(std::vector< geos::geom::Coordinate > &points)
Takes p_polygons in sample/line space and finds its subpixel accuracy.
geos::geom::MultiPolygon * Polys()
Return a geos Multipolygon.
Definition: ImagePolygon.h:221
void Incidence(double incidence)
Set the maximum incidence angle ( light contacting the planet )
Definition: ImagePolygon.h:193
~ImagePolygon()
Destroys the Polygon object.
int p_sampinc
The increment for walking along the polygon in the sample direction.
Definition: ImagePolygon.h:295
IO Handler for Isis Cubes.
Definition: Cube.h:170