示例#1
0
        private Area createMapViewAreaForCenterImg(MapView mapView)
        {
            Point       centerImgLocation = mapView.getCenterImgPosition();
            GpsLocation gpsLoc            = mapView.getGpsLocation();

            int   pixelsToLeftEdge   = centerImgLocation.X;
            int   pixelsToTopEdge    = centerImgLocation.Y;
            Image centerPart         = mapView.getImgByPoint(new Point(1, 1));
            int   pixelsToRightEdge  = centerPart.Width - centerImgLocation.X;
            int   pixelsToBottomEdge = centerPart.Height - centerImgLocation.Y;

            double latitudePerPixel  = this.currentMapPkg.getLatitudePerPixel();
            double longitudePerPixel = this.currentMapPkg.getLongitudePerPixel();

            double topLeftLatitude      = gpsLoc.getLatitude() + pixelsToTopEdge * latitudePerPixel;
            double topLeftLongitude     = gpsLoc.getLongitude() - pixelsToLeftEdge * longitudePerPixel;
            double bottomRightLatitude  = gpsLoc.getLatitude() - pixelsToBottomEdge * latitudePerPixel;
            double bottomRightLongitude = gpsLoc.getLongitude() + pixelsToRightEdge * longitudePerPixel;

            return(new Area(topLeftLatitude, topLeftLongitude, bottomRightLatitude, bottomRightLongitude));
        }
示例#2
0
文件: MapView.cs 项目: mitice/foo
 public bool isValidForGpsLocation(GpsLocation gpsLoc)
 {
     return(this.centerImgArea.contains(gpsLoc.getLatitude(), gpsLoc.getLongitude()));
 }
示例#3
0
 private double getLocationsDistance(GpsLocation gl1, GpsLocation gl2)
 {
     // distance between two points
     return(Math.Sqrt(Math.Pow(gl2.getLatitude() - gl1.getLatitude(), 2) +
                      Math.Pow(gl2.getLongitude() - gl1.getLongitude(), 2)));
 }