可以读取shapefile, 但是shapefile本身不含有topology,所以仍不能满足要求。
http://shapelib.maptools.org/shp_api.html
bool
NServerData::initShapeFile(){
const char* shp = "shapefile/freeway_polyline.shp";
const char* shx = "shapefile/freeway_polyline.shx";
const char* right = "rb";
// read shp file
SHPHandle h = SHPOpen(shp, right);
int pnEntities;
int pnShapeType;
double padfMinBound;
double padfMaxBound;
SHPGetInfo( h, &pnEntities, &pnShapeType,
&padfMinBound, &padfMaxBound );
cout << "shape info:"
<< pnEntities << " "
<< pnShapeType << " "
<< padfMinBound << " "
<< padfMaxBound << endl;
SHPObject* obj = NULL;
static int i=0;
obj = SHPReadObject( h,i );
while (obj){
cout << ++i << " " << obj->nShapeId << " " << obj->nVertices << endl;
SHPDestroyObject(obj);
obj = SHPReadObject( h, i );
}
SHPClose(h);
// read shx file
}