Esempio n. 1
0
        /// <summary>
        /// 两个坐标的角度
        /// </summary>
        /// <param name="me"></param>
        /// <param name="other"></param>
        /// <returns></returns>
        public static double GetAngleDeg(LonLat me, LonLat other)
        {
            double latDifferDeg = (other.Lat - me.Lat);
            double lonDifferDeg = (other.Lon - me.Lon);

            return(GetAngleDeg(latDifferDeg, lonDifferDeg));
        }
Esempio n. 2
0
        void gridLooper_Looping(Geo.Coordinates.LonLat lonlat)
        {
            var radius = AveRadiusOfEarch + HeightOnSphere;
            var val    = calculater.GetValue(maxOrder, lonlat, radius);

            AddToTable(lonlat, val);
        }
Esempio n. 3
0
        public LonLat GetLonLatFromScreenXy(System.Drawing.Point location, LonLat center, XY screenCenter, int zoom)
        {
            XY     centerXy = GetMercatorXyFromLonLat(center);
            XY     mercator = GetMecatorXyFromScreenXy(location, centerXy, screenCenter, zoom);
            LonLat lonLat   = GetLonLatFromMercatorXy(mercator);

            return(lonLat);
        }
Esempio n. 4
0
        /// <summary>
        /// 经纬度坐标转换为屏幕坐标。
        /// </summary>
        /// <param name="lonLat"></param>
        /// <param name="center"></param>
        /// <param name="screenSize"></param>
        /// <param name="zoom"></param>
        /// <returns></returns>
        public XY GetScreenXyFromLonLat(LonLat lonLat, LonLat center, XY screenCenter, int zoom)
        {
            XY mecatorXy = GetMercatorXyFromLonLat(lonLat);
            XY centerXy  = GetMercatorXyFromLonLat(center);
            XY pt        = GetScreenPointFromMercatorXy(mecatorXy, centerXy, screenCenter, zoom);

            return(pt);
        }
Esempio n. 5
0
        /// <summary>
        /// 空间直角坐标系到,站心坐标系的转换。
        /// </summary>
        /// <param name="vector">站心坐标系的目标向量</param>
        /// <param name="lonlat">站心的大地坐标</param>
        /// <param name="unit">当前输入的角度单位</param>
        /// <returns></returns>
        public static NEU XyzToNeu(XYZ vector, LonLat lonlat, AngleUnit unit = AngleUnit.Degree)
        {
            //double[][] trans = (GetGlobalToLocalCoordMatrix(lonlat));
            //double[] result = MatrixUtil.GetMultiply(trans, vector.Array);
            //XYZ xyz = XYZ.Parse(result);

            NEU neu = XyzToNeu(vector, lonlat.Lat, lonlat.Lon, unit);

            return(neu);
        }
Esempio n. 6
0
        /// <summary>
        /// 数值是否相等。
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public override bool Equals(object obj)
        {
            LonLat other = obj as LonLat;

            if (other == null)
            {
                return(false);
            }

            return(this.Lon == other.Lon && this.Lat == other.Lat);
        }
Esempio n. 7
0
        /// <summary>
        /// 得到Google Tile 编号。
        /// </summary>
        /// <param name="lonLat"></param>
        /// <returns></returns>
        public XY LonLatToTileXy(LonLat lonLat, int zoom)
        {
            XY worldCoordinate = LonLatToMecatorXy(lonLat);
            //像素坐标
            double temp            = Math.Pow(2, zoom);
            XY     pixelCoordinate = new XY(worldCoordinate.X * temp, worldCoordinate.Y * temp);
            //瓦片坐标。
            XY tileCoordinate = new XY(Math.Floor(pixelCoordinate.X / MERCATOR_RANGE), Math.Floor(pixelCoordinate.Y / MERCATOR_RANGE));

            return(tileCoordinate);
        }
Esempio n. 8
0
        /// <summary>
        /// World Coordinate
        /// </summary>
        /// <param name="lonLat"></param>
        /// <returns></returns>
        public XY LonLatToMecatorXy(LonLat lonLat)
        {
            XY point  = new XY();
            XY origin = this.pixelOrigin;

            point.X = origin.X + lonLat.Lon * this.pixelsPerLonDegree;
            // NOTE(appleton): Truncating to 0.9999 effectively limits latitude to
            // 89.189.  This is about a third of a tile past the edge of the world tile.
            double siny = Bound(Math.Sin(DegreesToRadians(lonLat.Lat)), -0.9999, 0.9999);

            point.Y = origin.Y + 0.5 * Math.Log((1 + siny) / (1 - siny)) * -this.pixelsPerLonRadian;
            return(point);
        }
        void gridLooper_Looping(Geo.Coordinates.LonLat lonlat)
        {
            //转换为日固坐标系
            LonLat lonLatSE = lonlat.GetSeLonLat(this.CurrentHarmanicsData.Time.DateTime);


            var radius = AveRadiusOfEarch + HeightOnSphere;

            //   var val = calculater.GetValue(maxOrder, lonlat, radius);
            var val = calculater.GetValue(maxOrder, lonLatSE, radius);


            AddToTable(lonlat, val);
        }
Esempio n. 10
0
        /// <summary>
        /// 经纬度转换到高斯坐标XY
        /// </summary>
        /// <param name="lonlat"></param>
        /// <param name="beltWidth"></param>
        /// <param name="Ellipsoid"></param>
        /// <param name="unit"></param>
        /// <param name="aveGeoHeight">投影面平均大地高</param>
        /// <param name="YConst">横轴Y加常数</param>
        /// <param name="orinalLonDeg">中央子午线,度小数</param>
        /// <param name="isYWithBeltNum"></param>
        /// <returns></returns>
        public static XY LonLatToGaussXy(LonLat lonlat, double aveGeoHeight, int beltWidth, ref double orinalLonDeg, bool IsIndicateOriginLon, Ellipsoid Ellipsoid, double YConst = 500000, AngleUnit unit = AngleUnit.Degree, bool isYWithBeltNum = true)
        {
            double B = lonlat.Lat;
            double L = lonlat.Lon;
            double x;
            double y;

            //单位转换
            L = AngularConvert.Convert(L, unit, AngleUnit.Degree);
            B = AngularConvert.Convert(B, unit, AngleUnit.Degree);
            Geo.Coordinates.GeodeticUtils.LonLatToGaussXy(L, B, aveGeoHeight, out x, out y, ref orinalLonDeg, IsIndicateOriginLon, beltWidth, YConst, isYWithBeltNum,
                                                          Ellipsoid.SemiMajorAxis, Ellipsoid.InverseFlattening);

            return(new XY(x, y));
        }
Esempio n. 11
0
        /// <summary>
        /// 经纬度所标转化为墨卡托投影坐标。没有Y或经度方向大小限制。
        /// </summary>
        /// <param name="lonLat"></param>
        /// <returns></returns>
        public XY GetMercatorXyFromLonLat(LonLat lonLat)
        {
            if (lonLat.Lat > MaxLat)
            {
                lonLat.Lat = MaxLat;
            }
            if (lonLat.Lat < -MaxLat)
            {
                lonLat.Lat = -MaxLat;
            }


            XY xy = mecator.LonLatToMecatorXy(lonLat);

            return(xy);
        }
Esempio n. 12
0
        /// <summary>
        /// 循环
        /// </summary>
        /// <param name="geoCoord"></param>
        protected void OnLooping(Geo.Coordinates.LonLat geoCoord)
        {
            if (IsCancel)
            {
                return;
            }

            Looping?.Invoke(geoCoord);

            //进度条控制
            CurrentCount++;

            if (IsLatFirst && CurrentCount % LatCount == 0)
            {
                PerformProcessStep();
            }
            else if (CurrentCount % LonCount == 0)
            {
                PerformProcessStep();
            }
        }
Esempio n. 13
0
        /// <summary>
        /// 测试
        /// </summary>
        /// <param name="zoom"></param>
        public void Test(int zoom)
        {
            LonLat lonLat = new LonLat(-87.6500523, 41.850033);

            string latlngStr = "Chicago, IL" + "<br />" + "LatLng: " + lonLat.Lat + " , " + lonLat.Lon + "<br />";

            MercatorProjection projection = new MercatorProjection();
            //世界坐标(Mecator)
            XY     worldCoordinate = projection.LonLatToMecatorXy(lonLat);
            string worldCoordStr   = "World Coordinate: " + worldCoordinate.X + " , " + worldCoordinate.Y;

            //像素坐标
            XY pixelCoordinate = new XY(worldCoordinate.X * Math.Pow(2, zoom), worldCoordinate.Y * Math.Pow(2, zoom));


            string pixelCoordStr = "<br />Pixel Coordinate: " + Math.Floor(pixelCoordinate.X) + " , " + Math.Floor(pixelCoordinate.Y);

            //瓦片坐标。
            XY     tileCoordinate = new XY(Math.Floor(pixelCoordinate.X / MERCATOR_RANGE), Math.Floor(pixelCoordinate.Y / MERCATOR_RANGE));
            string tileCoordStr   = "<br />Tile Coordinate: " + tileCoordinate.X + " , " + tileCoordinate.Y + " at Zoom Level: " + zoom;
        }
Esempio n. 14
0
        /// <summary>
        /// 驾驶方向
        /// </summary>
        /// <param name="pre"></param>
        /// <param name="now"></param>
        /// <param name="next"></param>
        /// <returns></returns>
        public static DrivenDirection GetDrivenDirection(LonLat pre, LonLat now, LonLat next)
        {
            double deg1   = GetAngleDeg(pre, now);
            double deg2   = GetAngleDeg(now, next);
            double degree = deg2 - deg1;

            //0<=degree<360
            if (degree < 0)
            {
                degree += 360;
            }
            if (degree >= 360)
            {
                degree -= 360;
            }

            if (-D45 < degree && degree <= D45)
            {
                return(DrivenDirection.Ahead);
            }
            int i = 1;

            if (D45 * (i) < degree && degree <= D45 * (i += 2))
            {
                return(DrivenDirection.Left);
            }
            if (D45 * (i) < degree && degree <= D45 * (i += 2))
            {
                return(DrivenDirection.Back);
            }
            if (D45 * (i) < degree && degree <= D45 * (i += 2))
            {
                return(DrivenDirection.Right);
            }
            if (D45 * (i) < degree && degree <= D45 * (i += 2))
            {
                return(DrivenDirection.Ahead);
            }
            return(DrivenDirection.Ahead);
        }
Esempio n. 15
0
        /// <summary>
        /// 由Google瓦片编号转换为Mercater坐标。
        /// </summary>
        /// <param name="tileXy"></param>
        /// <param name="zoom"></param>
        /// <returns></returns>
        public XY GetMercatorXyFromGoogleTileNumber(XY tileXy, int zoom)
        {
            LonLat lonlat = mecator.TileXyToLonLat(tileXy, zoom);

            return(new XY(lonlat.Lon, lonlat.Lat));
        }
Esempio n. 16
0
        //  const double PIPart8 = 0.39269908169872415480783042290994;

        /// <summary>
        /// 得到两个坐标点的相对方向。
        /// 第二个相对于第一个。
        /// </summary>
        /// <param name="me"></param>
        /// <param name="other"></param>
        /// <returns></returns>
        public static string GetDirectionString(LonLat me, LonLat other)
        {
            Direction dir = GetDirection(me, other);

            return(GetDirectionString(dir));
        }
Esempio n. 17
0
 public static double DistanceInMeter(LonLat start, LonLat end)
 {
     return(GeoDistance.GetDistanceInMeter(start, end));
     //LonLat differ = (start - end);
     //return (long)( Math.Sqrt(differ.Lat * differ.Lat + differ.Lon * differ.Lon) * 1.8 * 60);
 }
