Пример #1
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 18JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * Constructs a new <code>GeoBounds</code> whose upper-left corner is the
  * specified <code>GeoPoint</code>, and whose Width and Height are both zero.
  * @param p a <code>GeoPoint</code> that is the top left corner
  * of the <code>GeoBounds</code>
  */
 public GeoBounds(GeoPoint p)
     : this(p.X, p.Y, 0, 0)
 {
 }
Пример #2
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 18JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * Computes the geographical coordinates from pixel coordinates in the map.
  * @param pt pixel coordinates in the map.
  * @return the the geographical coordinates.
  */
 public GeoLatLng FromMapPixelToLatLng(GeoPoint pt)
 {
     GeoPoint center = FromLatLngToPixel(_mapCenterPt, _mapZoomLevel);
     GeoPoint topLeft = new GeoPoint(center.X - _mapSize.Width / 2.0,
             center.Y - _mapSize.Height / 2.0);
     GeoPoint pointPos = new GeoPoint(pt.X, pt.Y);
     pointPos.X += topLeft.X;
     pointPos.Y += topLeft.Y;
     GeoLatLng latLng = FromPixelToLatLng(pointPos, _mapZoomLevel);
     return latLng;
 }
Пример #3
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 18JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * Returns the square of the Distance from this
  * <code>GeoPoint</code> to a specified <code>GeoPoint</code>.
  *
  * @param pt the specified point to be measured
  *           against this <code>GeoPoint</code>
  * @return the square of the Distance between this
  * <code>GeoPoint</code> to a specified <code>GeoPoint</code>.
  */
 public double DistanceSq(GeoPoint pt)
 {
     double px = pt.GetX() - GetX();
     double py = pt.GetY() - GetY();
     return (px * px + py * py);
 }
Пример #4
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 21JUN2009  James Shen                 	          Initial Creation
        ////////////////////////////////////////////////////////////////////////////
        /**
         * @inheritDoc
         */
        public override void GetImage(int mtype, int x, int y, int zoomLevel)
        {
            lock (VectorMapAbstractCanvas.GRAPHICS_MUTEX)
            {

                int shiftWidth = 32;
                GeoPoint pt1 = new GeoPoint(x * MapLayer.MAP_TILE_WIDTH - shiftWidth,
                        y * MapLayer.MAP_TILE_WIDTH - shiftWidth);
                GeoPoint pt2 = new GeoPoint((x + 1) * MapLayer.MAP_TILE_WIDTH + shiftWidth,
                        (y + 1) * MapLayer.MAP_TILE_WIDTH + shiftWidth);
                GeoLatLng latLng1 = MapLayer.FromPixelToLatLng(pt1, zoomLevel);
                GeoLatLng latLng2 = MapLayer.FromPixelToLatLng(pt2, zoomLevel);
                double minY = Math.Min(latLng1.Lat(), latLng2.Lat());
                double maxY = Math.Max(latLng1.Lat(), latLng2.Lat());
                double minX = Math.Min(latLng1.Lng(), latLng2.Lng());
                double maxX = Math.Max(latLng1.Lng(), latLng2.Lng());
                double width =0.00;
                double height = 0.00;

                //width = width < 0.06 ? 0.06 : width;
                //height = height < 0.06 ? 0.06 : height;

                GeoLatLngBounds geoBounds = new GeoLatLngBounds(minX - width / 2.0, minY - height/2.0,
                        maxX - minX + width , maxY - minY + height);

                try
                {
                    Hashtable[] mapFeatures = _geoSet.Search(geoBounds);
                    int totalSize = 0;
                    for (int i = 0; i < mapFeatures.Length; i++)
                    {
                        Hashtable mapFeaturesInLayer = mapFeatures[i];
                        totalSize += mapFeaturesInLayer.Count;
                    }
                    totalSize += 1;
                    int mapObjectIndex = 0;
                    _vectorMapCanvas.ClearCanvas(0xffffff);

                    for (int i = 0; i < mapFeatures.Length; i++)
                    {
                        int zOrder = mapFeatures.Length - 1 - i;
                        Hashtable mapFeaturesInLayer = mapFeatures[zOrder];
                        ICollection enuKeys = mapFeaturesInLayer.Keys;
                        MapFeatureLayer mapLayer = _geoSet.GetMapFeatureLayer(zOrder);

                        foreach (var o in enuKeys)
                        {
                            int mapInfoID = (int)o;
                            MapFeature mapFeature = mapLayer
                                    .GetMapFeatureByID(mapInfoID);
                            mapObjectIndex++;
                            _vectorMapCanvas.SetFont(GetFont(mapLayer.FontName));
                            _vectorMapCanvas.SetFontColor(mapLayer.FontColor);
                            _vectorMapCanvas.DrawMapObject(mapFeature.MapObject,
                                    geoBounds, zoomLevel);
                            if (_readListener != null)
                            {
                                _readListener.readProgress(mapObjectIndex,
                                        totalSize);
                            }
                        }

                    }
                    _vectorMapCanvas.DrawMapText();
                    ImageArray = PNGEncoder.GetPngrgb(MapLayer.MAP_TILE_WIDTH,
                                                         MapLayer.MAP_TILE_WIDTH,
                                                         _vectorMapCanvas.GetRGB());
                    ImageArraySize = ImageArray.Length;
                    IsImagevalid = true;

                    if (ImageArraySize == 1933)
                    {
                        ImageArray = null;
                        IsImagevalid = false;
                        ImageArraySize = 0;

                    }

                    if (_readListener != null)
                    {
                        _readListener.readProgress(totalSize, totalSize);
                    }
                }
                catch (Exception e )
                {

                }
            }
        }
