Loading isis/src/base/apps/grid/grid.cpp +66 −3 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ UniversalGroundMap *gmap; int currentBand = 0; bool recalculateForEachBand = false; bool walkBoundary = false; bool extendGrid = false; Latitude minLat, maxLat; Longitude minLon, maxLon; Loading @@ -54,6 +55,7 @@ void IsisMain() { outline = ui.GetBoolean("OUTLINE"); ticks = ui.GetBoolean("TICKS"); extendGrid = ui.GetBoolean("EXTENDGRID"); if (ticks) { tickSize = ui.GetInteger("TICKSIZE") / 2; Loading Loading @@ -130,7 +132,8 @@ void IsisMain() { gmap = new UniversalGroundMap(*icube, UniversalGroundMap::ProjectionFirst); latLonGrid = new GroundGrid(gmap, ticks, icube->sampleCount(), icube->lineCount()); latLonGrid = new GroundGrid(gmap, ticks, extendGrid, icube->sampleCount(), icube->lineCount()); baseLat = Latitude(ui.GetDouble("BASELAT"), *latLonGrid->GetMappingGroup(), Angle::Degrees); Loading Loading @@ -160,6 +163,35 @@ void IsisMain() { latLonGrid->SetGroundLimits(minLat, minLon, maxLat, maxLon); // If the grid is not going to reach the min/max lon warn the user. if (!extendGrid) { // Check that the min/max lon values match the lon domain if ( latLonGrid->GetMappingGroup()->findKeyword("LongitudeDomain")[0] == "360" && (latLonGrid->minLongitude().degrees() < 0.0 || latLonGrid->maxLongitude().degrees() > 360.0) ) { QString msg = "**WARNING** minimum longitude [" + toString( latLonGrid->minLongitude().degrees() ) + "] and maximum longitude [" + toString( latLonGrid->maxLongitude().degrees() ) + "] are not in the 360 degree longitude domain and " "the EXTENDGRID parameter is set to false. " "Output grid may not cover the entire map projection."; std::cerr << msg << std::endl; } else if ( latLonGrid->GetMappingGroup()->findKeyword("LongitudeDomain")[0] == "180" && (latLonGrid->minLongitude().degrees() < -180.0 || latLonGrid->maxLongitude().degrees() > 180.0) ) { QString msg = "**WARNING** minimum longitude [" + toString( latLonGrid->minLongitude().degrees() ) + "] and maximum longitude [" + toString( latLonGrid->maxLongitude().degrees() ) + "] are not in the 180 degree longitude domain and " "the EXTENDGRID parameter is set to false. " "Output grid may not cover the entire map projection."; std::cerr << msg << std::endl; } } latLonGrid->CreateGrid(baseLat, baseLon, latInc, lonInc, &progress); if (ui.GetBoolean("BOUNDARY")) { Loading Loading @@ -313,10 +345,41 @@ void changeBand(int band){ gmap->SetBand(band); //update latLonGrid to use new UniversalGroundMap latLonGrid = new GroundGrid(gmap, ticks, icube->sampleCount(), icube->lineCount()); latLonGrid = new GroundGrid(gmap, ticks, extendGrid, icube->sampleCount(), icube->lineCount()); //re-set old ground limits from GUI latLonGrid->SetGroundLimits(minLat, minLon, maxLat, maxLon); // If the grid is not going to reach the min/max lon warn the user. if (!extendGrid) { // Check that the min/max lon values match the lon domain if ( latLonGrid->GetMappingGroup()->findKeyword("LongitudeDomain")[0] == "360" && (latLonGrid->minLongitude().degrees() < 0.0 || latLonGrid->maxLongitude().degrees() > 360.0) ) { QString msg = "**WARNING** minimum longitude [" + toString( latLonGrid->minLongitude().degrees() ) + "] and maximum longitude [" + toString( latLonGrid->maxLongitude().degrees() ) + "] are not in the 360 degree longitude domain and " "the EXTENDGRID parameter is set to false. " "Output grid may not cover the entire map projection for band[" + toString(band) + "]."; std::cerr << msg << std::endl; } else if ( latLonGrid->GetMappingGroup()->findKeyword("LongitudeDomain")[0] == "180" && (latLonGrid->minLongitude().degrees() < -180.0 || latLonGrid->maxLongitude().degrees() > 180.0) ) { QString msg = "**WARNING** minimum longitude [" + toString( latLonGrid->minLongitude().degrees() ) + "] and maximum longitude [" + toString( latLonGrid->maxLongitude().degrees() ) + "] are not in the 180 degree longitude domain and " "the EXTENDGRID parameter is set to false. " "Output grid may not cover the entire map projection for band[" + toString(band) + "]."; std::cerr << msg << std::endl; } } QString progressMessage = QString("Recalculating grid for band %1").arg(band); progress.SetText(progressMessage); Loading isis/src/base/apps/grid/grid.xml +15 −0 Original line number Diff line number Diff line Loading @@ -170,6 +170,9 @@ Fixed error introduced in last change which caused grid to no longer work on multi-band cubes without camera models (for example: a mosaic will not have a camera model.) Fixes #4586. </change> <change name="Jesse Mapel" date="2017-06-26"> Added a flag to extend the grid past the longitude domain boundary. Fixes #2185. </change> </history> <groups> Loading Loading @@ -279,6 +282,18 @@ MINLON, and MAXLON. </description> </parameter> <parameter name="EXTENDGRID"> <type>boolean</type> <default><item>false</item></default> <brief>If the grid should be extended past the longitude domain boundary.</brief> <description> If false, the grid will stop at the longitude domain boundary, -180 to 180 or 0 to 360, if the minimum or maximum longitude values are outside of the domain range. If true, the grid will extend all the way to the minimum and maximum longitudes regardless of the domain. </description> </parameter> </group> <group name="Image Grid Parameters"> Loading isis/src/base/apps/grid/tsts/extendGrid/Makefile 0 → 100644 +11 −0 Original line number Diff line number Diff line APPNAME = grid MOSAIC = Mars_Viking_MDIM21_Mosaic_TEST_SIMP_REDUCED_GRID include $(ISISROOT)/make/isismake.tsts commands: $(APPNAME) from=$(INPUT)/$(MOSAIC).cub to=$(OUTPUT)/$(MOSAIC)_GRID.cub \ linewidth=3 2> $(OUTPUT)/warning.txt 1> /dev/null; $(APPNAME) from=$(INPUT)/$(MOSAIC).cub to=$(OUTPUT)/$(MOSAIC)_EXTENDGRID.cub \ linewidth=3 extendgrid=true > /dev/null; isis/src/base/objs/GroundGrid/GroundGrid.cpp +67 −1 Original line number Diff line number Diff line Loading @@ -26,15 +26,19 @@ namespace Isis { * @param gmap A universal ground map to use for calculating the grid * @param splitLatLon Make two grids: one for latitude lines and * one for longitude lines * @param extendGrid If the grid should extend past the longitude domain * boundary. * @param width The width of the grid; often cube samples * @param height The height of the grid; often cube samples */ GroundGrid::GroundGrid(UniversalGroundMap *gmap, bool splitLatLon, bool extendGrid, unsigned int width, unsigned int height) { p_width = width; p_height = height; m_extendGrid = extendGrid; // Initialize our grid pointer to null p_grid = 0; Loading Loading @@ -537,6 +541,63 @@ namespace Isis { return p_mapping; } /** * Returns the minimum latitude for the grid. * * @return @b Latitude The minimum latitude for the grid. If no minimum has * been set, then a default Latitude object is returned. */ Latitude GroundGrid::minLatitude() const { if (p_minLat) { return *p_minLat; } return Latitude(); } /** * Returns the minimum longitude for the grid. * * @return @b Longitude The minimum longitude for the grid. If no minimum has * been set, then a default Longitude object is returned. */ Longitude GroundGrid::minLongitude() const { if (p_minLon) { return *p_minLon; } return Longitude(); } /** * Returns the maximum latitude for the grid. * * @return @b Latitude The maximum latitude for the grid. If no maximum has * been set, then a default Latitude object is returned. */ Latitude GroundGrid::maxLatitude() const { if (p_maxLat) { return *p_maxLat; } return Latitude(); } /** * Returns the maximum longitude for the grid. * * @return @b Longitude The maximum longitude for the grid. If no maximum has * been set, then a default Longitude object is returned. */ Longitude GroundGrid::maxLongitude() const { if (p_maxLon) { return *p_maxLon; } return Longitude(); } /** * This method converts a lat/lon to an X/Y. This implementation converts to * sample/line. Loading @@ -551,7 +612,12 @@ namespace Isis { bool GroundGrid::GetXY(Latitude lat, Longitude lon, unsigned int &x, unsigned int &y) { if (!GroundMap()) return false; if (m_extendGrid) { if (!GroundMap()->SetUnboundGround(lat, lon)) return false; } else { if (!GroundMap()->SetGround(lat, lon)) return false; } if (p_groundMap->Sample() < 0.5 || p_groundMap->Line() < 0.5) return false; if (p_groundMap->Sample() < 0.5 || p_groundMap->Line() < 0.5) return false; Loading isis/src/base/objs/GroundGrid/GroundGrid.h +10 −1 Original line number Diff line number Diff line Loading @@ -65,13 +65,16 @@ namespace Isis { * 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. * @history 2017-04-10 Jesse mapel - Modified to not throw an exception when calculating * @history 2017-04-10 Jesse Mapel - Modified to not throw an exception when calculating * longitude lines close to 90 or -90 latitude. Fixes #4766. * @history 2017-06-28 Jesse Mapel - Added a flag to extend the grid past the longitude * domain boundary. Fixes #2185. */ class GroundGrid { public: GroundGrid(UniversalGroundMap *gmap, bool splitLatLon, bool extendGrid, unsigned int width, unsigned int height); Loading Loading @@ -101,6 +104,11 @@ namespace Isis { bool PixelOnGrid(int x, int y); bool PixelOnGrid(int x, int y, bool latGrid); Latitude minLatitude() const; Longitude minLongitude() const; Latitude maxLatitude() const; Longitude maxLongitude() const; PvlGroup *GetMappingGroup(); protected: Loading Loading @@ -136,6 +144,7 @@ namespace Isis { 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. }; } Loading Loading
isis/src/base/apps/grid/grid.cpp +66 −3 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ UniversalGroundMap *gmap; int currentBand = 0; bool recalculateForEachBand = false; bool walkBoundary = false; bool extendGrid = false; Latitude minLat, maxLat; Longitude minLon, maxLon; Loading @@ -54,6 +55,7 @@ void IsisMain() { outline = ui.GetBoolean("OUTLINE"); ticks = ui.GetBoolean("TICKS"); extendGrid = ui.GetBoolean("EXTENDGRID"); if (ticks) { tickSize = ui.GetInteger("TICKSIZE") / 2; Loading Loading @@ -130,7 +132,8 @@ void IsisMain() { gmap = new UniversalGroundMap(*icube, UniversalGroundMap::ProjectionFirst); latLonGrid = new GroundGrid(gmap, ticks, icube->sampleCount(), icube->lineCount()); latLonGrid = new GroundGrid(gmap, ticks, extendGrid, icube->sampleCount(), icube->lineCount()); baseLat = Latitude(ui.GetDouble("BASELAT"), *latLonGrid->GetMappingGroup(), Angle::Degrees); Loading Loading @@ -160,6 +163,35 @@ void IsisMain() { latLonGrid->SetGroundLimits(minLat, minLon, maxLat, maxLon); // If the grid is not going to reach the min/max lon warn the user. if (!extendGrid) { // Check that the min/max lon values match the lon domain if ( latLonGrid->GetMappingGroup()->findKeyword("LongitudeDomain")[0] == "360" && (latLonGrid->minLongitude().degrees() < 0.0 || latLonGrid->maxLongitude().degrees() > 360.0) ) { QString msg = "**WARNING** minimum longitude [" + toString( latLonGrid->minLongitude().degrees() ) + "] and maximum longitude [" + toString( latLonGrid->maxLongitude().degrees() ) + "] are not in the 360 degree longitude domain and " "the EXTENDGRID parameter is set to false. " "Output grid may not cover the entire map projection."; std::cerr << msg << std::endl; } else if ( latLonGrid->GetMappingGroup()->findKeyword("LongitudeDomain")[0] == "180" && (latLonGrid->minLongitude().degrees() < -180.0 || latLonGrid->maxLongitude().degrees() > 180.0) ) { QString msg = "**WARNING** minimum longitude [" + toString( latLonGrid->minLongitude().degrees() ) + "] and maximum longitude [" + toString( latLonGrid->maxLongitude().degrees() ) + "] are not in the 180 degree longitude domain and " "the EXTENDGRID parameter is set to false. " "Output grid may not cover the entire map projection."; std::cerr << msg << std::endl; } } latLonGrid->CreateGrid(baseLat, baseLon, latInc, lonInc, &progress); if (ui.GetBoolean("BOUNDARY")) { Loading Loading @@ -313,10 +345,41 @@ void changeBand(int band){ gmap->SetBand(band); //update latLonGrid to use new UniversalGroundMap latLonGrid = new GroundGrid(gmap, ticks, icube->sampleCount(), icube->lineCount()); latLonGrid = new GroundGrid(gmap, ticks, extendGrid, icube->sampleCount(), icube->lineCount()); //re-set old ground limits from GUI latLonGrid->SetGroundLimits(minLat, minLon, maxLat, maxLon); // If the grid is not going to reach the min/max lon warn the user. if (!extendGrid) { // Check that the min/max lon values match the lon domain if ( latLonGrid->GetMappingGroup()->findKeyword("LongitudeDomain")[0] == "360" && (latLonGrid->minLongitude().degrees() < 0.0 || latLonGrid->maxLongitude().degrees() > 360.0) ) { QString msg = "**WARNING** minimum longitude [" + toString( latLonGrid->minLongitude().degrees() ) + "] and maximum longitude [" + toString( latLonGrid->maxLongitude().degrees() ) + "] are not in the 360 degree longitude domain and " "the EXTENDGRID parameter is set to false. " "Output grid may not cover the entire map projection for band[" + toString(band) + "]."; std::cerr << msg << std::endl; } else if ( latLonGrid->GetMappingGroup()->findKeyword("LongitudeDomain")[0] == "180" && (latLonGrid->minLongitude().degrees() < -180.0 || latLonGrid->maxLongitude().degrees() > 180.0) ) { QString msg = "**WARNING** minimum longitude [" + toString( latLonGrid->minLongitude().degrees() ) + "] and maximum longitude [" + toString( latLonGrid->maxLongitude().degrees() ) + "] are not in the 180 degree longitude domain and " "the EXTENDGRID parameter is set to false. " "Output grid may not cover the entire map projection for band[" + toString(band) + "]."; std::cerr << msg << std::endl; } } QString progressMessage = QString("Recalculating grid for band %1").arg(band); progress.SetText(progressMessage); Loading
isis/src/base/apps/grid/grid.xml +15 −0 Original line number Diff line number Diff line Loading @@ -170,6 +170,9 @@ Fixed error introduced in last change which caused grid to no longer work on multi-band cubes without camera models (for example: a mosaic will not have a camera model.) Fixes #4586. </change> <change name="Jesse Mapel" date="2017-06-26"> Added a flag to extend the grid past the longitude domain boundary. Fixes #2185. </change> </history> <groups> Loading Loading @@ -279,6 +282,18 @@ MINLON, and MAXLON. </description> </parameter> <parameter name="EXTENDGRID"> <type>boolean</type> <default><item>false</item></default> <brief>If the grid should be extended past the longitude domain boundary.</brief> <description> If false, the grid will stop at the longitude domain boundary, -180 to 180 or 0 to 360, if the minimum or maximum longitude values are outside of the domain range. If true, the grid will extend all the way to the minimum and maximum longitudes regardless of the domain. </description> </parameter> </group> <group name="Image Grid Parameters"> Loading
isis/src/base/apps/grid/tsts/extendGrid/Makefile 0 → 100644 +11 −0 Original line number Diff line number Diff line APPNAME = grid MOSAIC = Mars_Viking_MDIM21_Mosaic_TEST_SIMP_REDUCED_GRID include $(ISISROOT)/make/isismake.tsts commands: $(APPNAME) from=$(INPUT)/$(MOSAIC).cub to=$(OUTPUT)/$(MOSAIC)_GRID.cub \ linewidth=3 2> $(OUTPUT)/warning.txt 1> /dev/null; $(APPNAME) from=$(INPUT)/$(MOSAIC).cub to=$(OUTPUT)/$(MOSAIC)_EXTENDGRID.cub \ linewidth=3 extendgrid=true > /dev/null;
isis/src/base/objs/GroundGrid/GroundGrid.cpp +67 −1 Original line number Diff line number Diff line Loading @@ -26,15 +26,19 @@ namespace Isis { * @param gmap A universal ground map to use for calculating the grid * @param splitLatLon Make two grids: one for latitude lines and * one for longitude lines * @param extendGrid If the grid should extend past the longitude domain * boundary. * @param width The width of the grid; often cube samples * @param height The height of the grid; often cube samples */ GroundGrid::GroundGrid(UniversalGroundMap *gmap, bool splitLatLon, bool extendGrid, unsigned int width, unsigned int height) { p_width = width; p_height = height; m_extendGrid = extendGrid; // Initialize our grid pointer to null p_grid = 0; Loading Loading @@ -537,6 +541,63 @@ namespace Isis { return p_mapping; } /** * Returns the minimum latitude for the grid. * * @return @b Latitude The minimum latitude for the grid. If no minimum has * been set, then a default Latitude object is returned. */ Latitude GroundGrid::minLatitude() const { if (p_minLat) { return *p_minLat; } return Latitude(); } /** * Returns the minimum longitude for the grid. * * @return @b Longitude The minimum longitude for the grid. If no minimum has * been set, then a default Longitude object is returned. */ Longitude GroundGrid::minLongitude() const { if (p_minLon) { return *p_minLon; } return Longitude(); } /** * Returns the maximum latitude for the grid. * * @return @b Latitude The maximum latitude for the grid. If no maximum has * been set, then a default Latitude object is returned. */ Latitude GroundGrid::maxLatitude() const { if (p_maxLat) { return *p_maxLat; } return Latitude(); } /** * Returns the maximum longitude for the grid. * * @return @b Longitude The maximum longitude for the grid. If no maximum has * been set, then a default Longitude object is returned. */ Longitude GroundGrid::maxLongitude() const { if (p_maxLon) { return *p_maxLon; } return Longitude(); } /** * This method converts a lat/lon to an X/Y. This implementation converts to * sample/line. Loading @@ -551,7 +612,12 @@ namespace Isis { bool GroundGrid::GetXY(Latitude lat, Longitude lon, unsigned int &x, unsigned int &y) { if (!GroundMap()) return false; if (m_extendGrid) { if (!GroundMap()->SetUnboundGround(lat, lon)) return false; } else { if (!GroundMap()->SetGround(lat, lon)) return false; } if (p_groundMap->Sample() < 0.5 || p_groundMap->Line() < 0.5) return false; if (p_groundMap->Sample() < 0.5 || p_groundMap->Line() < 0.5) return false; Loading
isis/src/base/objs/GroundGrid/GroundGrid.h +10 −1 Original line number Diff line number Diff line Loading @@ -65,13 +65,16 @@ namespace Isis { * 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. * @history 2017-04-10 Jesse mapel - Modified to not throw an exception when calculating * @history 2017-04-10 Jesse Mapel - Modified to not throw an exception when calculating * longitude lines close to 90 or -90 latitude. Fixes #4766. * @history 2017-06-28 Jesse Mapel - Added a flag to extend the grid past the longitude * domain boundary. Fixes #2185. */ class GroundGrid { public: GroundGrid(UniversalGroundMap *gmap, bool splitLatLon, bool extendGrid, unsigned int width, unsigned int height); Loading Loading @@ -101,6 +104,11 @@ namespace Isis { bool PixelOnGrid(int x, int y); bool PixelOnGrid(int x, int y, bool latGrid); Latitude minLatitude() const; Longitude minLongitude() const; Latitude maxLatitude() const; Longitude maxLongitude() const; PvlGroup *GetMappingGroup(); protected: Loading Loading @@ -136,6 +144,7 @@ namespace Isis { 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. }; } Loading