如何使用arcObject创建折线shapefile

时间:2014-06-23 12:13:39

标签: c# .net arcobjects

我正在使用ArcObject。我想使用arcObject创建shape文件。我非常接近它。但需要一些更好的替代方案,因为我认为当有数十万条记录时,我的解决方案可能会达不到时间

我在sql数据库中有Geometry字段。从那里我得到Linstring,Multilinestring或Point

的字符串

EG。 " LINESTRING(-98.71702604799998 37.746413141000062,-98.717210399999942 37.738209632000064,-98.717347586999949 37.732091870000033)"

从这里我手动提取像

这样的坐标
 string d = st.Substring(12); // to get rid of LINESTRING 
 label d = d.Substring(0, d.Length - 1); // to get points as x1 y1,x2 y2,x3 y3 
 arr = d.Split(','); // now to get array [x1 y1, x2 y2, x3 y3] 

这是我的代码如何进行

  ESRI.ArcGIS.Geometry.IPoint[] pntArrayTemp = new ESRI.ArcGIS.Geometry.IPoint[arr.Length];
            int k = 0;
            ESRI.ArcGIS.Geometry.ILine[] linearray = new ESRI.ArcGIS.Geometry.LineClass[pntArrayTemp.Length];
            ESRI.ArcGIS.Geometry.ISegmentCollection[] paths = new ESRI.ArcGIS.Geometry.PathClass[pntArrayTemp.Length];
            foreach (string st1 in arr)
            {
                linearray[k] = new ESRI.ArcGIS.Geometry.LineClass();
                paths[k] = new ESRI.ArcGIS.Geometry.PathClass();
                pntArrayTemp[k] = new ESRI.ArcGIS.Geometry.PointClass();
                string[] temp1 = st1.Trim().Split(' ');
                pntArrayTemp[k].X = Convert.ToDouble(temp1[0].Replace(")", "").Replace("(", "").Trim());
                pntArrayTemp[k].Y = Convert.ToDouble(temp1[1].Replace(")", "").Replace("(", "").Trim());
                object obj1 = Type.Missing;
                paths[k].AddSegment((ISegment)linearray[k], ref obj1, ref obj1);
                k++;
            }
            for (int j = 0; j < paths.Length - 1; j++)
            {
                object obj1 = Type.Missing;
                pGeoColl12.AddGeometry((ESRI.ArcGIS.Geometry.IGeometry)paths[j], ref obj1, ref obj1);
                linearray[j].PutCoords(pntArrayTemp[j], pntArrayTemp[j + 1]);
            }

        }
        pGeoColl12.GeometriesChanged();
        return pGeoColl12 as IPolyline;
从这里我得到了一些坐标,我用它来创建线的形状。许多记录[100k或更多]是非常繁琐的程序。在arcObject中是否有任何简单易用的方法,我可以从LINESTRING中获取坐标,或者我可以使用LINESTRING绘制线条?

0 个答案:

没有答案