Isis 3 Programmer Reference
Isis::GroundGrid Class Reference

Calculates a lat/lon grid over an area. More...

#include <GroundGrid.h>

Collaboration diagram for Isis::GroundGrid:
Collaboration graph

Public Member Functions

 GroundGrid (UniversalGroundMap *gmap, bool splitLatLon, bool extendGrid, unsigned int width, unsigned int height)
 This method initializes the class by allocating the grid, calculating the lat/lon range, and getting a default grid resolution.
 
virtual ~GroundGrid ()
 Delete the object.
 
void CreateGrid (Latitude baseLat, Longitude baseLon, Angle latInc, Angle lonInc, Progress *progress=0)
 This method draws the grid internally, using default resolutions.
 
void CreateGrid (Latitude baseLat, Longitude baseLon, Angle latInc, Angle lonInc, Progress *progress, Angle latRes, Angle lonRes)
 This method draws the grid internally.
 
void WalkBoundary ()
 This draws grid lines along the extremes of the lat/lon box of the grid.
 
void SetGroundLimits (Latitude minLat, Longitude minLon, Latitude maxLat, Longitude maxLon)
 This restricts (or grows) the ground range in which to draw grid lines.
 
bool PixelOnGrid (int x, int y)
 Returns true if the grid is on this point.
 
bool PixelOnGrid (int x, int y, bool latGrid)
 Returns true if the grid is on this point.
 
Latitude minLatitude () const
 Returns the minimum latitude for the grid.
 
Longitude minLongitude () const
 Returns the minimum longitude for the grid.
 
Latitude maxLatitude () const
 Returns the maximum latitude for the grid.
 
Longitude maxLongitude () const
 Returns the maximum longitude for the grid.
 
PvlGroupGetMappingGroup ()
 Returns a mapping group representation of the projection or camera.
 

Protected Member Functions

virtual bool GetXY (Latitude lat, Longitude lon, unsigned int &x, unsigned int &y)
 This method converts a lat/lon to an X/Y.
 
UniversalGroundMapGroundMap ()
 Returns the ground map for children.
 

Private Member Functions

void SetGridBit (unsigned int x, unsigned int y, bool latGrid)
 This flags a bit as on the grid lines.
 
bool GetGridBit (unsigned int x, unsigned int y, bool latGrid)
 Returns true if the specified coordinate is on the grid lines.
 
void DrawLineOnGrid (unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, bool isLatLine)
 This sets the bits on the grid along the specified line.
 

Private Attributes

char * p_grid
 This stores the bits of each pixel in the grid.
 
char * p_latLinesGrid
 This stores the bits of each pixel in the grid.
 
char * p_lonLinesGrid
 This stores the bits of each pixel in the grid.
 
unsigned int p_width
 This is the width of the grid.
 
unsigned int p_height
 This is the height of the grid.
 
unsigned long p_gridSize
 This is width*height.
 
UniversalGroundMapp_groundMap
 This calculates single grid pts.
 
Latitudep_minLat
 Lowest latitude in image.
 
Longitudep_minLon
 Lowest longitude in image.
 
Latitudep_maxLat
 Highest latitude in image.
 
Longitudep_maxLon
 Highest longitude in image.
 
PvlGroupp_mapping
 The mapping group representation of the projection or camera.
 
double p_defaultResolution
 Default step size in degrees/pixel.
 
bool p_reinitialize
 True if we need to reset p_grid in CreateGrid.
 
bool m_extendGrid
 If the grid should extend past the longitude domain boundary.
 

Detailed Description

Calculates a lat/lon grid over an area.

This class, given a universal ground map, area width and height, base lat/lon, lat/lon increments, and optionalls a progress and resolutions will calculate where grid lines should lie.

Author
2010-01-06 Steven Lambright
History

2010-05-06 Steven Lambright - Added Split Lat/Lon functionality

2010-06-22 Steven Lambright - Improved handling of resolutions

