//////////////////////////////////////////////////////////////////////// //--------------------------------- 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); } }