Class ElevationUtilities
- java.lang.Object
-
- org.openstreetmap.atlas.checks.utility.ElevationUtilities
-
- All Implemented Interfaces:
java.io.Serializable
public final class ElevationUtilities extends java.lang.Object implements java.io.SerializableUsed 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 shortNO_ELEVATIONA 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 ElevationUtilitiesElevationUtilities(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 shortgetElevation(org.openstreetmap.atlas.geography.Location location)Get the elevation of a locationdoublegetIncline(org.openstreetmap.atlas.geography.Location start, org.openstreetmap.atlas.geography.Location end)Get the incline between two pointsint[]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.DistancegetResolution(org.openstreetmap.atlas.geography.Location location)Get the resolution of the data at the location.java.lang.StringgetSrtmFileName(int latitude, int longitude)The lower-left corner of each file is the file name.booleaninSameDataPoint(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)voidputMap(org.openstreetmap.atlas.geography.Location location, short[][] map)Associate a map with a location.
-
-
-
Field Detail
-
NO_ELEVATION
public static final short NO_ELEVATION
A non-number when there is no elevation data available. This is currently returnsShort.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 slopeend- The end of the slope- Returns:
- The incline from the start to the end (may be negative). May also return
Double.NaNif 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 viagetMap(Location). You also need that map for themapSizeparameter.- Parameters:
location- The location to get the index formapSize- 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 prefergetElevation(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 aNO_ELEVATIONarea). To get the index of aLocation, usegetIndex(Location, int). You need theshort[][]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.MAXIMUMif 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 checktwo- Another location to check- Returns:
trueif 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 usegetElevation(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
-
-