예제 #1
0
        private PointF ConvertLatLngToPoint(LatLng latLng, BackgroundImage backgroundImage)
        {
            var x = (float)((GetXTile(latLng.Lng, backgroundImage.N) - backgroundImage.TopLeft.X) * TARGET_TILE_SIZE_X / backgroundImage.Tiles.X);
            var y = (float)((GetYTile(latLng.Lat, backgroundImage.N) - backgroundImage.TopLeft.Y) * TARGET_TILE_SIZE_Y / backgroundImage.Tiles.Y);

            return(new PointF(x, y));
        }
예제 #2
0
 private void DrawRoutesOnImage(BackgroundImage backgroundImage, DataContainer dataContainer)
 {
     using (var graphics = Graphics.FromImage(backgroundImage.Image))
     {
         var routeColorIndex = 0;
         // HM TODO: add markers?
         foreach (var route in dataContainer.routes)
         {
             var points = route.segments.SelectMany(s => s.latlngs).Select(l => ConvertLatLngToPoint(l, backgroundImage)).ToArray();
             if (!points.Any())
             {
                 continue;
             }
             var lineColor = _routeColors[routeColorIndex++];
             routeColorIndex = routeColorIndex % _routeColors.Length;
             if (!string.IsNullOrEmpty(route.color))
             {
                 lineColor = ColorTranslator.FromHtml(route.color);
             }
             graphics.DrawLines(_outLinerPen, points);
             var linePen = new Pen(lineColor, PEN_WIDTH)
             {
                 LineJoin = LineJoin.Bevel
             };
             graphics.DrawLines(linePen, points);
             graphics.FillEllipse(_circleFillBrush, points.First().X - CIRCLE_SIZE_X / 2, points.First().Y - CIRCLE_SIZE_Y / 2, CIRCLE_SIZE_X, CIRCLE_SIZE_Y);
             graphics.DrawEllipse(_startRoutePen, points.First().X - CIRCLE_SIZE_X / 2, points.First().Y - CIRCLE_SIZE_Y / 2, CIRCLE_SIZE_X, CIRCLE_SIZE_Y);
             graphics.FillEllipse(_circleFillBrush, points.Last().X - CIRCLE_SIZE_X / 2, points.Last().Y - CIRCLE_SIZE_Y / 2, CIRCLE_SIZE_X, CIRCLE_SIZE_Y);
             graphics.DrawEllipse(_endRoutePen, points.Last().X - CIRCLE_SIZE_X / 2, points.Last().Y - CIRCLE_SIZE_Y / 2, CIRCLE_SIZE_X, CIRCLE_SIZE_Y);
         }
     }
 }
예제 #3
0
 private void DrawRoutesOnImage(BackgroundImage backgroundImage, DataContainer dataContainer)
 {
     using (var graphics = Graphics.FromImage(backgroundImage.Image))
     {
         var routeColorIndex = 0;
         foreach (var route in dataContainer.Routes)
         {
             var points       = route.Segments.SelectMany(s => s.Latlngs).Select(l => ConvertLatLngToPoint(l, backgroundImage)).ToArray();
             var markerPoints = route.Markers.Select(m => ConvertLatLngToPoint(m.Latlng, backgroundImage));
             var lineColor    = _routeColors[routeColorIndex++];
             routeColorIndex = routeColorIndex % _routeColors.Length;
             if (!string.IsNullOrEmpty(route.Color))
             {
                 lineColor = FromColorString(route.Color, route.Opacity);
             }
             var linePen = new Pen(lineColor, PEN_WIDTH)
             {
                 LineJoin = LineJoin.Bevel
             };
             if (points.Any())
             {
                 graphics.DrawLines(_outLinerPen, points);
                 graphics.DrawLines(linePen, points);
                 graphics.FillEllipse(_circleFillBrush, points.First().X - CIRCLE_SIZE_X / 2, points.First().Y - CIRCLE_SIZE_Y / 2, CIRCLE_SIZE_X, CIRCLE_SIZE_Y);
                 graphics.DrawEllipse(_startRoutePen, points.First().X - CIRCLE_SIZE_X / 2, points.First().Y - CIRCLE_SIZE_Y / 2, CIRCLE_SIZE_X, CIRCLE_SIZE_Y);
                 graphics.FillEllipse(_circleFillBrush, points.Last().X - CIRCLE_SIZE_X / 2, points.Last().Y - CIRCLE_SIZE_Y / 2, CIRCLE_SIZE_X, CIRCLE_SIZE_Y);
                 graphics.DrawEllipse(_endRoutePen, points.Last().X - CIRCLE_SIZE_X / 2, points.Last().Y - CIRCLE_SIZE_Y / 2, CIRCLE_SIZE_X, CIRCLE_SIZE_Y);
             }
             foreach (var markerPoint in markerPoints)
             {
                 graphics.FillEllipse(_circleFillBrush, markerPoint.X - CIRCLE_SIZE_X / 2, markerPoint.Y - CIRCLE_SIZE_Y / 2, CIRCLE_SIZE_X, CIRCLE_SIZE_Y);
                 graphics.DrawEllipse(linePen, markerPoint.X - CIRCLE_SIZE_X / 2, markerPoint.Y - CIRCLE_SIZE_Y / 2, CIRCLE_SIZE_X, CIRCLE_SIZE_Y);
             }
         }
     }
 }
예제 #4
0
 private PointF ConvertLatLngZToPoint(LatLngZ latLng, BackgroundImage backgroundImage)
 {
     var x = (float)((GetXTile(latLng.lng, backgroundImage.N) - backgroundImage.TopLeft.X) * TARGET_TILE_SIZE_X / backgroundImage.Tiles.X);
     var y = (float)((GetYTile(latLng.lat, backgroundImage.N) - backgroundImage.TopLeft.Y) * TARGET_TILE_SIZE_Y / backgroundImage.Tiles.Y);
     return new PointF(x, y);
 }