使用OGR读取OGRMultiLineString(类型为wkbMultiLineString)

                           使用OGR读取OGRMultiLineString(类型为wkbMultiLineString)

                                                    By  wangsh 2011.12.16

 

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

 

 

 

     

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

        OGRMultiLineString *poMultiLineString = (OGRMultiLineString *) poGeometry;
       int nGeoCount = poMultiLineString->getNumGeometries();
       int iLine = 0;

    OGRGeometry *poLineGeometry;
    for( iLine = 0; iLine < nGeoCount; iLine++ )
    {
     std :: vector<PointT> arrPoints;

      v++;
      nLineID++;

      poLineGeometry =  poMultiLineString->getGeometryRef(iLine);

      OGRLineString *poLineString = (OGRLineString *) poLineGeometry;

      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);

 

        }

   }

}

转载自:https://blog.csdn.net/wsh6759/article/details/7076419

You may also like...