Пример #1
0
 public static GeoCoord Minimizer(Func<GeoCoord, double> f, GeoCoord guess)
 {
     var ret = Minimizer((x) => f(new GeoCoord(x[0], x[1])), new double[] { guess.Latitude, guess.Longitude }, new double[] { 0.1, 0.1 });
     return new GeoCoord(ret[0], ret[1]);
 }
Пример #2
0
        public Point OffsetInMeters(GeoCoord geoC)
        {
            // Determine the actual size of the geography.
            // From http://en.wikipedia.org/wiki/Latitude,
            // and assuming the earth is spherical (e=1)

            double x = -(this.Longitude - geoC.Longitude) * LonDegreeSizeInMeters;
            double y = (this.Latitude - geoC.Latitude) * LatDegreeSizeInMeters;
            var ret = new Point(x, y);
            return ret;
        }
Пример #3
0
 public GeoCoord FromOffset(double x, double y)
 {
     double Longitude = this.Longitude + x / LonDegreeSizeInMeters;
     double Latitude = this.Latitude - y / LatDegreeSizeInMeters;
     var ret = new GeoCoord(Latitude, Longitude);
     return ret;
 }
Пример #4
0
 /// <returns>Meters squared</returns>
 public double DistSqr(GeoCoord x0)
 {
     var offsetMeters = OffsetInMeters(x0);
     return offsetMeters.Square();
 }
Пример #5
0
 internal double Strength(GeoCoord x)
 {
     var ret = FitFunction(x, new GeoCoord(this.CenterLatitude, this.CenterLongitude), 1 / Spread);
     return ret;
 }
Пример #6
0
 internal static double FitFunction(GeoCoord x, GeoCoord x0, double invWidth)
 {
     var ret = 100 * Math.Exp(-x.DistSqr(x0) * invWidth * invWidth);
     return ret;
 }