zoukankan      html  css  js  c++  java
  • 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);

    }

  • 相关阅读:
    使用JQuery从客户端调用C#方法
    上传文件插件 Uploadify使用说明 转
    juqery 操作select
    XP下安装IIS6.0的办法 转
    更改2003远程桌面端口3389为其他端口号
    Web打印
    远程桌面 客户端无法建立跟远程计算机的连接 解决办法
    WPF的“.NET研究”消息机制(一) 让应用程序动起来 狼人:
    应用Visual Studio 2010辅“.NET研究”助敏捷测试(上) 狼人:
    ASP.NET调用.sql文件(二“.NET研究”) 狼人:
  • 原文地址:https://www.cnblogs.com/roea1/p/13910673.html
Copyright © 2011-2022 走看看