Пример #5
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 18JUN2009  James Shen                 	          Initial Creation
        ////////////////////////////////////////////////////////////////////////////
        /**
         * Computes the geographical coordinates from pixel coordinates.
         * @param pt  pixel coordinates.
         * @param zoomLevel   current zoom level
         * @return the geographical coordinates (latitude,longitude) pair
         */
        public static GeoLatLng FromPixelToLatLng(GeoPoint pt, int zoomLevel)
        {
            //const double maxLat = Math.PI;
            //double zoom = zoomLevel;
            //const double tileWidth = 256.0;
            //const double tileHeight = 256.0;
            //double tileY = (pt.Y / tileHeight);
            //double y = (pt.Y - tileY * tileHeight);
            //double maxTileY = MathEx.Pow(2, zoom);
            //double mercatorY = tileY + y / tileHeight;
            //double res = maxLat * (1 - 2 * mercatorY / maxTileY);
            //double a = MathEx.Exp(2 * res);
            //a = (a - 1) / (a + 1);
            //a = a / MathEx.Sqrt(1 - a * a);
            //double lat = MathEx.Atan(a) * 180 / Math.PI;

            //double tileX = pt.X / tileHeight;
            //double x = (pt.X - tileX * tileHeight);
            //double maxTileX = MathEx.Pow(2, zoom);
            //double mercatorX = tileX + x / tileWidth;
            //res = mercatorX / maxTileX;
            //double lng = 360 * res - 180;
            //return new GeoLatLng(lat, lng);
            double lat;
            double lng;
            TileSystem.PixelXYToLatLong((int)pt.X,(int)pt.Y,zoomLevel,out lat,out lng);
            return new GeoLatLng(lat, lng);
        }
Пример #6
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 18JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * Check whether the current rectangle Contains given point.
  * @param point the point object.
  * @return true if the rectangular area (inclusively) Contains the pixel
  * coordinates.
  */
 public bool ContainsPoint(GeoPoint point)
 {
     SetBounds(MinX, MinY, MaxX - MinX, MaxY - MinY);
     return Contains(point.X, point.Y);
 }
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 18JUN2009  James Shen                 	          Initial Creation
        ////////////////////////////////////////////////////////////////////////////
        /**
         * Get the image at given X,Y zoom level.
         * @param X  X index of the map tile
         * @param Y  Y index of the map tile.
         * @param zoomLevel zoom level of the map tile
         * @return the given image.
         */
        public IImage GetImage(int x, int y, int zoomLevel)
        {
            MapDirection mapDirection = GetMapDirection();
            if (mapDirection != null)
            {
                try
                {
                    const int shiftWidth = 4;
                    GeoPoint pt1 = new GeoPoint(x * MapLayer.MAP_TILE_WIDTH - shiftWidth,
                            y * MapLayer.MAP_TILE_WIDTH - shiftWidth);
                    GeoPoint pt2 = new GeoPoint((x + 1) * MapLayer.MAP_TILE_WIDTH + shiftWidth,
                            (y + 1) * MapLayer.MAP_TILE_WIDTH + shiftWidth);
                    GeoLatLng latLng1 = MapLayer.FromPixelToLatLng(pt1, zoomLevel);
                    GeoLatLng latLng2 = MapLayer.FromPixelToLatLng(pt2, zoomLevel);
                    double minY = Math.Min(latLng1.Lat(), latLng2.Lat());
                    double maxY = Math.Max(latLng1.Lat(), latLng2.Lat());
                    double minX = Math.Min(latLng1.Lng(), latLng2.Lng());
                    double maxX = Math.Max(latLng1.Lng(), latLng2.Lng());
                    GeoLatLngBounds geoBounds = new GeoLatLngBounds(minX, minY,
                            maxX - minX, maxY - minY);
                    GeoLatLng centerPt = geoBounds.GetCenter();
                    _mapDirectionLayer.SetCenter(centerPt, zoomLevel);
                    _mapDirectionLayer._screenBounds = geoBounds;
                    _mapTileGraphics.SetColor(TRANSPARENCY);
                    _mapTileGraphics.FillRect(0, 0, MapLayer.MAP_TILE_WIDTH,
                            MapLayer.MAP_TILE_WIDTH);
                    _mapDirectionLayer.Paint(_mapTileGraphics);
                    IsImagevalid = true;
                    if (_readListener != null)
                    {
                        _readListener.readProgress(16, 16);
                    }
                    return _mapTileImage.ModifyAlpha(160,
                            TRANSPARENCY);

                }
                catch (Exception)
                {

                }
            }
            return null;
        }
