internals::PointLatLng PlateCarreeProjectionPergo::FromPixelToLatLng(const int &x, const int &y, const int &zoom)
{
    internals::PointLatLng ret;// = internals::PointLatLng.Empty;

    Size s = GetTileMatrixSizePixel(zoom);
    double mapSizeX = s.Width();
    //double mapSizeY = s.Height();

    double scale = 360.0 / mapSizeX;

    ret.SetLat(90 - (y * scale));
    ret.SetLng((x * scale) - 180);

    return ret;
}
Exemplo n.º 2
0
internals::PointLatLng MercatorProjection::FromPixelToLatLng(const int &x, const int &y, const int &zoom)
{
    internals::PointLatLng ret;// = internals::PointLatLng.Empty;

    Size s = GetTileMatrixSizePixel(zoom);
    double mapSizeX = s.Width();
    double mapSizeY = s.Height();

    double xx = (Clip(x, 0, mapSizeX - 1) / mapSizeX) - 0.5;
    double yy = 0.5 - (Clip(y, 0, mapSizeY - 1) / mapSizeY);

    ret.SetLat(90 - 360 * atan(exp(-yy * 2 * M_PI)) / M_PI);
    ret.SetLng(360 * xx);

    return ret;
}
Exemplo n.º 3
0
/**
 * @brief MercatorProjection::FromPixelToLatLng Referenced from top-left of globe, so the lat-lon (0,0), i.e. the intersection of the equator and prime meridian, would be [1<<(zoom-1), 1<<(zoom-1)]
 * @param x Horizontal location in [pixels], referenced from left edge of global map
 * @param y Vertical location in [pixels], referenced from top edge of global map
 * @param zoom
 * @return Latitude and Longitude in [degrees]
 */
internals::PointLatLng MercatorProjection::FromPixelToLatLng(const qint64 &x,const qint64 &y,const int &zoom)
{
    internals::PointLatLng ret;// = internals::PointLatLng.Empty;

    Size s = GetTileMatrixSizePixel(zoom);
    double mapSizeX = s.Width();
    double mapSizeY = s.Height();

    //Calculate the percentage distance between top and bottom, and left and right
    double xx = (bound(x, 0, mapSizeX - 1) / mapSizeX) - 0.5;
    double yy = 0.5 - (bound(y, 0, mapSizeY - 1) / mapSizeY);

    ret.SetLat(90 - 360 * atan(exp(-yy * 2 * M_PI)) / M_PI);
    ret.SetLng(360 * xx);

    return ret;
}
Point PlateCarreeProjectionPergo::FromLatLngToPixel(double lat, double lng, const int &zoom)
{
    Point ret;// = Point.Empty;

    lat = Clip(lat, MinLatitude, MaxLatitude);
    lng = Clip(lng, MinLongitude, MaxLongitude);

    Size s = GetTileMatrixSizePixel(zoom);
    double mapSizeX = s.Width();
    //double mapSizeY = s.Height();

    double scale = 360.0 / mapSizeX;

    ret.SetY((int) ((90.0 - lat) / scale));
    ret.SetX((int) ((lng + 180.0) / scale));

    return ret;
}
Exemplo n.º 5
0
Point MercatorProjection::FromLatLngToPixel(double lat, double lng, const int &zoom)
{
    Point ret;// = Point.Empty;

    lat = Clip(lat, MinLatitude, MaxLatitude);
    lng = Clip(lng, MinLongitude, MaxLongitude);

    double x = (lng + 180) / 360;
    double sinLatitude = sin(lat * M_PI / 180);
    double y = 0.5 - log((1 + sinLatitude) / (1 - sinLatitude)) / (4 * M_PI);

    Size s = GetTileMatrixSizePixel(zoom);
    int mapSizeX = s.Width();
    int mapSizeY = s.Height();

    ret.SetX((int) Clip(x * mapSizeX + 0.5, 0, mapSizeX - 1));
    ret.SetY((int) Clip(y * mapSizeY + 0.5, 0, mapSizeY - 1));

    return ret;
}
Exemplo n.º 6
0
 double PureProjection::GetGroundResolution(const int &zoom,const double &latitude)
 {
     return (cos(latitude * (PI / 180)) * 2 * PI * Axis()) / GetTileMatrixSizePixel(zoom).Width();
 }
Exemplo n.º 7
0
 /**
  * @brief PureProjection::GetGroundResolution Returns the conversion from pixels to meters
  * @param zoom Quadtile zoom level
  * @param latitude
  * @return Constant in [m/px]
  */
 double PureProjection::GetGroundResolution(const int &zoom, const double &latitude_D)
 {
     return (cos(latitude_D * DEG2RAD) * TWO_PI * Axis()) / GetTileMatrixSizePixel(zoom).Width();
 }