How can we calculate bound from a point?

Viewed 27

I have a coordinate. How can we calculate the bounds that the point is centered in map?

Call that point O and its bound has size 5x5m

enter image description here.

Do any of you have a solution? I don't have a solution yet.

1 Answers

Solution:

         * Returns the Point resulting from moving a distance from an origin in the
         * specified heading (expressed in degrees clockwise from north).
         *
         * @param from     The Point from which to start.
         * @param distance The distance to travel.
         * @param heading  The heading in degrees clockwise from north.
         */
public static Point computeOffset(Point from, double distance, double heading)
        {
            distance /= MathUtil.EARTH_RADIUS;
            heading = MathUtil.convertToRadians(heading);
            // http://williams.best.vwh.net/avform.htm#LL
            double fromLat = MathUtil.convertToRadians(from.Lat);
            double fromLng = MathUtil.convertToRadians(from.Lng);
            double cosDistance = Math.Cos(distance);
            double sinDistance = Math.Sin(distance);
            double sinFromLat = Math.Sin(fromLat);
            double cosFromLat = Math.Cos(fromLat);
            double sinLat = cosDistance * sinFromLat + sinDistance * cosFromLat * Math.Cos(heading);
            double dLng = Math.Atan2(sinDistance * cosFromLat * Math.Sin(heading), cosDistance - sinFromLat * sinLat);
            return new Point(MathUtil.toDegreesFromRadians(Math.Asin(sinLat)), MathUtil.toDegreesFromRadians(fromLng + dLng));
        }
Related