ucar.unidata.gis.shapefile
Class EsriShapefile

java.lang.Object
  extended by ucar.unidata.gis.shapefile.EsriShapefile

public class EsriShapefile
extends Object

EsriShapefile.java Encapsulates details of ESRI Shapefile format, documented at http://www.esri.com/library/whitepapers/pdfs/shapefile.pdf

Version:
$Revision: 1.27 $ $Date: 2005/05/13 18:29:48 $
Author:
Russ Rew

Nested Class Summary
 class EsriShapefile.EsriFeature
          EsriFeature.java Created: Sat Feb 20 17:19:53 1999
 class EsriShapefile.EsriMultipoint
          Represents a Multipoint in an ESRI shapefile.
 class EsriShapefile.EsriNull
          A NULL shape in an ESRI shapefile.
 class EsriShapefile.EsriPoint
          Represents a single point in an ESRI shapefile.
 class EsriShapefile.EsriPolygon
          Represents a Polygon in an ESRI shapefile as a List of GisParts.
 class EsriShapefile.EsriPolyline
          Represents a Polyline in an ESRI shapefile as a List of GisParts.
 
Field Summary
static int MULTIPATCH
          _more_
static int MULTIPOINT
          _more_
static int MULTIPOINTM
          _more_
static int MULTIPOINTZ
          _more_
static int NULL
          _more_
static int POINT
          _more_
static int POINTM
          _more_
static int POINTZ
          _more_
static int POLYGON
          _more_
static int POLYGONM
          _more_
static int POLYGONZ
          _more_
static int POLYLINE
          _more_
static int POLYLINEM
          _more_
static int POLYLINEZ
          _more_
static int SHAPEFILE_CODE
          _more_
 
Constructor Summary
EsriShapefile(InputStream iStream, Rectangle2D bBox, double coarseness)
          Read an ESRI shapefile and extract the subset of features that have bounding boxes that intersect a specified bounding box, with control of time versus resolution.
EsriShapefile(String filename)
          Read an ESRI shapefile and extract all features into an in-memory structure.
EsriShapefile(String filename, double coarseness)
          Read an ESRI shapefile and extract all features into an in-memory structure, with control of time versus resolution.
EsriShapefile(String filename, Rectangle2D bBox)
          Read an ESRI shapefile and extract the subset of features that have bounding boxes that intersect a specified bounding box.
EsriShapefile(String filename, Rectangle2D bBox, double coarseness)
          Read an ESRI shapefile and extract all features into an in-memory structure, with control of time versus resolution.
EsriShapefile(URL url)
          Read an ESRI shapefile from a URL and extract all features into an in-memory structure.
EsriShapefile(URL url, double coarseness)
          Read an ESRI shapefile from a URL and extract all features into an in-memory structure, with control of time versus resolution.
EsriShapefile(URL url, Rectangle2D bBox)
          Read an ESRI shapefile and extract the subset of features that have bounding boxes that intersect a specified bounding box
EsriShapefile(URL url, Rectangle2D bBox, double coarseness)
          Read an ESRI shapefile and extract the subset of features that have bounding boxes that intersect a specified bounding box
 
Method Summary
 Rectangle2D getBoundingBox()
          Get bounding box, according to file (not computed from features)
 DbaseFile getDbFile()
          _more_
 List getFeatures()
          Get a List of all the GisFeatures in the shapefile.
 List getFeatures(Rectangle2D bBox)
          Get a List of all the features in the shapefile that intersect the specified bounding box.
 int getFeatureType()
          _more_
 int getNumFeatures()
           
 int getVersion()
          Returns shapefile format version (currently 1000)
 int numShapes()
          Deprecated.  
 double percentRead()
          Return percent of file read, so far.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SHAPEFILE_CODE

public static final int SHAPEFILE_CODE
_more_

See Also:
Constant Field Values

NULL

public static final int NULL
_more_

See Also:
Constant Field Values

POINT

public static final int POINT
_more_

See Also:
Constant Field Values

POLYLINE

public static final int POLYLINE
_more_

See Also:
Constant Field Values

POLYGON

public static final int POLYGON
_more_

See Also:
Constant Field Values

MULTIPOINT

public static final int MULTIPOINT
_more_

See Also:
Constant Field Values

POINTZ

public static final int POINTZ
_more_

See Also:
Constant Field Values

POLYLINEZ

public static final int POLYLINEZ
_more_

See Also:
Constant Field Values

POLYGONZ

public static final int POLYGONZ
_more_

See Also:
Constant Field Values

MULTIPOINTZ

public static final int MULTIPOINTZ
_more_

See Also:
Constant Field Values

POINTM

public static final int POINTM
_more_

See Also:
Constant Field Values

POLYLINEM

public static final int POLYLINEM
_more_

See Also:
Constant Field Values

POLYGONM

public static final int POLYGONM
_more_

See Also:
Constant Field Values

MULTIPOINTM

