protected override RectangleShape GetBoundingBoxCore() { RectangleShape boundingBox = null; if (!LoadingFromShapeFile) { if (firstInputFeatureLayer.InternalFeatures.Count > 0) { firstInputFeatureLayer.Open(); boundingBox = firstInputFeatureLayer.GetBoundingBox(); } if (secondInputFeatureLayer.InternalFeatures.Count > 0) { secondInputFeatureLayer.Open(); if (boundingBox != null) { boundingBox.ExpandToInclude(secondInputFeatureLayer.GetBoundingBox()); } else { boundingBox = secondInputFeatureLayer.GetBoundingBox(); } } } else { if (!string.IsNullOrEmpty(firstShapeFilePathName)) { ShapeFileFeatureLayer coveredShapeFileFeatureLayer = new ShapeFileFeatureLayer(firstShapeFilePathName); coveredShapeFileFeatureLayer.Open(); boundingBox = coveredShapeFileFeatureLayer.GetBoundingBox(); coveredShapeFileFeatureLayer.Close(); } if (!string.IsNullOrEmpty(secondShapeFilePathName)) { ShapeFileFeatureLayer coveringShapeFileFeatureLayer = new ShapeFileFeatureLayer(secondShapeFilePathName); coveringShapeFileFeatureLayer.Open(); if (boundingBox == null) { boundingBox = coveringShapeFileFeatureLayer.GetBoundingBox(); } else { boundingBox.ExpandToInclude(coveringShapeFileFeatureLayer.GetBoundingBox()); } coveringShapeFileFeatureLayer.Close(); } } return(boundingBox); }
private RectangleShape GetFullExtent(float screenWidth, float screenHeight) { RectangleShape boundingBox = null; foreach (Layer layer in ((LayerOverlay)winformsMap1.Overlays[0]).Layers) { if (layer.HasBoundingBox) { if (!layer.IsOpen) { layer.Open(); } if (boundingBox == null) { boundingBox = layer.GetBoundingBox(); } else { boundingBox.ExpandToInclude(layer.GetBoundingBox()); } } } if (boundingBox != null) { boundingBox = MapEngine.GetDrawingExtent(boundingBox, screenWidth, screenHeight); } return(boundingBox); }
private void HandleUnloadChartMessage(ChartMessage message) { if (message.Charts != null) { if (map.Overlays.Contains(chartsOverlayName)) { LayerOverlay overlay = ((LayerOverlay)map.Overlays[chartsOverlayName]); foreach (ChartItem item in message.Charts) { for (int i = overlay.Layers.Count - 1; i >= 0; i--) { Layer layer = overlay.Layers[i]; if (item.FileName == layer.Name) { overlay.Layers.Remove(layer); boundingBoxPreviewLayer.InternalFeatures.Remove(layer.GetHashCode().ToString()); break; } } if (ChartSelectedItem != null && ChartSelectedItem.FullName == item.FileName) { ChartSelectedItem = new ChartSelectedItem(string.Empty, null); } } RectangleShape boundingBox = null; foreach (Layer layer in overlay.Layers) { layer.Open(); if (boundingBox == null) { boundingBox = layer.GetBoundingBox(); } else { boundingBox.ExpandToInclude(layer.GetBoundingBox()); } layer.Close(); } if (boundingBox != null) { map.CurrentExtent = boundingBox; } map.Refresh(); } } }
public RectangleShape GetBoundingBoxByIds(Collection <string> ids) { RectangleShape resultRectangleShape = null; if (ids.Count > 0) { resultRectangleShape = featureSource.GetBoundingBoxById(ids[0]); for (int i = 1; i < ids.Count; i++) { RectangleShape currentRectangleShape = featureSource.GetBoundingBoxById(ids[i]); resultRectangleShape.ExpandToInclude(currentRectangleShape); } } return(resultRectangleShape); }
private RectangleShape GetAnnotationsRect() { if (annotations.Count < 1) { return(null); } RectangleShape rect = annotations[0].Position.GetBoundingBox(); for (int i = 1; i < annotations.Count; i++) { rect.ExpandToInclude(annotations[i].Position); } rect.Id = Id; return(rect); }
private void HandleLoadChartMessage(ChartMessage message) { LayerOverlay overlay = null; if (message.Charts != null) { if (map.Overlays.Contains(chartsOverlayName)) { overlay = ((LayerOverlay)map.Overlays[chartsOverlayName]); } else { overlay = new LayerOverlay() { TileType = TileType.SingleTile, }; map.Overlays.Insert(1, chartsOverlayName, overlay); } overlay.Layers.Clear(); ChartSelectedItem = new ChartSelectedItem(string.Empty, null); IEnumerable <ChartItem> charts = message.Charts; RectangleShape boundingBox = null; foreach (ChartItem item in charts) { if (!File.Exists(item.IndexFileName)) { NauticalChartsFeatureSource.BuildIndexFile(item.FileName, BuildIndexMode.DoNotRebuild); } NauticalChartsFeatureLayer layer = new NauticalChartsFeatureLayer(item.FileName); if (map.MapUnit == GeographyUnit.Meter) { layer.FeatureSource.Projection = new Proj4Projection(4326, 3857); } layer.DrawingFeatures += hydrographyLayer_DrawingFeatures; layer.IsDepthContourTextVisible = Globals.IsDepthContourTextVisible; layer.IsLightDescriptionVisible = Globals.IsLightDescriptionVisible; layer.IsSoundingTextVisible = Globals.IsSoundingTextVisible; layer.SymbolTextDisplayMode = Globals.SymbolTextDisplayMode; layer.DisplayCategory = Globals.DisplayMode; layer.DefaultColorSchema = Globals.CurrentColorSchema; layer.SymbolDisplayMode = Globals.CurrentSymbolDisplayMode; layer.BoundaryDisplayMode = Globals.CurrentBoundaryDisplayMode; layer.SafetyDepthInMeter = NauticalChartsFeatureLayer.ConvertDistanceToMeters(Globals.SafetyDepth, Globals.CurrentDepthUnit); layer.ShallowDepthInMeter = NauticalChartsFeatureLayer.ConvertDistanceToMeters(Globals.ShallowDepth, Globals.CurrentDepthUnit); layer.DeepDepthInMeter = NauticalChartsFeatureLayer.ConvertDistanceToMeters(Globals.DeepDepth, Globals.CurrentDepthUnit); layer.SafetyContourDepthInMeter = NauticalChartsFeatureLayer.ConvertDistanceToMeters(Globals.SafetyContour, Globals.CurrentDepthUnit); layer.DrawingMode = Globals.CurrentDrawingMode; layer.IsFullLightLineVisible = Globals.IsFullLightLineVisible; layer.IsMetaObjectsVisible = Globals.IsMetaObjectsVisible; layer.Name = item.FileName; layer.Open(); if (boundingBox == null) { boundingBox = layer.GetBoundingBox(); } else { boundingBox.ExpandToInclude(layer.GetBoundingBox()); } boundingBoxPreviewLayer.InternalFeatures.Add(layer.GetHashCode().ToString(), new Feature(layer.GetBoundingBox())); layer.Close(); overlay.Layers.Add(item.FileName, layer); } if (boundingBox != null) { map.CurrentExtent = boundingBox; } //SetupAnimationForOverlay(overlay); ApplyOverlayOpacity(); map.Refresh(); } }