Exemplo n.º 1
0
GeoPoint
Projection::ScreenToGeo(int x, int y) const
{
  const FastIntegerRotation::Pair p =
    ScreenRotation.Rotate(x - ScreenOrigin.x, y - ScreenOrigin.y);

  GeoPoint g(PixelsToAngle(p.first), PixelsToAngle(p.second));

  g.Latitude = GeoLocation.Latitude - g.Latitude;
  g.Longitude = GeoLocation.Longitude + g.Longitude * g.Latitude.invfastcosine();

  return g;
}
Exemplo n.º 2
0
GeoPoint
Projection::ScreenToGeo(int x, int y) const
{
  const FastIntegerRotation::Pair p =
    screen_rotation.Rotate(x - screen_origin.x, y - screen_origin.y);

  GeoPoint g(PixelsToAngle(p.first), PixelsToAngle(p.second));

  g.latitude = geo_location.latitude - g.latitude;

  /* paranoid sanity check to avoid integer overflow near the poles;
     our projection isn't doing well at all there; this check avoids
     assertion failures when the user pans all the way up/down */
  const Angle latitude(std::min(Angle::Degrees(fixed(80)),
                                std::max(Angle::Degrees(fixed(-80)),
                                         g.latitude)));

  g.longitude = geo_location.longitude + g.longitude * latitude.invfastcosine();

  return g;
}