Package ucar.nc2.ui.gis.shapefile
Class EsriShapefile
- java.lang.Object
-
- ucar.nc2.ui.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
EsriShapefile.EsriFeature
EsriFeature.javaclass
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.
-
Constructor Summary
Constructors Constructor Description 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 boxEsriShapefile(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Rectangle2D
getBoundingBox()
Get bounding box, according to file (not computed from features)List
getFeatures()
Get a List of all the GisFeatures in the shapefile.List<EsriShapefile.EsriFeature>
getFeatures(Rectangle2D bBox)
Get a List of all the features in the shapefile that intersect the specified bounding box.int
getNumFeatures()
int
getVersion()
Returns shapefile format version (currently 1000)double
percentRead()
Return percent of file read, so far.String
toString()
-
-
-
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 shapefilecoarseness
- 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 shapefilebBox
- bounding box specifying which features to select, namely those whose bounding boxes intersect this one. If null, bounding box of whole shapefile is usedcoarseness
- 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 shapefilebBox
- bounding box specifying which features to select, namely those whose bounding boxes intersect this one. If null, bounding box of whole shapefile is usedcoarseness
- 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 shapefilebBox
- 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 shapefilebBox
- 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 readbBox
- 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
-
-
Method Detail
-
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
-
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<EsriShapefile.EsriFeature> 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.
-
-