public static void GetAllPolygonsFromShape(MapModel map, string geo)
        {
            using (var shp = new Shapefile(string.Format("./gis/{0}/alerts.shp", geo)))
            {
                foreach (Shape row in shp)
                {
                    ShapePolygon p = row as ShapePolygon;
                    map.StartNewPolygon();

                    foreach (var part in p.Parts)
                    {
                        foreach (var point in part)
                        {
                            map.AddPointToPolygon(new Location(point.Y, point.X));
                        }
                    }

                    var pol    = map.FinishCurrentPolygon();
                    var center = pol.CenterPosition();


                    map.Marks.Add(new LocationMark()
                    {
                        Longitude = center.Longitude,
                        Latitude  = center.Latitude,
                    });
                }
            }
        }
Exemplo n.º 2
0
        public Flight(Collection <LocationMark> detectedFires, GeoCoordinateCollection coveredArea, string filePath, MapModel mapModel)
        {
            Folder   = filePath;
            MapModel = mapModel;
            Images   = coveredArea.Count;
            Date     = DateTime.Now;

            if (MapModel != null)
            {
                if (detectedFires.Any())
                {
                    MapModel.Shading = MapPolygonExtensions.RED_AREA_SHADING;
                    MapModel.Stroke  = MapPolygonExtensions.RED_AREA_STROKE;
                }
                else
                {
                    MapModel.Shading = MapPolygonExtensions.GREEN_AREA_SHADING;
                    MapModel.Stroke  = MapPolygonExtensions.GREEN_AREA_STROKE;
                }

                var allCoveredArea = coveredArea.ConvexHull();

                MapPolygon analizedArea = null;
                if (allCoveredArea != null && allCoveredArea.Count > 2)
                {
                    MapModel.StartNewPolygon();

                    foreach (var point in allCoveredArea)
                    {
                        MapModel.AddPointToPolygon(point);
                    }

                    analizedArea = MapModel.FinishCurrentPolygon();
                    CoveredArea  = analizedArea.CoveredArea();
                }

                foreach (var loc in detectedFires)
                {
                    MapModel.Marks.Add(loc);
                }
            }
        }
        private void BmpPlanner_MouseDown(object sender, MouseEventArgs e)
        {
            if (_draftMapModel == null)
            {
                // If null, something is wrong
                BmpPlanner.MouseDown -= BmpPlanner_MouseDown;
                BmpPlanner.MouseMove -= BmpPlanner_MouseMove;
            }
            else
            {
                if (!_draftMapModel.IsCurrentlyDrawing)
                {
                    _draftMapModel.StartNewPolygon();
                    BmpPlanner.MouseMove += BmpPlanner_MouseMove;
                }

                _draftMapModel.AddPointToPolygon(e.GetPosition(BmpPlanner));
                RenderMap();
            }
        }
        public static void ConvertUGCtoPolygon(IEnumerable <string> ugcs, MapModel map)
        {
            using (var shp = new Shapefile("./gis/us/fz25jn18.shp"))
            {
                var ugcsLeft = ugcs.ToList();
                foreach (Shape row in shp)
                {
                    if (!ugcsLeft.Any())
                    {
                        break;
                    }

                    var ugc = string.Concat((string)row.DataRecord[0], "Z", (string)row.DataRecord[1]);

                    if (ugcsLeft.Contains(ugc))
                    {
                        ShapePolygon p = row as ShapePolygon;
                        map.StartNewPolygon();

                        foreach (var part in p.Parts)
                        {
                            foreach (var point in part)
                            {
                                map.AddPointToPolygon(new Location(point.Y, point.X));
                            }
                        }

                        map.FinishCurrentPolygon();

                        map.Marks.Add(new LocationMark()
                        {
                            Longitude = (double)row.DataRecord[7],
                            Latitude  = (double)row.DataRecord[8]
                        });

                        ugcsLeft.Remove(ugc);
                    }
                }
            }
        }