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(); } }
public StreetSegmentService( IStreetSegmentRepository streetSegmentRepository, AreasOfInterest options ) { StreetSegmentRepository = streetSegmentRepository; AreasOfInterest = options; }
public PatternAreaService( IPatternAreaRepository patternAreaRepository, AreasOfInterest options ) { PatternAreaRepository = patternAreaRepository; AreasOfInterest = options; }
public NeighborhoodService( INeighborhoodRepository neighborhoodRepository, AreasOfInterest options ) { NeighborhoodRepository = neighborhoodRepository; AreasOfInterest = options; }
public BicyclePathService( IBicyclePathRepository bicyclePathRepository, AreasOfInterest options ) { BicyclePathRepository = bicyclePathRepository; AreasOfInterest = options; }
private void CmdSave_Execute(object obj) { string name = AddFlightToHistory.PickUpName(); if (!string.IsNullOrEmpty(name)) { var area = AreasOfInterest.First(); area.Name = name.ToUpper(); SavedAreasOfInterest.Add(area); NotifyPropertyChanged("SavedAreasOfInterest"); } }
private void OpenSavedAOI_Execute(object aoi) { if (aoi is AreaOfInterest aoiObj) { if (!AreasOfInterest.Any((a) => a.Name == aoiObj.Name)) { CmdCleanMap_Execute(null); AreasOfInterest.Add(aoiObj); Flights.AddRange(aoiObj.Flights); } NotifyPropertyChanged("AreasOfInterest"); NotifyPropertyChanged("Flights"); RenderMap(); } }
private void CmdCleanMap_Execute(object obj) { FireAlert = Visibility.Collapsed; AreaIsGood = Visibility.Collapsed; NotifyPropertyChanged("FireAlert"); NotifyPropertyChanged("AreaIsGood"); Flights.Clear(); AreasOfInterest.Clear(); NotifyPropertyChanged("Flights"); NotifyPropertyChanged("AreasOfInterest"); AddToMyAreasVisibility = Visibility.Hidden; NotifyPropertyChanged("AddToMyAreasVisibility"); RenderMap(); }
private void CmdAnalizeNow_Execute(object obj) { var filePath = DialogTools.ShowFolderPickerDialog("Select the images folder"); if (!string.IsNullOrEmpty(filePath)) { var wdw = new AnalyzeImages() { FilePath = filePath, Owner = this }; wdw.ShowDialog(); var missingLocations = wdw.DetectedFires.Where((f) => f.Longitude == 0 && f.Latitude == 0); if (missingLocations.Any()) { var imageLocation = ResolveLocation.Resolve(true); if (imageLocation != null) { foreach (var l in missingLocations) { l.Latitude = imageLocation[0]; l.Longitude = imageLocation[1]; } } } var flight = new Flight(wdw.DetectedFires, wdw.CoveredArea, filePath, new MapModel(BmpPlanner)); Flights.Add(flight); NotifyPropertyChanged("Flights"); AreasOfInterest.AddToAnalizedArea(flight); AreasOfInterest.NotifyAllPropertyChanged("AnalizedAreaPercentage"); NotifyPropertyChanged("AreasOfInterest"); wdw.Close(); RenderMap(); } }
static async Task Main(string[] args) { var pathToContentRoot = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); var host = new HostBuilder() /* set cwd to the path we are executing in since * running 'dotnet run' would otherwise * set cwd to the folder it is executing from * and the json files we need are being copied to the output directory */ .UseContentRoot(pathToContentRoot) .ConfigureHostConfiguration((builder) => { builder.AddJsonFile("appsettings.json"); }) .ConfigureServices((context, services) => { // AutoMapper setup using profiles. Mapper.Initialize(cfg => { cfg.AddProfile <DeploymentProfile>(); cfg.AddProfile <TripProfile>(); cfg.AddProfile <CollisionProfile>(); cfg.AddProfile <ComplaintProfile>(); cfg.AddProfile <NeighborhoodProfile>(); cfg.AddProfile <PatternAreaProfile>(); cfg.AddProfile <StreetSegmentProfile>(); cfg.AddProfile <BicyclePathProfile>(); cfg.AddProfile <GeoJsonProfile>(); }); // use a different container with more features than the default .NET Core one var container = new Container(); container.Options.DefaultScopedLifestyle = new AsyncScopedLifestyle(); container.Register <ScootertownDbContext>(() => { var builder = new DbContextOptionsBuilder <ScootertownDbContext>(); builder.UseNpgsql( context.Configuration.GetConnectionString("postgres"), o => o.UseNetTopologySuite() ); var options = builder.Options; var dbContext = new ScootertownDbContext( options, new VehicleStoreOptions()); return(dbContext); }, Lifestyle.Scoped); container.Register <AreasOfInterest>(() => { var options = new AreasOfInterest { NeighborhoodsFile = Path.Combine( context.HostingEnvironment.ContentRootPath, context.Configuration.GetValue <string>("NeighborhoodsFile") ), PatternAreasFile = Path.Combine( context.HostingEnvironment.ContentRootPath, context.Configuration.GetValue <string>("PatternAreasFile") ), StreetSegmentsFile = Path.Combine( context.HostingEnvironment.ContentRootPath, context.Configuration.GetValue <string>("StreetSegmentsFile") ), BicyclePathsFile = Path.Combine( context.HostingEnvironment.ContentRootPath, context.Configuration.GetValue <string>("BicyclePathsFile") ) }; return(options); }, Lifestyle.Scoped); container.Register <APIOptions>(() => { var options = new APIOptions { BaseAddress = context.Configuration.GetValue <string>("BaseAddress") }; return(options); }, Lifestyle.Scoped); // add generic services for repositories for any geojson we'll read in container.Register <INeighborhoodRepository, NeighborhoodRepository>(Lifestyle.Scoped); container.Register <IPatternAreaRepository, PatternAreaRepository>(Lifestyle.Scoped); container.Register <IStreetSegmentRepository, StreetSegmentRepository>(Lifestyle.Scoped); container.Register <IStreetSegmentGroupRepository, StreetSegmentGroupRepository>(Lifestyle.Scoped); container.Register <IBicyclePathRepository, BicyclePathRepository>(Lifestyle.Scoped); container.Register <IBicyclePathGroupRepository, BicyclePathGroupRepository>(Lifestyle.Scoped); container.Register <ITripService, TripService>(Lifestyle.Scoped); container.Register <IDeploymentService, DeploymentService>(Lifestyle.Scoped); container.Register <ICollisionService, CollisionService>(Lifestyle.Scoped); container.Register <IComplaintService, ComplaintService>(Lifestyle.Scoped); container.Register <INeighborhoodService, NeighborhoodService>(Lifestyle.Scoped); container.Register <IPatternAreaService, PatternAreaService>(Lifestyle.Scoped); container.Register <IStreetSegmentService, StreetSegmentService>(Lifestyle.Scoped); container.Register <IBicyclePathService, BicyclePathService>(Lifestyle.Scoped); container.Register(ConfigureLogger, Lifestyle.Singleton); container.Register(typeof(ILogger <>), typeof(LoggingAdapter <>), Lifestyle.Scoped); container.Register <IMemoryCache>(() => { return(new MemoryCache(new MemoryCacheOptions())); }, Lifestyle.Singleton); container.Verify(); // use the default DI to manage our new container services.AddSingleton(container); services.AddSingleton <ILoggerFactory, LoggerFactory>(); // tell the DI container to start the application services.AddSingleton <IHostedService, Host>(); }) .ConfigureLogging((context, logging) => { logging.AddConfiguration(context.Configuration.GetSection("Logging")); logging.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace); logging.AddNLog(); NLog.LogManager.LoadConfiguration("nlog.config"); }) .ConfigureAppConfiguration((context, builder) => { }); await host.RunConsoleAsync(); }
private void RenderMap() { BmpPlanner.Children.Clear(); if (RenderWeatherConditions) { BmpPlanner.Children.Add(new MapTileLayer() { TileSource = new MSLPTileSource(), Opacity = 1 }); } if (RenderFIRMS) { BmpPlanner.Children.Add(new MapTileLayer() { TileSource = new FIRMSTileSource(), Opacity = 1 }); } MapLayer labelLayer = new MapLayer(); int totalFireCount = 0; if (_draftMapModel != null) { RenderMap(_draftMapModel, labelLayer, null, null); } foreach (var aoi in AreasOfInterest) { RenderMap(aoi.MapModel, labelLayer, null, null); } foreach (var flight in Flights) { totalFireCount += RenderMap(flight.MapModel, labelLayer, "Potential fire", (ControlTemplate)Application.Current.Resources["FirePushPinTemplate"]); } if (RenderRedFlagAlerts) { foreach (var redflag in RedFlagsNotifications) { RenderMap(redflag.MapModel, labelLayer, "Red flag warning", null); } } if (totalFireCount > 0) { var centerPoint = Flights.Where((f) => f.FireDetected).First().MapModel.Marks.First(); BmpPlanner.SetView(new Location(centerPoint.Latitude, centerPoint.Longitude), Math.Max(MAP_ZOOM_LEVEL_AREA, BmpPlanner.ZoomLevel)); FireAlert = Visibility.Visible; AreaIsGood = Visibility.Collapsed; NotifyPropertyChanged("AreaIsGood"); NotifyPropertyChanged("FireAlert"); } else if (Flights.Any()) { var centerPoint = Flights.First().MapModel.Polygons.First().CenterPosition(); BmpPlanner.SetView(new Location(centerPoint.Latitude, centerPoint.Longitude), Math.Max(MAP_ZOOM_LEVEL_AREA, BmpPlanner.ZoomLevel)); AreaIsGood = Visibility.Visible; FireAlert = Visibility.Collapsed; NotifyPropertyChanged("AreaIsGood"); NotifyPropertyChanged("FireAlert"); } else if (AreasOfInterest.Any()) { var centerPoint = AreasOfInterest.First().MapModel.Polygons.First().CenterPosition(); BmpPlanner.SetView(new Location(centerPoint.Latitude, centerPoint.Longitude), Math.Max(MAP_ZOOM_LEVEL_AREA, BmpPlanner.ZoomLevel)); } BmpPlanner.Children.Add(labelLayer); }