Isis 3 Programmer Reference
ImagePolygon.h
1#ifndef ImagePolygon_h
2#define ImagePolygon_h
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
26namespace Isis {
27
154
155 public:
156 ImagePolygon();
157 ImagePolygon(Blob &blob);
158 ImagePolygon(const ImagePolygon &other);
160
161 void Create(Cube &cube, int sinc = 1, int linc = 1,
162 int ss = 1, int sl = 1, int ns = 0, int nl = 0, int band = 1,
163 bool increasePrecision = false);
164
165 void Create(std::vector<std::vector<double>> polyCoordinates);
166
167 Camera * initCube(Cube &cube, int ss = 1, int sl = 1,
168 int ns = 0, int nl = 0, int band = 1);
169
175 void Emission(double emission) {
176 p_emission = emission;
177 }
183 void Incidence(double incidence) {
184 p_incidence = incidence;
185 }
186
193 void EllipsoidLimb(bool ellip) {
194 p_ellipsoid = ellip;
195 }
196
206 void SubpixelAccuracy(int div) {
207 p_subpixelAccuracy = div;
208 }
209
211 geos::geom::MultiPolygon *Polys() {
212 return p_polygons;
213 };
214
216 std::string polyStr() const {
217 return p_polyStr;
218 };
219
220 double validSampleDim();
221 double validLineDim();
222
224 int getSinc() const {
225 return p_sampinc;
226 }
227
229 int getLinc() const {
230 return p_lineinc;
231 }
232
233 int numVertices() const {
234 return p_pts->getSize();
235 }
236
237 Blob toBlob() const;
238
239 private:
240 // Please do not add new polygon manipulation methods to this class.
241 // Polygon manipulation should be done in the PolygonTools class.
242 bool SetImage(const double sample, const double line);
243
244 geos::geom::Coordinate FindFirstPoint();
245 void WalkPoly();
246 geos::geom::Coordinate FindNextPoint(geos::geom::Coordinate *currentPoint,
247 geos::geom::Coordinate lastPoint,
248 int recursionDepth = 0);
249
250 double DistanceSquared(const geos::geom::Coordinate *p1, const geos::geom::Coordinate *p2);
251
252 void MoveBackInsideImage(double &sample, double &line, double sinc, double linc);
253 bool InsideImage(double sample, double line);
254 void Fix360Poly();
255 void FixPolePoly(std::vector<geos::geom::Coordinate> *crossingPoints);
256
257 bool IsLimb();
258 geos::geom::Coordinate FindBestPoint(geos::geom::Coordinate *currentPoint,
259 geos::geom::Coordinate newPoint,
260 geos::geom::Coordinate lastPoint);
261 geos::geom::Coordinate FixCornerSkip(geos::geom::Coordinate *currentPoint,
262 geos::geom::Coordinate newPoint);
263
264 void FindSubpixel(std::vector<geos::geom::Coordinate> & points);
265
267
270
272
273 geos::geom::CoordinateSequence *p_pts;
274
275 geos::geom::MultiPolygon *p_polygons;
276
277 std::string p_polyStr;
278
280
281 geos::geom::Coordinate *m_leftCoord;
282 geos::geom::Coordinate *m_rightCoord;
283 geos::geom::Coordinate *m_topCoord;
284 geos::geom::Coordinate *m_botCoord;
285
290
293
294 double p_emission;
295 double p_incidence;
297
299
300 };
301};
302
303#endif
Buffer for containing a three dimensional section of an image.
Definition Brick.h:45
IO Handler for Isis Cubes.
Definition Cube.h:168
Create cube polygons, read/write polygons to blobs.
bool IsLimb()
Returns True when the input image is a limb image.
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.
Brick * p_brick
Used to check for valid DNs.
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.
Cube * p_cube
The cube provided.
void EllipsoidLimb(bool ellip)
If a limb is detected, use un ellipsoid shape model if true.
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.
int getLinc() const
Return the line increment used the create this polygon.
int p_sampinc
The increment for walking along the polygon in the sample direction.
ImagePolygon()
Constructs a Polygon object, setting the polygon name.
int p_cubeLines
The number of lines in the cube.
void Emission(double emission)
Set the maximum emission angle ( light refleted to camera )
geos::geom::CoordinateSequence * p_pts
The sequence of coordinates that compose the boundary of the image.
int p_cubeSamps
The number of samples in the cube.
int p_subpixelAccuracy
The subpixel accuracy to use.
int p_lineinc
The increment for walking along the polygon in the line direcction.
geos::geom::Coordinate * m_botCoord
The cube's bot-most valid coord.
geos::geom::Coordinate * m_leftCoord
The cube's left-most valid coord.
UniversalGroundMap * p_gMap
The cube's ground map.
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 p_cubeStartLine
The the line of the first valid point in the cube.
double p_incidence
The maximum incidence angle to consider valid.
double DistanceSquared(const geos::geom::Coordinate *p1, const geos::geom::Coordinate *p2)
Calculates the distance squared between two coordinates.
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.
void FindSubpixel(std::vector< geos::geom::Coordinate > &points)
Takes p_polygons in sample/line space and finds its subpixel accuracy.
std::string p_polyStr
The string representation of the polygon.
bool p_ellipsoid
Uses an ellipsoid if a limb is detected.
bool SetImage(const double sample, const double line)
Sets the sample/line values of the cube to get lat/lon values.
geos::geom::MultiPolygon * Polys()
Return a geos Multipolygon.
void Fix360Poly()
If the cube crosses the 0/360 boundary and does not include a pole, the polygon is separated into mul...
~ImagePolygon()
Destroys the Polygon object.
void WalkPoly()
Walks the image finding its lon lat polygon and stores it to p_pts.
std::string polyStr() const
Return a geos Multipolygon.
double validLineDim()
Retuns the maximum valid line width of the cube set with either initCube() or Create()
bool p_isProjected
True when the provided cube is projected.
bool InsideImage(double sample, double line)
This returns true if sample/line are inside the cube.
void calcImageBorderCoordinates()
Calculates the four border points, particularly for validSampleDim() and validLineDim()
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.
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::Coordinate * m_topCoord
The cube's top-most valid coord.
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...
Blob toBlob() const
Serialize the ImagePolygon to a Blob.
geos::geom::Coordinate * m_rightCoord
The cube's right-most valid coord.
geos::geom::MultiPolygon * p_polygons
The multipolygon of the image.
void SubpixelAccuracy(int div)
The subpixel accuracy to use.
int p_cubeStartSamp
The the sample of the first valid point in the cube.
int getSinc() const
Return the sample increment used the create this polygon.
void Incidence(double incidence)
Set the maximum incidence angle ( light contacting the planet )
Universal Ground Map.
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16