Package nl.tudelft.simulation.dsol.animation.gis.io.esri

## Class ShapeFile

- java.lang.Object
- - nl.tudelft.simulation.dsol.animation.gis.io.esri.ShapeFile

All Implemented Interfaces:
  `Serializable`, `DataSourceInterface`

    public class ShapeFile
    extends Object
    implements DataSourceInterface

This class reads ESRI-shapefiles and returns the shape objects.

Copyright (c) 2020-2021 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
`static int` `MULTIPATCH` the MULTIPATCH as defined by ESRI.
`static int` `MULTIPOINT` the MULTIPOINT as defined by ESRI.
`static int` `MULTIPOINTM` the MULTIPOINTM as defined by ESRI.
`static int` `MULTIPOINTZ` the MULTIPOINTZ as defined by ESRI.
`static int` `NULLSHAPE` the NULLSHAPE as defined by ESRI.
`static int` `POINT` the POINT as defined by ESRI.
`static int` `POINTM` the POINM as defined by ESRI.
`static int` `POINTZ` the POINTZ as defined by ESRI.
`static int` `POLYGON` the POLYGON as defined by ESRI.
`static int` `POLYGONM` the POLYGONM as defined by ESRI.
`static int` `POLYGONZ` the POLYGONZ as defined by ESRI.
`static int` `POLYLINE` the POLYLINE as defined by ESRI.
`static int` `POLYLINEM` the POLYLINEM as defined by ESRI.
`static int` `POLYLINEZ` the POLYLINEZ as defined by ESRI.

### Constructor Summary

Constructors
`ShapeFile​(URL url, CoordinateTransform coordinateTransform)` constructs a new ESRI ShapeFile.

### Method Summary

All Methods Instance Methods Concrete Methods
`String[][]` `getAttributes()` returns the attribute data.
`String[]` `getColumnNames()` returns the columnNames of the attribute data.
`URL` `getDataSource()` returns the URL of the data source.
`int` `getNumShapes()` returns the number of shapes of the particular data source.
`GisObject` `getShape​(int index)` returns a GisObject.
`List<GisObject>` `getShapes()` returns all the shapes of the particular data source.
`List<GisObject>` `getShapes​(String attribute, String columnName)` returns the shapes based on a particular value of the attributes.
`List<GisObject>` `getShapes​(Bounds2d extent)` returns the shapes of the particular data source in a particular extent.
`int` `getType()`
`boolean` `isCache()`
`void` `setCache​(boolean cache)` Set whether caching is allowed or not.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### 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

#### ShapeFile

    public ShapeFile​(URL url,
                     CoordinateTransform coordinateTransform)
              throws IOException

constructs a new ESRI ShapeFile.

Parameters:
  `url` - URL; URL may or may not end with their extension.
  `coordinateTransform` - CoordinateTransform; the transformation of (x, y) coordinates to (x', y') coordinates.
Throws:
  `IOException` - throws an IOException if the shxFile is not accessable

### Method Detail

#### isCache

    public boolean isCache()

Returns:
  Returns the cache.

#### setCache

    public void setCache​(boolean cache)

Set whether caching is allowed or not.

Parameters:
  `cache` - boolean; The caching preference to set

#### getColumnNames

    public String[] getColumnNames()

returns the columnNames of the attribute data.

Specified by:
  `getColumnNames` in interface `DataSourceInterface`
Returns:
  String[]

#### getAttributes

    public String[][] getAttributes()
                             throws IOException

returns the attribute data.

Specified by:
  `getAttributes` in interface `DataSourceInterface`
Returns:
  the attributes
Throws:
  `IOException` - on IOException

#### getDataSource

    public URL getDataSource()

returns the URL of the data source.

Specified by:
  `getDataSource` in interface `DataSourceInterface`
Returns:
  URL the URL of the file

#### getNumShapes

    public int getNumShapes()

returns the number of shapes of the particular data source.

Specified by:
  `getNumShapes` in interface `DataSourceInterface`
Returns:
  int the number of shapes

#### getShape

    public GisObject getShape​(int index)
                       throws IOException

returns a GisObject.

Specified by:
  `getShape` in interface `DataSourceInterface`
Parameters:
  `index` - int; the number of the shape to be returned
Returns:
  GisObject returns a `nl.javel.gisbeans.geom.GisObject`
Throws:
  `IOException` - on IOFailure

#### getShapes

    public List<GisObject> getShapes()
                              throws IOException

returns all the shapes of the particular data source.

Specified by:
  `getShapes` in interface `DataSourceInterface`
Returns:
  List the resulting ArrayList of `nl.javel.gisbeans.geom.GisObject`
Throws:
  `IOException` - on IOFailure

#### getShapes

    public List<GisObject> getShapes​(Bounds2d extent)
                              throws IOException

returns the shapes of the particular data source in a particular extent.

Specified by:
  `getShapes` in interface `DataSourceInterface`
Parameters:
  `extent` - Bounds2d; the extent of the box (in geo-coordinates)
Returns:
  List the resulting ArrayList of `nl.javel.gisbeans.geom.GisObject`
Throws:
  `IOException` - on IOFailure

#### getShapes

    public List<GisObject> getShapes​(String attribute,
                                     String columnName)
                              throws IOException

returns the shapes based on a particular value of the attributes.

Specified by:
  `getShapes` in interface `DataSourceInterface`
Parameters:
  `attribute` - String; the value of the attribute
  `columnName` - String; the columnName
Returns:
  List the resulting ArrayList of `nl.javel.gisbeans.geom.GisObject`
Throws:
  `IOException` - on IOFailure

#### getType

    public int getType()

Specified by:
  `getType` in interface `DataSourceInterface`
Returns:
  returns the type of this dataSouce.