Esempio n. 1
0
 public Area CalculateArea(Envelope envelope)
 {
     var h1 = Radius * (1 - Math.Cos(envelope.MaxLat.ToRadians()));
     var h2 = Radius * (1 - Math.Cos(envelope.MinLat.ToRadians()));
     var zoneArea = 2 * Math.PI * Radius * (h2 - h1);
     var lonPercentage = (envelope.MaxLon - envelope.MinLon) / 360;
     return new Area(zoneArea * lonPercentage);
 }
Esempio n. 2
0
 public bool Contains(Envelope envelope)
 {
     return envelope != null
         && envelope.MinLat > MinLat
         && envelope.MaxLat < MaxLat
         && envelope.MinLon > MinLon
         && envelope.MaxLat < MaxLat;
 }
Esempio n. 3
0
        public Envelope Combine(Envelope other)
        {
            if (other == null)
                return this;

            return new Envelope(
                Math.Min(MinLat, other.MinLat),
                Math.Min(MinLon, other.MinLon),
                Math.Min(MaxLat, other.MaxLat),
                Math.Min(MaxLon, other.MaxLon)
            );
        }
Esempio n. 4
0
        private bool TryReadEnvelope(string value, out ISpatial4nShape result)
        {
            var match = Regex.Match(value,
                        @"^ \s* (-?\d+.\d+?) \s+ (-?\d+.\d+?) \s+ (-?\d+.\d+?) \s+ (-?\d+.\d+?) \s* $",
                        RegexOptions.IgnorePatternWhitespace | RegexOptions.IgnoreCase);

            if (match.Success)
            {
                result = new Envelope(
                    double.Parse(match.Groups[2].Value, CultureInfo.InvariantCulture),
                    double.Parse(match.Groups[1].Value, CultureInfo.InvariantCulture),
                    double.Parse(match.Groups[4].Value, CultureInfo.InvariantCulture),
                    double.Parse(match.Groups[3].Value, CultureInfo.InvariantCulture)
                    );
                return true;
            }
            result = null;
            return false;
        }
Esempio n. 5
0
 public Distance CalculateLength(Envelope envelope)
 {
     return _sphereCalculator.CalculateLength(envelope);
 }
Esempio n. 6
0
 public Area CalculateArea(Envelope envelope)
 {
     return _sphereCalculator.CalculateArea(envelope);
 }
Esempio n. 7
0
        public Distance CalculateLength(Envelope envelope)
        {
            var lat = 180 / envelope.MaxLat - envelope.MinLat;
            var lon = 360 / envelope.MaxLon - envelope.MinLon;
            if (envelope.MinLon > envelope.MaxLon)
                lon = 1 - lon;

            var h1 = Radius * (1 - Math.Cos(envelope.MaxLat.ToRadians()));
            var h2 = Radius * (1 - Math.Cos(envelope.MinLat.ToRadians()));

            var r1 = Math.Sqrt(h1*(2*Radius - h1));
            var r2 = Math.Sqrt(h2*(2*Radius - h2));

            var c1 = 2 * Math.PI * r1 * lon;
            var c2 = 2 * Math.PI * r2 * lon;
            var c3 = 2 * Math.PI * Radius * lat * 2;

            return new Distance(c1 + c2 + c3);
        }
Esempio n. 8
0
 public bool Intersects(Envelope envelope)
 {
     return envelope.GetExtremeCoordinates().Any(Contains)
         || GetExtremeCoordinates().Any(envelope.Contains);
 }