2011-01-25 Steven Lambright - Now uses native units to the projection, Lat/Lon classes, and several bug fixes when it comes to out of range values or non-standard projection types.

2011-01-26 Steven Lambright - Fixed a bug where the grid was not consistent on the edges and added SetGroundLimits and WalkBoundary for the new grid options Bound lat/lon range.

2011-02-25 Steven Lambright - Min/Max Lat/Lons do not have to be known in the constructor any more

2011-12-08 Steven Lambright - Fixed a bug causing the longitude range to be incorrect. Fixes #607.

2014-06-06 Kristin Berry - Fixed a bug where lat/lon were swapped in the code. Fixes #2081.

2016-09-29 Jeannie Backer - Changed Latitude objects that were created with Latitude's mapping group constructor to have enum value Latitude::AllowPastPole. This was done for p_minLat in the GroundGrid constructor and for startLat in the CreateGrid() method. The reason for this is that these objects are copied to initialize another Latitude variable (lat) within for-loops that go past the poles. Thus lat must be allowed to go past the poles. This bug was uncovered when Latitude's virtual setAngle() method was fixed to match the signature of the parent method. Moved implementation of GroundMap() and GetMappingGroup() to the cpp file per ISIS coding standards.

2017-04-10 Jesse Mapel - Modified to not throw an exception when calculating longitude lines close to 90 or -90 latitude. Fixes #4766.

2017-06-28 Jesse Mapel - Added a flag to extend the grid past the longitude domain boundary. Fixes #2185.

Definition at line 58 of file GroundGrid.h.

Constructor & Destructor Documentation

◆ GroundGrid()

Isis::GroundGrid::GroundGrid ( UniversalGroundMap * gmap,
bool splitLatLon,
bool extendGrid,
unsigned int width,
unsigned int height )

This method initializes the class by allocating the grid, calculating the lat/lon range, and getting a default grid resolution.

Parameters
gmapA universal ground map to use for calculating the grid
splitLatLonMake two grids: one for latitude lines and one for longitude lines
extendGridIf the grid should extend past the longitude domain boundary.
widthThe width of the grid; often cube samples
heightThe height of the grid; often cube samples

Definition at line 40 of file GroundGrid.cpp.

References Isis::Latitude::AllowPastPole, Isis::Camera::BasicMapping(), Isis::UniversalGroundMap::Camera(), Isis::Angle::Degrees, Isis::UniversalGroundMap::HasCamera(), Isis::PvlContainer::hasKeyword(), Isis::Camera::HighestImageResolution(), Isis::Angle::isValid(), m_extendGrid, Isis::Distance::Meters, p_defaultResolution, p_grid, p_gridSize, p_groundMap, p_height, p_latLinesGrid, p_lonLinesGrid, p_mapping, p_maxLat, p_maxLon, p_minLat, p_minLon, p_reinitialize, p_width, Isis::UniversalGroundMap::Projection(), Isis::UniversalGroundMap::Resolution(), and Isis::toDouble().

◆ ~GroundGrid()

Isis::GroundGrid::~GroundGrid ( )
virtual

Delete the object.

Definition at line 167 of file GroundGrid.cpp.

References p_grid, p_latLinesGrid, p_lonLinesGrid, p_mapping, p_maxLat, p_maxLon, p_minLat, and p_minLon.

Member Function Documentation

◆ CreateGrid() [1/2]

void Isis::GroundGrid::CreateGrid ( Latitude baseLat,
Longitude baseLon,
Angle latInc,
Angle lonInc,
Progress * progress,
Angle latRes,
Angle lonRes )

This method draws the grid internally.

It is not valid to call PixelOnGrid until this method has been called.

Parameters
baseLatLatitude to hit in the grid
baseLonLongitude to hit in the grid
latIncDistance between latitude lines
lonIncDistance between longitude lines
progressIf passed in, this progress will be used
latResResolution of latitude lines (in degrees/pixel)
lonResResolution of longitude lines (in degrees/pixel)