Esempio n. 18
0
        /// <summary>
        /// 采用贝塞尔大地算法计算大地线长。
        /// </summary>
        /// <param name="lonLat1"></param>
        /// <param name="lonLat2"></param>
        /// <returns></returns>
        public static double GetDistanceInMeter(LonLat lonLat1, LonLat lonLat2)
        {
            double distance = GeodeticX.Geodetic.Bessel_BL_S(lonLat1.Lat, lonLat1.Lon, lonLat2.Lat, lonLat2.Lon, 6378137, 298.257223563);

            return(distance);
        }
Esempio n. 19
0
 /// <summary>
 /// 由大地坐标计算大地线长
 /// </summary>
 /// <param name="longlatADeg"></param>
 /// <param name="longlatBDeg"></param>
 /// <param name="aveGeoHeight">平均大地高</param>
 /// <param name="majorRadius"></param>
 /// <param name="inverseFlat"></param>
 /// <returns></returns>
 public static double BesselGeodeticLine(LonLat longlatADeg, LonLat longlatBDeg, double aveGeoHeight = 0, double majorRadius = Ellipsoid.SemiMajorAxisOfCGCS2000, double inverseFlat = Ellipsoid.InverseFlatOfCGCS2000)
 {
     return(BesselGeodeticLine(longlatADeg.Lon, longlatADeg.Lat, longlatBDeg.Lon, longlatBDeg.Lat, majorRadius + aveGeoHeight, inverseFlat));
 }
Esempio n. 20
0
        /// <summary>
        /// 墨卡托投影坐标转换为经纬度坐标。没有Y或经度方向大小限制。
        /// </summary>
        /// <param name="xy"></param>
        /// <returns></returns>
        public LonLat GetLonLatFromMercatorXy(XY xy)
        {
            LonLat lonLat = mecator.MecatorXyToLonLat(xy);

            return(lonLat);
        }
Esempio n. 21
0
 /// <summary>
 /// 计算贝塞尔大地方位角
 /// </summary>
 /// <param name="startXyz"></param>
 /// <param name="toXyz"></param>
 /// <returns></returns>
 public static double BesselAzimuthAngle(LonLat startXyz, LonLat toXyz, double majorRadius = Ellipsoid.SemiMajorAxisOfCGCS2000, double inverseFlat = Ellipsoid.InverseFlatOfCGCS2000)
 {
     return(BesselAzimuthAngle(startXyz.Lon, startXyz.Lat, toXyz.Lon, toXyz.Lat, majorRadius, inverseFlat));
 }
Esempio n. 22
0
        public System.Drawing.Point GetScreenPointFromLonLat(LonLat lonLat, int zoom)
        {
            XY xy = GetMercatorXyFromLonLat(lonLat);

            return(GetScreenPointFromMercatorXy(xy, zoom));
        }
Esempio n. 23
0
        /// <summary>
        /// 屏幕坐标转换为经纬度坐标。
        /// </summary>
        /// <param name="location"></param>
        /// <param name="center"></param>
        /// <param name="screenSize"></param>
        /// <param name="zoom"></param>
        /// <returns></returns>
        public LonLat GetLonLatFromScreenXy(System.Drawing.Point location, LonLat center, System.Drawing.Size screenSize, int zoom)
        {
            XY screenCenter = new XY(screenSize.Width / 2, screenSize.Height / 2);

            return(GetLonLatFromScreenXy(location, center, screenCenter, zoom));
        }
Esempio n. 24
0
 /// <summary>
 /// 经纬度转换为Google瓦片编号。
 /// </summary>
 /// <param name="lonLat"></param>
 /// <param name="zoom"></param>
 /// <returns></returns>
 public XY GetGoogleTileNumberFromLonLat(LonLat lonLat, int zoom)
 {
     return(mecator.LonLatToTileXy(lonLat, zoom));
 }
Esempio n. 25
0
 /// <summary>
 /// 方向获取
 /// </summary>
 /// <param name="me"></param>
 /// <param name="other"></param>
 /// <returns></returns>
 public static Direction GetDirection(LonLat me, LonLat other)
 {
     return(GetDirection(new XYZ(me.Lon, me.Lat), new XYZ(other.Lon, other.Lat)));
 }