ossama-othman / MaRC

MaRC - Map Reprojections and Conversions
GNU Lesser General Public License v2.1
1 stars 0 forks source link

Grid interval may be larger than maximum map lat/lon range #99

Open ossama-othman opened 5 years ago

ossama-othman commented 5 years ago

Describe the bug It is currently possible to specify latitude and longitude grid interval values that are larger than the maximum range of latitudes and longitudes being mapped, i.e. the half-open intervals [0, 180) and [0, 360), respectively..

To Reproduce Steps to reproduce the behavior:

  1. Create a Simple Cylindrical map with a specific latitude and longitude range with the full range of latitude and longitudes.
  2. Create a grid image for that map with latitude and longitude intervals greater than 180 and 360, respectively.
  3. MaRC handles the bogus values somewhat gracefully in that no grid will be created, but it still allows the user to specify such values without any diagnostic message.

Expected behavior MaRC and the MaRC library should not allow the invalid lat/lon grid intervals to be set to begin with. Such inputs should be validated beyond the existing negative value checks.

MaRC should also document that the latitude grid is always [-90 + lat_interval, 90) and (0, 360 - lon_interval], i.e. incrementing the latitude grid from -90, and decrementing the longitude from 360, even though the corresponding grid lines may not be in the map latitude/longitude range.

Desktop (please complete the following information):

Additional context The problem was first noticed through inspection in the MaRC::SimpleCylindrical::plot_grid() method, but the same problem exists for all MaRC map projection implementations. It might be useful to perform some minimal grid lat/lon interval validation in in MaRC::MapFactory::make_grid() to centralize such validation in one place common to all map projections.