public BitmapSource CreateOSMPictureWithOverLoadsViaKachel(MapKachel RootKachel, List<Marker> MarkersToOverlay, DrawMarkerEvent DrawMarkerHandler, GraphicSize RequestedGraphicSize) { GeometryInfo GeoInfo = new GeometryInfo(); //MapBasics.Instance.DrawMarkerHandler = DrawMarkerHandler; CalcGeometry(GeoInfo, RootKachel.MapBitmapImage.Width, RootKachel.MapBitmapImage.Height, RootKachel.GeographicalTopLeft.X, RootKachel.GeographicalTopLeft.Y, RootKachel.GeographicalBottomRight.X, RootKachel.GeographicalBottomRight.Y, RequestedGraphicSize); List<DrawAbleTrack> Tracks = new List<DrawAbleTrack>(); LoadTracks(MapDataWrapper.Instance.GetAllTracks("OrtsTeil"), "OrtsTeil", Tracks, new Pen(Brushes.Blue, 4)); LoadTracks(MapDataWrapper.Instance.GetAllTracks("Bezirk"), "Bezirk", Tracks, new Pen(Brushes.Red, 7)); MarkersToOverlay.AddRange(GetOrtsTeilDescriptionMarker(RootKachel)); return CreateOSMPictureWithOverLoadsViaGeometryInfo(GeoInfo, Tracks, MarkersToOverlay, DrawMarkerHandler); }
public BitmapSource CreateOSMPictureWithOverLoadsViaMeasurement (double WestLonToDrawInDegree, double NorthLatToDrawInDegree, double EastLonToDrawInDegree, double SouthLatToDrawInDegree, int Width, int Height, GraphicSize RequestedGraphicSize) { GeometryInfo GeoInfo = new GeometryInfo(); CalcGeometry(GeoInfo, Width, Height, WestLonToDrawInDegree, NorthLatToDrawInDegree, EastLonToDrawInDegree, SouthLatToDrawInDegree, RequestedGraphicSize); List<DrawAbleTrack> TrackList = new List<DrawAbleTrack>(); LoadTracks(MapDataWrapper.Instance.GetAllTracks("OrtsTeil"), "OrtsTeil", TrackList, new Pen(Brushes.Blue, 3)); LoadTracks(MapDataWrapper.Instance.GetAllTracks("Bezirk"), "Bezirk", TrackList, new Pen(Brushes.Red, 5)); return CreateOSMPictureWithOverLoadsViaGeometryInfo(GeoInfo, TrackList); }
public void CalcGeometry(GeometryInfo GeoInfo, double DrawingWidthInPixel, double DrawingHeightInPixel, double WestLonToDrawInDegree, double NorthLatToDrawInDegree, double EastLonToDrawInDegree, double SouthLatToDrawInDegree, GraphicSize RequestedGraphicSize) { switch (RequestedGraphicSize) { case GraphicSize.A3: DrawingWidthInPixel *= 1.5; DrawingHeightInPixel *= 1.5; break; case GraphicSize.A2: DrawingWidthInPixel *= 1.8; DrawingHeightInPixel *= 1.8; break; case GraphicSize.A4: case GraphicSize.Free: break; default: break; } double CenterLonToDrawInDegree = (WestLonToDrawInDegree + EastLonToDrawInDegree)/2; double CenterLatToDrawInDegree = (NorthLatToDrawInDegree + SouthLatToDrawInDegree)/2; double WestEastDistanceInDegrees = EastLonToDrawInDegree - WestLonToDrawInDegree; double SouthNorthDistanceInDegrees = NorthLatToDrawInDegree - SouthLatToDrawInDegree; double WestEastDistanceInMeter = CalculateDistanceFromGeoPoints (CenterLatToDrawInDegree, EastLonToDrawInDegree, CenterLatToDrawInDegree, WestLonToDrawInDegree); double SouthNorthDistanceInMeter = CalculateDistanceFromGeoPoints (CenterLonToDrawInDegree, NorthLatToDrawInDegree, CenterLonToDrawInDegree, SouthLatToDrawInDegree); double WidthScaleToDraw = WestEastDistanceInDegrees/DrawingWidthInPixel; //Basics.XDPIFactor); double HeightScaleToDraw = SouthNorthDistanceInDegrees/DrawingHeightInPixel; //Basics.YDPIFactor); double ScaleToDraw = 0; double TargetAspectRatio = DrawingWidthInPixel/DrawingHeightInPixel; double SourceAspectRatio = WestEastDistanceInMeter/SouthNorthDistanceInMeter; if (TargetAspectRatio < SourceAspectRatio) ScaleToDraw = WidthScaleToDraw; else { double CalculatedWestEastDistanceInMeter = SouthNorthDistanceInMeter*TargetAspectRatio; double CalculatedWestEastDistanceInDegrees = WestEastDistanceInDegrees / (WestEastDistanceInMeter/CalculatedWestEastDistanceInMeter); ScaleToDraw = CalculatedWestEastDistanceInDegrees/DrawingWidthInPixel; } //ScaleToDraw = 0.00009; CalcGeometry(GeoInfo, DrawingWidthInPixel, DrawingHeightInPixel, CenterLonToDrawInDegree, CenterLatToDrawInDegree, ScaleToDraw); }