Classes for Reading the Shapefile Format
The following classes are used to read the Shapefile format:
This class only reads .dbf files.
IlvShapeFileIndex IlvShapeSpatialIndex IlvShapeFileReader
This reader reads the
.shp file storing geometries and the
.dbf file storing attributes simultaneously, and merges the information into a single
IlvMapFeature object. The reader can also read an optional .
shx file to provide random access to geometries.
It can be instantiated in one of the following ways:
By specifying the name of the
.dbf,
.shp, and the optional .
shx files.
This is useful, for example, when using a derived
IlvShapeSHPReader object.
In both cases, when the reader is created with the ability to read the .
shx file, it provides random access to geometries through the
getFeatureAt method.
This reader uses three specialized readers: IlvShapeSHPReader, IlvShapeDBFReader, and IlvShapeFileIndex. Its getNextFeature method merges the information generated by these specialized readers into a single map feature.
For an example, see the Shapefile sample at the following location:
<installdir>/samples/maps/shapefile
IlvShapeSHPReader
This reader only reads .shp files, but if it is created with both .shp and .shx files, this reader allows random acces to geometries.
The geometries stored in Shapefiles are not necessarily 2D 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.
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.
The following are the shape types that are associated with measurements and elevations:
POINTZ POLYLINEZ POLYGONZ MULTIPOINTZ Since Rogue Wave Views Maps does not have a predefined geometry to represent shape objects of type
MULTIPATCH, which are essentially used for 3D 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.
IlvShapeDBFReader
This reader is used exclusively for reading a file of the .dbf format. It can be used to iterate over a file as follows:
IlvShapeDBFReader* reader = new IlvShapeDBFReader("myFile.dbf"); IlvFeatureAttributeProperty* attributes = reader->getNextRecord(); while (attributes) { // process attributes ... attributes = reader->getNextRecord(...); } |
As the .dbf file associates attributes with the objects in the .shp in a sequential way, you can access map feature attributes directly by specifying their record number:
reader->readRecord(index, error);
Version 5.5.1
Copyright © 2012, Rogue Wave Software, Inc. All Rights Reserved.