Question

I need to take a point, and determine what the point is that's N miles north-west of it, and N miles south-east of it. It'll essentially create a bounding box around the initial point.

I've looked around a bit, and found some stuff about Haversine, but it seems like all of the code implementations are for the distance between two points, not a new point component from a point.

Is there an existing implementation of such a thing, preferably in Java, that already exists? Or any other language?

Here is the methods I'd imagine that'd I'd need:

public float longitudeFromPoint( float lat, float long, int vertical, int horizontal )
{
    // something
}

public float latitudeFromPoint( float lat, float long, int vertical, int horizontal )
{
    // something
}

float startLat  = 41.829347;
float startLong = -87.633788

float northWestLat  = latitudeFromPoint( startLat, startLong, 1, -1 );
float northWestLong = latitudeFromPoint( startLat, startLong, 1, -1 );

float southWestLat  = latitudeFromPoint( startLat, startLong, -1, 1 );
float southWestLong = latitudeFromPoint( startLat, startLong, -1, 1 );
Was it helpful?

Solution

This may be worth reading: Finding Points Within a Distance of a Latitude/Longitude Using Bounding Coordinates. It gives a short theoretical background on spherical coordinates and provides some java code.

The link is borrowed from the accepted answer to this thread on SO: Calculating bounding box a certain distance away from a lat/long coordinate in Java

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top