Package hec.map.aidem

Class AiDemMap

All Implemented Interfaces:
ElevationMap, GridMap, MapObjectInterface, Serializable
Direct Known Subclasses:
GrassAsciiMap

public class AiDemMap extends AiDemBaseMap implements Serializable, MapObjectInterface
Simple class for reading ESRI .asc grid maps.
See Also:
  • Field Details

    • EXTENSION

      public static final String EXTENSION
      See Also:
    • BINARY_HEADER_LENGTH

      public static final long BINARY_HEADER_LENGTH
      Number of bytes for the header. Since the header starts at byte zero, the header occupies from byte 0 to byte 43. Byte 44 is the start of the float array.
      See Also:
  • Constructor Details

    • AiDemMap

      public AiDemMap(String fileName)
    • AiDemMap

      public AiDemMap(MapIdentifier id)
    • AiDemMap

      public AiDemMap()
  • Method Details

    • unload

      public void unload()
      Description copied from interface: MapObjectInterface
      Method to tell the Map Object to unload, because the map is done
      Specified by:
      unload in interface MapObjectInterface
      Overrides:
      unload in class AiDemBaseMap
    • load

      public void load() throws IOException
      Split the load between binary and ASCII
      Specified by:
      load in interface MapObjectInterface
      Overrides:
      load in class AiDemBaseMap
      Throws:
      IOException - Description of Exception
    • loadHeader

      public void loadHeader() throws IOException
      Loads the header section of the grid file giving us the information such as grid location, cell size, number of rows/columns.
      Specified by:
      loadHeader in class AiDemBaseMap
      Throws:
      IOException
    • fillArray

      public boolean fillArray(float[] dest, long destPosition, long srcPosition, int length) throws IOException
      Fills the destination array with data from this map starting at destPosition reading from srcPosition for length # of values.
      Specified by:
      fillArray in class AiDemBaseMap
      Throws:
      IOException
    • ensureBinaryFile

      public void ensureBinaryFile() throws IOException
      Ensures that the grid file is binary by checking for the presence of a .ascbin. If not, then the grid is converted to binary. This is done because reading a binary file is a lot quicker then reading the ascii version.
      Throws:
      IOException
    • readAsciiHeader

      protected boolean readAsciiHeader(BufferedReader in) throws IOException
      read the ASCII header. This was moved to its own method so that subclasses (in particular the GrassAsciiMap) can override since the format of their file is same except for the header
      Parameters:
      in - reader for the ASCII file
      Throws:
      IOException
    • loadBin

      public void loadBin(HecFile file) throws IOException
      Throws:
      IOException
    • mapIdentifierEquals

      public boolean mapIdentifierEquals(MapIdentifier mapid)
      check to see if the Map specified by the MapIdentifier mapid is the same map as this one. AiDem files create a binary version of the ascii file so the test needs to check both the .asc and the .ascbin extensions.
      Overrides:
      mapIdentifierEquals in class MapObject
      Parameters:
      mapid -
      Returns:
      true if the mapid references the same map file as this map.