Definition at line 239 of file GroundGrid.cpp.

References Isis::Latitude::AllowPastPole, Isis::Progress::CheckStatus(), Isis::Angle::Degrees, DrawLineOnGrid(), GetMappingGroup(), GetXY(), Isis::Angle::isValid(), p_defaultResolution, p_grid, p_gridSize, p_groundMap, p_latLinesGrid, p_lonLinesGrid, p_maxLat, p_maxLon, p_minLat, p_minLon, p_reinitialize, Isis::IException::Programmer, Isis::Latitude::setErrorChecking(), Isis::Progress::SetMaximumSteps(), and Isis::IException::Unknown.

◆ CreateGrid() [2/2]

void Isis::GroundGrid::CreateGrid ( Latitude baseLat,
Longitude baseLon,
Angle latInc,
Angle lonInc,
Progress * progress = 0 )

This method draws the grid internally, using default resolutions.

Parameters
baseLatLatitude to hit in the grid
baseLonLongitude to hit in the grid
latIncDistance between latitude lines
lonIncDistance between longitude lines
progressIf passed in, this progress will be used

Definition at line 218 of file GroundGrid.cpp.

References CreateGrid().

Referenced by CreateGrid().

◆ DrawLineOnGrid()

void Isis::GroundGrid::DrawLineOnGrid ( unsigned int x1,
unsigned int y1,
unsigned int x2,
unsigned int y2,
bool isLatLine )
private

This sets the bits on the grid along the specified line.

Parameters
x1Start X
y1Start Y
x2End X
y2End Y
isLatLine

Definition at line 730 of file GroundGrid.cpp.

References SetGridBit().

Referenced by CreateGrid(), and WalkBoundary().

◆ GetGridBit()

bool Isis::GroundGrid::GetGridBit ( unsigned int x,
unsigned int y,
bool latGrid )
private

Returns true if the specified coordinate is on the grid lines.

Parameters
xX-Coordinate (0-based)
yY-Coordinate (0-based)
latGridTrue if you want to access the latitude grid where there are separate lat/lon grids. False for lon. Irrelevant if using a single grid.
Returns
bool Value at grid coordinate

Definition at line 691 of file GroundGrid.cpp.

References p_grid, p_gridSize, p_latLinesGrid, p_lonLinesGrid, p_width, and Isis::IException::Programmer.

Referenced by PixelOnGrid(), and PixelOnGrid().

◆ GetMappingGroup()

PvlGroup * Isis::GroundGrid::GetMappingGroup ( )

Returns a mapping group representation of the projection or camera.

This is useful for matching units with lat/lons.

Returns
Returns a mapping group representation of the projection or camera

Definition at line 546 of file GroundGrid.cpp.

References p_mapping.

Referenced by CreateGrid().

◆ GetXY()

bool Isis::GroundGrid::GetXY ( Latitude lat,
Longitude lon,
unsigned int & x,
unsigned int & y )
protectedvirtual

This method converts a lat/lon to an X/Y.

This implementation converts to sample/line.

Parameters
latLatitude of Lat/Lon pair to convert to S/L
lonLongitude of Lat/Lon pair to convert to S/L
xOutput sample (0-based)
yOutput line (0-based)
Returns
bool Successful

Definition at line 618 of file GroundGrid.cpp.

References GroundMap(), Isis::UniversalGroundMap::Line(), m_extendGrid, p_groundMap, p_height, p_width, and Isis::UniversalGroundMap::Sample().

Referenced by CreateGrid(), and WalkBoundary().

◆ GroundMap()

UniversalGroundMap * Isis::GroundGrid::GroundMap ( )
protected

Returns the ground map for children.

Definition at line 643 of file GroundGrid.cpp.

References p_groundMap.

Referenced by GetXY().

◆ maxLatitude()

Latitude Isis::GroundGrid::maxLatitude ( ) const

Returns the maximum latitude for the grid.

Returns
Latitude The maximum latitude for the grid. If no maximum has been set, then a default Latitude object is returned.

