Class ShapeFileReader
- java.lang.Object
-
- nl.tudelft.simulation.dsol.animation.gis.esri.ShapeFileReader
-
- All Implemented Interfaces:
Serializable,DataSourceInterface
public class ShapeFileReader extends Object implements DataSourceInterface
This class reads ESRI-shapefiles and returns the shape objects.Copyright (c) 2020-2023 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information DSOL Manual. The DSOL project is distributed under a three-clause BSD-style license, which can be found at DSOL License.
The dsol-animation-gis project is based on the gisbeans project that has been part of DSOL since 2002, originally by Peter Jacobs and Paul Jacobs.
- Author:
- Alexander Verbraeck
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static intMULTIPATCHthe MULTIPATCH as defined by ESRI.static intMULTIPOINTthe MULTIPOINT as defined by ESRI.static intMULTIPOINTMthe MULTIPOINTM as defined by ESRI.static intMULTIPOINTZthe MULTIPOINTZ as defined by ESRI.static intNULLSHAPEthe NULLSHAPE as defined by ESRI.static intPOINTthe POINT as defined by ESRI.static intPOINTMthe POINM as defined by ESRI.static intPOINTZthe POINTZ as defined by ESRI.static intPOLYGONthe POLYGON as defined by ESRI.static intPOLYGONMthe POLYGONM as defined by ESRI.static intPOLYGONZthe POLYGONZ as defined by ESRI.static intPOLYLINEthe POLYLINE as defined by ESRI.static intPOLYLINEMthe POLYLINEM as defined by ESRI.static intPOLYLINEZthe POLYLINEZ as defined by ESRI.
-
Constructor Summary
Constructors Constructor Description ShapeFileReader(URL shapeUrl, CoordinateTransform coordinateTransform, List<FeatureInterface> featuresToRead)Construct a reader for an ESRI ShapeFile.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String[]getAttributeKeyNames()Return the key names of the attribute data.List<FeatureInterface>getFeatures()List<GisObject>getShapes(String attribute, String columnName)Return the shapes based on a particular value of the attributes.URLgetURL()booleanisDynamic()voidpopulateShapes()List<GisObject>readAllShapes()Read all shapes directly from the shape file, without caching (the cache is stored at the Features).GisObjectreadShape(int index)Read a particular shape directly from the shape file, without caching (the cache is stored at the Features).List<GisObject>readShapes(Bounds2d extent)Read all shapes for a certain extent directly from the shape file, without caching (the cache is stored at the Features).
-
-
-
Field Detail
-
NULLSHAPE
public static final int NULLSHAPE
the NULLSHAPE as defined by ESRI.- See Also:
- Constant Field Values
-
POINT
public static final int POINT
the POINT as defined by ESRI.- See Also:
- Constant Field Values
-
POLYLINE
public static final int POLYLINE
the POLYLINE as defined by ESRI.- See Also:
- Constant Field Values
-
POLYGON
public static final int POLYGON
the POLYGON as defined by ESRI.- See Also:
- Constant Field Values
-
MULTIPOINT
public static final int MULTIPOINT
the MULTIPOINT as defined by ESRI.- See Also:
- Constant Field Values
-
POINTZ
public static final int POINTZ
the POINTZ as defined by ESRI.- See Also:
- Constant Field Values
-
POLYLINEZ
public static final int POLYLINEZ
the POLYLINEZ as defined by ESRI.- See Also:
- Constant Field Values
-
POLYGONZ
public static final int POLYGONZ
the POLYGONZ as defined by ESRI.- See Also:
- Constant Field Values
-
MULTIPOINTZ
public static final int MULTIPOINTZ
the MULTIPOINTZ as defined by ESRI.- See Also:
- Constant Field Values
-
POINTM
public static final int POINTM
the POINM as defined by ESRI.- See Also:
- Constant Field Values
-
POLYLINEM
public static final int POLYLINEM
the POLYLINEM as defined by ESRI.- See Also:
- Constant Field Values
-
POLYGONM
public static final int POLYGONM
the POLYGONM as defined by ESRI.- See Also:
- Constant Field Values
-
MULTIPOINTM
public static final int MULTIPOINTM
the MULTIPOINTM as defined by ESRI.- See Also:
- Constant Field Values
-
MULTIPATCH
public static final int MULTIPATCH
the MULTIPATCH as defined by ESRI.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ShapeFileReader
public ShapeFileReader(URL shapeUrl, CoordinateTransform coordinateTransform, List<FeatureInterface> featuresToRead) throws IOException
Construct a reader for an ESRI ShapeFile.- Parameters:
shapeUrl- URL; URL may or may not end with their extension.coordinateTransform- CoordinateTransform; the transformation of (x, y) coordinates to (x', y') coordinates.featuresToRead- the features to read- Throws:
IOException- throws an IOException if the shxFile is not accessible
-
-
Method Detail
-
getFeatures
public List<FeatureInterface> getFeatures()
- Specified by:
getFeaturesin interfaceDataSourceInterface
-
populateShapes
public void populateShapes() throws IOException- Specified by:
populateShapesin interfaceDataSourceInterface- Throws:
IOException
-
readShape
public GisObject readShape(int index) throws IOException
Read a particular shape directly from the shape file, without caching (the cache is stored at the Features).- Parameters:
index- int; the index of the shape to read from the shape file, without using any caching- Returns:
- GisObject; the shape belonging to the index
- Throws:
IOException- when there is a problem reading the ESRI files.
-
readAllShapes
public List<GisObject> readAllShapes() throws IOException
Read all shapes directly from the shape file, without caching (the cache is stored at the Features).- Returns:
- List<GisObject>; the shapes that are directly read from the shape file
- Throws:
IOException- when there is a problem reading the ESRI files.
-
readShapes
public List<GisObject> readShapes(Bounds2d extent) throws IOException
Read all shapes for a certain extent directly from the shape file, without caching (the cache is stored at the Features).- Parameters:
extent- Bounds2d; the extent for which to read the shapes- Returns:
- List<GisObject>; the shapes for the given extent that are directly read from the shape file
- Throws:
IOException- when there is a problem reading the ESRI files.
-
getShapes
public List<GisObject> getShapes(String attribute, String columnName) throws IOException
Return the shapes based on a particular value of the attributes.- Parameters:
attribute- String; the value of the attributecolumnName- String; the columnName- Returns:
- List the resulting ArrayList of
nl.tudelft.simulation.dsol.animation.gis.GisObject - Throws:
IOException- on file IO or database connection failure
-
isDynamic
public boolean isDynamic()
- Specified by:
isDynamicin interfaceDataSourceInterface
-
getAttributeKeyNames
public String[] getAttributeKeyNames()
Return the key names of the attribute data. The attribute values are stored in the GisObject together with the shape.- Returns:
- String[]; the key names of the attribute data
-
getURL
public URL getURL()
- Specified by:
getURLin interfaceDataSourceInterface
-
-