user3245049
user3245049

Reputation: 3

Get lat/longitude values of bounding box given centre point and radius

I am using the Twitter4j API to get all streaming tweets in a given area.

FilterQuery is used to define this query and accepts co-ordinates for a bounding box search area in the following format:

double box[][] = {{lon1, lat1}, {lon2, lat2}};
new FilterQuery(count, idToFollow, stringsToTrack, box);

Given my centre points (latOriginal,longOriginal), and my radius (radius), is there a clever way of calculating these bounding box value co-ordinates?

Thanks

Upvotes: 0

Views: 1108

Answers (1)

geocodezip
geocodezip

Reputation: 161404

the bounding box is 2R across and 2R high.

var north = google.maps.geometry.spherical.computeOffset(center, radius, 0).lat();
var east  = google.maps.geometry.spherical.computeOffset(center, radius, 90).lng();
var south = google.maps.geometry.spherical.computeOffset(center, radius, 180).lat();
var west  = google.maps.geometry.spherical.computeOffset(center, radius, -90).lng();

Upvotes: 3

Related Questions