• shapelib 写线对象


    #include "shapefil.h"

    void  WriteFeature(string path)
    {
        //https://blog.csdn.net/feihongchen/article/details/105462156
        if (m_Roadvec.size() == 0)
         return;
       
        int roadnum = m_Roadvec.size();

        int n, nEntities, nShapeType;
        BOOL bSuccess = FALSE;
        double adfMin[4], adfMax[4];
       
        std::string shp_fn = path + "\NewRoad";
       
        SHPHandle hShp = SHPCreate(string(shp_fn + ".shp").c_str(), SHPT_ARC);
        DBFHandle hDbf = DBFCreate(string(shp_fn + ".dbf").c_str());
       
        DBFAddField(hDbf, "ysbh", FTInteger, 10, 0);
        DBFAddField(hDbf, "mc", FTString, 50, 0);
        DBFAddField(hDbf, "kd", FTDouble, 10, 3);
       
        //int record_idx = DBFGetRecordCount(hDbf);
       
        for (int i = 0;i < roadnum;i++)
        {
         JBroad tempRoad = m_Roadvec[i];
       
         int nVertices = tempRoad.m_vPoints.size();
       
         double* padfX = new double[nVertices];
         double* padfY = new double[nVertices];
         //double* padfZ = new double[nVertices];
       
         for (int j = 0; j < nVertices; ++j)
         {
          padfX[j] = tempRoad.m_vPoints[j].getX();
          padfY[j] = tempRoad.m_vPoints[j].getY();
         }
       
         //SHPObject* shpObject = SHPCreateObject(SHPT_ARCZ, -1, 0, NULL, NULL, nVertices, padfX, padfY, padfZ, NULL);
         SHPObject* shpObject = SHPCreateObject(SHPT_ARC, -1, 0, NULL, NULL, nVertices, padfX, padfY, NULL, NULL);
         SHPWriteObject(hShp, -1, shpObject);
         SHPDestroyObject(shpObject);
       
         delete[] padfX;
         delete[] padfY;
         //delete[] padfZ;
       
         //int field_idx = 0;
       
         DBFWriteIntegerAttribute(hDbf, i, 0, tempRoad.m_ElementCode);
         DBFWriteStringAttribute(hDbf, i, 1, tempRoad.m_RoadName.c_str());
         DBFWriteDoubleAttribute(hDbf, i, 2, tempRoad.m_RoadWidth);
        }
       
        DBFClose(hDbf);
        SHPClose(hShp);

    }

  • 相关阅读:
    Map,Multimap,Set,MultiSet,Hash_Map,Hash_Set,Share_ptr的区分
    mjpgstreamer源码分析
    S3C2410x介绍
    V4L2应用程序框架
    V4L2驱动框架
    Linux 视频设备驱动V4L2最常用的控制命令使用说明
    (转)在eclipse中查看android SDK的源代码
    [经验技巧] 利用WindowsPhone7_SDK_Full.rar_for_xp,在xp下安装sdk,部署xap软件的教程
    (收藏)智能手机开发
    Html5相关文章链接
  • 原文地址:https://www.cnblogs.com/roea1/p/13910673.html
Copyright © 2020-2023  润新知