private void addMarkerBtn_Click(object sender, EventArgs e) { if (perceel == null) { return; } datacontract.geojsonPolygon jsPoly = JsonConvert.DeserializeObject <datacontract.geojsonPolygon>(perceel.geometry.shape); IPolygon lbShape = geopuntHelper.geojson2esriPolygon(jsPoly, (int)dataHandler.CRS.Lambert72); IPolygon mapShape = (IPolygon)geopuntHelper.Transform(lbShape, map.SpatialReference); string adres = string.Join("-", perceel.adres.ToArray()); if (adres.Length > 120) { adres = adres.Substring(0, 120); } IRgbColor innerClr = new RgbColor() { Red = 0, Blue = 0, Green = 0 }; IRgbColor outlineClr = new RgbColor() { Red = 0, Blue = 200, Green = 0 }; IPoint center = ((IArea)mapShape).LabelPoint; geopuntHelper.AddGraphicToMap(map, mapShape, innerClr, outlineClr, 2, false); geopuntHelper.AddTextElement(map, center, perceel.capakey + "\r\n" + adres); view.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); }
private void appendParcelField(IFeatureClass parcelFC) { if (perceel == null) { return; } IFeatureCursor insertCursor = parcelFC.Insert(false); datacontract.geojsonPolygon jsPoly = JsonConvert.DeserializeObject <datacontract.geojsonPolygon>(perceel.geometry.shape); IPolygon lbShape = geopuntHelper.geojson2esriPolygon(jsPoly, (int)dataHandler.CRS.Lambert72); IPolygon mapShape = (IPolygon)geopuntHelper.Transform(lbShape, map.SpatialReference); IFeature feature = parcelFC.CreateFeature(); feature.Shape = (IGeometry)mapShape; int capakeyIdx = parcelFC.FindField("capakey"); feature.set_Value(capakeyIdx, perceel.capakey); int perceelnrIdx = parcelFC.FindField("perceelnr"); feature.set_Value(perceelnrIdx, perceel.perceelnummer); int grondnrIdx = parcelFC.FindField("grondnr"); feature.set_Value(grondnrIdx, perceel.grondnummer); int exponentIdx = parcelFC.FindField("exponent"); feature.set_Value(exponentIdx, perceel.exponent); int machtIdx = parcelFC.FindField("macht"); feature.set_Value(machtIdx, perceel.macht); int bisnrIdx = parcelFC.FindField("bisnr"); feature.set_Value(bisnrIdx, perceel.bisnummer); int perceeltypeIdx = parcelFC.FindField("type"); feature.set_Value(perceeltypeIdx, perceel.type); string adres = string.Join("-", perceel.adres.ToArray()); if (adres.Length > 254) { adres = adres.Substring(0, 254); } int adresIdx = parcelFC.FindField("adres"); feature.set_Value(adresIdx, adres); feature.Store(); }
public List<geojsonPolygon> toPolygonList() { List<geojsonPolygon> polyList = new List<geojsonPolygon>(); for (int n = 0; n < coordinates.Count; n++) { geojsonPolygon poly = new geojsonPolygon() { coordinates = coordinates[n], type = "Polygon", crs = crs }; polyList.Add(poly); } return polyList; }
private void createGrapicAndZoomTo(string capakeyResponse, datacontract.geojson Geom) { IRgbColor inClr = new RgbColorClass() { Red = 0, Blue = 100, Green = 0 };; IRgbColor outLine = new RgbColorClass() { Red = 0, Blue = 200, Green = 0, Transparency = 240 }; if (Geom.type == "MultiPolygon") { datacontract.geojsonMultiPolygon muniPolygons = JsonConvert.DeserializeObject <datacontract.geojsonMultiPolygon>(capakeyResponse); IGeometryCollection multiPoly = new GeometryBagClass(); clearGraphics(); foreach (datacontract.geojsonPolygon poly in muniPolygons.toPolygonList()) { IPolygon lbPoly = geopuntHelper.geojson2esriPolygon(poly, (int)dataHandler.CRS.Lambert72); lbPoly.SimplifyPreserveFromTo(); IGeometry prjGeom = geopuntHelper.Transform((IGeometry)lbPoly, map.SpatialReference); IElement muniGrapic = geopuntHelper.AddGraphicToMap(map, prjGeom, inClr, outLine, 2, true); graphics.Add(muniGrapic); multiPoly.AddGeometry(prjGeom); } view.Extent = ((IGeometryBag)multiPoly).Envelope; view.Refresh(); } else if (Geom.type == "Polygon") { datacontract.geojsonPolygon municipalityPolygon = JsonConvert.DeserializeObject <datacontract.geojsonPolygon>(capakeyResponse); IPolygon lbPoly = geopuntHelper.geojson2esriPolygon(municipalityPolygon, (int)dataHandler.CRS.Lambert72); lbPoly.SimplifyPreserveFromTo(); IPolygon prjPoly = (IPolygon)geopuntHelper.Transform((IGeometry)lbPoly, map.SpatialReference); view.Extent = prjPoly.Envelope; clearGraphics(); IElement muniGrapic = geopuntHelper.AddGraphicToMap(map, (IGeometry)prjPoly, inClr, outLine, 3, true); graphics.Add(muniGrapic); view.Refresh(); } }
public List <geojsonPolygon> toPolygonList() { List <geojsonPolygon> polyList = new List <geojsonPolygon>(); for (int n = 0; n < coordinates.Count; n++) { geojsonPolygon poly = new geojsonPolygon() { coordinates = coordinates[n], type = "Polygon", crs = crs }; polyList.Add(poly); } return(polyList); }
/// <summary>Convert a ESRI geometry to geojson </summary> /// <param name="esriPoint">A ESRI polygon object</param> /// <returns>A geojson Object</returns> public static datacontract.geojsonPolygon esri2geojsonPolygon(IPolygon esriPolygon) { int epsg; string epsgUri; if (esriPolygon.SpatialReference == null) { epsgUri = ""; } else if (esriPolygon.SpatialReference.FactoryCode == 900913 || esriPolygon.SpatialReference.FactoryCode == 102100) { epsg = 3857;//google mercator epsgUri = string.Format("http://www.opengis.net/def/crs/EPSG/0/{0}", epsg); } else { epsg = esriPolygon.SpatialReference.FactoryCode; epsgUri = string.Format("http://www.opengis.net/def/crs/EPSG/0/{0}", epsg); } datacontract.geojsonCRS JScrs = new datacontract.geojsonCRS() { type = "link", properties = new Dictionary<string, string>() { { "href", epsgUri } } }; datacontract.geojsonPolygon JSpolygon = new datacontract.geojsonPolygon() { type = "Polygon", crs = JScrs }; List<List<List<double>>> coords = new List<List<List<double>>>(); IGeometryCollection rings = esriPolygon as IGeometryCollection; for (int n = 0; n < rings.GeometryCount; n++) { IPointCollection4 ring = rings.get_Geometry(n) as IPointCollection4; List<List<double>> JSring = new List<List<double>>(); for (int i = 0; i < ring.PointCount; i++) { IPoint pt = ring.get_Point(i); List<double> JSpt = new List<double>() {pt.X, pt.Y }; JSring.Add(JSpt); } coords.Add(JSring); } JSpolygon.coordinates = coords; return JSpolygon; }