ilog.views.maps.format.shapefile
Class IlvSHPReader

java.lang.Object
  extended by ilog.views.maps.format.shapefile.IlvSHPReader
All Implemented Interfaces:
IlvLookAheadFeatureIterator, IlvMapFeatureIterator

public class IlvSHPReader
extends Object
implements IlvLookAheadFeatureIterator

This class can be used to read Shapefiles with the .shp extension. It implements the IlvMapFeatureIterator class. This class does not read the Shapefile attributes that are stored in .dbf files. To read .shp and .dbf files together, you must use an IlvShapeFileReader.

This implBeforeementation reads only 2D geometries and stores the additional values of 3D geometries and of geometries associated with values as attributes.

Since:
ILOG JViews 3.0
See Also:
IlvShapeFileReader

Field Summary
static int MULTIPATCH
          The Multiple Surface Patch shape type
static int MULTIPOINT
          The MULTIPOINT shape type
static int MULTIPOINTM
          The Measure MULTIPOINT shape type
static int MULTIPOINTZ
          The 3D MULTIPOINT shape type
static int NULL
          The NULL shape type
static int POINT
          The POINT shape type
static int POINTM
          The Measure POINT shape type
static int POINTZ
          The 3D POINT shape type
static int POLYGON
          The POLYGON shape type
static int POLYGONM
          The Measure POLYGON shape type
static int POLYGONZ
          The 3D POLYGON shape type
static int POLYLINE
          The POLYLINE shape type
static int POLYLINEM
          The Measure POLYLINE shape type
static int POLYLINEZ
          The 3D POLYLINE shape type
 
Constructor Summary
IlvSHPReader(DataInput dataInput)
          Initializes an IlvSHPReader for the specified DataInput.
IlvSHPReader(String fileName)
          Initializes an IlvSHPReader for the specified file.
IlvSHPReader(String shpFile, String shxFile)
          Initializes an IlvSHPReader to read data from the specified file, with the specified index file.
IlvSHPReader(URL url)
          Initializes an IlvSHPReader for the specified URL.
 
Method Summary
 void dispose()
          Releases the resources allocated to the reader.
 void finalize()
          Is called by the Java Garbage Collector to release the resources allocated to the reader.
 IlvAttributeInfoProperty getAttributeInfo()
          Returns the description of the attributes that are generated by the shape reader.
 IlvCoordinateSystem getCoordinateSystem()
          Returns the spatial reference system that describes the coordinate system of geometric coordinates of the map features.
 IlvFeatureRenderer getDefaultFeatureRenderer()
          Returns the default renderer used to display the map features returned by the reader.
 IlvMapFeature getFeatureAt(int index)
          Returns the feature located at the specified index.
protected  IlvMapInput getInput()
          Returns the IlvMapInput instance used to read the Shapefile.
 IlvCoordinate getLowerRightCorner()
          Returns the lower-right corner of the bounding box that delimits the objects read from the file.
 double getMaxMeasure()
          Returns the maximum value of the measurements.
 double getMinMeasure()
          Returns the minimum value of the measurements.
 IlvMapFeature getNextFeature()
          Reads the next record from the file.
 Object getNextFeatureId()
          Returns the ID of the next feature.
 int getNextFeatureIndex()
          Returns the index of the next feature that is read.
 int getShapeType()
          Returns the shape type of the objects contained in the file.
 String getShapeTypeDescription()
          Returns a string describing the shape type contained in the file.
 IlvCoordinate getUpperLeftCorner()
          Returns the upper-left corner of the bounding box that delimits the objects read from the file.
 double getZMax()
          Returns the maximum elevation.
 double getZMin()
          Returns the minimum elevation.
 boolean isGeoreferenced()
          This function of the IlvMapFeatureIterator interface returns true if a coordinate system has been set and false otherwise .
protected  IlvMapFeature readMultiPointMShape()
          Reads a MULTIPOINTM shape.
protected  IlvMapFeature readMultiPointShape()
          Reads a MULTIPOINT shape.
protected  IlvMapFeature readMultiPointZShape()
          Reads a MULTIPOINTZ shape.
