本文整理汇总了C++中OGRGeometry::getBoundary方法的典型用法代码示例。如果您正苦于以下问题:C++ OGRGeometry::getBoundary方法的具体用法?C++ OGRGeometry::getBoundary怎么用?C++ OGRGeometry::getBoundary使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OGRGeometry
的用法示例。
在下文中一共展示了OGRGeometry::getBoundary方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load
bool shape::load(string filename)
{
OGRRegisterAll();
// First open the shape file
ds = OGRSFDriverRegistrar::Open( filename.c_str(), FALSE );
// Now to load in the points .....
points = vector<vector<glm::vec2>>();
// Grab the first layer
OGRLayer* layer = ds->GetLayer(0);
// Grab the spatial reference and create a coordinate transform function
sr = layer->GetSpatialRef();
// Taking from http://www.compsci.wm.edu/SciClone/documentation/software/geo/gdal-1.9.0/html/ogr/ogr_apitut.html
OGRFeature *poFeature;
layer->ResetReading();
while( (poFeature = layer->GetNextFeature()) != NULL )
{
OGRFeatureDefn *poFDefn = layer->GetLayerDefn();
int iField;
OGRGeometry *poGeometry;
poGeometry = poFeature->GetGeometryRef();
if( poGeometry != NULL
&& wkbFlatten(poGeometry->getGeometryType()) == wkbPoint )
{
OGRPoint *poPoint = (OGRPoint *) poGeometry;
//printf( "%.3f,%3.f\n", poPoint->getX(), poPoint->getY() );
}
else if (poGeometry != NULL
&& wkbFlatten(poGeometry->getGeometryType()) == wkbLineString)
{
//cout << "LINES!!!!" << endl;
OGRLineString* ls= (OGRLineString*)poGeometry;
points.push_back(vector<glm::vec2>());
for(int i = 0; i < ls->getNumPoints(); i++ )
{
OGRPoint p;
ls->getPoint(i,&p);
// This function can transform a larget set of points.....
double x = p.getX();
double y = p.getY();
points[points.size()-1].push_back(glm::vec2(x,y));
//poTransform->Transform (1, &x, &y);
//cout << p.getX() << " " << p.getY() << "Transformed!: " << x << " " << y << endl;
}
}
else if (poGeometry != NULL
&& wkbFlatten(poGeometry->getGeometryType()) == wkbPolygon)
{
OGRLineString* ls= (OGRLineString*)poGeometry->getBoundary();
points.push_back(vector<glm::vec2>());
cout << "POLYGON" << ls->getNumPoints() << endl;
//exit(0);
for(int i = 0; i < ls->getNumPoints(); i++ )
{
OGRPoint p;
ls->getPoint(i,&p);
// This function can transform a larget set of points.....
double x = p.getX();
double y = p.getY();
points[points.size()-1].push_back(glm::vec2(x,y));
//poTransform->Transform (1, &x, &y);
//cout << p.getX() << " " << p.getY() << "Transformed!: " << x << " " << y << endl;
}
}
OGRFeature::DestroyFeature( poFeature );
}
return true;
}