Package uk.co.mccombe.terrain
Class DEMReader
java.lang.Object
java.beans.PropertyChangeSupport
uk.co.mccombe.terrain.DEMReader
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
SRTM2Reader,SRTM3Reader
DEMReader - an abstract base class for readers of various forms of Digital Elevation Model data sets
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classCacheEntry -- A class used to store a row of values -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final intprotected HashMap<String, DEMReader.CacheEntry> protected booleanprotected String[]protected longprotected Stringprotected longprotected static ZipInputStreamprotected Stringprotected intprotected static final Localeprotected static final intprotected longprotected static final doubleprotected longprotected longprotected boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract String[]abstract Stringabstract booleanprotected voiddownloadFile(String filename) Download a specific file and sand save it in scratch space on the local machineprotected abstract StringeastWest(double lon) abstract Stringextn()abstract Stringdoublefrac(int tile) Calculate the proportion of a degree represented by a particular element in the bufferprotected abstract StringdoubleCalculate terrain height at a specified location using biaxial cubic Lagrangian interpolation on surrounding points in the tile.protected StringgetProperty(TerrainProperties propertyName) protected DEMReader.CacheEntrylonghits()static doublelagrangian(double x, Point2D.Double... points) Fit an exact polynomial to a set of points and return its value at a specified pointabstract booleanprotected Stringabstract doublemaxLat()abstract doubleminLat()longmissing()abstract intprotected abstract StringnorthSouth(double lat) numEntryName(String name) byte[]Read the next byte record from the current ZipInputStreamint[]Read the next record from the current ZipInputStreamabstract intvoidlongprotected abstract voidprotected voidsetMessage(String msg) protected voidsetProgress(int val) doubletile(double x) Calculate the number of the element in the buffer that refers to a particular lat or lon valuelongtries()zipEntryName(String name) Methods inherited from class java.beans.PropertyChangeSupport
addPropertyChangeListener, addPropertyChangeListener, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, hasListeners, removePropertyChangeListener, removePropertyChangeListener
-
Field Details
-
in
-
DIRECTORY
-
cycle
protected long cycle -
cache
-
cacheEnable
protected boolean cacheEnable -
MAX_CACHE_SIZE
protected static final int MAX_CACHE_SIZE- See Also:
-
hits
protected long hits -
tries
protected long tries -
missing
protected long missing -
resultcount
protected long resultcount -
MISSING
protected static final double MISSING- See Also:
-
BUFFERLENGTH
protected static final int BUFFERLENGTH- See Also:
-
lastMessage
-
lastValue
protected int lastValue -
LOCALE
-
useLegacy
protected boolean useLegacy -
copyright
-
-
Constructor Details
-
DEMReader
- Throws:
DataFileException
-
-
Method Details
-
makename
-
getHeight
Calculate terrain height at a specified location using biaxial cubic Lagrangian interpolation on surrounding points in the tile. This method provides an exact fit at the points defined in the tile and a slightly smoothed surface in between. To speed the calculation up, rows of values from the tile are cached.- Parameters:
place- -- the LatLong of the place to calculate the height for.- Returns:
- -- the calculated height at place.
- Throws:
MissingDataFileExceptionDataFileException
-
getRow
protected DEMReader.CacheEntry getRow(String name, int ytile) throws MissingDataFileException, DataFileException -
readRecord
Read the next record from the current ZipInputStream- Returns:
- int[] buffer of length recordlength() containing the decoded next record;
- Throws:
IOException
-
readByteRecord
Read the next byte record from the current ZipInputStream- Returns:
- byte[] buffer of length recordlength() containing the decoded next record;
- Throws:
IOException
-
tile
public double tile(double x) Calculate the number of the element in the buffer that refers to a particular lat or lon value- Parameters:
x- the double lat/lon value- Returns:
- A double value representing the buffer element index
-
frac
public double frac(int tile) Calculate the proportion of a degree represented by a particular element in the buffer- Parameters:
tile- the integer number of the element- Returns:
- double number representing a fraction of a degree
-
downloadFile
protected void downloadFile(String filename) throws KeyManagementException, NoSuchAlgorithmException, IOException, MissingDataFileException, URISyntaxException Download a specific file and sand save it in scratch space on the local machine- Parameters:
filename- the name of the file to download- Throws:
KeyManagementExceptionNoSuchAlgorithmExceptionIOExceptionMissingDataFileExceptionURISyntaxException
-
lagrangian
Fit an exact polynomial to a set of points and return its value at a specified point- Parameters:
x- double the value at which to evaluate the calculated polynomialpoints- a set of java.awt.geom.Point2D.Double values- Returns:
- double value of the polynomial
-
hits
public long hits() -
resultcount
public long resultcount() -
tries
public long tries() -
missing
public long missing() -
resetCounts
public void resetCounts() -
setMessage
-
setProgress
protected void setProgress(int val) -
getProperty
-
getPropertyChangeListeners
- Overrides:
getPropertyChangeListenersin classPropertyChangeSupport
-
datasetName
-
downloadable
public abstract boolean downloadable() -
recordlength
public abstract int recordlength() -
formatstring
-
extn
-
littleendian
public abstract boolean littleendian() -
missingValue
public abstract int missingValue() -
copyright
-
setDownloadSiteName
-
getDownloadSiteName
-
eastWest
-
northSouth
-
maxLat
public abstract double maxLat() -
minLat
public abstract double minLat() -
zipEntryName
-
numEntryName
-