protected  IlvMapFeature readNullShape()
          Returns a shape where geometry and attributes of the map feature returned are set to null.
protected  IlvMapFeature readPointMShape()
          Reads a POINTM shape.
protected  IlvMapFeature readPointShape()
          Reads a POINT shape.
protected  IlvMapFeature readPointZShape()
          Reads a POINTZ shape.
protected  IlvMapFeature readPolygonMShape()
          Reads a POLYGONM shape.
protected  IlvMapFeature readPolygonShape()
          Reads a POLYGON from the Shapefile, that is, a IlvMapMultiArea.
protected  IlvMapFeature readPolygonZShape()
          Reads a POLYGONZ shape.
protected  IlvMapFeature readPolylineMShape()
          Reads a POLYLINEM shape.
protected  IlvMapFeature readPolylineShape()
          Reads a POLYLINE from the Shapefile, that is, a IlvMapMultiCurve.
protected  IlvMapFeature readPolylineZShape()
          Reads a POLYLINEZ shape.
 void setCoordinateSystem(IlvCoordinateSystem cs)
          Sets the coordinate system for this reader.
 boolean skipNextFeature()
          Skips the next feature available from this feature iterator.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NULL

public static final int NULL
The NULL shape type

See Also:
Constant Field Values

POINT

public static final int POINT
The POINT shape type

See Also:
Constant Field Values

POLYLINE

public static final int POLYLINE
The POLYLINE shape type

See Also:
Constant Field Values

POLYGON

public static final int POLYGON
The POLYGON shape type

See Also:
Constant Field Values

MULTIPOINT

public static final int MULTIPOINT
The MULTIPOINT shape type

See Also:
Constant Field Values

POINTZ

public static final int POINTZ
The 3D POINT shape type

See Also:
Constant Field Values

POLYLINEZ

public static final int POLYLINEZ
The 3D POLYLINE shape type

See Also:
Constant Field Values

POLYGONZ

public static final int POLYGONZ
The 3D POLYGON shape type

See Also:
Constant Field Values

MULTIPOINTZ

public static final int MULTIPOINTZ
The 3D MULTIPOINT shape type

See Also:
Constant Field Values

POINTM

public static final int POINTM
The Measure POINT shape type

See Also:
Constant Field Values

POLYLINEM

public static final int POLYLINEM
The Measure POLYLINE shape type

See Also:
Constant Field Values

POLYGONM

public static final int POLYGONM
The Measure POLYGON shape type

See Also:
Constant Field Values

MULTIPOINTM

public static final int MULTIPOINTM
The Measure MULTIPOINT shape type

See Also:
Constant Field Values

MULTIPATCH

public static final int MULTIPATCH
The Multiple Surface Patch shape type

See Also:
Constant Field Values
Constructor Detail

IlvSHPReader

public IlvSHPReader(String fileName)
             throws IOException,
                    IlvMapFormatException
Initializes an IlvSHPReader for the specified file.

Parameters:
fileName - The name of the Shapefile (with the .shp extension).
Throws:
IOException - If an error occurs while opening the file.
IlvMapFormatException - If the file contains a format error.

IlvSHPReader

public IlvSHPReader(String shpFile,
                    String shxFile)
             throws IOException,
                    IlvMapFormatException
Initializes an IlvSHPReader to read data from the specified file, with the specified index file.

Parameters:
shpFile - The name of the Shapefile (with the .shp extension).
shxFile - The name of the Shapefile index (with the .shx extension).
Throws:
IOException - If an error occurs while opening the file.
IlvMapFormatException - If the file contains a format error.
Since:
JViews 4.0

IlvSHPReader

public IlvSHPReader(URL url)
             throws IOException,
                    IlvMapFormatException
Initializes an IlvSHPReader for the specified URL.

Parameters:
url - The URL of the Shapefile (with the .shp extension).
Throws:
IOException - If an error occurs while opening the file.
IlvMapFormatException - If the file contains a format error.

IlvSHPReader

public IlvSHPReader(DataInput dataInput)
             throws IOException,
                    IlvMapFormatException
Initializes an IlvSHPReader for the specified DataInput.