Пример #8
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 18JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * Returns the pixel coordinates of the center of the rectangular area.
  * @return the center point of the GeoBounds.
  */
 public GeoPoint Mid()
 {
     GeoPoint point = new GeoPoint((MinX + MaxX) / 2, (MinY + MaxY) / 2);
     return point;
 }
Пример #9
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 18JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * Returns the pixel coordinates of the upper left corner of the rectangular
  *  area.
  * @return the  upper left corner of the rectangular area.
  */
 public GeoPoint Min()
 {
     GeoPoint point = new GeoPoint(MinX, MinY);
     return point;
 }
Пример #10
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 18JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Constructs and initializes a point with the same location as
         * the specified <code>Point</code> object.
         * @param       p a point
         */
        public GeoPoint(GeoPoint p)
            : this(p.X, p.Y)
        {
        }
Пример #11
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 18JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * Returns the pixel coordinates of the lower right corner of the
  * rectangular area.
  * @return the  upper lower right of the rectangular area.
  */
 public GeoPoint Max()
 {
     GeoPoint point = new GeoPoint(MaxX, MaxY);
     return point;
 }
Пример #12
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 18JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Sets the location of this <code>GeoPoint</code> to the same
         * coordinates as the specified <code>GeoPoint</code> object.
         * @param p the specified <code>GeoPoint</code> to which to set
         * this <code>GeoPoint</code>
         */
        public void SetLocation(GeoPoint p)
        {
            SetLocation(p.GetX(), p.GetY());
        }
Пример #13
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 18JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * Constructs and initializes a point with the same location as
  * the specified <code>Point</code> object.
  * @param       p a point
  */
 public GeoPoint(GeoPoint p)
     : this(p.X, p.Y)
 {
 }
Пример #14
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 18JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * Sets the location of this <code>GeoPoint</code> to the same
  * coordinates as the specified <code>GeoPoint</code> object.
  * @param p the specified <code>GeoPoint</code> to which to set
  * this <code>GeoPoint</code>
  */
 public void SetLocation(GeoPoint p)
 {
     SetLocation(p.GetX(), p.GetY());
 }
Пример #15
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 18JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * Adds the <code>GeoPoint</code> object <code>pt</code> to this
  * <code>GeoBounds</code>.
  * The resulting <code>GeoBounds</code> is the smallest
  * <code>GeoBounds</code> that Contains both the original
  * <code>GeoBounds</code> and the specified <code>GeoPoint</code>.
  * <p>
  * After adding a point, a call to <code>Contains</code> with the
  * added point as an argument does not necessarily return
  * <code>true</code>. The <code>Contains</code>
  * method does not return <code>true</code> for points on the right
  * or bottom edges of a rectangle. Therefore, if the added point falls
  * on the left or bottom edge of the enlarged rectangle,
  * <code>Contains</code> returns <code>false</code> for that point.
  * @param     pt the new <code>GeoPoint</code> to Add to this
  * <code>GeoBounds</code>.
  */
 public void Add(GeoPoint pt)
 {
     Add(pt.GetX(), pt.GetY());
 }
