Views
Maps Package API Reference Guide
Product Documentation:
Views Documentation Home
List of all members | Public Member Functions | Protected Member Functions
IlvShapeSHPReader Class Reference

This class reads geometries from .shp files. More...

#include <ilviews/maps/format/shapefile/shpreader.h>

Inheritance diagram for IlvShapeSHPReader:
IlvLookAheadFeatureIterator IlvMapFeatureIterator

Public Member Functions

 IlvShapeSHPReader (const char *fileName, const char *shxName=0)
 Initializes a new IlvShapeSHPReader to read from a Shapefile file. More...
 
 IlvShapeSHPReader (std::istream &shpStream, std::istream &shxStream)
 Initializes a new IlvShapeSHPReader to read from the specified input streams. More...
 
 IlvShapeSHPReader (std::istream &stream)
 Initializes a new IlvShapeSHPReader to read from an input stream. More...
 
IlvFeatureRenderergetDefaultFeatureRenderer (IlvDisplay *display)
 Returns the default renderer for this feature iterator. More...
 
virtual const IlvMapFeaturegetFeatureAt (IlInt index, IlvMapsError &status)
 Returns the feature located at the specified index. More...
 
const IlvFeatureAttributeInfogetFeatureAttributeInfo (IlvMapsError &status) const
 Returns the description of the attributes that are generated by the shape reader. More...
 
IlvMapsError getInitStatus () const
 Checks the initialization status of this reader. More...
 
IlBoolean getLowerRightCorner (IlvCoordinate &result) const
 Returns the lower right corner of the rectangle containing all the map features of this iterator. More...
 
IlvMapInputgetMapInput ()
 Returns the map input of this reader. More...
 
const IlvMapFeaturegetNextFeature (IlvMapsError &status)
 Returns the next available feature. More...
 
virtual IlvMapFeatureIdgetNextFeatureId (IlvMapsError &status)
 Returns the ID of the next feature. More...
 
virtual IlInt getNextFeatureIndex ()
 Returns the index of the next feature that is read. More...
 
const IlvProjectiongetProjection () const
 Returns the projection of geometries of this feature iterator. More...
 
IlvShapeFileIndexgetShapeFileIndex () const
 Returns the Shapefile index reader. More...
 
IlvShapeType getShapeType () const
 Returns the shape type of the objects contained in the file. More...
 
IlBoolean getUpperLeftCorner (IlvCoordinate &result) const
 Returns the upper left corner of the rectangle containing all the map features of this iterator. More...
 
virtual void setNextFeatureIndex (IlInt index)
 Sets the index of the next feature that is read. More...
 
void setSourceProjection (IlvProjection *projection)
 Sets the projection of geometries generated by this feature iterator. More...
 
virtual IlBoolean skipNextFeature (IlvMapsError &status)
 Skips the next feature available from this feature iterator. More...
 
- Public Member Functions inherited from IlvLookAheadFeatureIterator
virtual ~IlvLookAheadFeatureIterator ()
 Destructor.
 
- Public Member Functions inherited from IlvMapFeatureIterator
virtual IlvClassInfogetClassInfo () const =0
 Returns the class information for this feature iterator. More...
 

Protected Member Functions

IlvMapInputgetInput ()
 Returns the map input of this reader. More...
 
virtual IlvMapFeaturereadMultiPointMShape (IlvMapsError &status)
 Reads a MULTIPOINTM from the Shapefile. More...
 
virtual IlvMapFeaturereadMultiPointShape (IlvMapsError &status)
 Reads a MULTIPOINT from the Shapefile. More...
 
virtual IlvMapFeaturereadMultiPointZShape (IlvMapsError &status)
 Reads a MULTIPOINTZ from the Shapefile. More...
 
virtual IlvMapFeaturereadPointMShape (IlvMapsError &status)
 Reads a POINTM shape. More...
 
virtual IlvMapFeaturereadPointShape (IlvMapsError &status)
 Reads a POINT shape. More...
 
virtual IlvMapFeaturereadPointZShape (IlvMapsError &status)
 Reads a POINTZ shape. More...
 
