Пример #1
0
        public List <AreaInfo> GetEnvelopAreasOfLocation(Utils.Location loc, List <AreaInfo> inAreas)
        {
            List <AreaInfo> result = null;

            if (loc.Lat >= _shpYMin && loc.Lat <= _shpYMax && loc.Lon >= _shpXMin && loc.Lon <= _shpXMax)
            {
                //all areas with point in envelope
                var ais = from r in _areaInfos
                          join b in inAreas on r equals b
                          where loc.Lat >= r.MinLat && loc.Lat <= r.MaxLat && loc.Lon >= r.MinLon && loc.Lon <= r.MaxLon
                          select r;
                foreach (var ai in ais)
                {
                    if (IsLocationInEnvelopArea(loc, ai))
                    {
                        if (result == null)
                        {
                            result = new List <AreaInfo>();
                        }
                        result.Add(ai);
                    }
                }
            }
            return(result);
        }
Пример #2
0
        public override object Execute(object[] args, ExecutionContext ctx)
        {
            ArgumentChecker checker = new ArgumentChecker(this.GetType().Name);

            checker.CheckForNumberOfArguments(ref args, 1, 1);
            Utils.Location ll = Utils.Conversion.StringToLocation(args[0].ToString());
            if (ll != null)
            {
                return(ll.Lat.ToString("G", CultureInfo.InvariantCulture));
            }
            return("");
        }
Пример #3
0
        public List <AreaInfo> GetEnvelopAreasOfLocation(Utils.Location loc, List <AreaInfo> inAreas)
        {
            List <AreaInfo> result = new List <AreaInfo>();

            foreach (var sf in _shapeFiles)
            {
                List <AreaInfo> areas = sf.GetEnvelopAreasOfLocation(loc, inAreas);
                if (areas != null)
                {
                    result.AddRange(areas);
                }
            }
            return(result);
        }
Пример #4
0
        public override object Execute(object[] args, ExecutionContext ctx)
        {
            string          res     = "";
            ArgumentChecker checker = new ArgumentChecker(this.GetType().Name);

            checker.CheckForNumberOfArguments(ref args, 2, null);
            Utils.Location ll1 = Utils.Conversion.StringToLocation(args[0].ToString());
            Utils.Location ll2 = Utils.Conversion.StringToLocation(args[1].ToString());
            if ((ll1 != null) && (ll2 != null))
            {
                GeodeticMeasurement gm = Utils.Calculus.CalculateDistance(ll1.Lat, ll1.Lon, ll2.Lat, ll2.Lon);
                res = gm.Azimuth.Degrees.ToString("0");
            }
            return(res);
        }
Пример #5
0
 public override bool PrepareRun(Database.DBCon db, string tableName)
 {
     if (Values.Count > 1)
     {
         try
         {
             _loc   = Utils.Conversion.StringToLocation(Values[0]);
             _value = Utils.Conversion.StringToDouble(Values[1]);
         }
         catch
         {
         }
     }
     return(base.PrepareRun(db, tableName));
 }
Пример #6
0
        public override object Execute(object[] args, ExecutionContext ctx)
        {
            string          ret     = "";
            ArgumentChecker checker = new ArgumentChecker(this.GetType().Name);

            checker.CheckForNumberOfArguments(ref args, 3, null);
            Utils.Location ll       = Utils.Conversion.StringToLocation(args[0].ToString());
            double         distance = Utils.Conversion.StringToDouble(args[1].ToString());
            double         angle    = Utils.Conversion.StringToDouble(args[2].ToString());

            if (ll != null)
            {
                GeodeticCalculator gc = new GeodeticCalculator();
                GlobalCoordinates  p  = gc.CalculateEndingGlobalCoordinates(Ellipsoid.WGS84,
                                                                            new GlobalCoordinates(new Angle(ll.Lat), new Angle(ll.Lon)),
                                                                            new Angle(angle), distance);
                ret = Utils.Conversion.GetCoordinatesPresentation(p.Latitude.Degrees, p.Longitude.Degrees);
            }

            return(ret);
        }
