Class ElevationUtilities

  • All Implemented Interfaces:
    java.io.Serializable

    public final class ElevationUtilities
    extends java.lang.Object
    implements java.io.Serializable
    Used to determine assumed direction for some features (e.g. waterways). Assumptions are that any SRTM file follows the specification here: https://dds.cr.usgs.gov/srtm/version2_1/Documentation/Quickstart.pdf
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static short NO_ELEVATION
      A non-number when there is no elevation data available.
    • Constructor Summary

      Constructors 
      Constructor Description
      ElevationUtilities​(double srtmExtent, java.lang.String srtmExtension, java.lang.String srtmPath, ExternalDataFetcher fileFetcher)
      Create a configured ElevationUtilities
      ElevationUtilities​(org.openstreetmap.atlas.utilities.configuration.Configuration configuration, ExternalDataFetcher fileFetcher)
      Create a configured ElevationUtilities
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      short getElevation​(org.openstreetmap.atlas.geography.Location location)
      Get the elevation of a location
      double getIncline​(org.openstreetmap.atlas.geography.Location start, org.openstreetmap.atlas.geography.Location end)
      Get the incline between two points
      int[] getIndex​(org.openstreetmap.atlas.geography.Location location, int mapSize)
      Get the index to use for a short[latitude][longitude] = height in meters array.
      short[][] getMap​(org.openstreetmap.atlas.geography.Location location)
      Get the map for a specified location.
      org.openstreetmap.atlas.utilities.scalars.Distance getResolution​(org.openstreetmap.atlas.geography.Location location)
      Get the resolution of the data at the location.
      java.lang.String getSrtmFileName​(int latitude, int longitude)
      The lower-left corner of each file is the file name.
      boolean inSameDataPoint​(org.openstreetmap.atlas.geography.Location one, org.openstreetmap.atlas.geography.Location two)
      Check if two locations are in the same data point (i.e., same pixel in a HGT)
      void putMap​(org.openstreetmap.atlas.geography.Location location, short[][] map)
      Associate a map with a location.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • NO_ELEVATION

        public static final short NO_ELEVATION
        A non-number when there is no elevation data available. This is currently returns Short.MIN_VALUE.
        See Also:
        Constant Field Values
    • Constructor Detail

      • ElevationUtilities

        public ElevationUtilities​(org.openstreetmap.atlas.utilities.configuration.Configuration configuration,
                                  ExternalDataFetcher fileFetcher)
        Create a configured ElevationUtilities
        Parameters:
        configuration - A configuration which should (at a minimum) have a file path for elevation files.
        fileFetcher - The file fetcher to use to get data files
      • ElevationUtilities

        public ElevationUtilities​(double srtmExtent,
                                  java.lang.String srtmExtension,
                                  java.lang.String srtmPath,
                                  ExternalDataFetcher fileFetcher)
        Create a configured ElevationUtilities
        Parameters:
        srtmExtent - The extent of the files. The units are in degrees, and the default is 1 degree.
        srtmExtension - The extension of the files. Archive/compression file endings are not required (they will be automatically detected).
        srtmPath - The path for the files.
        fileFetcher - The file fetcher to use to get data files
    • Method Detail

      • getElevation

        public short getElevation​(org.openstreetmap.atlas.geography.Location location)
        Get the elevation of a location
        Parameters:
        location - The location to get the elevation of
        Returns:
        The meters of the elevation (does not show fractions of meters)
      • getIncline

        public double getIncline​(org.openstreetmap.atlas.geography.Location start,
                                 org.openstreetmap.atlas.geography.Location end)
        Get the incline between two points
        Parameters:
        start - The start of the slope
        end - The end of the slope
        Returns:
        The incline from the start to the end (may be negative). May also return Double.NaN if one of the elevations cannot be obtained.
        See Also:
        OSM Wiki Incline
      • getIndex

        public int[] getIndex​(org.openstreetmap.atlas.geography.Location location,
                              int mapSize)
        Get the index to use for a short[latitude][longitude] = height in meters array. Generally, this is used to get data from a map obtained via getMap(Location). You also need that map for the mapSize parameter.
        Parameters:
        location - The location to get the index for
        mapSize - The size of the map
        Returns:
        A [latitude, longitude] = int (index) array.
      • getMap

        public short[][] getMap​(org.openstreetmap.atlas.geography.Location location)
        Get the map for a specified location. Unless you need the raw map, you should prefer getElevation(org.openstreetmap.atlas.geography.Location). This also allows you to directly modify a map (i.e., you know that there is elevation data around a point, but the point is in a NO_ELEVATION area). To get the index of a Location, use getIndex(Location, int). You need the short[][] from this method.
        Parameters:
        location - The location to get the height map for
        Returns:
        A short[latitude][longitude] = height in meters array
      • getResolution

        public org.openstreetmap.atlas.utilities.scalars.Distance getResolution​(org.openstreetmap.atlas.geography.Location location)
        Get the resolution of the data at the location.
        Parameters:
        location - The location to get the resolution of
        Returns:
        The resolution of the data, or Distance.MAXIMUM if there is no data.
      • getSrtmFileName

        public java.lang.String getSrtmFileName​(int latitude,
                                                int longitude)
        The lower-left corner of each file is the file name. This does not append any archive extensions, it is just the name of the file with the configured SRTM extension.
        Parameters:
        latitude - The latitude (lower left)
        longitude - The longitude (lower left)
        Returns:
        The expected filename for the location. You should also check for archives.
      • inSameDataPoint

        public boolean inSameDataPoint​(org.openstreetmap.atlas.geography.Location one,
                                       org.openstreetmap.atlas.geography.Location two)
        Check if two locations are in the same data point (i.e., same pixel in a HGT)
        Parameters:
        one - A location to check
        two - Another location to check
        Returns:
        true if they are in the same grid and location
      • putMap

        public void putMap​(org.openstreetmap.atlas.geography.Location location,
                           short[][] map)
        Associate a map with a location. This is mostly useful for test methods. You should use getElevation(org.openstreetmap.atlas.geography.Location) instead (it automatically loads appropriate maps).
        Parameters:
        location - The location to use for the map location (uses the lower-left corner of the 1 degree by 1 degree box).
        map - The map to associate