开发者

Getting the rectangle four points of given one latitude and one longitude only

I am reading this: http://www.panoramio.com/api/widget/api.html#photo-widget to build a JavaScript photo widget.

Under Request -> request object table, it is written:

name: rect

example value: {'sw': {'lat': -开发者_开发技巧30, 'lng': 10.5}, 'ne': {'lat': 50.5, 'lng': 30}}

meaning: This option is only valid for requests where you do not use the ids option. It indicates that only photos that are in a certain area are to be shown. The area is given as a latitude-longitude rectangle, with sw at the south-west corner and ne at the north-east corner. Each corner has a lat field for the latitude, in degrees, and a lng field for the longitude, in degrees. Northern latitudes and eastern longitudes are positive, and southern latitudes and western longitudes are negative. Note that the south-west corner may be more "eastern" than the north-east corner if the selected rectangle crosses the 180° meridian

But usually we are only given one latitude point, and one longitude point.

What kind of expressions should I write to build the four points as stated above, to cover the pictures around the area given two points I have in hand?

For example, I have in Paris:

lat: 48.8566667

lng: 2.3509871

I want to cover pictures around it 10km rectangle.

Thanks.


Here's the answer I got from Panoramio Forum by QuentinUK.

Can't do a 10km distance because this implies a circular region. It can only do rectangular.

So you might as well approximate (best is use Vincenty's formulae) and calculate an angle +/- around the point.

function requestAroundLatLong(lat,lng,km){
   // angle per km = 360 / (2 * pi * 6378) = 0.0089833458
   var angle=km* 0.0089833458;
   var myRequest = new panoramio.PhotoRequest({
      'rect': {'sw': {'lat': lat-angle, 'lng': lng-angle}, 'ne': {'lat': lat+angle, 'lng': lng+angle}}
      });
   return myRequest;
   }

var widget = new panoramio.PhotoWidget('wapiblock', requestAroundLatLong(48.8566667, 2.3509871,10), myOptions); 


If you want to use REST api:

var Lattitude = "48.8566667"; var Longitude = "2.3509871";

var angle = km * 0.0089833458;

        testo.Text = "<script src=\"http://www.panoramio.com/map/get_panoramas.php?order=popularity&set=full&from=0&to=14&minx=" + clon - angle + "&miny=" + clat - angle + "&maxx=" + clon + angle + "&maxy=" + clat + angle + "&callback=mostrareFotos&size=medium\" type=\"text/javascript\"></script>";
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