Advertisement
Guest User

Untitled

a guest
Jul 10th, 2014
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.62 KB | None | 0 0
  1. List<string[]> points = new List<string[]>();
  2.  
  3. var xmlDocument = XDocument.Load(xmlpath);
  4.  
  5. XNamespace ns = xmlDocument.Root.GetDefaultNamespace();
  6. var values = xmlDocument.Root
  7. .Descendants(ns + "trkpt")
  8. .Select(x => new
  9. {
  10. lat = (string)x.Attribute("lat"),
  11. lon = (string)x.Attribute("lon"),
  12. ele = (string)x.Element(ns + "ele")
  13.  
  14. })
  15. .ToList();
  16. List<IPoint> ipoint = new List<IPoint>();
  17.  
  18. foreach (var val in values)
  19. {
  20. string[] cordinates = { val.lat, val.lon, val.ele};
  21. points.Add(cordinates);
  22. IPoint apoint = new Point();
  23. apoint.X = Convert.ToDouble(val.lat);
  24. apoint.Y = Convert.ToDouble(val.lon);
  25. apoint.Z = Convert.ToDouble(val.ele);
  26. ipoint.Add(apoint);
  27.  
  28.  
  29. }
  30.  
  31. return ipoint;
  32.  
  33.  
  34. }
  35.  
  36. IGeometryBridge2 pGeoBrg = new GeometryEnvironment() as IGeometryBridge2;
  37. IPointCollection4 pPointColl = new PolygonClass();
  38. //TODO:
  39. //pointCollection4.SpatialReference = 'Define the spatial reference of the new polygon.
  40.  
  41.  
  42. int numPoints = pList.Count;
  43. WKSPoint[] aWKSPointBuffer = new WKSPoint[numPoints];
  44. for(int i =0; i < pList.Count; i++)
  45. {
  46. WKSPoint A = new WKSPoint();
  47. A.X = pList[i].X;
  48. A.Y = pList[i].Y;
  49. aWKSPointBuffer[i] = A;
  50. }
  51. pGeoBrg.SetWKSPoints(pPointColl, ref aWKSPointBuffer);
  52. IPolygon pPointColl2 = pPointColl as IPolygon;
  53. pPointColl2.SpatialReference = spatialrefrence;
  54. return pPointColl2;
  55. }
  56.  
  57. enter code here public void ManipluteFeature(bool isNew,int ObjID,IFeatureClass featureClass, IPolygon polygon, string gpsID, string energy, int harv, string pool, string irrigation, string Water, string variety,
  58. int trees, string corp_type, string utilizat, int prop_ID, int number, string address, long pool_cap, string discript, long water_hour, int owner_ID, string w_source, long w_inche)
  59. {
  60. IFeature feature;
  61. if (isNew)
  62. {
  63. // Build the feature.
  64. feature = featureClass.CreateFeature();
  65. }
  66. else
  67. {
  68. feature = featureClass.GetFeature(ObjID);
  69.  
  70. }
  71. //TODO here must edit polygon shape if you want to edit feature
  72. feature.Shape = polygon;
  73.  
  74. // Apply the appropriate subtype to the feature.
  75. ISubtypes subtypes = (ISubtypes)featureClass;
  76. IRowSubtypes rowSubtypes = (IRowSubtypes)feature;
  77. if (subtypes.HasSubtype)
  78. {
  79. // In this example, the value of 3 represents the polymer vinyl chloride (PVC) subtype.
  80. rowSubtypes.SubtypeCode = 3;
  81. }
  82.  
  83. // Initialize any default values the feature has.
  84. rowSubtypes.InitDefaultValues();
  85.  
  86. // Update the value on a string field that indicates who installed the feature.
  87. int GPSIdFieldIndex = featureClass.FindField("GPSId");
  88. feature.set_Value(GPSIdFieldIndex, gpsID);
  89.  
  90. int EnergyFieldIndex = featureClass.FindField("Energy");
  91. feature.set_Value(EnergyFieldIndex, energy);
  92.  
  93. int harvestFieldIndex = featureClass.FindField("harvest");
  94. feature.set_Value(harvestFieldIndex, harv);
  95.  
  96. int PoolFieldIndex = featureClass.FindField("Pool");
  97. feature.set_Value(PoolFieldIndex, pool);
  98.  
  99. int irrigationFieldIndex = featureClass.FindField("irrigation");
  100. feature.set_Value(irrigationFieldIndex, irrigation);
  101.  
  102. int WaterFieldIndex = featureClass.FindField("Water");
  103. feature.set_Value(WaterFieldIndex, Water);
  104.  
  105. int varietyFieldIndex = featureClass.FindField("variety");
  106. feature.set_Value(varietyFieldIndex, variety);
  107.  
  108. int treesFieldIndex = featureClass.FindField("trees");
  109. feature.set_Value(treesFieldIndex, trees);
  110.  
  111. int corp_typeFieldIndex = featureClass.FindField("corp_type");
  112. feature.set_Value(corp_typeFieldIndex, corp_type);
  113.  
  114. int utilizatFieldIndex = featureClass.FindField("utilizat");
  115. feature.set_Value(utilizatFieldIndex, utilizat);
  116.  
  117. int prop_IDFieldIndex = featureClass.FindField("prop_ID");
  118. feature.set_Value(prop_IDFieldIndex, prop_ID);
  119.  
  120. int numberFieldIndex = featureClass.FindField("number");
  121. feature.set_Value(numberFieldIndex, number);
  122.  
  123. int addressFieldIndex = featureClass.FindField("address");
  124. feature.set_Value(addressFieldIndex, address);
  125.  
  126. int pool_capFieldIndex = featureClass.FindField("pool_cap");
  127. feature.set_Value(pool_capFieldIndex,pool_cap );
  128.  
  129. int discriptFieldIndex = featureClass.FindField("discript");
  130. feature.set_Value(discriptFieldIndex, discript);
  131.  
  132. int water_hourFieldIndex = featureClass.FindField("water_hour");
  133. feature.set_Value(water_hourFieldIndex, water_hour);
  134.  
  135. int owner_IDFieldIndex = featureClass.FindField("owner_ID");
  136. feature.set_Value(owner_IDFieldIndex, owner_ID);
  137.  
  138. int w_sourceFieldIndex = featureClass.FindField("w_source");
  139. feature.set_Value(w_sourceFieldIndex, w_source);
  140.  
  141. int w_incheFieldIndex = featureClass.FindField("w_inche");
  142. feature.set_Value(w_incheFieldIndex, w_inche);
  143.  
  144. IArea area = polygon as IArea;
  145. int areaFieldIndex = featureClass.FindField("Area");
  146. feature.set_Value(areaFieldIndex, area.Area.ToString());
  147.  
  148. // Commit the new feature to the geodatabase.
  149. feature.Store();
  150. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement