ilog.views.maps.format.shapefile
Class IlvShapeFileIndex

java.lang.Object
  extended by ilog.views.maps.format.shapefile.IlvShapeFileIndex

public class IlvShapeFileIndex
extends Object

This class allows applications to take advantage of ESRI Shapefile index files (.shx files).
Index files allow direct access to geometries in the main Shapefile (.shp file). Index files map record indexes to file offsets.
Index files are typically used to load geometries on demand.

Since:
JViews 4.0

Constructor Summary
IlvShapeFileIndex(DataInput dataInput)
          Initializes an IlvShapeFileIndex from the specified DataInput.
IlvShapeFileIndex(String filename)
          Initializes an IlvShapeFileIndex from the .shx file specified.
IlvShapeFileIndex(URL url)
          Initializes an IlvShapeFileIndex from the specified URL.
 
Method Summary
 void dispose()
          Disposes of this object.
 void finalize()
          Called by the Java Garbage Collector to release the resources allocated to the reader.
 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.
 int getRecordCount()
          Returns the number of objects in this index.
 int getRecordLength(int index)
          Returns the record length (in bytes) of the object at the specified index.
 long getRecordOffset(int index)
          Returns the file offset of the object at the specified index.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IlvShapeFileIndex

public IlvShapeFileIndex(String filename)
                  throws IOException,
                         IlvMapFormatException
Initializes an IlvShapeFileIndex from the .shx file specified.
This constructor initializes the index with a random access file, allowing random record access.

Parameters:
filename - The name of the .shx file.
Throws:
IOException - if an error occurs while opening the file.
IlvMapFormatException - if the file contains a format error.

IlvShapeFileIndex

public IlvShapeFileIndex(DataInput dataInput)
                  throws IOException,
                         IlvMapFormatException
Initializes an IlvShapeFileIndex from the specified DataInput.
When created this way, this index can only retrieve record offsets in an incremental way.

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.

IlvShapeFileIndex

public IlvShapeFileIndex(URL url)
                  throws IOException,
                         IlvMapFormatException
Initializes an IlvShapeFileIndex from the specified URL.

Parameters:
url - The data url pointing to the shape data.
Throws:
IlvMapFormatException - if the file contains a format error.
IOException
Since:
JViews 7.5
Method Detail

dispose

public void dispose()
Disposes of this object. After this method is called, this object should not be accessed again.


finalize

public void finalize()
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()

getRecordOffset

public long getRecordOffset(int index)
                     throws IOException,
                            UnsupportedOperationException
Returns the file offset of the object at the specified index. Index of objects are in the range [0,getRecordCount()].
File offset is expressed in bytes, from the start of the files. As there is a 100 bytes header in the .shp file, the index of the first object is at offset 100.

Parameters:
index - The index of the object.
Throws:
IOException - if an error occurs when reading from the file.
UnsupportedOperationException - if index leads to a negative skip in the input file and the input file is not a random access file.

getRecordLength

public int getRecordLength(int index)
                    throws IOException,
                           UnsupportedOperationException
Returns the record length (in bytes) of the object at the specified index. Index of objects are in the range [0,getRecordCount()].
Note: The length is specified as the content length of the record. It does not include the 4 byte header.

Parameters:
index - The index of the object.
Throws:
IOException - if an error occurs when reading from the file.
UnsupportedOperationException - if index leads to a negative skip in the input file and the input file is not a random access file.

getUpperLeftCorner

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


getLowerRightCorner

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


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.


getRecordCount

public int getRecordCount()
Returns the number of objects in this index.



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