jwo.landserf.process.io
Class FileHandler

java.lang.Object
  extended by jwo.landserf.process.io.FileHandler

public class FileHandler
extends Object

Contains a collection of static methods for reading and writing files in a range of formats. See doc/howto/fileformats.html.

Version:
2.3, 27th September, 2008.
Author:
Jo Wood

Field Summary
static int ARC_BIN_R
          ArcGIS binary float raster.
static int ARC_TEXT_R
          ArcGIS ASCII raster.
static int ARC_TEXT_V
          ArcGIS 'generate' vector.
static int ATT_TABLE
          Text attribute table.
static int BIL_R
          Binary Integer Interleaved.
static int BIN_R
          Generic binary raster.
static int BIN_V
          Generic binary vector.
static int BIN16_R
          Generic 16 bit binary raster.
static int BIN32_R
          Generic 32 bit binary raster.
static int BIN8_R
          Generic 8 bit binary raster.
static int BT_R
          Virtual Terrain BT binary.
static int COLOUR_TABLE
          Colour table.
static int CONTROL_POINTS
          Control points.
static int DTED_R
          DTED (Digital Terrain Elevation Data).
static int EDX_TEXT_R
          EDX ASCII raster.
static int EDX_TEXT_V
          EDX ASCII vector.
static int GML
          GML file.
static int GPX
          GPX GPS interchange file.
static int GRASS_BIN_R
          GRASS binary raster.
static int GRASS_BIN_V
          GRASS binary vector.
static int GRASS_TEXT_R
          GRASS ASCII raster.
static int GRASS_TEXT_V
          GRASS ASCII vector.
static int GSHHS_V
          Global Hierarchical Shorelines.
static int GTOPO30_R
          USGS GTOPO30 format.
static int IDRISI_BIN_R
          Idrisi binary raster.
static int IDRISI_BIN_V
          Idrisi binary vector.
static int IDRISI_TEXT_R
          Idrisi ASCII raster.
static int IDRISI_TEXT_V
          Idrisi ASCII vector.
static int IMAGE
          GIF or JPEG graphics file.
static int KML
          Keyhole Markup Language (KML, Google Earth/Maps) file.
static int KMZ
          Keyhole Markup Language Archive (KMZ, Google Earth/Maps) file.
static int LANDSCRIPT
          LandScript file.
static int LANDSERF_R
          LandSerf serialized raster.
static int LANDSERF_V
          LandSerf serialized vector.
static int MASTERMAP
          MasterMap (GML)file.
static int MOLA_PEDR
          MOLA (Mars Orbiter) format.
static int MSN_TEXT
          Metric surface network.
static int NTF_TEXT_R
          NTF raster (Ordnance Survey).
static int NTF_TEXT_V
          NTF vector (Ordnance Survey).
static int POINT_TEXT_R
          Generic ASCII point raster.
static int POINT_TEXT_V
          Generic ASCII point vector.
static int POINTDEN_TEXT_R
          Generic point density raster.
static int ROUTE_TEXT_V
          Route vector.
static int SHAPEFILE_V
          ESRI shapefile vector.
static int SRTM_R
          Shuttle Radar Topography Mission DEM.
static int SVG
          Scalable Vector Graphics (SVG).
static int TERRAGEN_RAW_R
          Terragen raw binary raster.
static int TERRAGEN_TERRAIN_R
          Terragen native terrain.
static int TEXT
          Generic text file.
static int TEXT_R
          Generic ASCII raster.
static int TEXT_V
          Generic ASCII vector.
static int UNDEFINED
          Undefined file type.
static int USGS_R
          USGS DEM format.
static int VECTOR_STYLES
          Vector display styles.
static int VISTA_BIN_R
          VistaPro binary raster.
static int VISTA_BIN_V
          VistaPro binary vector.
static int VISTA_TEXT_R
          VistaPro ASCII raster.
static int VISTA_TEXT_V
          VistaPro ASCII vector.
static int VRML_FACESET
          VRML indexed face set.
static int VRML_HEIGHTFIELD
          VRML heightfield.
static int VRML_WORLD
          VRML world.
static int VRML97_FACESET
          Deprecated. Should use VRML_FACESET instead.
static int VRML97_HEIGHTFIELD
          Deprecated. Should use VRML_HEIGHTFIELD instead.
static int VRML97_WORLD
          Deprecated. Should use VRML_WORLD instead.
static int XML
          XML metadata file.
 
Constructor Summary
FileHandler()
           
 
Method Summary
static int getFileType(String typeID)
          Reports the file type based on the supplied ID.
static int guessFileType(String fileName)
          Guesses the type of file based on the extension of the given file name.
static SpatialObject readFile(String name, int type, GISFrame gisFrame, LSThread lsThread)
          Reads the contents of one or more files.
static boolean writeFile(SpatialObject spObject, String fileName, int type, GISFrame gisFrame, LSThread lsThread)
          Writes the contents of the given spatial object to one or more files.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNDEFINED

public static final int UNDEFINED
Undefined file type.

See Also:
Constant Field Values

LANDSERF_R

public static final int LANDSERF_R
LandSerf serialized raster.

See Also:
Constant Field Values

LANDSERF_V

public static final int LANDSERF_V
LandSerf serialized vector.

See Also:
Constant Field Values

TEXT_R

public static final int TEXT_R
Generic ASCII raster.

See Also:
Constant Field Values

TEXT_V

public static final int TEXT_V
Generic ASCII vector.

See Also:
Constant Field Values

POINT_TEXT_V

public static final int POINT_TEXT_V
Generic ASCII point vector.

See Also:
Constant Field Values

POINT_TEXT_R

public static final int POINT_TEXT_R
Generic ASCII point raster.

See Also:
Constant Field Values

POINTDEN_TEXT_R

public static final int POINTDEN_TEXT_R
Generic point density raster.

See Also:
Constant Field Values

BIN8_R

public static final int BIN8_R
Generic 8 bit binary raster.

See Also:
Constant Field Values

BIN16_R

public static final int BIN16_R
Generic 16 bit binary raster.

See Also:
Constant Field Values

BIN32_R

public static final int BIN32_R
Generic 32 bit binary raster.

See Also:
Constant Field Values

BIN_R

public static final int BIN_R
Generic binary raster.

See Also:
Constant Field Values

BIN_V

public static final int BIN_V
Generic binary vector.

See Also:
Constant Field Values

GRASS_TEXT_R

public static final int GRASS_TEXT_R
GRASS ASCII raster.

See Also:
Constant Field Values

GRASS_TEXT_V

public static final int GRASS_TEXT_V
GRASS ASCII vector.

See Also:
Constant Field Values

GRASS_BIN_R

public static final int GRASS_BIN_R
GRASS binary raster.

See Also:
Constant Field Values

GRASS_BIN_V

public static final int GRASS_BIN_V
GRASS binary vector.

See Also:
Constant Field Values

IDRISI_TEXT_R

public static final int IDRISI_TEXT_R
Idrisi ASCII raster.

See Also:
Constant Field Values

IDRISI_TEXT_V

public static final int IDRISI_TEXT_V
Idrisi ASCII vector.

See Also:
Constant Field Values

IDRISI_BIN_R

public static final int IDRISI_BIN_R
Idrisi binary raster.

See Also:
Constant Field Values

IDRISI_BIN_V

public static final int IDRISI_BIN_V
Idrisi binary vector.

See Also:
Constant Field Values

NTF_TEXT_R

public static final int NTF_TEXT_R
NTF raster (Ordnance Survey).

See Also:
Constant Field Values

NTF_TEXT_V

public static final int NTF_TEXT_V
NTF vector (Ordnance Survey).

See Also:
Constant Field Values

VISTA_TEXT_R

public static final int VISTA_TEXT_R
VistaPro ASCII raster.

See Also:
Constant Field Values

VISTA_TEXT_V

public static final int VISTA_TEXT_V
VistaPro ASCII vector.

See Also:
Constant Field Values

VISTA_BIN_R

public static final int VISTA_BIN_R
VistaPro binary raster.

See Also:
Constant Field Values

ARC_TEXT_R

public static final int ARC_TEXT_R
ArcGIS ASCII raster.

See Also:
Constant Field Values

ARC_BIN_R

public static final int ARC_BIN_R
ArcGIS binary float raster.

See Also:
Constant Field Values

ARC_TEXT_V

public static final int ARC_TEXT_V
ArcGIS 'generate' vector.

See Also:
Constant Field Values

SHAPEFILE_V

public static final int SHAPEFILE_V
ESRI shapefile vector.

See Also:
Constant Field Values

VISTA_BIN_V

public static final int VISTA_BIN_V
VistaPro binary vector.

See Also:
Constant Field Values

EDX_TEXT_R

public static final int EDX_TEXT_R
EDX ASCII raster.

See Also:
Constant Field Values

EDX_TEXT_V

public static final int EDX_TEXT_V
EDX ASCII vector.

See Also:
Constant Field Values

VRML97_WORLD

public static final int VRML97_WORLD
Deprecated. Should use VRML_WORLD instead.
VRML97 world.

See Also:
Constant Field Values

VRML_WORLD

public static final int VRML_WORLD
VRML world.

See Also:
Constant Field Values

VRML97_HEIGHTFIELD

public static final int VRML97_HEIGHTFIELD
Deprecated. Should use VRML_HEIGHTFIELD instead.
VRML97 heightfield.

See Also:
Constant Field Values

VRML_HEIGHTFIELD

public static final int VRML_HEIGHTFIELD
VRML heightfield.

See Also:
Constant Field Values

VRML97_FACESET

public static final int VRML97_FACESET
Deprecated. Should use VRML_FACESET instead.
VRML97 heightfield.

See Also:
Constant Field Values

VRML_FACESET

public static final int VRML_FACESET
VRML indexed face set.

See Also:
Constant Field Values

SRTM_R

public static final int SRTM_R
Shuttle Radar Topography Mission DEM.

See Also:
Constant Field Values

TERRAGEN_RAW_R

public static final int TERRAGEN_RAW_R
Terragen raw binary raster.

See Also:
Constant Field Values

TERRAGEN_TERRAIN_R

public static final int TERRAGEN_TERRAIN_R
Terragen native terrain.

See Also:
Constant Field Values

XML

public static final int XML
XML metadata file.

See Also:
Constant Field Values

GML

public static final int GML
GML file.

See Also:
Constant Field Values

MASTERMAP

public static final int MASTERMAP
MasterMap (GML)file.

See Also:
Constant Field Values

ROUTE_TEXT_V

public static final int ROUTE_TEXT_V
Route vector.

See Also:
Constant Field Values

MSN_TEXT

public static final int MSN_TEXT
Metric surface network.

See Also:
Constant Field Values

BT_R

public static final int BT_R
Virtual Terrain BT binary.

See Also:
Constant Field Values

BIL_R

public static final int BIL_R
Binary Integer Interleaved.

See Also:
Constant Field Values

GSHHS_V

public static final int GSHHS_V
Global Hierarchical Shorelines.

See Also:
Constant Field Values

SVG

public static final int SVG
Scalable Vector Graphics (SVG).

See Also:
Constant Field Values

ATT_TABLE

public static final int ATT_TABLE
Text attribute table.

See Also:
Constant Field Values

USGS_R

public static final int USGS_R
USGS DEM format.

See Also:
Constant Field Values

DTED_R

public static final int DTED_R
DTED (Digital Terrain Elevation Data).

See Also:
Constant Field Values

GTOPO30_R

public static final int GTOPO30_R
USGS GTOPO30 format.

See Also:
Constant Field Values

MOLA_PEDR

public static final int MOLA_PEDR
MOLA (Mars Orbiter) format.

See Also:
Constant Field Values

GPX

public static final int GPX
GPX GPS interchange file.

See Also:
Constant Field Values

KML

public static final int KML
Keyhole Markup Language (KML, Google Earth/Maps) file.

See Also:
Constant Field Values

KMZ

public static final int KMZ
Keyhole Markup Language Archive (KMZ, Google Earth/Maps) file.

See Also:
Constant Field Values

IMAGE

public static final int IMAGE
GIF or JPEG graphics file.

See Also:
Constant Field Values

CONTROL_POINTS

public static final int CONTROL_POINTS
Control points.

See Also:
Constant Field Values

COLOUR_TABLE

public static final int COLOUR_TABLE
Colour table.

See Also:
Constant Field Values

TEXT

public static final int TEXT
Generic text file.

See Also:
Constant Field Values

LANDSCRIPT

public static final int LANDSCRIPT
LandScript file.

See Also:
Constant Field Values

VECTOR_STYLES

public static final int VECTOR_STYLES
Vector display styles.

See Also:
Constant Field Values
Constructor Detail

FileHandler

public FileHandler()
Method Detail

writeFile

public static boolean writeFile(SpatialObject spObject,
                                String fileName,
                                int type,
                                GISFrame gisFrame,
                                LSThread lsThread)
Writes the contents of the given spatial object to one or more files. If file is not saved correctly, FileIO.getErrorMessage() can be called to identify the fault.

Parameters:
spObject - Spatial object to save.
fileName - Name to save file under.
type - Type of file format to save.
gisFrame - GUI that called this method in which to report results.
lsThread - Thread that called this method (allows this to be interrupted).
Returns:
True if saved successfully.

readFile

public static SpatialObject readFile(String name,
                                     int type,
                                     GISFrame gisFrame,
                                     LSThread lsThread)
Reads the contents of one or more files. If file is not read correctly, FileIO.getErrorMessage() can be called to identify the fault.

Parameters:
name - Name file to read.
type - Type of file format to read.
gisFrame - GUI in which to report progress.
lsThread - Thread that called this method (allows this to be interrupted).
Returns:
Spatial object that has been read, or null if problems reading file.

guessFileType

public static int guessFileType(String fileName)
Guesses the type of file based on the extension of the given file name. Will default to LandSerf raster if type cannot be guessed from extension. Note that this can produce an incorrect guess for file types that share the same extension (e.g. .txt files are assumed to be generic raster text).

Parameters:
fileName - Name of file with extension.
Returns:
Type of file assumed from extension.

getFileType

public static int getFileType(String typeID)
Reports the file type based on the supplied ID. This is primarily used for scripting commands that need to specifically a file type.

Parameters:
typeID - ID to identify file type. See the LandSerf File Formats 'Howto' for details.
Returns:
Type of file or UNDEFINED if ID not recognised.


Copyright Jo Wood, 1996-2009, last modified, 17th April, 2009