コード例 #1
0
        public Bitmap CreateMapAndRouteImage(bool showMap, double zoomValue, SessionCollection sessionsToDraw, WaypointAttribute colorCodingAttribute, WaypointAttribute?secondaryColorCodingAttribute, RouteDrawingMode mode, SessionSettings sessionSettings)
        {
            Bitmap mapImage;

            if (showMap)
            {
                mapImage = CreateMapImage(zoomValue);
            }
            else
            {
                var size = GetMapImageSize(zoomValue);
                mapImage = new Bitmap(size.Width, size.Height, PixelFormat.Format32bppPArgb);
            }

            if (mode == RouteDrawingMode.None)
            {
                return(mapImage);
            }

            var mapAndRouteImage    = new Bitmap(mapImage.Width, mapImage.Height, PixelFormat.Format32bppPArgb);
            var mapAndRouteGraphics = Graphics.FromImage(mapAndRouteImage);

            mapAndRouteGraphics.SmoothingMode = SmoothingMode.AntiAlias;

            DrawRoutes(sessionsToDraw, zoomValue, mapAndRouteGraphics, mapImage, mode, colorCodingAttribute, secondaryColorCodingAttribute, sessionSettings);

            mapAndRouteGraphics.Dispose();
            mapImage.Dispose();
            return(mapAndRouteImage);
        }
コード例 #2
0
ファイル: SessionCollection.cs プロジェクト: gabbe/quickroute
        /// <summary>
        /// Creates a shallow copy.
        /// </summary>
        /// <returns></returns>
        public SessionCollection Copy()
        {
            var copy = new SessionCollection();

            foreach (var s in sessions)
            {
                copy.Add(s);
            }
            return(copy);
        }
コード例 #3
0
 protected Document(SerializationInfo info, StreamingContext context)
 {
     Map              = (Map)(info.GetValue("map", typeof(Map)));
     settings         = (DocumentSettings)(info.GetValue("settings", typeof(DocumentSettings)));
     sessions         = (SessionCollection)(info.GetValue("sessions", typeof(SessionCollection)));
     projectionOrigin = (LongLat)(info.GetValue("projectionOrigin", typeof(LongLat)));
     // todo: how handle non-existing properties field?
     try
     {
         properties = (DocumentProperties)(info.GetValue("properties", typeof(DocumentProperties)));
     }
     catch (Exception)
     { }
 }
コード例 #4
0
        private static SessionCollection ReadSessions(BinaryReader reader)
        {
            var sessions     = new SessionCollection();
            var sessionCount = reader.ReadUInt32();

            for (int i = 0; i < sessionCount; i++)
            {
                var tag       = (Tags)reader.ReadByte();
                var tagLength = Convert.ToInt32(reader.ReadUInt32());
                switch (tag)
                {
                case Tags.Session:
                    sessions.Add(ReadSession(reader, tagLength));
                    break;

                default:
                    reader.BaseStream.Position += tagLength;
                    break;
                }
            }
            return(sessions);
        }
コード例 #5
0
        // todo: skip showRouteLine parameter, use RouteDrawingMode instead
        public Bitmap CreateMapAndRouteImage(bool showRouteLine, double zoomValue, Session sessionToDraw, List <int> legsToDraw, double frameWidth, WaypointAttribute colorCodingAttribute, WaypointAttribute?secondaryColorCodingAttribute, RouteDrawingMode mode, SessionSettings sessionSettings)
        {
            RectangleD frame = GetFrame(zoomValue, sessionToDraw, legsToDraw, frameWidth, colorCodingAttribute, mode);

            var sc = new SessionCollection();

            sc.Add(sessionToDraw);
            var wholeImage = CreateMapAndRouteImage(true, zoomValue, sc, colorCodingAttribute, secondaryColorCodingAttribute, mode, sessionSettings);

            AdjustFrameToImage(frame, wholeImage);

            var croppedImage = new Bitmap(
                Convert.ToInt32(Math.Ceiling(frame.Right) - Math.Floor(frame.Left)),
                Convert.ToInt32(Math.Ceiling(frame.Bottom) - Math.Floor(frame.Top)));
            var croppedImageGraphics = Graphics.FromImage(croppedImage);

            croppedImageGraphics.DrawImage(
                wholeImage,
                -Convert.ToInt32(Math.Floor(frame.Left)),
                -Convert.ToInt32(Math.Floor(frame.Top)));
            croppedImageGraphics.Dispose();
            wholeImage.Dispose();
            return(croppedImage);
        }
コード例 #6
0
        public static QuickRouteJpegExtensionData FromQuickRouteDocument(Document document, SessionCollection sessions, Rectangle imageBounds, Rectangle mapBounds, double percentualSize)
        {
            var data = new QuickRouteJpegExtensionData
            {
                Version = currentVersion,
                ImageCornerPositions       = document.GetImageCornersLongLat(imageBounds, mapBounds, percentualSize),
                MapCornerPositions         = document.GetMapCornersLongLat(),
                MapLocationAndSizeInPixels = mapBounds,
                Sessions       = sessions,
                PercentualSize = percentualSize
            };

            return(data);
        }