virtual IlvMapFeaturereadPolygonMShape (IlvMapsError &status)
 Reads a POLYGONM from the Shapefile. More...
 
virtual IlvMapFeaturereadPolygonShape (IlvMapsError &status)
 Reads a POLYGON from the Shapefile. More...
 
virtual IlvMapFeaturereadPolygonZShape (IlvMapsError &status)
 Reads a POLYGONZ from the Shapefile. More...
 
virtual IlvMapFeaturereadPolylineMShape (IlvMapsError &status)
 Reads a POLYLINEM from the Shapefile. More...
 
virtual IlvMapFeaturereadPolylineShape (IlvMapsError &status)
 Reads a POLYLINE from the Shapefile. More...
 
virtual IlvMapFeaturereadPolylineZShape (IlvMapsError &status)
 Reads a POLYLINEZ from the Shapefile. More...
 
virtual void setInitStatus (IlvMapsError status)
 Sets the initialization status of this reader. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from IlvMapFeatureIterator
static IlvClassInfoClassInfo ()
 Returns the class information of the class. More...
 
static IlvClassInfo ** ClassInfoRef ()
 Returns the address of the class information of the class. More...
 

Detailed Description

This class reads geometries from .shp files.

Library: ilvmaps

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 implementation reads only 2D geometries and stores the additonnal values of 3D geometries with values as attribute.

See also
IlvShapeFileReader, IlvShapeDBFReader.

Constructor & Destructor Documentation

◆ IlvShapeSHPReader() [1/3]

IlvShapeSHPReader::IlvShapeSHPReader ( const char *  fileName,
const char *  shxName = 0 
)

Initializes a new IlvShapeSHPReader to read from a Shapefile file.

You can also specify an index (.shx) file name if you want to perform random access on geometries through the getFeatureAt() method.

Parameters
fileNameThe name of the .shp input file.
shxNameThe name of an .shx input file.

◆ IlvShapeSHPReader() [2/3]

IlvShapeSHPReader::IlvShapeSHPReader ( std::istream &  stream)

Initializes a new IlvShapeSHPReader to read from an input stream.

Warning
On PC, the stream must be opened on an in binary mode.
Parameters
streamThe input stream.

◆ IlvShapeSHPReader() [3/3]

IlvShapeSHPReader::IlvShapeSHPReader ( std::istream &  shpStream,
std::istream &  shxStream 
)

Initializes a new IlvShapeSHPReader to read from the specified input streams.

With this constructor, in addition to the stream opened on a Shapefile file, you can specify a stream opened on an index file (.shx) in order to perform random access on geometries through the getFeatureAt() method.

Warning
On PCs, the streams must be opened in binary mode.
Parameters
shpStreamThe input stream opened on an .shp file.
shxStreamThe input stream opened on an .shx file.

Member Function Documentation

◆ getDefaultFeatureRenderer()

IlvFeatureRenderer* IlvShapeSHPReader::getDefaultFeatureRenderer ( IlvDisplay display)
virtual

Returns the default renderer for this feature iterator.

Returns a renderer that can be used to translate the map features returned by this iterator into graphic objects. Feature iterators that store some rendering information in the attributes of the map features, such as color, text font, line thickness and so on, can return a specific renderer which is able to take these attributes into account during the rendering process.

Parameters
displayThe display instance the graphic objects are attached to.
Returns
A renderer to be used to translate the map features to graphic objects.

Implements IlvMapFeatureIterator.

◆ getFeatureAt()

virtual const IlvMapFeature* IlvShapeSHPReader::getFeatureAt ( IlInt  index,
IlvMapsError &  status 
)
virtual

Returns the feature located at the specified index.

Note
This only works if this IlvShapeSHPReader has been constructed with a .shx file.
Parameters
indexThe location of the feature.
statusSet to the status of this reader on return.
Returns
The IlvMapFeature that was read or 0 if an error occurs.

◆ getFeatureAttributeInfo()

const IlvFeatureAttributeInfo* IlvShapeSHPReader::getFeatureAttributeInfo ( IlvMapsError &  status) const

Returns the description of the attributes that are generated by the shape reader.

Parameters
statusSet to the status of this reader on return.
Returns
The IlvFeatureAttributeInfo that describes 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 0.

◆ getInitStatus()

IlvMapsError IlvShapeSHPReader::getInitStatus ( ) const
virtual

Checks the initialization status of this reader.

Returns
IlvMaps::NoError() if the initialization of this reader is successful, or an error if an error occured during the initalization.

Implements IlvMapFeatureIterator.

◆ getInput()

IlvMapInput& IlvShapeSHPReader::getInput ( )
protected

Returns the map input of this reader.

Returns
The map input of this reader.

◆ getLowerRightCorner()

IlBoolean IlvShapeSHPReader::getLowerRightCorner ( IlvCoordinate result) const
virtual

Returns the lower right corner of the rectangle containing all the map features of this iterator.

Parameters
resultSet to the result on return.
Returns
IlFalse if lower right is unknown.

Implements IlvMapFeatureIterator.

◆ getMapInput()

IlvMapInput* IlvShapeSHPReader::getMapInput ( )

Returns the map input of this reader.

Returns
The map input of this reader.

◆ getNextFeature()

const IlvMapFeature* IlvShapeSHPReader::getNextFeature ( IlvMapsError &  status)
virtual

Returns the next available feature.

Parameters
statusAn IlvMapsError to store the read status.
Returns
The next map feature available from this feature iterator, or 0 if the iteration is finished. The returned feature is owned by the iterator, and therefore must not be deleted by the application.

Implements IlvMapFeatureIterator.

◆ getNextFeatureId()

virtual IlvMapFeatureId* IlvShapeSHPReader::getNextFeatureId ( IlvMapsError &  status)
virtual

Returns the ID of the next feature.

For Shapefiles, IDs are created as IlvMapFeatureIntegerId.

Returns
An ID created using new IlvMapFeatureIntegerId(getNextFeatureIndex()).

Implements IlvLookAheadFeatureIterator.

◆ getNextFeatureIndex()

virtual IlInt IlvShapeSHPReader::getNextFeatureIndex ( )
virtual

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.
Returns
The index of the next feature that is read.

◆ getProjection()

const IlvProjection* IlvShapeSHPReader::getProjection ( ) const
virtual

Returns the projection of geometries of this feature iterator.

Returns the projection in which the geometric coordinates of the map features are expressed or 0 if the feature iterator returns ungeoreferenced map features.

Returns
The projection in which the geometric coordinates are specified.

Implements IlvMapFeatureIterator.

◆ getShapeFileIndex()

IlvShapeFileIndex* IlvShapeSHPReader::getShapeFileIndex ( ) const

Returns the Shapefile index reader.

Returns
The Shapefile index if this reader was constructed with a valid .shx file name. If not, this method returns 0.

◆ getShapeType()

IlvShapeType IlvShapeSHPReader::getShapeType ( ) const

Returns the shape type of the objects contained in the file.

Returns
The type of objects.

◆ getUpperLeftCorner()

IlBoolean IlvShapeSHPReader::getUpperLeftCorner ( IlvCoordinate result) const
virtual

Returns the upper left corner of the rectangle containing all the map features of this iterator.

Parameters
resultSet to the result on return.
Returns
IlFalse if upper left is unknown.

Implements IlvMapFeatureIterator.

◆ readMultiPointMShape()

virtual IlvMapFeature* IlvShapeSHPReader::readMultiPointMShape ( IlvMapsError &  status)
protectedvirtual

Reads a MULTIPOINTM from the Shapefile.

The read measures are set as attributes.

Parameters
statusSet to the status of this reader on return.
Returns
The feature that is read.

◆ readMultiPointShape()

virtual IlvMapFeature* IlvShapeSHPReader::readMultiPointShape ( IlvMapsError &  status)
protectedvirtual

Reads a MULTIPOINT from the Shapefile.

Parameters
statusSet to the status of this reader on return.
Returns
The feature that is read.

◆ readMultiPointZShape()

virtual IlvMapFeature* IlvShapeSHPReader::readMultiPointZShape ( IlvMapsError &  status)
protectedvirtual

Reads a MULTIPOINTZ from the Shapefile.