Definition at line 585 of file GroundGrid.cpp.

References p_maxLat.

◆ maxLongitude()

Longitude Isis::GroundGrid::maxLongitude ( ) const

Returns the maximum longitude for the grid.

Returns
Longitude The maximum longitude for the grid. If no maximum has been set, then a default Longitude object is returned.

Definition at line 599 of file GroundGrid.cpp.

References p_maxLon.

◆ minLatitude()

Latitude Isis::GroundGrid::minLatitude ( ) const

Returns the minimum latitude for the grid.

Returns
Latitude The minimum latitude for the grid. If no minimum has been set, then a default Latitude object is returned.

Definition at line 557 of file GroundGrid.cpp.

References p_minLat.

◆ minLongitude()

Longitude Isis::GroundGrid::minLongitude ( ) const

Returns the minimum longitude for the grid.

Returns
Longitude The minimum longitude for the grid. If no minimum has been set, then a default Longitude object is returned.

Definition at line 571 of file GroundGrid.cpp.

References p_minLon.

◆ PixelOnGrid() [1/2]

bool Isis::GroundGrid::PixelOnGrid ( int x,
int y )

Returns true if the grid is on this point.

Parameters
xX-Coordinate of grid (0-based)
yY-Coordinate of grid (0-based)
Returns
bool Pixel lies on grid

Definition at line 529 of file GroundGrid.cpp.

References GetGridBit(), p_height, and p_width.

◆ PixelOnGrid() [2/2]

bool Isis::GroundGrid::PixelOnGrid ( int x,
int y,
bool latGrid )

Returns true if the grid is on this point.

Using this method is recommended if lat/lon grids are separate.

Parameters
xX-Coordinate of grid (0-based)
yY-Coordinate of grid (0-based)
latGridTrue for latitude lines, false for longitude lines
Returns
bool Pixel lies on grid

Definition at line 510 of file GroundGrid.cpp.

References GetGridBit(), p_height, and p_width.

◆ SetGridBit()

void Isis::GroundGrid::SetGridBit ( unsigned int x,
unsigned int y,
bool latGrid )
private

This flags a bit as on the grid lines.

Parameters
xX-Coordinate (0-based)
yY-Coordinate (0-based)
latGridTrue if this is derived from a latitude line

Definition at line 655 of file GroundGrid.cpp.

References p_grid, p_gridSize, p_latLinesGrid, p_lonLinesGrid, p_width, and Isis::IException::Programmer.

Referenced by DrawLineOnGrid().

◆ SetGroundLimits()

void Isis::GroundGrid::SetGroundLimits ( Latitude minLat,
Longitude minLon,
Latitude maxLat,
Longitude maxLon )

This restricts (or grows) the ground range in which to draw grid lines.

Parameters
minLatThe lowest latitude extreme to draw grid lines to
maxLatThe highest latitude extreme to draw grid lines to
minLonThe lowest longitude extreme to draw grid lines to
maxLonThe highest longitude extreme to draw grid lines to

Definition at line 411 of file GroundGrid.cpp.

References Isis::Angle::isValid(), p_maxLat, p_maxLon, p_minLat, and p_minLon.

◆ WalkBoundary()

void Isis::GroundGrid::WalkBoundary ( )

This draws grid lines along the extremes of the lat/lon box of the grid.

Definition at line 434 of file GroundGrid.cpp.

References Isis::Latitude::AllowPastPole, Isis::Angle::Degrees, DrawLineOnGrid(), GetXY(), p_defaultResolution, p_maxLat, p_maxLon, p_minLat, p_minLon, and Isis::Latitude::setErrorChecking().

Member Data Documentation

◆ m_extendGrid

bool Isis::GroundGrid::m_extendGrid
private

If the grid should extend past the longitude domain boundary.

Definition at line 132 of file GroundGrid.h.

Referenced by GetXY(), and GroundGrid().

◆ p_defaultResolution

