////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 21JUN2009  James Shen                 	          Initial Creation
        ////////////////////////////////////////////////////////////////////////////
        /**
         * draw a map object.
         * @param mapObject the map object to be drawing.
         * @param drawBoundary the drawing boundry.
         * @param zoomLevel the current zoomLevel.
         */
        public override void DrawMapObject(MapObject mapObject, GeoLatLngBounds drawBoundary,
                int zoomLevel)
        {
            GeoLatLng drawPt = new GeoLatLng();
            _sutherlandHodgman = new SutherlandHodgman(drawBoundary);
            _mapZoomLevel = zoomLevel;
            _mapCenterPt.X = drawBoundary.GetCenterX();
            _mapCenterPt.Y = drawBoundary.GetCenterY();
            bool pointFound = false;
            switch (mapObject.GetMapObjectType())
            {
                case MapObject.NONE:
                    break;
                case MapObject.POINT:
                    {
                        MapPoint mapPoint = (MapPoint)mapObject;
                        DrawPoint(mapPoint);
                        drawPt.X = mapPoint.Point.X;
                        drawPt.Y = mapPoint.Point.Y;
                        pointFound = true;
                    }
                    break;
                case MapObject.MULTIPOINT:
                    {
                        MapMultiPoint mapMultiPoint = (MapMultiPoint)mapObject;
                        for (int i = 0; i < mapMultiPoint.Points.Length; i++)
                        {
                            MapPoint mapPoint = new MapPoint
                                                    {
                                                        SymbolType = mapMultiPoint.SymbolType,
                                                        Point = new GeoLatLng(mapMultiPoint.Points[i])
                                                    };
                            DrawPoint(mapPoint);
                        }
                        for (int i = 0; i < mapMultiPoint.Points.Length; i++)
                        {
                            if (drawBoundary.Contains(mapMultiPoint.Points[i]))
                            {
                                drawPt.X = mapMultiPoint.Points[i].X;
                                drawPt.Y = mapMultiPoint.Points[i].Y;
                                pointFound = true;
                                break;
                            }
                        }

                    }
                    break;
                case MapObject.PLINE:
                    {
                        MapPline mapPline = (MapPline)mapObject;
                        DrawPline(mapPline.PenStyle, mapPline.Pline);
                        for (int i = 0; i < mapPline.Pline.GetVertexCount(); i++)
                        {
                            if (drawBoundary.Contains(mapPline.Pline.GetVertex(i)))
                            {
                                drawPt.X = mapPline.Pline.GetVertex(i).X;
                                drawPt.Y = mapPline.Pline.GetVertex(i).Y;
                                pointFound = true;
                                break;
                            }
                        }
                    }
                    break;
                case MapObject.MULTIPLINE:
                    {
                        MapMultiPline mapMultiPline = (MapMultiPline)mapObject;
                        for (int i = 0; i < mapMultiPline.Plines.Length; i++)
                        {
                            DrawPline(mapMultiPline.PenStyle,
                                    mapMultiPline.Plines[i]);
                            for (int j = 0; j < mapMultiPline.Plines[i].GetVertexCount(); j++)
                            {
                                if (drawBoundary.Contains(mapMultiPline.Plines[i].GetVertex(j)))
                                {
                                    drawPt.X = mapMultiPline.Plines[i].GetVertex(j).X;
                                    drawPt.Y = mapMultiPline.Plines[i].GetVertex(j).Y;
                                    pointFound = true;
                                    break;
                                }
                            }
                        }
                    }
                    break;
                case MapObject.REGION:
                    {
                        MapRegion mapRegion = (MapRegion)mapObject;
                        DrawRegion(mapRegion.PenStyle, mapRegion.BrushStyle,
                                mapRegion.Region);
                        drawPt.X = mapRegion.CenterPt.X;
                        drawPt.Y = mapRegion.CenterPt.Y;
                        pointFound = true;
                    }
                    break;
                case MapObject.MULTIREGION:
                    {
                        MapMultiRegion mapMultiRegion = (MapMultiRegion)mapObject;
                        for (int i = 0; i < mapMultiRegion.Regions.Length; i++)
                        {
                            DrawRegion(mapMultiRegion.PenStyle,
                                    mapMultiRegion.BrushStyle,
                                    mapMultiRegion.Regions[i]);

                        }
                        drawPt.X = mapMultiRegion.CenterPt.X;
                        drawPt.Y = mapMultiRegion.CenterPt.Y;
                        pointFound = true;
                    }
                    break;
                case MapObject.COLLECTION:
                    {
                        MapCollection mapCollection = (MapCollection)mapObject;
                        if (mapCollection.MultiRegion != null)
                        {
                            MapMultiRegion mapMultiRegion = mapCollection.MultiRegion;
                            for (int i = 0; i < mapMultiRegion.Regions.Length; i++)
                            {
                                DrawRegion(mapMultiRegion.PenStyle,
                                        mapMultiRegion.BrushStyle,
                                        mapMultiRegion.Regions[i]);
                            }
                        }
                        if (mapCollection.MultiPline != null)
                        {
                            MapMultiPline mapMultiPline = mapCollection.MultiPline;
                            for (int i = 0; i < mapMultiPline.Plines.Length; i++)
                            {
                                DrawPline(mapMultiPline.PenStyle,
                                        mapMultiPline.Plines[i]);
                            }
                        }
                        if (mapCollection.MultiPoint != null)
                        {
                            MapMultiPoint mapMultiPoint = mapCollection.MultiPoint;
                            for (int i = 0; i < mapMultiPoint.Points.Length; i++)
                            {
                                MapPoint mapPoint = new MapPoint
                                                        {
                                                            SymbolType = mapMultiPoint.SymbolType,
                                                            Point = new GeoLatLng(mapMultiPoint.Points[i])
                                                        };
                                DrawPoint(mapPoint);
                            }
                        }
                        pointFound = true;
                        drawPt.X = mapCollection.Bounds.X + mapCollection.Bounds.Width / 2;
                        drawPt.Y = mapCollection.Bounds.Y + mapCollection.Bounds.Height / 2;

                    }
                    break;
                case MapObject.TEXT:
                    {
                        MapText mapText = (MapText)mapObject;
                        drawPt.X = mapText.Point.X;
                        drawPt.Y = mapText.Point.Y;
                        pointFound = true;
                    }
                    break;
            }
            if (!mapObject.Name.ToLower().Equals("unknown") && pointFound)
            {
                MapText mapName = new MapText {Font = _font};
                mapName.SetForeColor(_fontColor);
                mapName.TextString = mapObject.Name;
                GeoPoint screenPt = FromLatLngToMapPixel(drawPt);
                mapName.Point.X = screenPt.X;
                mapName.Point.Y = screenPt.Y;
                mapName.Bounds.X = mapName.Point.X;
                mapName.Bounds.Y = mapName.Point.Y;
                if (_font != null)
                {
                    mapName.Bounds.Height = IMAGE_PATERN_WIDTH;
                    mapName.Bounds.Width = _font.CharsWidth(mapObject.Name.ToCharArray(), 0,
                            mapObject.Name.ToCharArray().Length);

                }
                AddMapName(mapName);

            }
        }
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 21JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * draw a map object.
         * @param mapObject the map object to be drawing.
         * @param drawBoundary the drawing boundry.
         * @param zoomLevel the current zoomLevel.
         */
        public override void DrawMapObject(MapObject mapObject, GeoLatLngBounds drawBoundary,
                                           int zoomLevel)
        {
            GeoLatLng drawPt = new GeoLatLng();

            _sutherlandHodgman = new SutherlandHodgman(drawBoundary);
            _mapZoomLevel      = zoomLevel;
            _mapCenterPt.X     = drawBoundary.GetCenterX();
            _mapCenterPt.Y     = drawBoundary.GetCenterY();
            bool pointFound = false;

            switch (mapObject.GetMapObjectType())
            {
            case MapObject.NONE:
                break;

            case MapObject.POINT:
            {
                MapPoint mapPoint = (MapPoint)mapObject;
                DrawPoint(mapPoint);
                drawPt.X   = mapPoint.Point.X;
                drawPt.Y   = mapPoint.Point.Y;
                pointFound = true;
            }
            break;

            case MapObject.MULTIPOINT:
            {
                MapMultiPoint mapMultiPoint = (MapMultiPoint)mapObject;
                for (int i = 0; i < mapMultiPoint.Points.Length; i++)
                {
                    MapPoint mapPoint = new MapPoint
                    {
                        SymbolType = mapMultiPoint.SymbolType,
                        Point      = new GeoLatLng(mapMultiPoint.Points[i])
                    };
                    DrawPoint(mapPoint);
                }
                for (int i = 0; i < mapMultiPoint.Points.Length; i++)
                {
                    if (drawBoundary.Contains(mapMultiPoint.Points[i]))
                    {
                        drawPt.X   = mapMultiPoint.Points[i].X;
                        drawPt.Y   = mapMultiPoint.Points[i].Y;
                        pointFound = true;
                        break;
                    }
                }
            }
            break;

            case MapObject.PLINE:
            {
                MapPline mapPline = (MapPline)mapObject;
                DrawPline(mapPline.PenStyle, mapPline.Pline);
                for (int i = 0; i < mapPline.Pline.GetVertexCount(); i++)
                {
                    if (drawBoundary.Contains(mapPline.Pline.GetVertex(i)))
                    {
                        drawPt.X   = mapPline.Pline.GetVertex(i).X;
                        drawPt.Y   = mapPline.Pline.GetVertex(i).Y;
                        pointFound = true;
                        break;
                    }
                }
            }
            break;

            case MapObject.MULTIPLINE:
            {
                MapMultiPline mapMultiPline = (MapMultiPline)mapObject;
                for (int i = 0; i < mapMultiPline.Plines.Length; i++)
                {
                    DrawPline(mapMultiPline.PenStyle,
                              mapMultiPline.Plines[i]);
                    for (int j = 0; j < mapMultiPline.Plines[i].GetVertexCount(); j++)
                    {
                        if (drawBoundary.Contains(mapMultiPline.Plines[i].GetVertex(j)))
                        {
                            drawPt.X   = mapMultiPline.Plines[i].GetVertex(j).X;
                            drawPt.Y   = mapMultiPline.Plines[i].GetVertex(j).Y;
                            pointFound = true;
                            break;
                        }
                    }
                }
            }
            break;

            case MapObject.REGION:
            {
                MapRegion mapRegion = (MapRegion)mapObject;
                DrawRegion(mapRegion.PenStyle, mapRegion.BrushStyle,
                           mapRegion.Region);
                drawPt.X   = mapRegion.CenterPt.X;
                drawPt.Y   = mapRegion.CenterPt.Y;
                pointFound = true;
            }
            break;

            case MapObject.MULTIREGION:
            {
                MapMultiRegion mapMultiRegion = (MapMultiRegion)mapObject;
                for (int i = 0; i < mapMultiRegion.Regions.Length; i++)
                {
                    DrawRegion(mapMultiRegion.PenStyle,
                               mapMultiRegion.BrushStyle,
                               mapMultiRegion.Regions[i]);
                }
                drawPt.X   = mapMultiRegion.CenterPt.X;
                drawPt.Y   = mapMultiRegion.CenterPt.Y;
                pointFound = true;
            }
            break;

            case MapObject.COLLECTION:
            {
                MapCollection mapCollection = (MapCollection)mapObject;
                if (mapCollection.MultiRegion != null)
                {
                    MapMultiRegion mapMultiRegion = mapCollection.MultiRegion;
                    for (int i = 0; i < mapMultiRegion.Regions.Length; i++)
                    {
                        DrawRegion(mapMultiRegion.PenStyle,
                                   mapMultiRegion.BrushStyle,
                                   mapMultiRegion.Regions[i]);
                    }
                }
                if (mapCollection.MultiPline != null)
                {
                    MapMultiPline mapMultiPline = mapCollection.MultiPline;
                    for (int i = 0; i < mapMultiPline.Plines.Length; i++)
                    {
                        DrawPline(mapMultiPline.PenStyle,
                                  mapMultiPline.Plines[i]);
                    }
                }
                if (mapCollection.MultiPoint != null)
                {
                    MapMultiPoint mapMultiPoint = mapCollection.MultiPoint;
                    for (int i = 0; i < mapMultiPoint.Points.Length; i++)
                    {
                        MapPoint mapPoint = new MapPoint
                        {
                            SymbolType = mapMultiPoint.SymbolType,
                            Point      = new GeoLatLng(mapMultiPoint.Points[i])
                        };
                        DrawPoint(mapPoint);
                    }
                }
                pointFound = true;
                drawPt.X   = mapCollection.Bounds.X + mapCollection.Bounds.Width / 2;
                drawPt.Y   = mapCollection.Bounds.Y + mapCollection.Bounds.Height / 2;
            }
            break;

            case MapObject.TEXT:
            {
                MapText mapText = (MapText)mapObject;
                drawPt.X   = mapText.Point.X;
                drawPt.Y   = mapText.Point.Y;
                pointFound = true;
            }
            break;
            }
            if (!mapObject.Name.ToLower().Equals("unknown") && pointFound)
            {
                MapText mapName = new MapText {
                    Font = _font
                };
                mapName.SetForeColor(_fontColor);
                mapName.TextString = mapObject.Name;
                GeoPoint screenPt = FromLatLngToMapPixel(drawPt);
                mapName.Point.X  = screenPt.X;
                mapName.Point.Y  = screenPt.Y;
                mapName.Bounds.X = mapName.Point.X;
                mapName.Bounds.Y = mapName.Point.Y;
                if (_font != null)
                {
                    mapName.Bounds.Height = IMAGE_PATERN_WIDTH;
                    mapName.Bounds.Width  = _font.CharsWidth(mapObject.Name.ToCharArray(), 0,
                                                             mapObject.Name.ToCharArray().Length);
                }
                AddMapName(mapName);
            }
        }
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 21JUN2009  James Shen                 	          Initial Creation
        ////////////////////////////////////////////////////////////////////////////
        /**
         * draw a map object.
         * @param mapObject the map object to be drawing.
         * @param drawBoundary the drawing boundry.
         * @param zoomLevel the current zoomLevel.
         */
        public override void DrawMapObject(MapObject mapObject, GeoLatLngBounds drawBoundary,
                int zoomLevel)
        {
            GeoLatLng drawPt = new GeoLatLng();
            _sutherlandHodgman = new SutherlandHodgman(drawBoundary);
            _mapZoomLevel = zoomLevel;
            _mapCenterPt.X = drawBoundary.GetCenterX();
            _mapCenterPt.Y = drawBoundary.GetCenterY();
            bool pointFound = false;
            Point[] plinePoints=null;
            switch (mapObject.GetMapObjectType())
            {
                case MapObject.NONE:
                    break;
                case MapObject.POINT:
                    {
                        MapPoint mapPoint = (MapPoint)mapObject;
                        DrawPoint(mapPoint);
                        drawPt.X = mapPoint.Point.X;
                        drawPt.Y = mapPoint.Point.Y;
                        pointFound = true;
                    }
                    break;
                case MapObject.MULTIPOINT:
                    {
                        MapMultiPoint mapMultiPoint = (MapMultiPoint)mapObject;
                        for (int i = 0; i < mapMultiPoint.Points.Length; i++)
                        {
                            MapPoint mapPoint = new MapPoint
                            {
                                SymbolType = mapMultiPoint.SymbolType,
                                Point = new GeoLatLng(mapMultiPoint.Points[i])
                            };
                            DrawPoint(mapPoint);
                        }
                        for (int i = 0; i < mapMultiPoint.Points.Length; i++)
                        {
                            if (drawBoundary.Contains(mapMultiPoint.Points[i]))
                            {
                                drawPt.X = mapMultiPoint.Points[i].X;
                                drawPt.Y = mapMultiPoint.Points[i].Y;
                                pointFound = true;
                                break;
                            }
                        }

                    }
                    break;
                case MapObject.PLINE:
                    {
                        MapPline mapPline = (MapPline)mapObject;
                        plinePoints=DrawPline(mapPline.PenStyle, mapPline.Pline);
                        for (int i = 0; i < mapPline.Pline.GetVertexCount(); i++)
                        {
                            if (drawBoundary.Contains(mapPline.Pline.GetVertex(i)))
                            {
                                drawPt.X = mapPline.Pline.GetVertex(i).X;
                                drawPt.Y = mapPline.Pline.GetVertex(i).Y;
                                pointFound = true;
                                break;
                            }
                        }
                    }
                    break;
                case MapObject.MULTIPLINE:
                    {
                        MapMultiPline mapMultiPline = (MapMultiPline)mapObject;
                        for (int i = 0; i < mapMultiPline.Plines.Length; i++)
                        {
                            DrawPline(mapMultiPline.PenStyle,
                                    mapMultiPline.Plines[i]);
                            for (int j = 0; j < mapMultiPline.Plines[i].GetVertexCount(); j++)
                            {
                                if (drawBoundary.Contains(mapMultiPline.Plines[i].GetVertex(j)))
                                {
                                    drawPt.X = mapMultiPline.Plines[i].GetVertex(j).X;
                                    drawPt.Y = mapMultiPline.Plines[i].GetVertex(j).Y;
                                    pointFound = true;
                                    break;
                                }
                            }
                        }
                    }
                    break;
                case MapObject.REGION:
                    {
                        MapRegion mapRegion = (MapRegion)mapObject;
                        DrawRegion(mapRegion.PenStyle, mapRegion.BrushStyle,
                                mapRegion.Region);
                        drawPt.X = mapRegion.CenterPt.X;
                        drawPt.Y = mapRegion.CenterPt.Y;
                        pointFound = true;
                    }
                    break;
                case MapObject.MULTIREGION:
                    {
                        MapMultiRegion mapMultiRegion = (MapMultiRegion)mapObject;
                        for (int i = 0; i < mapMultiRegion.Regions.Length; i++)
                        {
                            DrawRegion(mapMultiRegion.PenStyle,
                                    mapMultiRegion.BrushStyle,
                                    mapMultiRegion.Regions[i]);

                        }
                        drawPt.X = mapMultiRegion.CenterPt.X;
                        drawPt.Y = mapMultiRegion.CenterPt.Y;
                        pointFound = true;
                    }
                    break;
                case MapObject.COLLECTION:
                    {
                        MapCollection mapCollection = (MapCollection)mapObject;
                        if (mapCollection.MultiRegion != null)
                        {
                            MapMultiRegion mapMultiRegion = mapCollection.MultiRegion;
                            for (int i = 0; i < mapMultiRegion.Regions.Length; i++)
                            {
                                DrawRegion(mapMultiRegion.PenStyle,
                                        mapMultiRegion.BrushStyle,
                                        mapMultiRegion.Regions[i]);
                            }
                        }
                        if (mapCollection.MultiPline != null)
                        {
                            MapMultiPline mapMultiPline = mapCollection.MultiPline;
                            for (int i = 0; i < mapMultiPline.Plines.Length; i++)
                            {
                                DrawPline(mapMultiPline.PenStyle,
                                        mapMultiPline.Plines[i]);
                            }
                        }
                        if (mapCollection.MultiPoint != null)
                        {
                            MapMultiPoint mapMultiPoint = mapCollection.MultiPoint;
                            for (int i = 0; i < mapMultiPoint.Points.Length; i++)
                            {
                                MapPoint mapPoint = new MapPoint
                                {
                                    SymbolType = mapMultiPoint.SymbolType,
                                    Point = new GeoLatLng(mapMultiPoint.Points[i])
                                };
                                DrawPoint(mapPoint);
                            }
                        }
                        pointFound = true;
                        drawPt.X = mapCollection.Bounds.X + mapCollection.Bounds.Width / 2;
                        drawPt.Y = mapCollection.Bounds.Y + mapCollection.Bounds.Height / 2;

                    }
                    break;
                case MapObject.TEXT:
                    {
                        MapText mapText = (MapText)mapObject;
                        drawPt.X = mapText.Point.X;
                        drawPt.Y = mapText.Point.Y;
                        pointFound = true;
                    }
                    break;
            }
            if (!(mapObject.Name.ToLower().Equals("unknown") || mapObject.Name.Length==0) && pointFound)
            {
                MapText mapName = new MapText { Font = _font };
                mapName.SetForeColor(_fontColor);
                mapName.TextString = mapObject.Name;
                GeoPoint screenPt = FromLatLngToMapPixel(drawPt);
                mapName.Point.X = screenPt.X;
                mapName.Point.Y = screenPt.Y;
                mapName.Bounds.X = mapName.Point.X;
                mapName.Bounds.Y = mapName.Point.Y;
                Font font = null;
                if (_font != null)
                {

                    font = (Font)_font.GetNativeFont();
                    SizeF sizeF = SharedGraphics2D.Graphics.MeasureString(mapName.TextString, font);
                    mapName.Bounds.Height = sizeF.Height;
                    mapName.Bounds.Width = sizeF.Width;

                }
                TextPosInfo textPosInfo = new TextPosInfo();
                textPosInfo._mapText = mapName;
                if(mapObject.GetMapObjectType()==MapObject.PLINE)
                {
                    if(plinePoints!=null)
                    {
                        GraphicsPath graphicsPath = new GraphicsPath();
                        graphicsPath.AddLines(plinePoints);
                        RectangleF []rectangleF;
                        double angle = GetAngle(plinePoints[0], plinePoints[plinePoints.Length - 1]);
                        if (angle < 180)
                        {
                            graphicsPath.Reverse();
                        }
                        angle = GetAngle(plinePoints[0], plinePoints[plinePoints.Length - 1]);

                        float rotateAngle = GetRotateAngle(angle);
                        rectangleF = SharedGraphics2D.Graphics.MeasureString(mapName.TextString, font,
                                                                                new SolidBrush(
                                                                                    Color.FromArgb(_fontColor)),
                                                                                TextPathAlign.Center,
                                                                                TextPathPosition.CenterPath, 100, rotateAngle,
                                                                                graphicsPath);

                        textPosInfo._graphicsPath = graphicsPath;
                        textPosInfo._rectangles = rectangleF;

                        if (rectangleF.Length == mapName.TextString.Length)
                        {

                            //RectangleF[] rectangleFs = new RectangleF[rectangleF.Length];
                            //Array.Copy(rectangleF, rectangleFs, rectangleF.Length);
                            //for (int i = 0; i < rectangleFs.Length;i++ )
                            //{
                            //    for(int j=0;j<rectangleF.Length;j++)
                            //    {
                            //        if(i!=j)
                            //        {
                            //            if(rectangleFs[i].IntersectsWith(rectangleF[j]))
                            //            {
                            //                return;
                            //            }
                            //        }
                            //    }
                            //}

                           AddMapName(textPosInfo);
                        }

                    }
                }else
                {
                    textPosInfo._graphicsPath = null;
                    textPosInfo._rectangles = new[]{new RectangleF((float)textPosInfo._mapText.Bounds.X, (float)textPosInfo._mapText.Bounds.Y,
                                                           (float)textPosInfo._mapText.Bounds.Width,
                                                           (float)textPosInfo._mapText.Bounds.Height)};
                    AddMapName(textPosInfo);
                }

            }
        }
