iosobjective-cpanoramio

Can't get Panoramio Data with API


I am trying to get panoramio picture around a given coordinate. However always my query returns zero photos. This is the code I am using.

const double WGS84_a = 6378137.0;
const double WGS84_b = 6356752.3;

double Deg2rad(double degrees) {
  return degrees * M_PI / 180.0;
}

double Rad2deg(double radians) {
  return radians * 180.0 / M_PI;
}
double WGS84EarthRadius(double lat)
{
  double An = WGS84_a*WGS84_a * cos(lat);
  double Bn = WGS84_b*WGS84_b * sin(lat);
  double Ad = WGS84_a * cos(lat);
  double Bd = WGS84_b * sin(lat);
  return sqrt( (An*An + Bn*Bn)/(Ad*Ad + Bd*Bd) );
}
MapRect LatLonDestPoint(CLLocationCoordinate2D origin, double halfSideInKm) {

  double lat = Deg2rad(origin.latitude);
  double lon = Deg2rad(origin.longitude);
  double halfSide = 1000*halfSideInKm;

  double radius = WGS84EarthRadius(lat);
  double pradius = radius*cos(lat);

  double latMin = lat - halfSide/radius;
  double latMax = lat + halfSide/radius;
  double lonMin = lon - halfSide/pradius;
  double lonMax = lon + halfSide/pradius;
  return MKMapRectMake(Rad2deg(latMin), Rad2deg(lonMin), Rad2deg(latMax), Rad2deg(lonMax));
}

Now for a coordinate (60.1190935704,-149.439081366) I get the API like

http://www.panoramio.com/map/get_panoramas.php?set=public&from=0&to=20&minx=60.029034&miny=-149.619843&maxx=60.209152&maxy=-149.258316&size=medium&mapfilter=true

This always returns me zero results. Please help me with what I am doing wrong.


Solution

  • You have x and y coordinates the wrong way around.

    Swapping these returns:-

    {"count":379,"has_more":true,"map_location":{"lat":60.118290103595498,"lon":-149.45469385385852,"panoramio_zoom":6}

    etc

    ps Do not rely on the count being correct. Use the has_more flag.