org.geotools.shapefile
Class Shapefile

java.lang.Object
  extended by org.geotools.shapefile.Shapefile

public class Shapefile
extends java.lang.Object

This class represents an ESRI Shape file.

You construct it with a file name, and later you can read the file's properties, i.e. Sizes, Types, and the data itself.

Copyright 1998 by James Macgill.

Version 1.0beta1.1 (added construct with inputstream) 1.0beta1.2 (made Shape type constants public 18/Aug/98) This class supports the Shape file as set out in :-
"ESRI(r) Shapefile - A Technical Description"
'An ESRI White Paper . May 1997'

This code is coverd by the LGPL. Mail the Author


Field Summary
static int ARC
           
static int ARCM
           
static int ARCZ
           
static int MULTIPATCH
           
static int MULTIPOINT
           
static int MULTIPOINTM
           
static int MULTIPOINTZ
           
static int NULL
           
static int POINT
           
static int POINTM
           
static int POINTZ
           
static int POLYGON
           
static int POLYGONM
           
static int POLYGONZ
           
static int UNDEFINED
           
 
Constructor Summary
Shapefile(java.io.InputStream IS)
           
Shapefile(java.net.URL url)
          Creates and initialises a shapefile from a url
 
Method Summary
 void close()
           
 int getErrorNumber()
          Get the number of errors found after a read.
static ShapeHandler getShapeHandler(com.vividsolutions.jts.geom.Geometry geom, int ShapeFileDimension)
           
static ShapeHandler getShapeHandler(int type)
           
static int getShapeType(com.vividsolutions.jts.geom.Geometry geom, int ShapeFileDimension)
          Returns the Shape Type corresponding to geometry geom of dimension ShapeFileDimension.
static java.lang.String getShapeTypeDescription(int index)
          Returns a string describing the shape type.
 com.vividsolutions.jts.geom.GeometryCollection read(com.vividsolutions.jts.geom.GeometryFactory geometryFactory)
          Initialises a shapefile from disk.
 void readIndex(java.io.InputStream is)
           
 void write(com.vividsolutions.jts.geom.GeometryCollection geometries, int ShapeFileDimension)
          Saves a shapefile to an output stream.
 void writeIndex(com.vividsolutions.jts.geom.GeometryCollection geometries, EndianDataOutputStream file, int ShapeFileDimension)
          Saves a shapefile index (shx) to an output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NULL

public static final int NULL
See Also:
Constant Field Values

POINT

public static final int POINT
See Also:
Constant Field Values

POINTZ

public static final int POINTZ
See Also:
Constant Field Values

POINTM

public static final int POINTM
See Also:
Constant Field Values

ARC

public static final int ARC
See Also:
Constant Field Values

ARCM

public static final int ARCM
See Also:
Constant Field Values

ARCZ

public static final int ARCZ
See Also:
Constant Field Values

POLYGON

public static final int POLYGON
See Also:
Constant Field Values

POLYGONM

public static final int POLYGONM
See Also:
Constant Field Values

POLYGONZ

public static final int POLYGONZ
See Also:
Constant Field Values

MULTIPOINT

public static final int MULTIPOINT
See Also:
Constant Field Values

MULTIPOINTM

public static final int MULTIPOINTM
See Also:
Constant Field Values

MULTIPOINTZ

public static final int MULTIPOINTZ
See Also:
Constant Field Values

MULTIPATCH

public static final int MULTIPATCH
See Also:
Constant Field Values

UNDEFINED

public static final int UNDEFINED
See Also:
Constant Field Values
Constructor Detail

Shapefile

public Shapefile(java.net.URL url)
Creates and initialises a shapefile from a url

Parameters:
url - The url of the shapefile

Shapefile

public Shapefile(java.io.InputStream IS)
Method Detail

close

public void close()

read

public com.vividsolutions.jts.geom.GeometryCollection read(com.vividsolutions.jts.geom.GeometryFactory geometryFactory)
                                                    throws java.io.IOException,
                                                           ShapefileException,
                                                           java.lang.Exception
Initialises a shapefile from disk. Use Shapefile(String) if you don't want to use LEDataInputStream directly (recommended)

Parameters:
geometryFactory - the geometry factory to use to read the shapes
Throws:
java.io.IOException
ShapefileException
java.lang.Exception

getErrorNumber

public int getErrorNumber()
Get the number of errors found after a read.


write

public void write(com.vividsolutions.jts.geom.GeometryCollection geometries,
                  int ShapeFileDimension)
           throws java.io.IOException,
                  java.lang.Exception
Saves a shapefile to an output stream.

Parameters:
geometries - geometry collection to write
ShapeFileDimension - shapefile dimension (2=x,y ; 3=x,y,m ; 4=x,y,z,m)
Throws:
java.io.IOException
java.lang.Exception

writeIndex

public void writeIndex(com.vividsolutions.jts.geom.GeometryCollection geometries,
                       EndianDataOutputStream file,
                       int ShapeFileDimension)
                throws java.io.IOException,
                       java.lang.Exception
Saves a shapefile index (shx) to an output stream.

Parameters:
geometries - geometry collection to write
file - file to write to
ShapeFileDimension - shapefile dimension (2=x,y ; 3=x,y,m ; 4=x,y,z,m)
Throws:
java.io.IOException
java.lang.Exception

getShapeTypeDescription

public static java.lang.String getShapeTypeDescription(int index)
Returns a string describing the shape type.

Parameters:
index - An int coresponding to the shape type to be described
Returns:
A string describing the shape type

getShapeHandler

public static ShapeHandler getShapeHandler(com.vividsolutions.jts.geom.Geometry geom,
                                           int ShapeFileDimension)
                                    throws java.lang.Exception
Throws:
java.lang.Exception

getShapeHandler

public static ShapeHandler getShapeHandler(int type)
                                    throws java.lang.Exception
Throws:
java.lang.Exception

getShapeType

public static int getShapeType(com.vividsolutions.jts.geom.Geometry geom,
                               int ShapeFileDimension)
                        throws ShapefileException
Returns the Shape Type corresponding to geometry geom of dimension ShapeFileDimension.

Parameters:
geom - the geom
ShapeFileDimension - the dimension of the geom (2=x,y ; 3=x,y,m ; 4=x,y,z,m)
Returns:
A int representing the Shape Type
Throws:
ShapefileException

readIndex

public void readIndex(java.io.InputStream is)
               throws java.io.IOException
Throws:
java.io.IOException