使用OGR读取OGRLineString(类型为wkbLineString)

  

                           使用OGR读取OGRLineString(类型为wkbLineString)

                                                    By  wangsh 2011.12.16

 

     最近在使用ogr读取道路数据,发现大多数对象为多线类型,以前仅处理简单线,这里必须考虑解析读取多线对象。这里列出处理简单线例子供大家参考:

 

poFeature = poLayer->GetNextFeature()

 poGeometry = poFeature->GetGeometryRef();

if( poGeometry != NULL && wkbFlatten(poGeometry->getGeometryType()) == wkbLineString )
   {

       std :: vector<PointT> arrPoints;
      OGRLineString *poLineString = (OGRLineString *) poGeometry;    

     std :: vector<PointT> arrPoints;

      v++;
      nLineID++;

      int nnCount = poLineString->getNumPoints();

      SHPLine sShpLine;
      sShpLine.nLineID = nLineID;
      sShpLine.nCount  = nnCount;

      PointT point;

      for (int j=0; j < nnCount; j++)
      {

       point.x = poLineString->getX(j);
       point.y = poLineString->getY(j);
       double vx = point.x;
       double vy = point.y;

       arrPoints.push_back(point);

 

        }

  

}

你可能感兴趣的:(null)