Parameters:
dataInput - The data input containing the shape data.
Throws:
IOException - If an error occurs while reading the input stream.
IlvMapFormatException - If the file contains a format error.
Method Detail

getAttributeInfo

public IlvAttributeInfoProperty getAttributeInfo()
Returns the description of the attributes that are generated by the shape reader.
This implementation returns additional attributes to store the measurements of POINTM, POLYLINEM, POLYGONM and MULTIPOINTM, and to store the elevations and measurements of POINTZ, POLYLINEZ, POLYGONZ and MULTIPOINTZ. If the shape type does not require additional attributes, this method returns a null value.


dispose

public void dispose()
Releases the resources allocated to the reader. Once this method has been called, no other access to the reader should be performed.

Specified by:
dispose in interface IlvMapFeatureIterator

finalize

public void finalize()
Is called by the Java Garbage Collector to release the resources allocated to the reader. If the dispose method was not called, it releases the resources used by the reader.

Overrides:
finalize in class Object
See Also:
dispose()

getShapeType

public final int getShapeType()
Returns the shape type of the objects contained in the file.


getShapeTypeDescription

public String getShapeTypeDescription()
Returns a string describing the shape type contained in the file.


getUpperLeftCorner

public IlvCoordinate getUpperLeftCorner()
Returns the upper-left corner of the bounding box that delimits the objects read from the file.

Specified by:
getUpperLeftCorner in interface IlvMapFeatureIterator

getLowerRightCorner

public IlvCoordinate getLowerRightCorner()
Returns the lower-right corner of the bounding box that delimits the objects read from the file.

Specified by:
getLowerRightCorner in interface IlvMapFeatureIterator

getZMin

public double getZMin()
Returns the minimum elevation. This data is valid only if the shape type is a 3D object.


getZMax

public double getZMax()
Returns the maximum elevation. This data is valid only if the shape type is a 3D object.


getMinMeasure

public double getMinMeasure()
Returns the minimum value of the measurements. This data is valid only if the shape type is a measurement object.


getMaxMeasure

public double getMaxMeasure()
Returns the maximum value of the measurements. This data is valid only of the shape type is a measurement object.


getFeatureAt

public IlvMapFeature getFeatureAt(int index)
                           throws IOException
Returns the feature located at the specified index. Note that this only works if this IlvSHPReader has been constructed with a .shx file.

Parameters:
index - The location of the feature.
Returns:
The IlvMapFeature read, or null if an error occurs.
Throws:
IOException - If an error occurs.
UnsupportedOperationException - If this operation is not supported on this IlvSHPReader.
IllegalArgumentException - If there is no feature at the specified index.
Since:
JViews 4.0

getNextFeature

public IlvMapFeature getNextFeature()
                             throws IOException,
                                    IlvMapFormatException
Reads the next record from the file. The geometry and attributes are set in the feature provided as parameter.

Specified by:
getNextFeature in interface IlvMapFeatureIterator
Throws:
IOException - If an error occurs while reading the file.
IlvMapFormatException - If the file contains a format error.

skipNextFeature

public boolean skipNextFeature()
                        throws IOException
Skips the next feature available from this feature iterator.

Specified by:
skipNextFeature in interface IlvLookAheadFeatureIterator
Returns:
true if the skipped feature is not the last feature. In JViews 4.0, the return type of this method was void.
Throws:
IOException - If an error occurs while reading the file.
IlvMapFormatException - If the file contains a format error.
EOFException - If there are no more features to skip.
Since:
JViews 5.0

getNextFeatureIndex

public int getNextFeatureIndex()
Returns the index of the next feature that is read. Note: This will return the index of the next feature, even if the end of file is reached.

Since:
JViews 4.0

getNextFeatureId

public Object getNextFeatureId()
                        throws IOException
Returns the ID of the next feature. For Shapefiles, IDs are created as java.lang.Integer.

Specified by:
getNextFeatureId in interface IlvLookAheadFeatureIterator
Returns:
An ID created using new java.lang.Integer(getNextFeatureIndex()).
Throws:
IOException
Since:
JViews 4.0

readNullShape

protected IlvMapFeature readNullShape()
                               throws IOException
