示例#1
0
        public void getData(IPolyline profileLineGeom)
        {
            try
            {
                polyLineLam72 = (IPolyline)geopuntHelper.Transform((IGeometry)profileLineGeom, lam72);

                int samplesCount             = (int)samplesNum.Value;
                datacontract.geojsonLine gjs = geopuntHelper.esri2geojsonLine(polyLineLam72);
                profileData = dhm.getDataAlongLine(gjs, samplesCount, dataHandler.CRS.Lambert72);

                ArcMap.Application.CurrentTool = oldCmd;

                this.WindowState = FormWindowState.Normal;
                this.Focus();

                maxH = profileData.Select(c => c[3]).Max();
                minH = profileData.Where(c => c[3] > -999).Select(c => c[3]).Min();
                maxD = profileData.Select(c => c[0]).Max();
                profileGrp.GraphPane.YAxis.Scale.Max = maxH;
                profileGrp.GraphPane.YAxis.Scale.Min = minH;
                profileGrp.GraphPane.XAxis.Scale.Max = maxD;

                addLineGrapic();
                createGraph();
            }
            catch (WebException wex)
            {
                if (wex.Status == WebExceptionStatus.Timeout)
                {
                    MessageBox.Show("De connectie werd afgebroken." +
                                    " Het duurde te lang voor de server een resultaat terug gaf.\n" +
                                    "U kunt via de instellingen de 'timout'-tijd optrekken.", wex.Message);
                }
                else if (wex.Response != null)
                {
                    string resp = new StreamReader(wex.Response.GetResponseStream()).ReadToEnd();
                    MessageBox.Show(resp, wex.Message);
                }
                else
                {
                    MessageBox.Show(wex.Message, "Error");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + " " + ex.StackTrace, "Error");
            }
        }
示例#2
0
        /// <summary>Convert a ESRI geometry to geojson </summary>
        /// <param name="esriPoint">A ESRI polyline object</param>
        /// <returns>A geojson Object</returns>
        public static datacontract.geojsonLine esri2geojsonLine(IPolyline esriLine)
        {
            int epsg;
            string epsgUri;

            if (esriLine.SpatialReference == null)
            {
                epsgUri = "";
            }
            else if (esriLine.SpatialReference.FactoryCode == 900913 || esriLine.SpatialReference.FactoryCode == 102100)
            {
                epsg = 3857;//google mercator
                epsgUri = string.Format("http://www.opengis.net/def/crs/EPSG/0/{0}", epsg);
            }
            else
            {
                epsg = esriLine.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.geojsonLine JSline = new datacontract.geojsonLine() {type = "Polyline", crs = JScrs };
            List<List<double>> coords = new List<List<double>>();

            IPointCollection4 nodes = esriLine as IPointCollection4;

            for (int n = 0; n < nodes.PointCount; n++)
            {
                IPoint node = nodes.get_Point(n);
                List<double> pt = new List<double>() {node.X, node.Y };
                coords.Add(pt);
            }
            JSline.coordinates = coords;

            return JSline;
        }