public static final int MULTIPOINTM
_more_

See Also:
Constant Field Values

MULTIPATCH

public static final int MULTIPATCH
_more_

See Also:
Constant Field Values
Constructor Detail

EsriShapefile

public EsriShapefile(String filename)
              throws IOException
Read an ESRI shapefile and extract all features into an in-memory structure.

Parameters:
filename - name of ESRI shapefile (typically has ".shp" extension)
Throws:
IOException

EsriShapefile

public EsriShapefile(URL url)
              throws IOException
Read an ESRI shapefile from a URL and extract all features into an in-memory structure.

Parameters:
url - URL of ESRI shapefile
Throws:
IOException

EsriShapefile

public EsriShapefile(String filename,
                     double coarseness)
              throws IOException
Read an ESRI shapefile and extract all features into an in-memory structure, with control of time versus resolution.

Parameters:
filename - name of ESRI shapefile (typically has ".shp" extension)
coarseness - to tradeoff plot quality versus speed.
Throws:
IOException

EsriShapefile

public EsriShapefile(URL url,
                     double coarseness)
              throws IOException
Read an ESRI shapefile from a URL and extract all features into an in-memory structure, with control of time versus resolution.

Parameters:
url - URL of ESRI shapefile
coarseness - to tradeoff plot quality versus speed.
Throws:
IOException

EsriShapefile

public EsriShapefile(URL url,
                     Rectangle2D bBox,
                     double coarseness)
              throws IOException
Read an ESRI shapefile and extract the subset of features that have bounding boxes that intersect a specified bounding box

Parameters:
url - URL of ESRI shapefile
bBox - bounding box specifying which features to select, namely those whose bounding boxes intersect this one. If null, bounding box of whole shapefile is used
coarseness - to tradeoff plot quality versus speed.
Throws:
IOException

EsriShapefile

public EsriShapefile(String filename,
                     Rectangle2D bBox,
                     double coarseness)
              throws IOException
Read an ESRI shapefile and extract all features into an in-memory structure, with control of time versus resolution.

Parameters:
filename - name of ESRI shapefile
bBox - bounding box specifying which features to select, namely those whose bounding boxes intersect this one. If null, bounding box of whole shapefile is used
coarseness - to tradeoff plot quality versus speed.
Throws:
IOException

EsriShapefile

public EsriShapefile(URL url,
                     Rectangle2D bBox)
              throws IOException
Read an ESRI shapefile and extract the subset of features that have bounding boxes that intersect a specified bounding box

Parameters:
url - URL of ESRI shapefile
bBox - bounding box specifying which features to select, namely those whose bounding boxes intersect this one. If null, bounding box of whole shapefile is used
Throws:
IOException

EsriShapefile

public EsriShapefile(String filename,
                     Rectangle2D bBox)
              throws IOException
Read an ESRI shapefile and extract the subset of features that have bounding boxes that intersect a specified bounding box.

Parameters:
filename - name of ESRI shapefile
bBox - bounding box specifying which features to select, namely those whose bounding boxes intersect this one. If null, bounding box of whole shapefile is used
Throws:
IOException

EsriShapefile

public EsriShapefile(InputStream iStream,
                     Rectangle2D bBox,
                     double coarseness)
              throws IOException
Read an ESRI shapefile and extract the subset of features that have bounding boxes that intersect a specified bounding box, with control of time versus resolution.

Parameters:
iStream - input from which to read
bBox - bounding box specifying which features to select, namely those whose bounding boxes intersect this one. If null, bounding box of whole shapefile is used
coarseness -
Throws:
IOException
Method Detail

getDbFile

public DbaseFile getDbFile()
_more_

Returns:
_more_

percentRead

public double percentRead()
Return percent of file read, so far.

Returns:
percent of file read, so far.

getNumFeatures

public int getNumFeatures()
Returns:
number of features in shapefile

numShapes

public int numShapes()
Deprecated. 

Returns:
number of features in shapefile

getVersion

public int getVersion()
Returns shapefile format version (currently 1000)

Returns:
version, as stored in shapefile.

getBoundingBox

public Rectangle2D getBoundingBox()
Get bounding box, according to file (not computed from features)

Returns:
bounding box for shapefilew, as stored in header.

getFeatures

public List getFeatures()
Get a List of all the GisFeatures in the shapefile. This is very fast after the constructor has been called, since it is created during construction.

Returns:
a List of features

getFeatures

public List getFeatures(Rectangle2D bBox)
Get a List of all the features in the shapefile that intersect the specified bounding box. This requires testing every feature in the List created at construction, so it's faster to just give a bounding box o the constructor if you will only do this once.

Parameters:
bBox - specifying the bounding box with which all the returned features bounding boxes have a non-empty intersection.
Returns:
a new list of features in the shapefile whose bounding boxes intersect the specified bounding box.

getFeatureType

public int getFeatureType()
_more_

Returns:
_more_