The read measures and altitudes are set as attributes.

Parameters
statusSet to the status of this reader on return.
Returns
The feature that is read.

◆ readPointMShape()

virtual IlvMapFeature* IlvShapeSHPReader::readPointMShape ( IlvMapsError &  status)
protectedvirtual

Reads a POINTM shape.

The read measures are set as attributes.

Parameters
statusSet to the status of this reader on return.
Returns
The feature that is read.

◆ readPointShape()

virtual IlvMapFeature* IlvShapeSHPReader::readPointShape ( IlvMapsError &  status)
protectedvirtual

Reads a POINT shape.

Parameters
statusSet to the status of this reader on return.
Returns
The feature that is read.

◆ readPointZShape()

virtual IlvMapFeature* IlvShapeSHPReader::readPointZShape ( IlvMapsError &  status)
protectedvirtual

Reads a POINTZ shape.

The read measures and altitudes are set as attributes.

Parameters
statusSet to the status of this reader on return.
Returns
The feature that is read.

◆ readPolygonMShape()

virtual IlvMapFeature* IlvShapeSHPReader::readPolygonMShape ( IlvMapsError &  status)
protectedvirtual

Reads a POLYGONM from the Shapefile.

The read measures are set as attributes.

Parameters
statusSet to the status of this reader on return.
Returns
The feature that is read.

◆ readPolygonShape()

virtual IlvMapFeature* IlvShapeSHPReader::readPolygonShape ( IlvMapsError &  status)
protectedvirtual

Reads a POLYGON from the Shapefile.

Parameters
statusSet to the status of this reader on return.
Returns
The feature that is read.

◆ readPolygonZShape()

virtual IlvMapFeature* IlvShapeSHPReader::readPolygonZShape ( IlvMapsError &  status)
protectedvirtual

Reads a POLYGONZ from the Shapefile.

The read measures and altitudes are set as attributes.

Parameters
statusSet to the status of this reader on return.
Returns
The feature that is read.

◆ readPolylineMShape()

virtual IlvMapFeature* IlvShapeSHPReader::readPolylineMShape ( IlvMapsError &  status)
protectedvirtual

Reads a POLYLINEM from the Shapefile.

The read measures are set as attributes.

Parameters
statusSet to the status of this reader on return.
Returns
The feature that is read.

◆ readPolylineShape()

virtual IlvMapFeature* IlvShapeSHPReader::readPolylineShape ( IlvMapsError &  status)
protectedvirtual

Reads a POLYLINE from the Shapefile.

Parameters
statusSet to the status of this reader on return.
Returns
The feature that is read.

◆ readPolylineZShape()

virtual IlvMapFeature* IlvShapeSHPReader::readPolylineZShape ( IlvMapsError &  status)
protectedvirtual

Reads a POLYLINEZ from the Shapefile.

The read measures and altitudes are set as attributes.

Parameters
statusSet to the status of this reader on return.
Returns
The feature that is read.

◆ setInitStatus()

virtual void IlvShapeSHPReader::setInitStatus ( IlvMapsError  status)
protectedvirtual

Sets the initialization status of this reader.

Parameters
statusThe new initialization status.

◆ setNextFeatureIndex()

virtual void IlvShapeSHPReader::setNextFeatureIndex ( IlInt  index)
virtual

Sets the index of the next feature that is read.

Parameters
indexThe index of the next feature that is read.

◆ setSourceProjection()

void IlvShapeSHPReader::setSourceProjection ( IlvProjection projection)
virtual

Sets the projection of geometries generated by this feature iterator.

This method is to be used when feature source is not georeferenced.

Parameters
projectionThe projection to be set. This projection becomes shared and is locked by this feature iterator.

Reimplemented from IlvMapFeatureIterator.

◆ skipNextFeature()

virtual IlBoolean IlvShapeSHPReader::skipNextFeature ( IlvMapsError &  status)
virtual

Skips the next feature available from this feature iterator.

Parameters
statusSet to the status of this reader on return.
Returns
IlTrue if the feature is skipped properly, and IlFalse if an error occurs.

Implements IlvLookAheadFeatureIterator.