Пример #16
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 18JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * Determines where the specified {@link GeoPoint} lies with
  * respect to this <code>GeoBounds</code>.
  * This method computes a binary OR of the appropriate mask values
  * indicating, for each side of this <code>GeoBounds</code>,
  * whether or not the specified <code>GeoPoint</code> is on the same
  * side of the edge as the rest of this <code>GeoBounds</code>.
  * @param p the specified <code>GeoPoint</code>
  * @return the logical OR of all appropriate out codes.
  */
 public int Outcode(GeoPoint p)
 {
     return Outcode(p.GetX(), p.GetY());
 }
Пример #17
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 18JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * check if this rectangle Contains given point.
  * @param p the point to be checked
  * @return true,it Contains given point.
  */
 public bool Contains(GeoPoint p)
 {
     return Contains(p.GetX(), p.GetY());
 }
Пример #18
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 18JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * Sets the location and size of the framing rectangle of this
  * <code>IShape</code> to the specified {@link GeoPoint} and
  * {@link GeoSize}, respectively.  The framing rectangle is used
  * by the subclasses of <code>RectangularShape</code> to define
  * their geometry.
  * @param loc the specified <code>GeoPoint</code>
  * @param size the specified <code>GeoSize</code>
  */
 public void SetFrame(GeoPoint loc, GeoSize size)
 {
     SetFrame(loc.GetX(), loc.GetY(), size.GetWidth(), size.GetHeight());
 }
Пример #19
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 18JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * Enlarges this box so that the point is also contained in this box.
  * @param point the point object.
  */
 public void Extend(GeoPoint point)
 {
     SetBounds(MinX, MinY, MaxX - MinX, MaxY - MinY);
     Add(point.X, point.Y);
     MinX = X;
     MinY = Y;
     MaxX = X + Width;
     MaxY = Y + Height;
 }
Пример #20
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 18JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * Sets the framing rectangle of this <code>IShape</code> based on a
  * specified center <code>GeoPoint</code> and corner
  * <code>GeoPoint</code>.  The framing rectangle is used by the subclasses
  * of <code>RectangularShape</code> to define their geometry.
  * @param center the specified center <code>GeoPoint</code>
  * @param corner the specified corner <code>GeoPoint</code>
  */
 public void SetFrameFromCenter(GeoPoint center, GeoPoint corner)
 {
     SetFrameFromCenter(center.GetX(), center.GetY(),
             corner.GetX(), corner.GetY());
 }
            ////////////////////////////////////////////////////////////////////////
            //--------------------------------- 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);
                }
            }
Пример #22
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 18JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * Sets the diagonal of the framing rectangle of this <code>IShape</code>
  * based on two specified <code>GeoPoint</code> objects.  The framing
  * rectangle is used by the subclasses of <code>RectangularShape</code>
  * to define their geometry.
  *
  * @param p1 the start <code>GeoPoint</code> of the specified diagonal
  * @param p2 the end <code>GeoPoint</code> of the specified diagonal
  */
 public void SetFrameFromDiagonal(GeoPoint p1, GeoPoint p2)
 {
     SetFrameFromDiagonal(p1.GetX(), p1.GetY(), p2.GetX(), p2.GetY());
 }
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 21JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * Computes the pixel coordinates of the given geographical point vector
  * in the map.
  * @param vpts the geographical coordinates vector.
  * @return the pixel coordinates in the map.
  */
 protected GeoPoint[] FromLatLngToMapPixel(ArrayList vpts)
 {
     GeoPoint[] retPoints = new GeoPoint[vpts.Count];
     for (int i = 0; i < vpts.Count; i++)
     {
         retPoints[i] = FromLatLngToMapPixel(
                 (GeoLatLng)vpts[i]);
     }
     return retPoints;
 }
