![]() |
Isis 3 Programmer Reference
|
Create cube polygons, read/write polygons to blobs. More...
#include <ImagePolygon.h>
Public Member Functions | |
ImagePolygon () | |
Constructs a Polygon object, setting the polygon name. More... | |
ImagePolygon (Blob &blob) | |
Constructs a Polygon object from a Blob. More... | |
~ImagePolygon () | |
Destroys the Polygon object. More... | |
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. More... | |
void | Create (std::vector< std::vector< double >> polyCoordinates) |
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. More... | |
void | Emission (double emission) |
Set the maximum emission angle ( light refleted to camera ) More... | |
void | Incidence (double incidence) |
Set the maximum incidence angle ( light contacting the planet ) More... | |
void | EllipsoidLimb (bool ellip) |
If a limb is detected, use un ellipsoid shape model if true. More... | |
void | SubpixelAccuracy (int div) |
The subpixel accuracy to use. More... | |
geos::geom::MultiPolygon * | Polys () |
Return a geos Multipolygon. More... | |
std::string | polyStr () const |
Return a geos Multipolygon. More... | |
double | validSampleDim () |
Retuns the maximum valid sample width of the cube set with either initCube() or Create() More... | |
double | validLineDim () |
Retuns the maximum valid line width of the cube set with either initCube() or Create() More... | |
int | getSinc () const |
Return the sample increment used the create this polygon. More... | |
int | getLinc () const |
Return the line increment used the create this polygon. More... | |
int | numVertices () const |
Blob | toBlob () const |
Serialize the ImagePolygon to a Blob. More... | |
Private Member Functions | |
bool | SetImage (const double sample, const double line) |
Sets the sample/line values of the cube to get lat/lon values. More... | |
geos::geom::Coordinate | FindFirstPoint () |
Finds the first point that projects in an image. More... | |
void | WalkPoly () |
Walks the image finding its lon lat polygon and stores it to p_pts. More... | |
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. More... | |
double | DistanceSquared (const geos::geom::Coordinate *p1, const geos::geom::Coordinate *p2) |
Calculates the distance squared between two coordinates. More... | |
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. More... | |
bool | InsideImage (double sample, double line) |
This returns true if sample/line are inside the cube. More... | |
void | Fix360Poly () |
If the cube crosses the 0/360 boundary and does not include a pole, the polygon is separated into multiple polygons, usually one on each side of the boundary. More... | |
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 polygon to unwrap properly. More... | |
bool | IsLimb () |
Returns True when the input image is a limb image. More... | |
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 first valid point found and the last point which failed its validity test using a linear search. More... | |
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 grab valid corner data. More... | |
void | FindSubpixel (std::vector< geos::geom::Coordinate > &points) |
Takes p_polygons in sample/line space and finds its subpixel accuracy. More... | |
void | calcImageBorderCoordinates () |
Calculates the four border points, particularly for validSampleDim() and validLineDim() More... | |
Private Attributes | |
Cube * | p_cube |
The cube provided. More... | |
bool | p_isProjected |
True when the provided cube is projected. More... | |
Brick * | p_brick |
Used to check for valid DNs. More... | |
geos::geom::CoordinateSequence * | p_pts |
The sequence of coordinates that compose the boundry of the image. More... | |
geos::geom::MultiPolygon * | p_polygons |
The multipolygon of the image. More... | |
std::string | p_polyStr |
The string representation of the polygon. More... | |
UniversalGroundMap * | p_gMap |
The cube's ground map. More... | |
geos::geom::Coordinate * | m_leftCoord |
The cube's left-most valid coord. More... | |
geos::geom::Coordinate * | m_rightCoord |
The cube's right-most valid coord. More... | |
geos::geom::Coordinate * | m_topCoord |
The cube's top-most valid coord. More... | |
geos::geom::Coordinate * | m_botCoord |
The cube's bot-most valid coord. More... | |
int | p_cubeStartSamp |
The the sample of the first valid point in the cube. More... | |
int | p_cubeStartLine |
The the line of the first valid point in the cube. More... | |
int | p_cubeSamps |
The number of samples in the cube. More... | |
int | p_cubeLines |
The number of lines in the cube. More... | |
int | p_sampinc |
The increment for walking along the polygon in the sample direction. More... | |
int | p_lineinc |
The increment for walking along the polygon in the line direcction. More... | |
double | p_emission |
The maximum emission angle to consider valid. More... | |
double | p_incidence |
The maximum incidence angle to consider valid. More... | |
bool | p_ellipsoid |
Uses an ellipsoid if a limb is detected. More... | |
int | p_subpixelAccuracy |
The subpixel accuracy to use. More... | |
Create cube polygons, read/write polygons to blobs.
This class creates polygons defining an image boundary, reads the polygon from a cube blob, and writes a polygon to a cube blob. The GEOS (Geometry Engine Open Source) package is used to create and manipulate the polygons. See http://geos.refractions.net for information about this package.
Definition at line 153 of file ImagePolygon.h.
Isis::ImagePolygon::ImagePolygon | ( | ) |
Constructs a Polygon object, setting the polygon name.
Definition at line 40 of file ImagePolygon.cpp.
Isis::ImagePolygon::ImagePolygon | ( | Blob & | blob | ) |
Constructs a Polygon object from a Blob.
Definition at line 66 of file ImagePolygon.cpp.
References Isis::Blob::getBuffer(), Isis::PolygonTools::MakeMultiPolygon(), p_polygons, p_polyStr, p_pts, and Isis::Blob::Size().
Isis::ImagePolygon::~ImagePolygon | ( | ) |
Destroys the Polygon object.
Definition at line 86 of file ImagePolygon.cpp.
References m_botCoord, m_leftCoord, m_rightCoord, m_topCoord, p_cube, and p_polygons.
|
private |
Calculates the four border points, particularly for validSampleDim() and validLineDim()
Definition at line 589 of file ImagePolygon.cpp.
References Isis::Cube::lineCount(), m_botCoord, m_leftCoord, m_rightCoord, m_topCoord, p_cube, p_cubeLines, p_cubeSamps, p_cubeStartLine, p_cubeStartSamp, and SetImage().
Referenced by validLineDim(), and validSampleDim().
void Isis::ImagePolygon::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.
[in] | cube | (Cube &) Cube used to create polygon |
[in] | sinc | (Default=1) (in) Pixel increment to define the granularity of the resulting polygon in the sample direction |
[in] | linc | (Default=1) (in) Pixel increment to define the granularity of the resulting polygon in the line direction |
[in] | ss | (Default=1) (in) Starting sample number |
[in] | sl | (Default=1) (in) Starting Line number |
[in] | ns | (Default=0) (in) Number of samples used to create the polygon. Default of 0 will cause ns to be set to the number of samples in the cube. |
[in] | nl | (Default=0) (in) Number of lines used to create the polygon. Default of 0 will cause nl to be set to the number of lines in the cube. |
[in] | band | (Default=1) (in) Image band number |
increasePrecision | Iteratively refine sinc and linc (defaults to false) |
Definition at line 217 of file ImagePolygon.cpp.
References Isis::Camera::BasicMapping(), Isis::UniversalGroundMap::Camera(), Isis::Cube::fileName(), Fix360Poly(), Isis::Sensor::IgnoreElevationModel(), initCube(), p_brick, p_gMap, p_lineinc, p_pts, p_sampinc, Isis::IException::print(), Isis::IException::User, and WalkPoly().
Referenced by Isis::Image::createFootprint(), and Isis::Shape::createFootprint().
|
private |
Calculates the distance squared between two coordinates.
p1 | The first Coordinate for the calculation |
p2 | The second Coordinate for the calculation |
return The distance squared between the Coordinates
Definition at line 1373 of file ImagePolygon.cpp.
Referenced by FixPolePoly(), and WalkPoly().
|
inline |
If a limb is detected, use un ellipsoid shape model if true.
If false, use the default (spiceinit defined) shape model.
ellip | True to use ellipsoid on limb images |
Definition at line 192 of file ImagePolygon.h.
References p_ellipsoid.
|
inline |
Set the maximum emission angle ( light refleted to camera )
emission | The maximum valid emission angle |
Definition at line 174 of file ImagePolygon.h.
References p_emission.
|
private |
While walking the image in sample/line space, this function finds the best valid point between the first valid point found and the last point which failed its validity test using a linear search.
currentPoint | The last point added to the polygon |
newPoint | The first valid point found for the next step. |
lastPoint | The last point that was found to be invalid which checking for the next step. |
Definition at line 1407 of file ImagePolygon.cpp.
References FixCornerSkip(), p_cubeLines, p_cubeSamps, p_cubeStartLine, p_cubeStartSamp, p_lineinc, p_sampinc, and SetImage().
Referenced by FindNextPoint().
|
private |
Finds the first point that projects in an image.
Definition at line 528 of file ImagePolygon.cpp.
References FindNextPoint(), p_cubeLines, p_cubeSamps, p_cubeStartLine, p_cubeStartSamp, SetImage(), and Isis::IException::User.
Referenced by WalkPoly().
|
private |
Finds the next point on the image using a left hand rule walking algorithm.
To initiate the walk pass it the same point for both currentPoint and lastPoint.
[in] | currentPoint | (geos::geom::Coordinate *currentPoint) This is the currentPoint in the path. You are looking for its successor. |
[in] | lastPoint | (geos::geom::Coordinate lastPoint) This is the lastPoint in the path, it allows the algorithm to calculate direction. |
[in] | recursionDepth | (int) This optional parameter keeps track of how far it has walked around a point. By default it is zero. |
throws Isis::iException::Programmer - Error walking the file
Definition at line 316 of file ImagePolygon.cpp.
References FindBestPoint(), InsideImage(), MoveBackInsideImage(), p_lineinc, p_sampinc, Isis::IException::Programmer, SetImage(), and Isis::IException::Unknown.
Referenced by FindFirstPoint(), and WalkPoly().
|
private |
Takes p_polygons in sample/line space and finds its subpixel accuracy.
This algorithm depends on a left-hand-turn algorithm and assumes that the vector of Coordinates provided is not empty.
points | The vector of Coordinate to set to subpixel accuracy |
Definition at line 1528 of file ImagePolygon.cpp.
References InsideImage(), p_lineinc, p_sampinc, p_subpixelAccuracy, and SetImage().
Referenced by WalkPoly().
|
private |
If the cube crosses the 0/360 boundary and does not include a pole, the polygon is separated into multiple polygons, usually one on each side of the boundary.
These polygons are put into a geos Multipolygon. If the cube does not cross the 0/360 boundary then the Multipolygon will be a single Polygon.
Definition at line 1141 of file ImagePolygon.cpp.
References Isis::PolygonTools::Intersect(), Isis::PolygonTools::MakeMultiPolygon(), p_polygons, p_pts, Isis::IException::Unknown, and Isis::IException::what().
Referenced by Create().
|
private |
Looks at the next possible point relative to the lasts and attempts to adjust the point outward to grab valid corner data.
currentPoint | The last valid point added to the polygon |
newPoint | The new point to be added to the polygon |
Definition at line 1472 of file ImagePolygon.cpp.
References p_cubeLines, p_cubeSamps, p_lineinc, p_sampinc, and SetImage().
Referenced by FindBestPoint().
|
private |
If the cube crosses the 0/360 boundary and contains a pole, Some points are added to allow the polygon to unwrap properly.
Throws an error if both poles are in the image. Returns if there is no pole in the image.
crossingPoints | The coordinate sequence that crosses the 0/360 boundry |
Definition at line 835 of file ImagePolygon.cpp.
References Isis::UniversalGroundMap::Camera(), DistanceSquared(), Isis::Sensor::EmissionAngle(), Isis::Sensor::IncidenceAngle(), Isis::Camera::Line(), Isis::Null, p_emission, p_gMap, p_incidence, p_pts, Isis::IException::Programmer, Isis::UniversalGroundMap::Projection(), Isis::Camera::Sample(), Isis::UniversalGroundMap::SetUniversalGround(), Isis::Projection::WorldX(), and Isis::Projection::WorldY().
Referenced by WalkPoly().
|
inline |
Return the line increment used the create this polygon.
Definition at line 228 of file ImagePolygon.h.
References p_lineinc.
|
inline |
Return the sample increment used the create this polygon.
Definition at line 223 of file ImagePolygon.h.
References p_sampinc.
|
inline |
Set the maximum incidence angle ( light contacting the planet )
incidence | The maximum valid incidence angle |
Definition at line 182 of file ImagePolygon.h.
References p_incidence.
Camera * Isis::ImagePolygon::initCube | ( | Cube & | cube, |
int | ss = 1 , |
||
int | sl = 1 , |
||
int | ns = 0 , |
||
int | nl = 0 , |
||
int | band = 1 |
||
) |
Create a Polygon from given cube.
[in] | cube | (Cube &) Cube used to create polygon |
[in] | ss | (Default=1) (in) Starting sample number |
[in] | sl | (Default=1) (in) Starting Line number |
[in] | ns | (Default=0) (in) Number of samples used to create the polygon. Default of 0 will cause ns to be set to the number of samples in the cube. |
[in] | nl | (Default=0) (in) Number of lines used to create the polygon. Default of 0 will cause nl to be set to the number of lines in the cube. |
[in] | band | (Default=1) (in) Image band number |
Definition at line 121 of file ImagePolygon.cpp.
References Isis::IException::append(), Isis::Cube::camera(), Isis::UniversalGroundMap::Camera(), Isis::Cube::fileName(), Isis::Camera::HasProjection(), Isis::Sensor::IgnoreElevationModel(), IsLimb(), Isis::Cube::lineCount(), p_brick, p_cube, p_cubeLines, p_cubeSamps, p_cubeStartLine, p_cubeStartSamp, p_ellipsoid, p_gMap, p_isProjected, Isis::Cube::pixelType(), Isis::Cube::projection(), Isis::Cube::sampleCount(), Isis::UniversalGroundMap::SetBand(), and Isis::IException::User.
Referenced by Create().
|
private |
This returns true if sample/line are inside the cube.
sample | |
line |
Definition at line 514 of file ImagePolygon.cpp.
References p_cubeLines, p_cubeSamps, p_cubeStartLine, and p_cubeStartSamp.
Referenced by FindNextPoint(), and FindSubpixel().
|
private |
Returns True when the input image is a limb image.
Definition at line 1383 of file ImagePolygon.cpp.
References p_cubeLines, p_cubeSamps, and SetImage().
Referenced by initCube().
|
private |
This method ensures sample/line after sinc/linc have been applied is inside the image.
If not, it snaps to the edge of the image - given we didn't start at the edge.
sample | Sample after sinc applied |
line | Line after linc applied |
sinc | Sample increment (we can back up at most this much) |
linc | Line increment (we can back up at most this much) |
Definition at line 446 of file ImagePolygon.cpp.
References p_cubeLines, p_cubeSamps, p_cubeStartLine, and p_cubeStartSamp.
Referenced by FindNextPoint().
|
inline |
Return a geos Multipolygon.
Definition at line 210 of file ImagePolygon.h.
References p_polygons.
Referenced by Isis::Image::createFootprint(), Isis::Shape::createFootprint(), Isis::ImageOverlapSet::FindImageOverlaps(), Isis::UniversalGroundMap::GroundRange(), and Isis::Image::initQuickFootprint().
|
inline |
Return a geos Multipolygon.
Definition at line 215 of file ImagePolygon.h.
References p_polyStr.
Referenced by Isis::GisGeometry::fromCube(), and toBlob().
|
private |
Sets the sample/line values of the cube to get lat/lon values.
This method checks whether the image pixel is Null for level 2 images and if so, it is considered an invalid pixel.
[in] | sample | (const double) Sample coordinate of the cube |
[in] | line | (const double) Line coordinate of the cube |
This check has been removed because it causes push frame cameras to fail inbetween the framelets, resulting in only the first framlet to be walked, leaving out the rest of the image.
This can cause autoseed/jigsaw issues, since they require conversion from lat/lon to samp/line
Definition at line 1079 of file ImagePolygon.cpp.
References Isis::UniversalGroundMap::Camera(), Isis::Sensor::EmissionAngle(), Isis::Sensor::IncidenceAngle(), Isis::IsNullPixel(), p_brick, p_cube, p_emission, p_gMap, p_incidence, p_isProjected, Isis::Cube::read(), Isis::Brick::SetBasePosition(), and Isis::UniversalGroundMap::SetImage().
Referenced by calcImageBorderCoordinates(), FindBestPoint(), FindFirstPoint(), FindNextPoint(), FindSubpixel(), FixCornerSkip(), IsLimb(), and WalkPoly().
|
inline |
The subpixel accuracy to use.
This accuracy is the number of binary steps to take to find the subpixel accuracy. A higher number provided gives more accurate results at the cost of runtime.
ImagePolygon's constructor sets a default value of 50
div | The subpixel accuracy to use |
Definition at line 205 of file ImagePolygon.h.
References p_subpixelAccuracy.
Blob Isis::ImagePolygon::toBlob | ( | ) | const |
Serialize the ImagePolygon to a Blob.
The polygon will be serialized as a WKT srtring.
Definition at line 1347 of file ImagePolygon.cpp.
References p_polygons, polyStr(), Isis::IException::Programmer, and Isis::Blob::setData().
Referenced by Isis::Image::isFootprintable(), Isis::Shape::isFootprintable(), and Isis::Cube::write().
double Isis::ImagePolygon::validLineDim | ( | ) |
Retuns the maximum valid line width of the cube set with either initCube() or Create()
Definition at line 570 of file ImagePolygon.cpp.
References calcImageBorderCoordinates(), m_botCoord, and m_topCoord.
double Isis::ImagePolygon::validSampleDim | ( | ) |
Retuns the maximum valid sample width of the cube set with either initCube() or Create()
Definition at line 555 of file ImagePolygon.cpp.
References calcImageBorderCoordinates(), m_leftCoord, and m_rightCoord.
|
private |
Walks the image finding its lon lat polygon and stores it to p_pts.
WARNING: Very large pixel increments for cubes that have cameras/projections with no data at any of the 4 corners can still fail in this algorithm.
If we have a very large polygon, look for the inability to find the starting point by looking for the first cycle in the polygon
"very large" is defined as 250 points
Definition at line 638 of file ImagePolygon.cpp.
References DistanceSquared(), FindFirstPoint(), FindNextPoint(), FindSubpixel(), FixPolePoly(), p_cubeLines, p_cubeSamps, p_gMap, p_lineinc, p_pts, p_sampinc, Isis::IException::Programmer, SetImage(), Isis::UniversalGroundMap::UniversalLatitude(), and Isis::UniversalGroundMap::UniversalLongitude().
Referenced by Create().
|
private |
The cube's bot-most valid coord.
Definition at line 283 of file ImagePolygon.h.
Referenced by calcImageBorderCoordinates(), validLineDim(), and ~ImagePolygon().
|
private |
The cube's left-most valid coord.
Definition at line 280 of file ImagePolygon.h.
Referenced by calcImageBorderCoordinates(), validSampleDim(), and ~ImagePolygon().
|
private |
The cube's right-most valid coord.
Definition at line 281 of file ImagePolygon.h.
Referenced by calcImageBorderCoordinates(), validSampleDim(), and ~ImagePolygon().
|
private |
The cube's top-most valid coord.
Definition at line 282 of file ImagePolygon.h.
Referenced by calcImageBorderCoordinates(), validLineDim(), and ~ImagePolygon().
|
private |
Used to check for valid DNs.
Definition at line 270 of file ImagePolygon.h.
Referenced by Create(), initCube(), and SetImage().
|
private |
The cube provided.
Definition at line 267 of file ImagePolygon.h.
Referenced by calcImageBorderCoordinates(), initCube(), SetImage(), and ~ImagePolygon().
|
private |
The number of lines in the cube.
Definition at line 288 of file ImagePolygon.h.
Referenced by calcImageBorderCoordinates(), FindBestPoint(), FindFirstPoint(), FixCornerSkip(), initCube(), InsideImage(), IsLimb(), MoveBackInsideImage(), and WalkPoly().
|
private |
The number of samples in the cube.
Definition at line 287 of file ImagePolygon.h.
Referenced by calcImageBorderCoordinates(), FindBestPoint(), FindFirstPoint(), FixCornerSkip(), initCube(), InsideImage(), IsLimb(), MoveBackInsideImage(), and WalkPoly().
|
private |
The the line of the first valid point in the cube.
Definition at line 286 of file ImagePolygon.h.
Referenced by calcImageBorderCoordinates(), FindBestPoint(), FindFirstPoint(), initCube(), InsideImage(), and MoveBackInsideImage().
|
private |
The the sample of the first valid point in the cube.
Definition at line 285 of file ImagePolygon.h.
Referenced by calcImageBorderCoordinates(), FindBestPoint(), FindFirstPoint(), initCube(), InsideImage(), and MoveBackInsideImage().
|
private |
Uses an ellipsoid if a limb is detected.
Definition at line 295 of file ImagePolygon.h.
Referenced by EllipsoidLimb(), and initCube().
|
private |
The maximum emission angle to consider valid.
Definition at line 293 of file ImagePolygon.h.
Referenced by Emission(), FixPolePoly(), and SetImage().
|
private |
The cube's ground map.
Definition at line 278 of file ImagePolygon.h.
Referenced by Create(), FixPolePoly(), initCube(), SetImage(), and WalkPoly().
|
private |
The maximum incidence angle to consider valid.
Definition at line 294 of file ImagePolygon.h.
Referenced by FixPolePoly(), Incidence(), and SetImage().
|
private |
True when the provided cube is projected.
Definition at line 268 of file ImagePolygon.h.
Referenced by initCube(), and SetImage().
|
private |
The increment for walking along the polygon in the line direcction.
Definition at line 291 of file ImagePolygon.h.
Referenced by Create(), FindBestPoint(), FindNextPoint(), FindSubpixel(), FixCornerSkip(), getLinc(), and WalkPoly().
|
private |
The multipolygon of the image.
Definition at line 274 of file ImagePolygon.h.
Referenced by Fix360Poly(), ImagePolygon(), Polys(), toBlob(), and ~ImagePolygon().
|
private |
The string representation of the polygon.
Definition at line 276 of file ImagePolygon.h.
Referenced by ImagePolygon(), and polyStr().
|
private |
The sequence of coordinates that compose the boundry of the image.
Definition at line 272 of file ImagePolygon.h.
Referenced by Create(), Fix360Poly(), FixPolePoly(), ImagePolygon(), and WalkPoly().
|
private |
The increment for walking along the polygon in the sample direction.
Definition at line 290 of file ImagePolygon.h.
Referenced by Create(), FindBestPoint(), FindNextPoint(), FindSubpixel(), FixCornerSkip(), getSinc(), and WalkPoly().
|
private |
The subpixel accuracy to use.
Definition at line 297 of file ImagePolygon.h.
Referenced by FindSubpixel(), and SubpixelAccuracy().
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:19:50 |