public static RectangleShape GetDefaultMaxExtent(GeographyUnit mapUnit) { RectangleShape maxExtent = new RectangleShape(); switch (mapUnit) { case GeographyUnit.DecimalDegree: maxExtent = new RectangleShape(-180, 90, 180, -90); break; case GeographyUnit.Meter: BitmapTileCache meterCache = new FileBitmapTileCache(); meterCache.TileMatrix.BoundingBoxUnit = GeographyUnit.Meter; meterCache.TileMatrix.BoundingBox = new RectangleShape(-1000000000, 1000000000, 1000000000, -1000000000); maxExtent = meterCache.TileMatrix.BoundingBox; break; case GeographyUnit.Feet: BitmapTileCache feetCache = new FileBitmapTileCache(); feetCache.TileMatrix.BoundingBoxUnit = GeographyUnit.Feet; feetCache.TileMatrix.BoundingBox = new RectangleShape(-1000000000, 1000000000, 1000000000, -1000000000); maxExtent = feetCache.TileMatrix.BoundingBox; break; default: break; } return(maxExtent); }
private static Collection <Feature> AscendingSearch(double x, double y, GeographyUnit currentUnit, FeatureLayer featureLayer, double lowerScale, double upperScale) { Collection <Feature> results = null; if (currentUnit == GeographyUnit.DecimalDegree) { if (Math.Round(y, 4) > 90 || Math.Round(y, 4) < -90 || Math.Round(x, 4) > 180 || Math.Round(x, 4) < -180) { return(null); } } for (double i = lowerScale; i < upperScale; i++) { var featuresInDistance = featureLayer.FeatureSource .GetFeaturesWithinDistanceOf(new Feature(x, y), currentUnit, DistanceUnit.Meter, lowerScale, ReturningColumnsType.NoColumns); if (featuresInDistance.Count > 0) { results = featuresInDistance; break; } } return(results); }
private static double GetInchesPreUnit(GeographyUnit targetUnit) { double returnValue = 0; switch (targetUnit) { case GeographyUnit.Unknown: break; case GeographyUnit.DecimalDegree: returnValue = 4374754; break; case GeographyUnit.Feet: returnValue = 12; break; case GeographyUnit.Meter: returnValue = 39.3701; break; default: break; } return(returnValue); }
private void btnSetUnit_Click(object sender, EventArgs e) { switch (comboBox1.Text) { case "Unknown": currentUnit = GeographyUnit.Unknown; break; case "DecimalDegree": currentUnit = GeographyUnit.DecimalDegree; break; case "Feet": currentUnit = GeographyUnit.Feet; break; case "Meter": currentUnit = GeographyUnit.Meter; break; default: break; } Close(); }
private Feature FindFeatureByPoint(double x, double y) { Feature result = null; IEnumerable <FeatureLayer> allFeatureLayers = null; string currentProj4 = String.Empty; if (ParentMap != null) { allFeatureLayers = ParentMap.GetFeatureLayers(true).Reverse(); currentProj4 = ParentMap.DisplayProjectionParameters; } else { allFeatureLayers = new Collection <FeatureLayer>(); } GeographyUnit currentUnit = GeographyUnit.DecimalDegree; if (!string.IsNullOrEmpty(currentProj4)) { currentUnit = GisEditorWpfMap.GetGeographyUnit(currentProj4); } foreach (var featureLayer in allFeatureLayers) { Collection <Feature> featuresInDistance = null; featureLayer.SafeProcess(() => { featuresInDistance = AscendingSearch(x, y, currentUnit, featureLayer, 1, 20); }); //featureLayer.Open(); //var featuresInDistance = AscendingSearch(x, y, currentUnit, featureLayer, 1, 20); //featureLayer.Close(); if (featuresInDistance != null && featuresInDistance.Count > 0) { if (featuresInDistance.Count > 1) { result = featuresInDistance[0]; for (int i = 0; i < featuresInDistance.Count - 1; i++) { result = result.GetIntersection(featuresInDistance[i + 1]); } } else { result = featuresInDistance[0]; } result.Tag = Convert.ToBase64String(result.GetWellKnownBinary()); break; } } return(result); }
public RadiusMearsureTrackInteractiveOverlay(DistanceUnit distanceUnit, GeographyUnit mapUnit) { this.mapUnit = mapUnit; this.distanceUnit = distanceUnit; TrackShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.CreateSimpleCircleStyle(GeoColor.SimpleColors.DarkBlue, 8); TrackShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.SimpleColors.White, 3, true); TrackShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.FromArgb(80, GeoColor.SimpleColors.LightGreen), GeoColor.SimpleColors.White, 2); TrackShapeLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; }
private static double GetInchesByUnit(GeographyUnit unit) { switch (unit) { case GeographyUnit.Feet: return(feetsPerInch); case GeographyUnit.Meter: return(meterPerInch); case GeographyUnit.DecimalDegree: return(decimalDegreePerInch); default: return(double.NaN); } }
public static double GetInchesByUnit(GeographyUnit unit) { switch (unit) { case GeographyUnit.Feet: return(Feet); case GeographyUnit.Meter: return(Meter); case GeographyUnit.DecimalDegree: return(DecimalDegree); default: return(double.NaN); } }
private GeoImage GetCacheImage(PageGeoCanvas pageGeoCanvas, GeographyUnit geographyUnit, RectangleShape adjustedWorldExtent, Collection <SimpleCandidate> labelsInAllLayers, double width, double height) { RectangleShape currentBoundingBox = GetBoundingBox(); if (mapImageCache == null && Layers.Count > 0) { Bitmap bitmap = null; MemoryStream memoryStream = null; try { bitmap = new Bitmap((int)width, (int)height); PlatformGeoCanvas tmpCanvas = new PlatformGeoCanvas(); tmpCanvas.DrawingQuality = DrawingQuality.HighSpeed; tmpCanvas.BeginDrawing(bitmap, currentBoundingBox, geographyUnit); pageGeoCanvas.BeginDrawing(tmpCanvas, adjustedWorldExtent, MapUnit); lock (Layers) { foreach (Layer layer in Layers) { if (!layer.IsOpen) { layer.Open(); } pageGeoCanvas.Flush(); layer.Draw(pageGeoCanvas, labelsInAllLayers); } } pageGeoCanvas.EndDrawing(); tmpCanvas.EndDrawing(); IsDrawing = false; memoryStream = new MemoryStream(); bitmap.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Png); mapImageCache = new GeoImage(memoryStream); } catch (Exception ex) { GisEditor.LoggerManager.Log(LoggerLevel.Debug, ex.Message, new ExceptionInfo(ex)); } finally { bitmap?.Dispose(); } } return(mapImageCache); }
private static RectangleShape CalculateExtent(Point center, double scale, GeographyUnit mapUnit, double mapWidth, double mapHeight) { if (Double.IsNaN(mapWidth) || Double.IsNaN(mapHeight)) { return(null); } double resolution = GetResolutionFromScale(scale, mapUnit); double widthInDegree = mapWidth * resolution; double heightInDegree = mapHeight * resolution; double left = center.X - widthInDegree * .5; double right = center.X + widthInDegree * .5; double top = center.Y + heightInDegree * .5; double bottom = center.Y - heightInDegree * .5; return(new RectangleShape(left, top, right, bottom)); }
public static double GetCellWidthByLevel(RectangleShape extent, GeographyUnit extentMapUnit, int level, DistanceUnit returnDistanceUnit) { PointShape centerPoint = extent.GetCenterPoint(); PointShape centerLeft = new PointShape(extent.LowerLeftPoint.X, centerPoint.Y); PointShape centerRight = new PointShape(extent.UpperRightPoint.X, centerPoint.Y); PointShape centerUpper = new PointShape(centerPoint.X, extent.UpperLeftPoint.Y); PointShape centerLower = new PointShape(centerPoint.X, extent.LowerLeftPoint.Y); double centerWidth = centerLeft.GetDistanceTo(centerRight, extentMapUnit, returnDistanceUnit); double centerHeight = centerUpper.GetDistanceTo(centerLower, extentMapUnit, returnDistanceUnit); double longestEdge = Math.Max(centerWidth, centerHeight); double cellWidth = longestEdge / Math.Sqrt(Math.Pow(4, level - 1)); return(cellWidth); }
public static int GetLevelByCellWidth(RectangleShape extent, GeographyUnit extentMapUnit, double cellWidth, DistanceUnit widthDistanceUnit) { PointShape centerPoint = extent.GetCenterPoint(); PointShape centerLeft = new PointShape(extent.LowerLeftPoint.X, centerPoint.Y); PointShape centerRight = new PointShape(extent.UpperRightPoint.X, centerPoint.Y); PointShape centerUpper = new PointShape(centerPoint.X, extent.UpperLeftPoint.Y); PointShape centerLower = new PointShape(centerPoint.X, extent.LowerLeftPoint.Y); double centerWidth = centerLeft.GetDistanceTo(centerRight, extentMapUnit, widthDistanceUnit); double centerHeight = centerUpper.GetDistanceTo(centerLower, extentMapUnit, widthDistanceUnit); double longestEdge = Math.Max(centerWidth, centerHeight); double level = Math.Round(2 * Math.Log((longestEdge / cellWidth), 4) + 1); return((int)level); }
public RadiusMearsureTrackInteractiveOverlay(DistanceUnit distanceUnit, GeographyUnit mapUnit) { DistanceUnit = distanceUnit; MapUnit = mapUnit; textBlock = new TextBlock(); textBlock.Visibility = Visibility.Collapsed; OverlayCanvas.Children.Add(textBlock); PolygonTrackMode = PolygonTrackMode.LineWithFill; RenderMode = RenderMode.DrawingVisual; areaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.FromArgb(80, GeoColor.SimpleColors.LightGreen), GeoColor.SimpleColors.White, 2); pointStyle = PointStyles.CreateSimpleCircleStyle(GeoColor.SimpleColors.DarkBlue, 8); lineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.SimpleColors.White, 3, true); SetStylesForInMemoryFeatureLayer(TrackShapeLayer); SetStylesForInMemoryFeatureLayer(TrackShapesInProcessLayer); }
public static string GetFormattedWorldCoordinate(this GisEditorWpfMap map, ScreenPointF screenPoint, MouseCoordinateType mouseCoordinateType) { PointShape lonlat = map.ToWorldCoordinate(screenPoint.X, screenPoint.Y); double xInCurrentProjection = lonlat.X; double yInCurrentProjection = lonlat.Y; string projectionFullName = "Unknown"; if (map.DisplayProjectionParameters != null) { string projectionShortName = map.DisplayProjectionParameters.Split(' ')[0].Replace("+proj=", string.Empty); projectionFullName = projectionAbbreviations[projectionShortName]; } GeographyUnit mapUnit = GisEditorWpfMap.GetGeographyUnit(map.DisplayProjectionParameters); if (projectionFullName == "Unknown" && mapUnit == GeographyUnit.Unknown) { return(String.Format("X:{0}, Y:{1}", lonlat.X.ToString("N4", CultureInfo.InvariantCulture), lonlat.Y.ToString("N4", CultureInfo.InvariantCulture))); } else { if (mapUnit != GeographyUnit.DecimalDegree) { try { Proj4Projection proj = new Proj4Projection(); proj.InternalProjectionParametersString = map.DisplayProjectionParameters; proj.ExternalProjectionParametersString = Proj4Projection.GetDecimalDegreesParametersString(); proj.Open(); lonlat = proj.ConvertToExternalProjection(lonlat) as PointShape; proj.Close(); } catch { lonlat = new PointShape(); } } return(GetMouseCoordinates(lonlat.X, lonlat.Y, mouseCoordinateType, map.DisplayProjectionParameters, xInCurrentProjection, yInCurrentProjection)); } }
public void DrawStaticLayers(StringBuilder kmlStringBuilder, GeographyUnit geographyUnit) { LayersDrawingEventArgs layersDrawingEventArgs = new LayersDrawingEventArgs(StaticLayers, CurrentExtent, kmlStringBuilder); OnLayersDrawing(layersDrawingEventArgs); if (!layersDrawingEventArgs.Cancel) { foreach (Layer layer in StaticLayers) { LayerDrawingEventArgs layerDrawingEventArgs = new LayerDrawingEventArgs(layer, CurrentExtent, kmlStringBuilder); OnLayerDrawing(layerDrawingEventArgs); if (!layerDrawingEventArgs.Cancel) { _kmlGeoCanvas.BeginDrawing(kmlStringBuilder, CurrentExtent, geographyUnit); layer.Draw(_kmlGeoCanvas, new Collection <SimpleCandidate>()); } OnLayerDrawn(new LayerDrawnEventArgs(layer, CurrentExtent, kmlStringBuilder)); } } OnLayersDrawn(new LayersDrawnEventArgs(StaticLayers, CurrentExtent, kmlStringBuilder)); _kmlGeoCanvas.EndDrawing(); }
private static double GetInchesPerUnit(GeographyUnit mapUnit) { double inchesPerUnit = 0; switch (mapUnit) { case GeographyUnit.DecimalDegree: inchesPerUnit = 4374754; break; case GeographyUnit.Feet: inchesPerUnit = 12; break; case GeographyUnit.Meter: inchesPerUnit = 39.3701; break; default: break; } return(inchesPerUnit); }
public static double GetCellWidthByLevel(RectangleShape extent, GeographyUnit extentMapUnit, int level, DistanceUnit returnDistanceUnit) { PointShape centerPoint = extent.GetCenterPoint(); PointShape centerLeft = new PointShape(extent.LowerLeftPoint.X, centerPoint.Y); PointShape centerRight = new PointShape(extent.UpperRightPoint.X, centerPoint.Y); PointShape centerUpper = new PointShape(centerPoint.X, extent.UpperLeftPoint.Y); PointShape centerLower = new PointShape(centerPoint.X, extent.LowerLeftPoint.Y); double centerWidth = centerLeft.GetDistanceTo(centerRight, extentMapUnit, returnDistanceUnit); double centerHeight = centerUpper.GetDistanceTo(centerLower, extentMapUnit, returnDistanceUnit); double longestEdge = Math.Max(centerWidth, centerHeight); double cellWidth = longestEdge / Math.Sqrt(Math.Pow(4, level - 1)); return cellWidth; }
internal static int GetSnappedZoomLevelIndex(RectangleShape extent, GeographyUnit mapUnit, Collection <double> zoomLevelScales, double actualWidth, double actualHeight) { double scale = GetScale(mapUnit, extent, actualWidth, actualHeight); return(GetSnappedZoomLevelIndex(scale, zoomLevelScales)); }
public static ContentPresenter GetMapBasicInformation(this GisEditorWpfMap map) { string projectionFullName = "Unknown"; GeographyUnit mapUnit = GeographyUnit.Unknown; if (map.DisplayProjectionParameters != null) { string projectionShortName = map.DisplayProjectionParameters.Split(' ')[0].Replace("+proj=", string.Empty); projectionFullName = projectionAbbreviations[projectionShortName]; mapUnit = GisEditorWpfMap.GetGeographyUnit(map.DisplayProjectionParameters); } double scaleValue = map.CurrentScale; int zoomLevel = map.GetSnappedZoomLevelIndex(scaleValue) + 1; bool isPreciseZoomLevel = map.ZoomLevelSet.GetZoomLevels()[zoomLevel - 1] is PreciseZoomLevel; TextBlock projectionTextBlock = new TextBlock(); projectionTextBlock.SetResourceReference(TextBlock.TextProperty, "MapExtensionProjectionText"); TextBlock projectionValueTextBlock = new TextBlock(); projectionValueTextBlock.Text = string.Format(" {0} | ", projectionFullName); TextBlock mapUnitTextBlock = new TextBlock(); mapUnitTextBlock.SetResourceReference(TextBlock.TextProperty, "MapExtensionMapUnitText"); TextBlock mapUnitValueTextBlock = new TextBlock(); mapUnitValueTextBlock.Text = string.Format(" {0} | ", mapUnit); TextBlock zoomLevelTextBlock = new TextBlock(); zoomLevelTextBlock.SetResourceReference(TextBlock.TextProperty, "MapExtensionZoomLevelText"); TextBlock zoomLevelValueTextBlock = new TextBlock(); if (isPreciseZoomLevel) { zoomLevelValueTextBlock.Text = string.Format(" Temporary Zoom Level | "); } else { zoomLevelValueTextBlock.Text = string.Format(" {0:D2} | ", zoomLevel); } TextBlock scaleTextBlock = new TextBlock(); scaleTextBlock.SetResourceReference(TextBlock.TextProperty, "MapExtensionScaleText"); TextBlock scaleValueTextBlock = new TextBlock(); scaleValueTextBlock.Text = string.Format(" 1:{0:N0}", scaleValue); StackPanel mapInformationStackPanel = new StackPanel(); mapInformationStackPanel.Orientation = Orientation.Horizontal; mapInformationStackPanel.Children.Add(projectionTextBlock); mapInformationStackPanel.Children.Add(projectionValueTextBlock); mapInformationStackPanel.Children.Add(mapUnitTextBlock); mapInformationStackPanel.Children.Add(mapUnitValueTextBlock); mapInformationStackPanel.Children.Add(zoomLevelTextBlock); mapInformationStackPanel.Children.Add(zoomLevelValueTextBlock); mapInformationStackPanel.Children.Add(scaleTextBlock); mapInformationStackPanel.Children.Add(scaleValueTextBlock); ContentPresenter contentPresenter = new ContentPresenter(); contentPresenter.Content = mapInformationStackPanel; return(contentPresenter); }
private static double GetScale(GeographyUnit mapUnit, RectangleShape boundingBox, double widthInPixel, double heightInPixel) { double resolution = GetResolution(boundingBox, widthInPixel, heightInPixel); return(GetScaleFromResolution(resolution, mapUnit)); }
protected static double GetResolutionFromScale(double scale, GeographyUnit mapUnit) { double resolution = scale / (GetInchesPerUnit(mapUnit) * 96); return(resolution); }
public static RectangleShape CalculateExtent(PointShape center, double scale, GeographyUnit mapUnit, double mapWidth, double mapHeight) { return(CalculateExtent(new Point(center.X, center.Y), scale, mapUnit, mapWidth, mapHeight)); }
private static double GetScaleFromResolution(double resolution, GeographyUnit unit) { return(resolution * (GetInchesByUnit(unit) * dotsPerInch)); }
private static double GetResolutionFromScale(double scale, GeographyUnit unit) { return(scale / (GetInchesByUnit(unit) * dotsPerInch)); }
protected override void BeginDrawingCore(object nativeImage, RectangleShape worldExtent, GeographyUnit drawingMapUnit) { //Sets the parameters to get the page to screen coordinates conversion properly on the canvas. canvas = (GeoCanvas)nativeImage; this.CurrentWorldExtent = worldExtent; this.pageBaseUnitToPageUnitRatio = PrinterHelper.GetPointsPerGeographyUnit(canvas.MapUnit); this.Width = (float)((pageBoundingBox.Width)); this.Height = (float)((pageBoundingBox.Height)); X1 = pageBoundingBox.LowerLeftPoint.X; X2 = pageBoundingBox.UpperRightPoint.X; Y1 = pageBoundingBox.UpperRightPoint.Y; Y2 = pageBoundingBox.LowerLeftPoint.Y; Xp1 = ExtentHelper.ToScreenCoordinate(canvas.CurrentWorldExtent, printBoundingBox.UpperLeftPoint, (float)canvas.Width, (float)canvas.Height).X; Xp2 = ExtentHelper.ToScreenCoordinate(canvas.CurrentWorldExtent, printBoundingBox.LowerRightPoint, (float)canvas.Width, (float)canvas.Height).X; Yp1 = ExtentHelper.ToScreenCoordinate(canvas.CurrentWorldExtent, printBoundingBox.LowerRightPoint, (float)canvas.Width, (float)canvas.Height).Y; Yp2 = ExtentHelper.ToScreenCoordinate(canvas.CurrentWorldExtent, printBoundingBox.UpperLeftPoint, (float)canvas.Width, (float)canvas.Height).Y; }
public BufferAccessibleAreaAnalyst(PointShape startLocation, GeographyUnit geographyUnit) : this(startLocation, geographyUnit, 2, DistanceUnit.Mile) { }
protected override void BeginDrawingCore(object nativeImage, RectangleShape worldExtent, GeographyUnit unit) { kmlBuilder = (StringBuilder)nativeImage; virtualWorldExtent = worldExtent; extrudeString = Extrude ? @"<extrude>1</extrude>" : ""; tessellateString = Tessellate ? @"<tessellate>1</tessellate>" : ""; switch (AltitudeMode) { case AltitudeMode.Absolute: altitudeModeString = "<altitudeMode>absolute</altitudeMode>"; break; case AltitudeMode.RelativeToGround: altitudeModeString = "<altitudeMode>relativeToGround</altitudeMode>"; break; default: break; } kmlBuilder.AppendLine(@"<?xml version=""1.0"" encoding=""UTF-8""?>"); kmlBuilder.AppendLine(@"<kml xmlns=""http://www.opengis.net/kml/2.2"">"); kmlBuilder.AppendLine(@"<Document>"); }
public BufferAccessibleAreaAnalyst(PointShape startLocation, GeographyUnit geographyUnit, int distance, DistanceUnit distanceUnit) : base(startLocation, geographyUnit) { this.Distance = distance; this.DistanceUnit = distanceUnit; }
public RouteAccessibleAreaAnalyst(PointShape startLocation, GeographyUnit geographyUnit, int drivingTimeInMinutes) : base(startLocation, geographyUnit) { this.drivingTimeInMinutes = drivingTimeInMinutes; }
public static int GetLevelByCellWidth(RectangleShape extent, GeographyUnit extentMapUnit, double cellWidth, DistanceUnit widthDistanceUnit) { PointShape centerPoint = extent.GetCenterPoint(); PointShape centerLeft = new PointShape(extent.LowerLeftPoint.X, centerPoint.Y); PointShape centerRight = new PointShape(extent.UpperRightPoint.X, centerPoint.Y); PointShape centerUpper = new PointShape(centerPoint.X, extent.UpperLeftPoint.Y); PointShape centerLower = new PointShape(centerPoint.X, extent.LowerLeftPoint.Y); double centerWidth = centerLeft.GetDistanceTo(centerRight, extentMapUnit, widthDistanceUnit); double centerHeight = centerUpper.GetDistanceTo(centerLower, extentMapUnit, widthDistanceUnit); double longestEdge = Math.Max(centerWidth, centerHeight); double level = Math.Round(2 * Math.Log((longestEdge / cellWidth), 4) + 1); return (int)level; }
protected AccessibleAreaAnalyst(PointShape startLocation, GeographyUnit geographyUnit) { this.startLocation = startLocation; this.geographyUnit = geographyUnit; }
public RouteAccessibleAreaAnalyst(PointShape startLocation, GeographyUnit geographyUnit) : this(startLocation, geographyUnit, 6) { }