Пример #24
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 18JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * Constructs a rectangle that Contains all the given points.
  * @param points an array of points.
  */
 public GeoBounds(GeoPoint[] points)
     : this()
 {
     if (points == null)
     {
         SetRect(0, 0, 0, 0);
     }
     if (points != null)
     {
         int count = points.Length;
         switch (count)
         {
             case 0:
                 SetRect(0, 0, 0, 0);
                 break;
             case 1:
                 SetRect(points[0].X, points[0].Y, 0, 0);
                 break;
             case 2:
                 {
                     double x1 = Math.Min(points[0].X, points[1].X);
                     double x2 = Math.Max(points[0].X, points[1].X);
                     double y1 = Math.Min(points[0].Y, points[1].Y);
                     double y2 = Math.Max(points[0].Y, points[1].Y);
                     SetRect(x1, y1, x2 - x1, y2 - y1);
                 }
                 break;
             default:
                 {
                     double x1 = Math.Min(points[0].X, points[1].X);
                     double x2 = Math.Max(points[0].X, points[1].X);
                     double y1 = Math.Min(points[0].Y, points[1].Y);
                     double y2 = Math.Max(points[0].Y, points[1].Y);
                     SetRect(x1, y1, x2 - x1, y2 - y1);
                 }
                 for (int i = 2; i < count; i++)
                 {
                     Add(points[i].X, points[i].Y);
                 }
                 break;
         }
     }
     MinX = X;
     MinY = Y;
     MaxX = X + Width;
     MaxY = Y + Height;
 }
Пример #25
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 18JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * Computes the pixel coordinates of the given geographical point in the map.
  * @param latlng the geographical coordinates.
  * @return the pixel coordinates in the map.
  */
 public GeoPoint FromLatLngToMapPixel(GeoLatLng latlng)
 {
     GeoPoint center = FromLatLngToPixel(_mapCenterPt, _mapZoomLevel);
     GeoPoint topLeft = new GeoPoint(center.X - _mapSize.Width / 2.0,
             center.Y - _mapSize.Height / 2.0);
     GeoPoint pointPos = FromLatLngToPixel(latlng, _mapZoomLevel);
     pointPos.X -= topLeft.X;
     pointPos.Y -= topLeft.Y;
     return new GeoPoint((int)(pointPos.X + 0.5), (int)(pointPos.Y + 0.5));
 }
Пример #26
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 03JAN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * Constructs a new <code>GeoBounds</code> whose upper-left corner is
  * specified by the {@link GeoPoint} argument, and
  * whose Width and Height are specified by the
  * {@link GeoSize} argument.
  * @param p a <code>GeoPoint</code> that is the upper-left corner of
  * the <code>GeoBounds</code>
  * @param size a <code>GeoSize</code>, representing the
  * Width and Height of the <code>GeoBounds</code>
  */
 public GeoBounds(GeoPoint p, GeoSize size)
     : this(p.X, p.Y, size.Width, size.Height)
 {
 }
Пример #27
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 18JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * return screen boundary in geo coordinates.
  * @param pt the center of the screen.
  * @return screen boundary in geo coordinates.
  */
 public GeoLatLngBounds GetScreenBounds(GeoLatLng pt)
 {
     lock (_syncObject)
     {
         GeoPoint center = FromLatLngToPixel(pt, _mapZoomLevel);
         int shiftWidth = _screenSize.Width;
         GeoPoint topLeft = new GeoPoint(center.X - _screenSize.Width / 2.0 - shiftWidth,
                                         center.Y - _screenSize.Height / 2.0 - _screenSize.Height);
         GeoPoint bottomRight = new GeoPoint(center.X + _screenSize.Width / 2.0 + shiftWidth,
                                             center.Y + _screenSize.Height / 2.0 + _screenSize.Height);
         GeoLatLng topLeftLatLng = FromPixelToLatLng(topLeft, _mapZoomLevel);
         GeoLatLng bottomRightLatLng = FromPixelToLatLng(bottomRight, _mapZoomLevel);
         double minY = Math.Min(bottomRightLatLng.Lat(), topLeftLatLng.Lat());
         double maxY = Math.Max(bottomRightLatLng.Lat(), topLeftLatLng.Lat());
         double minX = Math.Min(bottomRightLatLng.Lng(), topLeftLatLng.Lng());
         double maxX = Math.Max(bottomRightLatLng.Lng(), topLeftLatLng.Lng());
         return new GeoLatLngBounds(minX, minY, maxX - minX, maxY - minY);
     }
 }
Пример #28
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 18JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * Returns the Distance from this <code>GeoPoint</code> to a
  * specified <code>GeoPoint</code>.
  *
  * @param pt the specified point to be measured
  *           against this <code>GeoPoint</code>
  * @return the Distance between this <code>GeoPoint</code> and
  * the specified <code>GeoPoint</code>.
  */
 public double Distance(GeoPoint pt)
 {
     double px = pt.GetX() - GetX();
     double py = pt.GetY() - GetY();
     return MathEx.Sqrt(px * px + py * py);
 }