double Isis::GroundGrid::p_defaultResolution
private

Default step size in degrees/pixel.

Definition at line 129 of file GroundGrid.h.

Referenced by CreateGrid(), GroundGrid(), and WalkBoundary().

◆ p_grid

char* Isis::GroundGrid::p_grid
private

This stores the bits of each pixel in the grid.

Definition at line 113 of file GroundGrid.h.

Referenced by CreateGrid(), GetGridBit(), GroundGrid(), SetGridBit(), and ~GroundGrid().

◆ p_gridSize

unsigned long Isis::GroundGrid::p_gridSize
private

This is width*height.

Definition at line 118 of file GroundGrid.h.

Referenced by CreateGrid(), GetGridBit(), GroundGrid(), and SetGridBit().

◆ p_groundMap

UniversalGroundMap* Isis::GroundGrid::p_groundMap
private

This calculates single grid pts.

Definition at line 119 of file GroundGrid.h.

Referenced by CreateGrid(), GetXY(), GroundGrid(), and GroundMap().

◆ p_height

unsigned int Isis::GroundGrid::p_height
private

This is the height of the grid.

Definition at line 117 of file GroundGrid.h.

Referenced by GetXY(), GroundGrid(), PixelOnGrid(), and PixelOnGrid().

◆ p_latLinesGrid

char* Isis::GroundGrid::p_latLinesGrid
private

This stores the bits of each pixel in the grid.

Definition at line 114 of file GroundGrid.h.

Referenced by CreateGrid(), GetGridBit(), GroundGrid(), SetGridBit(), and ~GroundGrid().

◆ p_lonLinesGrid

char* Isis::GroundGrid::p_lonLinesGrid
private

This stores the bits of each pixel in the grid.

Definition at line 115 of file GroundGrid.h.

Referenced by CreateGrid(), GetGridBit(), GroundGrid(), SetGridBit(), and ~GroundGrid().

◆ p_mapping

PvlGroup* Isis::GroundGrid::p_mapping
private

The mapping group representation of the projection or camera.

Definition at line 127 of file GroundGrid.h.

Referenced by GetMappingGroup(), GroundGrid(), and ~GroundGrid().

◆ p_maxLat

Latitude* Isis::GroundGrid::p_maxLat
private

Highest latitude in image.

Definition at line 123 of file GroundGrid.h.

Referenced by CreateGrid(), GroundGrid(), maxLatitude(), SetGroundLimits(), WalkBoundary(), and ~GroundGrid().

◆ p_maxLon

Longitude* Isis::GroundGrid::p_maxLon
private

Highest longitude in image.

Definition at line 124 of file GroundGrid.h.

Referenced by CreateGrid(), GroundGrid(), maxLongitude(), SetGroundLimits(), WalkBoundary(), and ~GroundGrid().

◆ p_minLat

Latitude* Isis::GroundGrid::p_minLat
private

Lowest latitude in image.

Definition at line 121 of file GroundGrid.h.

Referenced by CreateGrid(), GroundGrid(), minLatitude(), SetGroundLimits(), WalkBoundary(), and ~GroundGrid().

◆ p_minLon

Longitude* Isis::GroundGrid::p_minLon
private

Lowest longitude in image.

Definition at line 122 of file GroundGrid.h.

Referenced by CreateGrid(), GroundGrid(), minLongitude(), SetGroundLimits(), WalkBoundary(), and ~GroundGrid().

◆ p_reinitialize

bool Isis::GroundGrid::p_reinitialize
private

True if we need to reset p_grid in CreateGrid.

Definition at line 131 of file GroundGrid.h.

Referenced by CreateGrid(), and GroundGrid().

◆ p_width

unsigned int Isis::GroundGrid::p_width
private

This is the width of the grid.

Definition at line 116 of file GroundGrid.h.

Referenced by GetGridBit(), GetXY(), GroundGrid(), PixelOnGrid(), PixelOnGrid(), and SetGridBit().


The documentation for this class was generated from the following files: