Пример #1
0
        private void button_lonlatToGauss_Click(object sender, EventArgs e)
        {
            var strs   = this.richTextBoxControl_lonlat.Lines;
            var inputs = new List <LonLat>();

            foreach (string item in strs)
            {
                if (String.IsNullOrWhiteSpace(item))
                {
                    continue;
                }
                inputs.Add(LonLat.Parse(item));
            }

            var    results      = new List <XY>();
            double orinalLonDeg = this.namedFloatControl_orinalLonDeg.GetValue();

            foreach (var item in inputs)
            {
                var longlat = Coordinates.CoordTransformer.LonLatToGaussXy(item, AveGeoHeight, BeltWidth3Or6, ref orinalLonDeg, IsIndicateOriginLon, Ellipsoid, YConst, AngleUnit, IsWithBeltNum);
                results.Add(longlat);
            }
            this.namedFloatControl_orinalLonDeg.SetValue(orinalLonDeg);
            var           spliter = IsOutSplitByTab ? "\t" : ", ";
            StringBuilder sb      = new StringBuilder();

            foreach (var item in results)
            {
                sb.AppendLine(item.ToString("0.000000", spliter));
            }
            this.richTextBoxControl_gauss.Text = sb.ToString();
        }
Пример #2
0
        /// <summary>
        /// 获取值
        /// </summary>
        /// <param name="order">最大阶次</param>
        /// <param name="coord">经纬度坐标,球面坐标</param>
        /// <param name="radius">球半径</param>
        /// <returns></returns>
        public double GetValue(int order, LonLat coord, double radius)
        {
            var lon_rad = Geo.Coordinates.AngularConvert.ToRad(coord.Lon, coord.Unit);
            var lat_rad = Geo.Coordinates.AngularConvert.ToRad(coord.Lat, coord.Unit);

            return(GetValue(order, lon_rad, lat_rad, radius));
        }
Пример #3
0
        private void backgroundWorker2_DoWork(object sender, DoWorkEventArgs e)
        {
            if (calculater == null)
            {
                Geo.Utils.FormUtil.ShowWarningMessageBox("请先读取数据。");
                return;
            }
            var    coordStr = this.namedStringControlCoord.GetValue();
            double val      = 0;

            if (this.radioButtonLonLat.Checked)
            {
                var    radius = HeightOnSphere + AveRadiusOfEarch;
                LonLat lonlat = LonLat.Parse(coordStr);
                val = calculater.GetValue(maxOrder, lonlat, radius);
            }
            else
            {
                XYZ lonlat = XYZ.Parse(coordStr);
                var polar  = Geo.Coordinates.CoordTransformer.XyzToPolar(lonlat);
                val = calculater.GetValue(maxOrder, polar);
            }
            var span = DateTime.Now - Start;

            Geo.Utils.FormUtil.SetText(this.richTextBoxControl1, "计算值:" + val + ",耗时 : " + span + "");
            log.Info("计算完毕! ,计算值:" + val + ",耗时 : " + span + "");
        }
        public string GetCoordinates(string vars)
        {
            List <string> list  = extractVars(vars);
            string        regex = "^(?:[0-9]{1,3}\\.){3}[0-9]{1,3}$";
            Match         match = Regex.Match(list[0], regex, RegexOptions.IgnoreCase);

            LonLat x;

            if (match.Success)
            {
                string ip   = list[0];
                int    port = 5400;
                int.TryParse(list[1], out port);
                x = CoordinatesFromServer(ip, port);
            }
            else
            {
                string file  = list[0];
                int    index = 0;
                int.TryParse(list[1], out index);
                x = CoordinatesFromFile(file, index);
            }

            if (x != null)
            {
                return(x.ToXml());
            }
            else
            {
                return(LonLat.NullLonLatToXML());
            }
        }
Пример #5
0
        /// <summary>
        /// 字符串列表解析为属性
        /// </summary>
        /// <param name="items"></param>
        /// <returns></returns>
        public override IdAstroProduct Parse(string[] items)
        {
            var name  = items[PropertyIndexes[VariableNames.Id]];
            var coord = new LonLat(
                Double.Parse(items[PropertyIndexes[VariableNames.Lon]]),
                Double.Parse(items[PropertyIndexes[VariableNames.Lat]])
                );
            var Azimuth        = Double.Parse(items[PropertyIndexes[VariableNames.Azimuth]]);
            var DirectionPoint = items[PropertyIndexes[VariableNames.ToId]];

            if (this.IsPropertyUnitChanged)
            {
                coord.Lon = Convert(VariableNames.Lon, coord.Lon);
                coord.Lat = Convert(VariableNames.Lat, coord.Lat);
                Azimuth   = Convert(VariableNames.Azimuth, Azimuth);
            }

            IdAstroProduct citem = new IdAstroProduct(name, coord)
            {
                Azimuth = Azimuth,
                ToId    = DirectionPoint
            };

            return(citem);
        }
