I am working on ArcObject. I want to create shape file using arcObject. I am very close to it. but need some better alternative as I feel my solution may fall short in time when there are hundreds of thousands of records
I have Geometry field in sql database. from that I get the string which is Linstring,Multilinestring or Point
Eg. "LINESTRING (-98.71702604799998 37.746413141000062, -98.717210399999942 37.738209632000064, -98.717347586999949 37.732091870000033)"
from this I manually extract the coordinates like
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]
here is how my code goes
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;
from this I get array of the co-ordinates which I use to create shape for line. It is very tedious procedure for many record[100k or more]. Is there any simple easy method in arcObject that I can get the coordinates from LINESTRING on fly or I can use the LINESTRING to draw lines ?