Exemplo n.º 1
0
        public Double getDistance(String firstAddress, String secondAddress)
        {
            GeoCodingResult firstCoordinate  = googleGeocoding.geocode(firstAddress);
            GeoCodingResult secondCoordinate = googleGeocoding.geocode(secondAddress);

            return(distanceEngine.evaluate(firstCoordinate, secondCoordinate));
        }
Exemplo n.º 2
0
        public double evaluate(GeoCodingResult c1, GeoCodingResult c2)
        {
            double dlong = (c2.lng - c1.lng) * DEGREE_TO_RADIAN;
            double dlat  = (c2.lat - c1.lat) * DEGREE_TO_RADIAN;
            double a     = Math.Pow(Math.Sin(dlat / 2D), 2D) +
                           Math.Cos(c1.lat * DEGREE_TO_RADIAN) * Math.Cos(c2.lat * DEGREE_TO_RADIAN) * Math.Pow(Math.Sin(dlong / 2D), 2D);
            double c = 2D * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1D - a));

            return(EARTH_RADIUS_IN_METERS * c);
        }
Exemplo n.º 3
0
        public Boolean equals(GeoCodingResult that)
        {
            if (that == null)
            {
                return(false);
            }
            if (this == that)
            {
                return(true);
            }

            return(lat == that.lat && lng == that.lng);
        }