The ilog.views.maps.format.shapefile package
includes the following classes:
-
This class implements the IlvMapFeatureIterator interface and allows you to read
.shp
,.dbf
and.shx
files. Since Shapefiles provide no information on the projection system used, this reader is not georeferenced. This reader uses the two specialized readers described below. Its getNextFeaturegetNext
method merges the information generated by these specialized readers into a single map feature. -
This class implements the IlvMapFeatureIterator interface. This reader only reads
.shp
files. - IlvDBFReader: reads
.dbf
files. - IlvShapeFileIndex: reads
.shx
files. - IlvShapeSpatialIndex: reads maps spatial index
.idx
files.
The IlvSHPReader class
The geometries stored in Shapefiles are
not necessarily 2-D objects. Each point that makes up a shape
object can be associated with measurements, or with measurements
and an elevation.
Measurements are stored in an attribute of type IlvAttributeArray, which itself is stored
in the map feature attribute of index 0.
The following are the shape types that are
associated with measurements:
POINTZ
POLYLINEZ
POLYGONZ
MULTIPOINTZ
POINTM
POLYLINEM
POLYGONM
MULTIPOINTM
Elevations are stored in an attribute of type IlvAttributeArray, which itself is stored
in the map feature attribute of index 1.
The following are the shape types that are
associated with measurements and elevations:
POINTZ
POLYLINEZ
POLYGONZ
MULTIPOINTZ
Since the JViews Maps
package does not have a predefined geometry to represent shape
objects of type
MULTIPATCH
, which are essentially used for 3-D rendering, these are
ignored. It is possible, however, to modify this behavior by
subtyping the class
IlvShapeSHPReader
. Since shape objects are read in protected methods, modifying
the reader to include new geometries requires minimal effort.
The IlvDBFReader class
This reader is used exclusively for reading a file of the
.dbf
format. It can be used to iterate over a file as follows:
try { IlvDBFReader reader = new IlvDBFReader("myFile.dbf"); IlvFeatureAttributeProperty attributes = reader.getNextRecord(); while (attributes != null) { // Process attributes. ... attributes = reader.getNextRecord(); } } catch (Exception e) { e.printStackTrace(); }
If the reader has been created from a file
and not from a URL, you can access map feature attributes
directly by specifying their record number:
reader.readRecord(index);
The IlvShapeFileReader class
This reader reads the
.shp
file storing geometries and the
.dbf
file storing attributes simultaneously, and merges the
information into a single IlvMapFeature object.
It can be instantiated in one of three
ways:
- By specifying the name of the
.dbf
and.shp
files. - By specifying the URL of these two files.
- By specifying an
IlvDBFReader
andIlvSHPReader
object directly.This is useful, for example, when using a derivedIlvSHPReader
object.