Пример #6
0
        private void button_calculate_Click(object sender, EventArgs e)
        {
            Time   time     = new Time(this.namedTimeControl1.GetValue());
            LonLat geoCoord = LonLat.Parse(this.namedStringControl1_geoCoord.GetValue());
            var    result   = this.IonoFileService.Get(time, geoCoord);

            this.richTextBoxControl1.Text = result.ToString();
        }
Пример #7
0
        void looper_Looping(LonLat geoCoord)
        {
            var result = this.IonoFileService.Get(time, geoCoord);

            tableData.Set(geoCoord.Lon, geoCoord.Lat, result.Value);
            tableRmsData.Set(geoCoord.Lon, geoCoord.Lat, result.Rms);
            //  this.richTextBoxControl1.Text = result.ToString();
        }
Пример #8
0
 /// <summary>
 /// Creates new AirportInfo object
 /// </summary>
 /// <param name="name"></param>
 /// <param name="city"></param>
 /// <param name="country"></param>
 /// <param name="iata"></param>
 /// <param name="icao"></param>
 /// <param name="lat">Deg value</param>
 /// <param name="lon">Deg value</param>
 public AirportInfo(string name, string city, string country, string iata, string icao, float lat, float lon)
 {
     Name    = name;
     City    = city;
     Country = country;
     IATA    = iata;
     ICAO    = icao;
     LonLat  = new LonLat(Coordinate.FromDeg(lon), Coordinate.FromDeg(lat));
 }
Пример #9
0
 private void AddToTable(LonLat lonlat, double val)
 {
     lock (locker)
     {
         table.NewRow();
         table.AddItem("Lon", lonlat.Lon);
         table.AddItem("Lat", lonlat.Lat);
         table.AddItem("Val", val);
     }
 }
Пример #10
0
        /// <summary>
        /// 垂直方向的电子数量
        /// </summary>
        /// <param name="time"></param>
        /// <param name="geocentricLonlatDeg"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        private static RmsedNumeral GetValue(Time time, LonLat geocentricLonlatDeg, IonoHarmonicSection data)
        {
            SphericalHarmonicsCalculater calculater = new SphericalHarmonicsCalculater(data);
            var    radius   = Geo.Referencing.Ellipsoid.MeanRaduis;           // HeightOnSphere + AveRadiusOfEarch;
            LonLat lonLatSE = geocentricLonlatDeg.GetSeLonLat(time.DateTime); //转换为日固坐标系

            var val = calculater.GetValue(data.MaxDegree, lonLatSE, radius);

            return(new RmsedNumeral(val, 0));
        }
Пример #11
0
        private LonLat zr(LonLat a, double[] b)
        {
            var c = b[0] + b[1] * Math.Abs(a.Lon);
            var d = Math.Abs(a.Lat) / b[9];

            d = b[2] + b[3] * d + b[4] * d * d + b[5] * d * d * d + b[6] * d * d * d * d + b[7] * d * d * d * d * d
                + b[8] * d * d * d * d * d * d;
            c = c * (0 > a.Lon ? -1 : 1);
            d = d * (0 > a.Lat ? -1 : 1);
            return(new LonLat(c, d));
        }
Пример #12
0
 /// <summary>
 /// Equals method checks latitude and longitude parameters for equality
 /// </summary>
 /// <param name="pos">position to compare with this one</param>
 /// <returns>true if both latitude and longitude are equal to compared LonLat</returns>
 public bool Equals(LonLat pos)
 {
     if (this.Longitude == pos.Longitude && this.Latitude == pos.Latitude)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Пример #13
0
        /// <summary>
        /// 経緯度の位置 a と b の緯度方向の距離を計算する
        /// </summary>
        /// <param name="a">経緯度の位置1つめ</param>
        /// <param name="b">経緯度の位置2つめ</param>
        /// <param name="llda">経緯度の距離を計算するアルゴリズム</param>
        /// <param name="planet">楕円体近似した惑星の形状定義; null の場合は <see cref="GeometricalSpecification.Earth_WGS84"/> が採用されます </param>
        /// <returns>緯度方向の距離</returns>
        public static Length LatitudeDistanceTo
            (this ILonLatGettable a
            , ILonLatGettable b
            , LonLatDistanceAlgorithm llda             = LonLatDistanceAlgorithm.Haversine
            , IGeometricalSpecificationGettable planet = null
            )
        {
            var aa = new LonLat(PlaneAngle.Zero, a.Latitude);
            var bb = new LonLat(PlaneAngle.Zero, b.Latitude);

            return(aa.DistanceTo(bb, llda, planet));
        }
Пример #14
0
        ///// <summary>
        ///// .斜TEC转垂直TEC的乘法因子。
        ///// </summary>
        ///// <param name="satElevation">卫星高度角,角度degree</param>
        ///// <param name="radiusOfMeanEarth">地球平均半径</param>
        ///// <param name="heightOfIono">电离层模型高度</param>
        ///// <returns></returns>
        //private static double GetSlopeToVerticalFactor(double satElevation, double radiusOfMeanEarth, double heightOfIono)
        //{
        //    return Math.Sqrt(1.0 - Math.Pow(radiusOfMeanEarth * Math.Cos(satElevation * Geo.Coordinates.AngularConvert.DegToRadMultiplier) / (radiusOfMeanEarth + heightOfIono), 2.0));
        //}
        /// <summary>
        /// 垂直TEC转斜TEC的乘法因子。
        /// </summary>
        /// <param name="satElevation">卫星高度角,角度degree</param>
        /// <param name="radiusOfMeanEarth">地球平均半径</param>
        /// <param name="heightOfIono">电离层模型高度</param>
        /// <returns></returns>
        //private static double GetVerticalToSlopeFactor(double satElevation, double radiusOfMeanEarth, double heightOfIono)
        //{
        //    return 1.0 /  GetSlopeToVerticalFactor(satElevation, radiusOfMeanEarth, heightOfIono);
        //}

        /// <summary>
        /// 获取服务为,原始数据。单位 1e16.
        /// </summary>
        /// <param name="time"></param>
        /// <param name="geocentricLonlatDeg"></param>
        /// <returns></returns>
        public RmsedNumeral Get(Time time, LonLat geocentricLonlatDeg)
        {
            double bufferedTime = 2 * 3600;

            this.TimePeriod.SetSameBuffer(bufferedTime);
            if (!TimePeriod.BufferedContains(time))
            {
                log.Error(Name + " 不在有效服务时段内。 " + TimePeriod + ", " + time);
                return(null);

                throw new ApplicationException();
            }

            List <Time> times = TimeUtil.GetNearst(this.IonoFile.Keys, time);

            if (times.Count == 1)//刚好,或在边界,无需拟合
            {
                return(Interpolate(this.IonoFile.Get(times[0]), geocentricLonlatDeg));
            }
            else if (times.Count >= 3)//需要拟合
            {
                var         smallTime  = times[1];
                var         largerTime = times[2];
                IonoSection regoin1    = this.IonoFile.Get(smallTime);
                IonoSection regoin2    = this.IonoFile.Get(largerTime);


                var val1 = Interpolate(regoin1, geocentricLonlatDeg);
                var val2 = Interpolate(regoin2, geocentricLonlatDeg);
                var t    = time.TickTime.SecondsOfWeek;
                var t1   = smallTime.TickTime.SecondsOfWeek;
                var t2   = largerTime.TickTime.SecondsOfWeek;

                if (t2 == 0)
                {
                    t2 = SecondTime.SECOND_PER_WEEK;// 3600 * 24 * 7;
                }

                var val = Geo.Utils.DoubleUtil.Interpolate(t, t1, t2, val1.Value, val2.Value);
                var rms = Geo.Utils.DoubleUtil.Interpolate(t, t1, t2, val1.Rms, val2.Rms);

                return(new RmsedNumeral(val, rms));
            }

            IonoSection   regoin = this.IonoFile.Get(times[0]);
            List <double> lats   = Geo.Utils.DoubleUtil.GetNearst(regoin.Keys, geocentricLonlatDeg.Lat, false);

            IonoRecord    record = regoin.Get(lats[0]);
            List <double> lons   = Geo.Utils.DoubleUtil.GetNearst(record.Keys, geocentricLonlatDeg.Lon, false);

            return(record[lons[0]]);
        }
Пример #15
0
 /// <summary>
 /// 内部计算纬度顺序
 /// </summary>
 /// <param name="lon"></param>
 private void InnerLatAscLoop(double lon)
 {
     for (double lat = LatSpan.Start; lat <= LatSpan.End; lat = lat + LatStep)
     {
         if (IsCancel)
         {
             break;
         }
         //高程是否需要地形数据?????
         var geoCoord = new LonLat(lon, lat);
         OnLooping(geoCoord);
     }
 }
Пример #16
0
 /// <summary>
 /// 内部经度逆序循环
 /// </summary>
 /// <param name="lat"></param>
 private void InnerLonDescLoop(double lat)
 {
     for (double lon = LonSpan.End; lon >= LonSpan.Start; lon = lon - LonStep)
     {
         if (IsCancel)
         {
             break;
         }
         //高程是否需要地形数据?????
         var geoCoord = new LonLat(lon, lat);
         OnLooping(geoCoord);
     }
 }
Пример #17
0
        /// <summary>
        /// 経緯度の位置 a と b の中間の緯度における経度方向の距離を計算する
        /// </summary>
        /// <param name="a">経緯度の位置1つめ</param>
        /// <param name="b">経緯度の位置2つめ</param>
        /// <param name="llda">経緯度の距離を計算するアルゴリズム</param>
        /// <param name="planet">楕円体近似した惑星の形状定義; null の場合は <see cref="GeometricalSpecification.Earth_WGS84"/> が採用されます </param>
        /// <returns>経度方向の距離</returns>
        public static Length LongitudeDistanceTo
            (this ILonLatGettable a
            , ILonLatGettable b
            , LonLatDistanceAlgorithm llda             = LonLatDistanceAlgorithm.Haversine
            , IGeometricalSpecificationGettable planet = null
            )
        {
            var alat = (a.Latitude + b.Latitude) / 2.0;
            var aa   = new LonLat(a.Longitude, alat);
            var bb   = new LonLat(b.Longitude, alat);

            return(aa.DistanceTo(bb, llda, planet));
        }
Пример #18
0
        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);
        }
Пример #19
0
        void Inner_Looping(double obj)
        {
            LonLat coord = null;

            if (IsLatFirst)
            {
                coord = new LonLat(obj, Outer.Current);
            }
            else
            {
                coord = new LonLat(Outer.Current, obj);
            }

            TotalCoords.Add(coord);
        }
        public string GetCoordinatesAndSave(string vars)
        {
            List <string> l = extractVars(vars);
            // Default value
            int port = 5400;

            int.TryParse(l[1], out port);
            LonLat x = FacadeModel.GetInstance().GetCoordinatesAndSave(l[0], port, l[2]);

            if (x == null)
            {
                return(LonLat.NullLonLatToXML());
            }
            // Else
            return(x.ToXml());
        }
Пример #21
0
        /// <summary>
        /// Gets the geographical location of a point based on spatial data or location expression.
        /// If a data row is provided (not null), data (location expressions or spatial data)
        /// is assumed to be actual fields in that row, and is NOT evaluated.
        /// If the data row is null, data is evaluated against the ParentReport, so may
        /// constitute expressions.
        /// </summary>
        /// <param name="layer">The map layer for which location is retrieved.</param>
        /// <param name="source">The data row (of the layer's custom data source) or null.</param>
        /// <param name="allOk">OUT: true if all points have numeric coordinates, false if at least one is a NaN.</param>
        /// <returns>Location, in geographical coordinates (X is longitude, Y is latitude).</returns>
        private List <LonLat <double> > GetLocations(LayerBase layer, IReportScriptContext context, out bool allOk)
        {
            allOk = true;
            Func <LonLat <string>, List <string>, LonLat <double> > getLoc = (lonlat, locExpr) =>
            {
                if (locExpr != null)
                {
                    // Make address string:
                    var sb = new StringBuilder();
                    for (int i = 0; i < locExpr.Count; ++i)
                    {
                        string s = ParentReport.Evaluate(locExpr[i], context) as string;
                        if (!string.IsNullOrEmpty(s))
                        {
                            sb.Append(s);
                            if (i < locExpr.Count - 1)
                            {
                                sb.Append(", ");
                            }
                        }
                    }
                    return(_geocoder.GetLocation(sb.ToString()));
                }
                else
                {
                    return(new LonLat <double>(
                               Maps.Util.GetDouble(ParentReport.Evaluate(lonlat.Longitude, context)),
                               Maps.Util.GetDouble(ParentReport.Evaluate(lonlat.Latitude, context))));
                }
            };

            var locExprs = layer.PointsLocationExpressions;
            var lonlats  = layer.PointsLocations;
            var points   = new List <LonLat <double> >(lonlats.Count);

            for (int i = 0; i < lonlats.Count; ++i)
            {
                LonLat <double> pt = getLoc(lonlats[i], locExprs[i]);
                points.Add(pt);
                if (allOk && (double.IsNaN(pt.Longitude) || double.IsNaN(pt.Latitude)))
                {
                    allOk = false;
                }
            }
            return(points);
        }
Пример #22
0
        /// <summary>
        /// 斜距
        /// </summary>
        /// <param name="receiverTime"></param>
        /// <param name="geocentricLonLat"></param>
        /// <param name="satElevationOfSiteDeg"></param>
        /// <returns></returns>
        public RmsedNumeral GetSlope(Time receiverTime, LonLat geocentricLonLat, double satElevationOfSiteDeg)
        {
            var tec = Get(receiverTime, geocentricLonLat);

            if (tec == null)
            {
                return(null);
            }

            var includeAngle = GetSatZenithAngleOfPuncturePointInSphereRad(satElevationOfSiteDeg, HeightOfModel);
            var factor       = 1 / Math.Cos(includeAngle);

            return(new RmsedNumeral()
            {
                Value = tec.Value * factor,
                Rms = tec.Rms * factor
            });
        }
Пример #23
0
        /// <summary>
        /// 获取斜距方向
        /// </summary>
        /// <param name="time">时间</param>
        /// <param name="geocentricLonLatOfIntersection">穿刺点球坐标(经纬度,单位:度)</param>
        /// <param name="satElevationOfSiteDeg">测站的卫星高度角,单位:度</param>
        /// <returns></returns>
        public RmsedNumeral GetSlope(Time time, LonLat geocentricLonLatOfIntersection, double satElevationOfSiteDeg)
        {
            var tec = Get(time, geocentricLonLatOfIntersection);

            if (tec == null)
            {
                return(null);
            }
            // var factor1 = GetVerticalToSlopeFactor(satElevationDeg, Geo.Referencing.Ellipsoid.MeanRaduis, HeightOfModel);
            // var factor = 1 / Math.Sin(satElevationOfSiteDeg * Geo.Coordinates.AngularConvert.DegToRadMultiplier);
            var includeAngle = GetSatZenithAngleOfPuncturePointInSphereRad(satElevationOfSiteDeg, HeightOfModel);
            var factor       = 1 / Math.Cos(includeAngle);

            return(new RmsedNumeral()
            {
                Value = tec.Value * factor,
                Rms = tec.Rms * factor
            });
        }
Пример #24
0
        /// <summary>
        /// 垂直方向的电子数量,获取服务,为原始计算和拟合数据。单位 1e16.
        /// 失败返回 NaN
        /// </summary>
        /// <param name="time"></param>
        /// <param name="geocentricLonlatDeg">以度为单位的</param>
        /// <returns>失败返回 NaN</returns>
        public RmsedNumeral Get(Time time, LonLat geocentricLonlatDeg)
        {
            if (!this.TimePeriod.Contains(time))
            {
                return(RmsedNumeral.NaN);
            }

            //首先查找附近的时间。
            if (this.IonoHarmonicFile.Contains(time))
            {
                var data = this.IonoHarmonicFile.Get(time);
                return(GetValue(time, geocentricLonlatDeg, data));
            }

            //如果在之前或之后,则直接采用一个
            if (time < TimePeriod.Start)
            {
                var data = this.IonoHarmonicFile.Get(TimePeriod.Start);
                return(GetValue(time, geocentricLonlatDeg, data));
            }
            if (time > TimePeriod.End)
            {
                var data = this.IonoHarmonicFile.Get(TimePeriod.End);
                return(GetValue(time, geocentricLonlatDeg, data));
            }
            //在中间
            var times = TimeUtil.GetNearst(IonoHarmonicFile.OrderedKeys, time);

            if (times.Count == 1)
            {
                var data = this.IonoHarmonicFile.Get(times[0]);
                return(GetValue(time, geocentricLonlatDeg, data));
            }
            //一定是三个
            var    prevTime = times[1];
            var    nextTime = times[2];
            var    preVal   = GetValue(time, geocentricLonlatDeg, this.IonoHarmonicFile.Get(prevTime));
            var    nextVal  = GetValue(time, geocentricLonlatDeg, this.IonoHarmonicFile.Get(nextTime));
            double val      = Geo.Utils.DoubleUtil.WeightedAverage(preVal.Value, nextVal.Value, Math.Abs(time - prevTime), Math.Abs(time - nextTime));

            return(new RmsedNumeral(val, 0));
        }
Пример #25
0
        private void Generate(BaseQtree qtree, Mapa mapa)
        {
            if (!IsIncludedInQtree(mapa, qtree))
            {
                return;
            }

            for (var j = mapa.Poligonales.Count - 1; j >= 0; j--)
            {
                var poligonal = mapa.Poligonales[j];
                if (!Drawable(poligonal.Nivel))
                {
                    continue;
                }

                var vertices = mapa.Poligonales.GetVertices(j);

                LonLat last     = null;
                var    drawNext = true;
                foreach (var vertice in vertices)
                {
                    var lonlat = new LonLat(mapa.Coords[Math.Abs(vertice)]);
                    if (last != null && drawNext)
                    {
                        var qs = qtree.MakeLeafLine(last.Longitud, last.Latitud, lonlat.Longitud, lonlat.Latitud, GetNivel(poligonal.Nivel).BrushSize);
                        for (var i = 0; i < qs.Count; i++)
                        {
                            var leaf = qs[i];
                            if (!leaf.Locked && CanOverwrite(poligonal.Nivel, leaf.Valor) &&
                                qtree.IsInsideQtree(leaf.Posicion.Latitud, leaf.Posicion.Longitud))
                            {
                                var latlon = qtree.GetCenterLatLon(leaf.Posicion);
                                qs[i] = qtree.SetValue(latlon.Latitud, latlon.Longitud, GetNivel(poligonal.Nivel).NivelQtree);
                                qtree.Commit();
                            }
                        }
                    }
                    last     = lonlat;
                    drawNext = vertice > 0;
                }
            }
        }
Пример #26
0
        public void LoadDEMTest1()
        {
            const byte   z           = 12;
            const double lat         = 41.797184;
            const double lon         = 140.756831;
            var          center      = new LonLat(PlaneAngle.FromDegrees(lon), PlaneAngle.FromDegrees(lat));
            var          delta_angle = PlaneAngle.FromDegrees(0, 8, 0);
            var          delta       = new LonLat(delta_angle, delta_angle);
            //var vs = LoadDEM( z, center, delta );
            var vs = LoadDEM(out var d, z, center, Length.From_km(18));

            System.Console.WriteLine($"{d}");
            Assert.IsNotNull(vs);
            //Assert.AreEqual( 0.19, vs[ 694, 1014 ], 0.01 );
            //Assert.AreEqual( 4.01, vs[ 695, 1014 ], 0.01 );
            //Assert.AreEqual( 3.18, vs[ 696, 1014 ], 0.01 );
            //Assert.AreEqual( 3.18, vs[ 697, 1014 ], 0.01 );
            var i = SavePNGNumberTileS(vs, 1.0e-2, 0, Color.FromArgb(255, 128, 0, 0));

            i.Save(System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.DesktopDirectory), $"GK/tmp/neko{z}.png"), System.Drawing.Imaging.ImageFormat.Png);
        }
Пример #27
0
        static void Main(string[] args)
        {
            Console.Write("QuadTree Tester Inicializando v 1.0\r\n");

            string basedir = @"C:\QTREE_REPO";

            var repo = new Repository();

            if (!System.IO.Directory.Exists(basedir))
            {
                Console.Write("El repositorio [{0}] no existe, lo creamos.\r\n", basedir);
                StorageGeometry sgeom = new StorageGeometry()
                {
                    Signature       = "0123456789ABCDEF",
                    CellBits        = (char)4,
                    ActiveKey       = 0x55AA55AA,
                    DataStart       = 2,
                    FileSectorCount = 64,
                    Lat_OffSet      = 340000000,
                    Lon_OffSet      = 580000000,
                    Lat_Grid        = 5000,
                    Lon_Grid        = 5000,
                    Lat_GridCount   = 2000,
                    Lon_GridCount   = 2000
                };

                if (!repo.Init(basedir, sgeom))
                {
                    Console.Write("Imposible inicializar el repositorio GR2\r\n");
                    Console.ReadLine();
                    return;
                }
            }

            StorageGeometry sgeom2 = new StorageGeometry();

            if (!repo.Open(basedir, ref sgeom2))
            {
                Console.Write("El repositorio GR2 parece corrupto.\r\n");
                Console.ReadLine();
                return;
            }


            Console.WriteLine("Header Signature: {0}", sgeom2.Signature);
            Console.ReadLine();


            var Cartografia = new Cartografia("C:\\MapasCopia");

            foreach (var map in Cartografia)
            {
                for (int j = map.Poligonos.Count - 1; j >= 0; j--)
                {
                    var poligono = map.Poligonos[j];
                    if (poligono.Nivel != 5000)
                    {
                        continue;
                    }
                    int[] vertices = map.Poligonos.GetVertices(j);


                    for (int i = 0; i < vertices.Length; i++)
                    {
                        var vertex = vertices[i];
                        var lonlat = new LonLat(map.Coords[vertex]);
                        //6T.TRACE("Creando vertice #{0} {1} {2}", vertex, lonlat.Latitud, lonlat.Longitud);
                        repo.SetPositionClass((float)lonlat.Latitud, (float)lonlat.Longitud, 1);
                        var Gr2Cache = repo.IndexCatalog.OfType <GR2>().FirstOrDefault();
                        Gr2Cache.SetReference((float)lonlat.Latitud, (float)lonlat.Longitud, "v", map.Vertices[vertex]);
                    }
                }
            }

            repo.SetPositionClass(34.5665F, 55.2235F, 12);
            int clase     = repo.GetPositionClass(34.5665F, 55.2235F);
            var Gr2Cache2 = repo.IndexCatalog.OfType <GR2>().FirstOrDefault();
            var rd        = Gr2Cache2.GetReference <Vertice>(34.5665F, 55.2235F, "vertices");

            Vertice ppp = new Vertice()
            {
                Tipo = 22123123, Prioridad = 1234, NReg = 2357
            };

            Gr2Cache2.SetReference(34.5665F, 55.2235F, "vertices", ppp);
            Console.Write("sample: clase leida {0}\r\n", clase);
            Console.Write("\r\n");

            /*
             * qtree.SetPositionClass(34.2665, 55.4235, 3);
             * qtree.SetPositionClass(34.267, 55.4235, 4);
             * qtree.SetPositionClass(34.268, 55.4235, 5);
             * qtree.SetPositionClass(34.269, 55.4235, 6);
             * qtree.SetPositionClass(34.270, 55.4235, 7);
             * qtree.SetPositionClass(34.271, 55.4235, 8);
             *
             * clase = qtree.GetPositionClass(34.2665, 55.4235);
             * Console.Write("sample: clase leida {0}\r\n", clase);
             * Console.Write("\r\n");
             *
             * clase = qtree.GetPositionClass(34.5665, 55.2235);
             * Console.Write("sample: clase leida {0}\r\n", clase);
             * Console.Write("\r\n");
             *
             * clase = qtree.GetPositionClass(34.2665, 55.4235);
             * Console.Write("sample: clase leida {0}\r\n", clase);
             * Console.Write("\r\n");
             *
             * qtree.SetPositionClass(37.5665, 55.2235, 12);
             * clase = qtree.GetPositionClass(37.5665, 55.2235);
             * Console.Write("sample: clase leida {0}\r\n", clase);
             * Console.Write("\r\n");
             *
             * qtree.SetPositionClass(37.2665, 55.4235, 3);
             * clase = qtree.GetPositionClass(37.2665, 55.4235);
             *
             * Console.Write("sample: clase leida {0}\r\n", clase);
             * Console.Write("\r\n");
             *
             * clase = qtree.GetPositionClass(37.5665, 55.2235);
             * Console.Write("sample: clase leida {0}\r\n", clase);
             * Console.Write("\r\n");
             *
             * clase = qtree.GetPositionClass(37.2665, 55.4235);
             * Console.Write("sample: clase leida {0}\r\n", clase);
             * Console.Write("\r\n");
             *
             * qtree.SetPositionClass(37.2665, 55.4235, 8);
             * clase = qtree.GetPositionClass(37.2665, 55.4235);
             * Console.Write("sample: clase leida {0}\r\n", clase);
             * Console.Write("\r\n");
             *
             * qtree.SetPositionClass(34.0, 55.0, 4);
             * qtree.SetPositionClass(34.99999, 55.99999, 4);
             *
             * qtree.SetPositionClass(46.5, 65.5, 5);
             * qtree.SetPositionClass(47.2, 56.4, 15); */


            repo.Close();
            Console.ReadLine();
        }
Пример #28
0
 /// <summary>
 /// 获取,未实现
 /// </summary>
 /// <param name="time"></param>
 /// <param name="geocentricLonlatDeg"></param>
 /// <returns></returns>
 public RmsedNumeral Get(Time time, LonLat geocentricLonlatDeg)
 {
     throw new Exception("参数化电离层服务不提供此服务!");
 }
Пример #29
0
 /// <summary>
 /// 経緯度を元に生成
 /// </summary>
 /// <param name="a">経緯度</param>
 /// <param name="crs">測地系; 省略時 null</param>
 /// <param name="u">不確実性パラメーター値; 省略時 null</param>
 public GeoURI(LonLat a, string crs = null, string u = null)
     : this(a.Longitude, a.Latitude, null, crs, u)
 {
 }
Пример #30
0
        /// <summary>
        /// 内插不同经纬度的值。
        /// </summary>
        /// <param name="IonoSection"></param>
        /// <param name="geoCoord">待内插坐标</param>
        /// <returns></returns>
        public RmsedNumeral Interpolate(IonoSection IonoSection, LonLat geoCoord)
        {
            List <double> lats = Geo.Utils.DoubleUtil.GetNearst(IonoSection.Keys, geoCoord.Lat, false);

            if (lats.Count == 1)//在指定的纬度圈上面
            {
                var           lat    = lats[0];
                IonoRecord    record = IonoSection.Get(lat);
                List <double> lons   = Geo.Utils.DoubleUtil.GetNearst(record.Keys, geoCoord.Lon, false);
                if (lons.Count == 1) //刚好,找到你了,不用差值
                {
                    var lon = lons[0];
                    return(record[lon]);
                }
                else if (lons.Count == 3)//差值
                {
                    var lon1 = lons[1];
                    var lon2 = lons[2];
                    var val1 = record[lon1];
                    var val2 = record[lon2];
                    var val  = Geo.Utils.DoubleUtil.Interpolate(geoCoord.Lon, lon1, lon2, val1.Value, val2.Value);
                    var rms  = Geo.Utils.DoubleUtil.Interpolate(geoCoord.Lon, lon1, lon2, val1.Rms, val2.Rms);
                    return(new RmsedNumeral(val, rms));
                }
                else
                {
                    throw new Exception("内插错误,获取经度值失败");
                }
            }
            else if (lats.Count == 3)
            {
                var lat1 = lats[1];
                var lat2 = lats[2];

                IonoRecord record1 = IonoSection.Get(lat1);
                IonoRecord record2 = IonoSection.Get(lat2);

                var           lat    = lats[0];
                IonoRecord    record = IonoSection.Get(lat);
                List <double> lons   = Geo.Utils.DoubleUtil.GetNearst(record1.Keys, geoCoord.Lon, false);

                if (lons.Count == 1)
                {
                    var lon  = lons[0];
                    var val0 = record1[lon];
                    var val1 = record2[lon];
                    var val  = Geo.Utils.DoubleUtil.Interpolate(geoCoord.Lat, lat1, lat2, val0.Value, val1.Value);
                    var rms  = Geo.Utils.DoubleUtil.Interpolate(geoCoord.Lat, lat1, lat2, val0.Rms, val1.Rms);
                    return(new RmsedNumeral(val, rms));
                }
                else if (lons.Count >= 3)
                {
                    var lon1 = lons[1];
                    var lon2 = lons[2];

                    var val11 = record1[lon1];
                    var val12 = record1[lon2];
                    var val21 = record2[lon1];
                    var val22 = record2[lon2];


                    var val = Geo.Utils.DoubleUtil.Interpolate(geoCoord.Lon, geoCoord.Lat, lon1, lon2, lat1, lat2, val11.Value, val12.Value, val21.Value, val22.Value);
                    var rms = Geo.Utils.DoubleUtil.Interpolate(geoCoord.Lon, geoCoord.Lat, lon1, lon2, lat1, lat2, val11.Rms, val12.Rms, val21.Rms, val22.Rms);
                    return(new RmsedNumeral(val, rms));
                }
            }
            else
            {
                throw new Exception("内插错误,获取值纬度失败");
            }
            throw new Exception("内插错误,不可能出现");
        }