Пример #7
0
        private bool IsLocationInEnvelopArea(Utils.Location loc, AreaInfo area)
        {
            bool result = false;

            //point in envelope of area
            if (loc.Lat >= area.MinLat && loc.Lat <= area.MaxLat && loc.Lon >= area.MinLon && loc.Lon <= area.MaxLon)
            {
                GetPolygonOfArea(area);
                if (area.Polygons != null)
                {
                    foreach (var r in area.Polygons)
                    {
                        //point in envelope of polygon
                        if (loc.Lat >= r.MinLat && loc.Lat <= r.MaxLat && loc.Lon >= r.MinLon && loc.Lon <= r.MaxLon)
                        {
                            result = true;
                            break;
                        }
                    }
                }
            }
            return(result);
        }
Пример #8
0
 private bool IsLocationInArea(Utils.Location loc, AreaInfo area)
 {
     return(IsLocationInArea(loc.Lat, loc.Lon, area));
 }
 public override bool PrepareRun(Database.DBCon db, string tableName)
 {
     if (Values.Count > 1)
     {
         try
         {
             _loc = Utils.Conversion.StringToLocation(Values[0]);
             _value = Utils.Conversion.StringToDouble(Values[1]);
         }
         catch
         {
         }
     }
     return base.PrepareRun(db, tableName);
 }
Пример #10
0
        public override object Execute(object[] args, ExecutionContext ctx)
        {
            string          ret     = StrRes.GetString(StrRes.STR_NO_CROSSING);
            ArgumentChecker checker = new ArgumentChecker(this.GetType().Name);

            checker.CheckForNumberOfArguments(ref args, 4, null);

            Utils.Location ll0 = Utils.Conversion.StringToLocation(args[0].ToString());
            Utils.Location ll1 = Utils.Conversion.StringToLocation(args[1].ToString());
            Utils.Location ll2 = Utils.Conversion.StringToLocation(args[2].ToString());
            Utils.Location ll3 = Utils.Conversion.StringToLocation(args[3].ToString());

            // x -> Lon , y -> Lat
            decimal y0 = (decimal)ll0.Lat;
            decimal y1 = (decimal)ll1.Lat;
            decimal y2 = (decimal)ll2.Lat;
            decimal y3 = (decimal)ll3.Lat;

            decimal x0 = (decimal)ll0.Lon;
            decimal x1 = (decimal)ll1.Lon;
            decimal x2 = (decimal)ll2.Lon;
            decimal x3 = (decimal)ll3.Lon;

            decimal?m0 = null;  // Gerade 1 senkrecht -> alle x-Werte der Geraden sind gleich
            decimal?m1 = null;  // Gerade 2 senkrecht -> alle x-Werte der Geraden sind gleich
            decimal?n0 = null;
            decimal?n1 = null;

            if (x1 != x0)
            {
                m0 = (y1 - y0) / (x1 - x0);
            }

            if (x3 != x2)
            {
                m1 = (y3 - y2) / (x3 - x2);
            }

            if (m0 != m1)
            {
                decimal?lon = null;
                decimal?lat = null;
                if (m0 == null)
                {
                    n1  = y2 - x2 * m1;
                    lon = x0;
                    lat = m1 * x0 + n1;
                }
                else if (m1 == null)
                {
                    n0  = y0 - x0 * m0;
                    lon = x2;
                    lat = m0 * x2 + n0;
                }
                else
                {
                    n0 = y0 - x0 * m0;
                    n1 = y2 - x2 * m1;

                    lon = (n1 - n0) / (m0 - m1); // x
                    lat = lon * m0 + n0;         // y
                }
                ret = Utils.Conversion.GetCoordinatesPresentation((double)lat, (double)lon);
            }
            return(ret);
        }