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,
                    });
                }
            }
        }
        private void CmdEndPolygonDrawing_Execute(object obj)
        {
            if (_draftMapModel != null && _draftMapModel.IsCurrentlyDrawing)
            {
                var pol = _draftMapModel.FinishCurrentPolygon();

                BmpPlanner.MouseDown -= BmpPlanner_MouseDown;
                BmpPlanner.MouseMove -= BmpPlanner_MouseMove;

                DrawingRequested = false;
                NotifyPropertyChanged("DrawingRequested");
                NotifyPropertyChanged("DrawingHelpVisible");

                var areaInAcres = pol.CoveredArea();

                AreasOfInterest.Add(new AreaOfInterest()
                {
                    AnalizedArea       = 0,
                    Area               = areaInAcres,
                    RequiredFlightTime = Math.Round(areaInAcres * 1.0425 / 6, 2),
                    RequiredImages     = (int)Math.Ceiling(areaInAcres * 37 / 6),
                    MapModel           = _draftMapModel
                });
                NotifyPropertyChanged("AreasOfInterest");

                AddToMyAreasVisibility = Visibility.Visible;
                NotifyPropertyChanged("AddToMyAreasVisibility");

                _draftMapModel = null;

                RenderMap();
            }
        }
Exemple #3
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);
                }
            }
        }
        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);
                    }
                }
            }
        }