GShapeFile Class Reference

[libgfc Index] [libgfc Hierarchy] [Headers]


ArcView shapefile reader class. More...

#include <utils/src/gshapefile.h>

Public Members

Protected Members


Detailed Description

If you want to read associated attributes for each shape record, use the class DBFile that comes with this class for that purpose. This class only reads the geometry record in the .shp file which

is indexed by the .shx file. DBFile will read the .dbf file or tabular attributes. The tabular records and the geometry records have one-to-one mappings, and appear in the same order in the .shp file and .dbf file respectively.


GShapeFile(const char* name) [public]

this constructor automatically opens the named shapefile for read access.

friend ostream& operator<<(ostream& os, const GShapeFile& shp) [public]

print the basic info. about the shapefile to the console.

int openShapeFile(const char* name) [public]

GShapeFile :: openShapeFile --

Given a shape file name, tries to open the corresponding .shp, .shx, and .dbf files. If success then read the header info into in-memory structure. The files will be memory-mapped.

Return 0 upon success, otherwise -1.

Side effects: The three files are opened and header structures read into memory. Ready to retrieve individual shape/attribute records.

ShapeType shapeType() const [public]

return the type of shape record in a shapefile. It is one of the following types: av_Point, av_Arc, av_Polygon, av_MultiPoint, and av_Null if unknown.

int numRecords() const [public]

return the number of records in a shapefile

int bndRect(double& xmin, double& ymin, double& xmax, double& ymax) const [public]

return the universal bounding rectangle for all the shape records in a shapefile.

Result getShapeRec(int nth, int& n_parts, int& n_verts, int*& parts, double*& vertices, GRect&) [public]

retrieve a shape record's information.

Return NULL if failed. Otherwise the following values are set properly: verticies: contains all the verticies parts: contains the parts index (in the unit of vertices) into the "vertices" array. Each verticy has two double coordinates. n_parts: number of parts n_verts: number of total vertices (summed over all parts) vertices: the array of vertices (pair of doubles).

GSpatial* getShapeRec(int nth) [public]

return the pointer to the nth spatial record as a GFC ADT object. the returned pointer points to a memory address owned by this GShapeFile object.

Result getShapeRec(int nth, GPoint* p) [public]

retrieves a shape record as a spatial GFC ADT. val must be a valid pointer to the proper type of GFC ADTs. The following is the correspondence between ArcView spatial types and GFC spatail ADTs: ArcView GFC point GPoint arc GArc polygon GPolygon multi-point not-supported yet

Result getMBR(int nth, GRect& rect) [public]

retrieve the mbr of 'nth' shape record

char* makePath(const char* name, char* dest=0) [protected]

make full path to the shape file

long mainRecordOffset(int nth, int& len) [protected]

get the offset (in bytes) of the nth record in the main (.shp) file. The offset is relative to the beginning of the file and starts with 0.

Parameters:
nth is the number of record of concern. starts w/ 0.
len is the content length (in byte) of the record.

int advise(int ad) [protected]

gives advice about how the shapefile will be accessed


Documentation generated by lqian@lqian-sun on Wed Jul 14 09:36:10 EDT 1999
Kdoc