void ExpandOverlayHandler() { try { var vm = new OverlayExpandViewModel(RangeComplexes.SelectedRangeComplex, RangeComplexes.SelectedArea); var result = ESME.Globals.VisualizerService.ShowDialog("OverlayExpandView", vm); if ((!result.HasValue) || (!result.Value)) return; var curOverlay = RangeComplexes.SelectedArea.OverlayShape; var limits = new Limits(ConvexHull.Create(curOverlay.Geos, true)); var expandedLimits = limits.CreateExpandedLimit(vm.BufferSize); //in km. var coordinateList = expandedLimits.Geos; var testShape = new OverlayLineSegments(coordinateList, Colors.Black); if (!testShape.IsUsableAsPerimeter) coordinateList = ConvexHull.Create(coordinateList, true); RangeComplexes.SelectedArea = RangeComplexes.SelectedRangeComplex.CreateArea(vm.OverlayName, coordinateList); } catch (Exception e) { ESME.Globals.MessageBoxService.ShowError(e.Message); } }
void ExpandOverlayHandler() { var originalBufferSize = 0f; if (!string.IsNullOrEmpty(SelectedOverlayDescriptor.Metadata.OverlayFilename)) { originalBufferSize = SelectedOverlayDescriptor.Metadata.BufferZoneSize; SelectedOverlayDescriptor = (NAEMOOverlayDescriptor)NAEMOOverlayDescriptors[SelectedOverlayDescriptor.Metadata.OverlayFilename]; } if (!IsOverlayFileSelected) return; var vm = new OverlayExpandViewModel(SelectedOverlayDescriptor.Metadata) {BufferSize = originalBufferSize}; var result = _visualizerService.ShowDialog("OverlayExpandView", vm); if ((!result.HasValue) || (!result.Value)) return; var curOverlay = SelectedOverlayDescriptor.Data; //var limits = (Limits)(new GeoRect(curOverlay.Shapes[0].EarthCoordinates)); var limits = new Limits(ConvexHull.Create(curOverlay.Shapes[0].EarthCoordinates, true)); var expandedLimits = limits.CreateExpandedLimit(vm.BufferSize); //in km. var boundingBox = new GeoRect(expandedLimits.GeoPointList); var coordinateList = expandedLimits.GeoPointList.Select(geo => new EarthCoordinate(geo)).ToList(); var testShape = new OverlayLineSegments(coordinateList.ToArray(), Colors.Black); if (!testShape.IsUsableAsPerimeter) coordinateList = ConvexHull.Create(coordinateList, true); NAEMOOverlayDescriptors.CreateNewOverlay(SelectedRangeComplexDescriptor.Data.Name, vm.OverlayName, coordinateList, boundingBox, vm.BufferSize, Path.GetFileNameWithoutExtension(SelectedOverlayDescriptor.DataFilename)); SelectedOverlayDescriptor = (NAEMOOverlayDescriptor)NAEMOOverlayDescriptors[vm.OverlayName]; }