示例#4
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 21JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * draw a map object.
         * @param mapObject the map object to be drawing.
         * @param drawBoundary the drawing boundry.
         * @param zoomLevel the current zoomLevel.
         */
        public override void DrawMapObject(MapObject mapObject, GeoLatLngBounds drawBoundary,
                                           int zoomLevel)
        {
            GeoLatLng drawPt = new GeoLatLng();

            _sutherlandHodgman = new SutherlandHodgman(drawBoundary);
            _mapZoomLevel      = zoomLevel;
            _mapCenterPt.X     = drawBoundary.GetCenterX();
            _mapCenterPt.Y     = drawBoundary.GetCenterY();
            bool pointFound = false;

            Point[] plinePoints = null;
            switch (mapObject.GetMapObjectType())
            {
            case MapObject.NONE:
                break;

            case MapObject.POINT:
            {
                MapPoint mapPoint = (MapPoint)mapObject;
                DrawPoint(mapPoint);
                drawPt.X   = mapPoint.Point.X;
                drawPt.Y   = mapPoint.Point.Y;
                pointFound = true;
            }
            break;

            case MapObject.MULTIPOINT:
            {
                MapMultiPoint mapMultiPoint = (MapMultiPoint)mapObject;
                for (int i = 0; i < mapMultiPoint.Points.Length; i++)
                {
                    MapPoint mapPoint = new MapPoint
                    {
                        SymbolType = mapMultiPoint.SymbolType,
                        Point      = new GeoLatLng(mapMultiPoint.Points[i])
                    };
                    DrawPoint(mapPoint);
                }
                for (int i = 0; i < mapMultiPoint.Points.Length; i++)
                {
                    if (drawBoundary.Contains(mapMultiPoint.Points[i]))
                    {
                        drawPt.X   = mapMultiPoint.Points[i].X;
                        drawPt.Y   = mapMultiPoint.Points[i].Y;
                        pointFound = true;
                        break;
                    }
                }
            }
            break;

            case MapObject.PLINE:
            {
                MapPline mapPline = (MapPline)mapObject;
                plinePoints = DrawPline(mapPline.PenStyle, mapPline.Pline);
                for (int i = 0; i < mapPline.Pline.GetVertexCount(); i++)
                {
                    if (drawBoundary.Contains(mapPline.Pline.GetVertex(i)))
                    {
                        drawPt.X   = mapPline.Pline.GetVertex(i).X;
                        drawPt.Y   = mapPline.Pline.GetVertex(i).Y;
                        pointFound = true;
                        break;
                    }
                }
            }
            break;

            case MapObject.MULTIPLINE:
            {
                MapMultiPline mapMultiPline = (MapMultiPline)mapObject;
                for (int i = 0; i < mapMultiPline.Plines.Length; i++)
                {
                    DrawPline(mapMultiPline.PenStyle,
                              mapMultiPline.Plines[i]);
                    for (int j = 0; j < mapMultiPline.Plines[i].GetVertexCount(); j++)
                    {
                        if (drawBoundary.Contains(mapMultiPline.Plines[i].GetVertex(j)))
                        {
                            drawPt.X   = mapMultiPline.Plines[i].GetVertex(j).X;
                            drawPt.Y   = mapMultiPline.Plines[i].GetVertex(j).Y;
                            pointFound = true;
                            break;
                        }
                    }
                }
            }
            break;

            case MapObject.REGION:
            {
                MapRegion mapRegion = (MapRegion)mapObject;
                DrawRegion(mapRegion.PenStyle, mapRegion.BrushStyle,
                           mapRegion.Region);
                drawPt.X   = mapRegion.CenterPt.X;
                drawPt.Y   = mapRegion.CenterPt.Y;
                pointFound = true;
            }
            break;

            case MapObject.MULTIREGION:
            {
                MapMultiRegion mapMultiRegion = (MapMultiRegion)mapObject;
                for (int i = 0; i < mapMultiRegion.Regions.Length; i++)
                {
                    DrawRegion(mapMultiRegion.PenStyle,
                               mapMultiRegion.BrushStyle,
                               mapMultiRegion.Regions[i]);
                }
                drawPt.X   = mapMultiRegion.CenterPt.X;
                drawPt.Y   = mapMultiRegion.CenterPt.Y;
                pointFound = true;
            }
            break;

            case MapObject.COLLECTION:
            {
                MapCollection mapCollection = (MapCollection)mapObject;
                if (mapCollection.MultiRegion != null)
                {
                    MapMultiRegion mapMultiRegion = mapCollection.MultiRegion;
                    for (int i = 0; i < mapMultiRegion.Regions.Length; i++)
                    {
                        DrawRegion(mapMultiRegion.PenStyle,
                                   mapMultiRegion.BrushStyle,
                                   mapMultiRegion.Regions[i]);
                    }
                }
                if (mapCollection.MultiPline != null)
                {
                    MapMultiPline mapMultiPline = mapCollection.MultiPline;
                    for (int i = 0; i < mapMultiPline.Plines.Length; i++)
                    {
                        DrawPline(mapMultiPline.PenStyle,
                                  mapMultiPline.Plines[i]);
                    }
                }
                if (mapCollection.MultiPoint != null)
                {
                    MapMultiPoint mapMultiPoint = mapCollection.MultiPoint;
                    for (int i = 0; i < mapMultiPoint.Points.Length; i++)
                    {
                        MapPoint mapPoint = new MapPoint
                        {
                            SymbolType = mapMultiPoint.SymbolType,
                            Point      = new GeoLatLng(mapMultiPoint.Points[i])
                        };
                        DrawPoint(mapPoint);
                    }
                }
                pointFound = true;
                drawPt.X   = mapCollection.Bounds.X + mapCollection.Bounds.Width / 2;
                drawPt.Y   = mapCollection.Bounds.Y + mapCollection.Bounds.Height / 2;
            }
            break;

            case MapObject.TEXT:
            {
                MapText mapText = (MapText)mapObject;
                drawPt.X   = mapText.Point.X;
                drawPt.Y   = mapText.Point.Y;
                pointFound = true;
            }
            break;
            }
            if (!(mapObject.Name.ToLower().Equals("unknown") || mapObject.Name.Length == 0) && pointFound)
            {
                MapText mapName = new MapText {
                    Font = _font
                };
                mapName.SetForeColor(_fontColor);
                mapName.TextString = mapObject.Name;
                GeoPoint screenPt = FromLatLngToMapPixel(drawPt);
                mapName.Point.X  = screenPt.X;
                mapName.Point.Y  = screenPt.Y;
                mapName.Bounds.X = mapName.Point.X;
                mapName.Bounds.Y = mapName.Point.Y;
                Font font = null;
                if (_font != null)
                {
                    font = (Font)_font.GetNativeFont();
                    SizeF sizeF = SharedGraphics2D.Graphics.MeasureString(mapName.TextString, font);
                    mapName.Bounds.Height = sizeF.Height;
                    mapName.Bounds.Width  = sizeF.Width;
                }
                TextPosInfo textPosInfo = new TextPosInfo();
                textPosInfo._mapText = mapName;
                if (mapObject.GetMapObjectType() == MapObject.PLINE)
                {
                    if (plinePoints != null)
                    {
                        GraphicsPath graphicsPath = new GraphicsPath();
                        graphicsPath.AddLines(plinePoints);
                        RectangleF [] rectangleF;
                        double        angle = GetAngle(plinePoints[0], plinePoints[plinePoints.Length - 1]);
                        if (angle < 180)
                        {
                            graphicsPath.Reverse();
                        }
                        angle = GetAngle(plinePoints[0], plinePoints[plinePoints.Length - 1]);

                        float rotateAngle = GetRotateAngle(angle);
                        rectangleF = SharedGraphics2D.Graphics.MeasureString(mapName.TextString, font,
                                                                             new SolidBrush(
                                                                                 Color.FromArgb(_fontColor)),
                                                                             TextPathAlign.Center,
                                                                             TextPathPosition.CenterPath, 100, rotateAngle,
                                                                             graphicsPath);

                        textPosInfo._graphicsPath = graphicsPath;
                        textPosInfo._rectangles   = rectangleF;



                        if (rectangleF.Length == mapName.TextString.Length)
                        {
                            //RectangleF[] rectangleFs = new RectangleF[rectangleF.Length];
                            //Array.Copy(rectangleF, rectangleFs, rectangleF.Length);
                            //for (int i = 0; i < rectangleFs.Length;i++ )
                            //{
                            //    for(int j=0;j<rectangleF.Length;j++)
                            //    {
                            //        if(i!=j)
                            //        {
                            //            if(rectangleFs[i].IntersectsWith(rectangleF[j]))
                            //            {
                            //                return;
                            //            }
                            //        }
                            //    }
                            //}


                            AddMapName(textPosInfo);
                        }
                    }
                }
                else
                {
                    textPosInfo._graphicsPath = null;
                    textPosInfo._rectangles   = new[] { new RectangleF((float)textPosInfo._mapText.Bounds.X, (float)textPosInfo._mapText.Bounds.Y,
                                                                       (float)textPosInfo._mapText.Bounds.Width,
                                                                       (float)textPosInfo._mapText.Bounds.Height) };
                    AddMapName(textPosInfo);
                }
            }
        }
            ////////////////////////////////////////////////////////////////////////
            //--------------------------------- REVISIONS --------------------------
            // Date       Name                 Tracking #         Description
            // ---------  -------------------  -------------      ------------------
            // 18JUN2009  James Shen                 	          Initial Creation
            ////////////////////////////////////////////////////////////////////////
            /**
             *
             * @param mapDirection
             * @param X
             * @param Y
             * @param Width
             * @param Height
             */
            private void DrawRouteImage(MapDirection mapDirection, int x, int y,
                    int width, int height)
            {
                if (!_routeDrawWaypointOnly)
                {
                    _sutherlandHodgman = new SutherlandHodgman(_screenBounds);

                    ArrayList polyline = new ArrayList();
                    int minLevel = NeedShowLevel(mapDirection.Polyline.NumLevels, GetZoom());
                    for (int i = 0; i < mapDirection.Polyline.GetVertexCount(); i++)
                    {
                        int level = mapDirection.Polyline.GetLevel(i);
                        if (level >= minLevel)
                        {
                            polyline.Add(mapDirection.Polyline.GetVertex(i));
                        }
                    }
                    ArrayList clippedPts = _sutherlandHodgman.ClipPline(polyline);

                    GeoPoint newPt1;
                    GeoPoint newPt2;

                    GeoPoint drawPt1 = new GeoPoint(0, 0), drawPt2 = new GeoPoint(0, 0);
                    const int steps = 1;
                    int numOfTiles = MAP_TILE_WIDTH / _mapDrawingTileWidth;
                    Rectangle drawArea = new Rectangle();
                    Rectangle intersectRect = new Rectangle(0, 0, width, height);
                    int xIndex;
                    for (xIndex = 0; xIndex < numOfTiles; xIndex++)
                    {
                        int yIndex;
                        for (yIndex = 0; yIndex < numOfTiles; yIndex++)
                        {
                            bool hasPt1 = false;
                            GeoLatLng pt1 = null;
                            _routeGraphics2D.Clear(Color.White);
                            drawArea.X = xIndex * _mapDrawingTileWidth;
                            drawArea.Y = yIndex * _mapDrawingTileWidth;
                            drawArea.Width = drawArea.Height = _mapDrawingTileWidth;
                            drawArea = intersectRect.Intersection(drawArea);
                            int totalPointSize = clippedPts.Count;
                            if (!drawArea.IsEmpty())
                            {
                                _routeGraphics2D.SetClip(0, 0,
                                        drawArea.Width, drawArea.Height);
                                try
                                {
                                    for (int j = 0; j < totalPointSize; j += steps)
                                    {
                                        GeoLatLng pt = (GeoLatLng)clippedPts[j];
                                        int level = minLevel;
                                        if (hasPt1 == false)
                                        {
                                            if (level >= minLevel)
                                            {
                                                {
                                                    {
                                                        hasPt1 = true;
                                                        pt1 = pt;
                                                        continue;
                                                    }
                                                }
                                            }
                                        }
                                        if (hasPt1)
                                        {
                                            if (level >= minLevel)
                                            {
                                                GeoLatLng pt2 = pt;
                                                newPt1 = FromLatLngToMapPixel(pt1);
                                                newPt2 = FromLatLngToMapPixel(pt2);
                                                newPt1.X -= x + xIndex * _mapDrawingTileWidth;
                                                newPt1.Y -= y + yIndex * _mapDrawingTileWidth;
                                                newPt2.X -= x + xIndex * _mapDrawingTileWidth;
                                                newPt2.Y -= y + yIndex * _mapDrawingTileWidth;
                                                drawPt1.X = (int)newPt1.X;
                                                drawPt1.Y = (int)newPt1.Y;
                                                drawPt2.X = (int)newPt2.X;
                                                drawPt2.Y = (int)newPt2.Y;

                                                if ((drawPt1.Distance(drawPt2) > 0))
                                                {
                                                    _routeGraphics2D.DrawLine(RoutePen, (int)drawPt1.X,
                                                            (int)drawPt1.Y,
                                                            (int)drawPt2.X, (int)drawPt2.Y);
                                                    pt1 = pt2;
                                                    if (_readListener != null)
                                                    {
                                                        _readListener.readProgress(j,
                                                                totalPointSize);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                catch (Exception)
                                {

                                }
                            }

                            _routeGraphics.DrawRGB(_routeGraphics2D.GetRGB(), 0,
                                    _mapDrawingTileWidth,
                                    xIndex * _mapDrawingTileWidth,
                                    yIndex * _mapDrawingTileWidth,
                                    _mapDrawingTileWidth,
                                    _mapDrawingTileWidth, true);
                        }
                    }
                }
                else
                {
                    _routeGraphics.SetColor(TRANSPARENCY);
                    _routeGraphics.FillRect(0, 0, MAP_TILE_WIDTH, MAP_TILE_WIDTH);
                }
            }