Returns a shape where geometry and attributes of the map feature returned are set to null.

Returns:
A null shape.
Throws:
IOException - If an error occurs while reading the data.
Since:
JViews 6.0

readPointShape

protected IlvMapFeature readPointShape()
                                throws IOException
Reads a POINT shape.

Throws:
IOException - If an error occurs while reading the data.

readPointMShape

protected IlvMapFeature readPointMShape()
                                 throws IOException
Reads a POINTM shape. Measurements read from the file are set as attributes.

Returns:
The geometry of this POINTM.
Throws:
IOException - If an error occurs while reading the data.

readPointZShape

protected IlvMapFeature readPointZShape()
                                 throws IOException
Reads a POINTZ shape. The Z coordinate is set as an attributes value at index 0. Measurements are set as attribute value at index 1.

Throws:
IException - If an error occurs while reading the data.
IOException

readMultiPointShape

protected IlvMapFeature readMultiPointShape()
                                     throws IOException
Reads a MULTIPOINT shape.

Throws:
IOException - If an error occurs while reading the data.

readMultiPointMShape

protected IlvMapFeature readMultiPointMShape()
                                      throws IOException
Reads a MULTIPOINTM shape. The measurements read from the file are set to attributes[0].

Throws:
IOException - If an error occurs while reading the data.

readMultiPointZShape

protected IlvMapFeature readMultiPointZShape()
                                      throws IOException
Reads a MULTIPOINTZ shape. The Z coordinate is set to attributes[0]. The measurements are set to attributes[1].

Throws:
IOException - If an error occurs while reading the file.

readPolylineShape

protected IlvMapFeature readPolylineShape()
                                   throws IOException
Reads a POLYLINE from the Shapefile, that is, a IlvMapMultiCurve.

Throws:
IOException - If an error occurs while reading the data.

readPolylineMShape

protected IlvMapFeature readPolylineMShape()
                                    throws IOException
Reads a POLYLINEM shape. The measurements read from the file are set to attributes[0].

Throws:
IOException - If an error occurs while reading the data.

readPolylineZShape

protected IlvMapFeature readPolylineZShape()
                                    throws IOException
Reads a POLYLINEZ shape. The Z coordinate is set to attributes[0]. The measurements are set to attributes[1].

Throws:
IOException - If an error occurs while reading the data.

readPolygonShape

protected IlvMapFeature readPolygonShape()
                                  throws IOException
Reads a POLYGON from the Shapefile, that is, a IlvMapMultiArea.

Throws:
IOException - If an error occurs while reading the data.

readPolygonMShape

protected IlvMapFeature readPolygonMShape()
                                   throws IOException
Reads a POLYGONM shape. The measurements read from the file are set to attributes[0].

Throws:
IOException - If an error occurs while reading the data.

readPolygonZShape

protected IlvMapFeature readPolygonZShape()
                                   throws IOException
Reads a POLYGONZ shape. The Z coordinate is set to attributes[0]. The measurements are set to attributes[1].

Throws:
IOException - If an error occurs while reading the data.

getInput

protected IlvMapInput getInput()
Returns the IlvMapInput instance used to read the Shapefile.


getCoordinateSystem

public IlvCoordinateSystem getCoordinateSystem()
Returns the spatial reference system that describes the coordinate system of geometric coordinates of the map features.

Specified by:
getCoordinateSystem in interface IlvMapFeatureIterator
Returns:
The coordinate system that has been set by the setCoordinateSystem method.
Since:
JViews 5.0

setCoordinateSystem

public void setCoordinateSystem(IlvCoordinateSystem cs)
Sets the coordinate system for this reader.

Since:
JViews 5.0

isGeoreferenced

public boolean isGeoreferenced()
This function of the IlvMapFeatureIterator interface returns true if a coordinate system has been set and false otherwise .

Specified by:
isGeoreferenced in interface IlvMapFeatureIterator

getDefaultFeatureRenderer

public IlvFeatureRenderer getDefaultFeatureRenderer()
Returns the default renderer used to display the map features returned by the reader.

Specified by:
getDefaultFeatureRenderer in interface IlvMapFeatureIterator


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.