Beispiel #1
0
        private void DrawBeatSegment(string bsID)
        {
            /*
             * BeatSeg bs = GeoClass.beatsegs.Find(delegate(BeatSeg find) { return find.BeatSegID == bsID; });
             * if (bs != null)
             * {
             *
             *  GMapOverlay polyOverlay = new GMapOverlay(gMapControl1, "polygons");
             *  List<PointLatLng> points = new List<PointLatLng>();
             *  for (int i = 1; i < bs.geo.STNumPoints(); i++)
             *  {
             *      SqlGeography point = bs.geo.STPointN(i);
             *      points.Add(new PointLatLng((double)point.Lat, (double)point.Long));
             *  }
             *  GMapPolygon polygon = new GMapPolygon(points, bs.BeatSegID);
             *  polygon.Fill = new SolidBrush(Color.FromArgb(50, Color.Red));
             *  polygon.Stroke = new Pen(Color.Red, 1);
             *  polyOverlay.Polygons.Add(polygon);
             *  gMapControl1.Overlays.Add(polyOverlay);
             * }
             * else
             * {
             *  MessageBox.Show("Couldn't find beat segment " + txtBeatSeg.Text);
             * }*/
            esriData ed = GeoClass.segPolygons.Find(delegate(esriData find) { return(find.BeatSegID == bsID); });

            if (ed != null)
            {
                GMapOverlay        polyOverlay = new GMapOverlay(gMapControl1, "polygons");
                List <PointLatLng> pointList   = new List <PointLatLng>();
                Polygon            p           = (Polygon)ed.segData.Geometry;
                foreach (PointCollection points in p.Rings)
                {
                    for (int i = 1; i < points.Count; i++)
                    {
                        pointList.Add(new PointLatLng((double)points[i].Y, (double)points[i].X));
                    }
                    GMapPolygon polygon = new GMapPolygon(pointList, ed.BeatSegID);
                    polygon.Fill   = new SolidBrush(Color.FromArgb(50, Color.Red));
                    polygon.Stroke = new Pen(Color.Red, 1);
                    polyOverlay.Polygons.Add(polygon);
                }
                gMapControl1.Overlays.Add(polyOverlay);
            }
            else
            {
                MessageBox.Show("Couldn't find beat segment " + bsID);
            }
        }
Beispiel #2
0
        public void GetBeatSegs()
        {
            QueryTask qt    = new QueryTask("http://38.124.164.214:6080/arcgis/rest/services/SegementsTest/FeatureServer/0");
            Query     query = new Query();

            query.ReturnGeometry = true;
            //query.Geometry = "POLYGON";
            query.Where = "1=1";
            qt.Execute(query);
            foreach (Graphic resultFeature in qt.LastResult.Features)
            {
                string bsID = string.Empty;
                System.Collections.Generic.IDictionary <string, object> allAttributes = resultFeature.Attributes;
                foreach (string theKey in allAttributes.Keys)
                {
                    object theValue = allAttributes[theKey];
                    bsID = theValue.ToString();
                }

                esriData ed = new esriData();
                ed.BeatSegID = bsID;
                ed.segData   = resultFeature;
                GeoClass.segPolygons.Add(ed);

                /*
                 * LatLonList lList = new LatLonList();
                 * lList.pairs = new List<List<LatLonPair>>();
                 * string s = resultFeature.Geometry.Extent.ToString();
                 * Polygon p = (Polygon)resultFeature.Geometry;
                 * PointCollection pcc = new PointCollection();
                 * MapPoint mp = new MapPoint(32.0, 54.35);
                 * pcc.Add(mp);
                 * if (p.Rings.Contains(pcc))
                 * {
                 *  string hi = "hi";
                 * }
                 * List<PointCollection> pcol = p.Rings.ToList<PointCollection>();
                 * foreach (PointCollection pc in pcol)
                 * {
                 *  List<LatLonPair> llpList = new List<LatLonPair>();
                 *  for (int i = 0; i < pc.Count(); i++)
                 *  {
                 *      LatLonPair llp = new LatLonPair();
                 *      llp.lat = pc[i].X;
                 *      llp.lon = pc[i].Y;
                 *      llpList.Add(llp);
                 *  }
                 *  lList.pairs.Add(llpList);
                 * }
                 * if (lList.pairs.Count == 1)
                 * {
                 *  if (lList.pairs[0].Count < 4) //make line
                 *  {
                 *      makeAndAddLine(bsID, lList);
                 *  }
                 *  else //make polygon
                 *  {
                 *      makeAndAddGeo(bsID, lList);
                 *  }
                 * }
                 * if (lList.pairs.Count > 1)
                 * {
                 *  makeAndAddMultiPolygon(bsID, lList);
                 * }
                 * */
            }
        }