Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- List<string[]> points = new List<string[]>();
- var xmlDocument = XDocument.Load(xmlpath);
- XNamespace ns = xmlDocument.Root.GetDefaultNamespace();
- var values = xmlDocument.Root
- .Descendants(ns + "trkpt")
- .Select(x => new
- {
- lat = (string)x.Attribute("lat"),
- lon = (string)x.Attribute("lon"),
- ele = (string)x.Element(ns + "ele")
- })
- .ToList();
- List<IPoint> ipoint = new List<IPoint>();
- foreach (var val in values)
- {
- string[] cordinates = { val.lat, val.lon, val.ele};
- points.Add(cordinates);
- IPoint apoint = new Point();
- apoint.X = Convert.ToDouble(val.lat);
- apoint.Y = Convert.ToDouble(val.lon);
- apoint.Z = Convert.ToDouble(val.ele);
- ipoint.Add(apoint);
- }
- return ipoint;
- }
- IGeometryBridge2 pGeoBrg = new GeometryEnvironment() as IGeometryBridge2;
- IPointCollection4 pPointColl = new PolygonClass();
- //TODO:
- //pointCollection4.SpatialReference = 'Define the spatial reference of the new polygon.
- int numPoints = pList.Count;
- WKSPoint[] aWKSPointBuffer = new WKSPoint[numPoints];
- for(int i =0; i < pList.Count; i++)
- {
- WKSPoint A = new WKSPoint();
- A.X = pList[i].X;
- A.Y = pList[i].Y;
- aWKSPointBuffer[i] = A;
- }
- pGeoBrg.SetWKSPoints(pPointColl, ref aWKSPointBuffer);
- IPolygon pPointColl2 = pPointColl as IPolygon;
- pPointColl2.SpatialReference = spatialrefrence;
- return pPointColl2;
- }
- 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,
- 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)
- {
- IFeature feature;
- if (isNew)
- {
- // Build the feature.
- feature = featureClass.CreateFeature();
- }
- else
- {
- feature = featureClass.GetFeature(ObjID);
- }
- //TODO here must edit polygon shape if you want to edit feature
- feature.Shape = polygon;
- // Apply the appropriate subtype to the feature.
- ISubtypes subtypes = (ISubtypes)featureClass;
- IRowSubtypes rowSubtypes = (IRowSubtypes)feature;
- if (subtypes.HasSubtype)
- {
- // In this example, the value of 3 represents the polymer vinyl chloride (PVC) subtype.
- rowSubtypes.SubtypeCode = 3;
- }
- // Initialize any default values the feature has.
- rowSubtypes.InitDefaultValues();
- // Update the value on a string field that indicates who installed the feature.
- int GPSIdFieldIndex = featureClass.FindField("GPSId");
- feature.set_Value(GPSIdFieldIndex, gpsID);
- int EnergyFieldIndex = featureClass.FindField("Energy");
- feature.set_Value(EnergyFieldIndex, energy);
- int harvestFieldIndex = featureClass.FindField("harvest");
- feature.set_Value(harvestFieldIndex, harv);
- int PoolFieldIndex = featureClass.FindField("Pool");
- feature.set_Value(PoolFieldIndex, pool);
- int irrigationFieldIndex = featureClass.FindField("irrigation");
- feature.set_Value(irrigationFieldIndex, irrigation);
- int WaterFieldIndex = featureClass.FindField("Water");
- feature.set_Value(WaterFieldIndex, Water);
- int varietyFieldIndex = featureClass.FindField("variety");
- feature.set_Value(varietyFieldIndex, variety);
- int treesFieldIndex = featureClass.FindField("trees");
- feature.set_Value(treesFieldIndex, trees);
- int corp_typeFieldIndex = featureClass.FindField("corp_type");
- feature.set_Value(corp_typeFieldIndex, corp_type);
- int utilizatFieldIndex = featureClass.FindField("utilizat");
- feature.set_Value(utilizatFieldIndex, utilizat);
- int prop_IDFieldIndex = featureClass.FindField("prop_ID");
- feature.set_Value(prop_IDFieldIndex, prop_ID);
- int numberFieldIndex = featureClass.FindField("number");
- feature.set_Value(numberFieldIndex, number);
- int addressFieldIndex = featureClass.FindField("address");
- feature.set_Value(addressFieldIndex, address);
- int pool_capFieldIndex = featureClass.FindField("pool_cap");
- feature.set_Value(pool_capFieldIndex,pool_cap );
- int discriptFieldIndex = featureClass.FindField("discript");
- feature.set_Value(discriptFieldIndex, discript);
- int water_hourFieldIndex = featureClass.FindField("water_hour");
- feature.set_Value(water_hourFieldIndex, water_hour);
- int owner_IDFieldIndex = featureClass.FindField("owner_ID");
- feature.set_Value(owner_IDFieldIndex, owner_ID);
- int w_sourceFieldIndex = featureClass.FindField("w_source");
- feature.set_Value(w_sourceFieldIndex, w_source);
- int w_incheFieldIndex = featureClass.FindField("w_inche");
- feature.set_Value(w_incheFieldIndex, w_inche);
- IArea area = polygon as IArea;
- int areaFieldIndex = featureClass.FindField("Area");
- feature.set_Value(areaFieldIndex, area.Area.ToString());
- // Commit the new feature to the geodatabase.
- feature.Store();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement