glm::dvec4 MercatorProjection::TileLonLatBounds(const TileID _tileCoord) const { glm::dvec2 boundMin, boundMax; glm::dvec4 tileBounds, lonLatBounds; tileBounds = TileBounds(_tileCoord); boundMin = MetersToLonLat(glm::dvec2(tileBounds.x, tileBounds.y)); boundMax = MetersToLonLat(glm::dvec2(tileBounds.z, tileBounds.w)); lonLatBounds = glm::dvec4(boundMin.x, boundMin.y, boundMax.x, boundMax.y); return lonLatBounds; }
//------------------------------------------------------------------------- // // Convert tile center plus pixel offset to lat/lon. Offset increases right and down // LonLat OpenStreetMapSource::tileCenterToLonLat( const int tileSize, const MapTileCoordinate& tile, const double offsetX, const double offsetY ) //------------------------------------------------------------------------- { double meterX, meterY; double pixelX, pixelY; TileCenterPixels( tileSize, tile.getX( ), tile.getY( ), pixelX, pixelY ); pixelX += offsetX; pixelY += offsetY; PixelsToMeters( pixelX, pixelY, tile.getMagnification( ), meterX, meterY ); double lon, lat; MetersToLonLat( meterX, meterY, lon, lat ); return LonLat( lon, lat ); }
//------------------------------------------------------------------------- // // Convert tile center plus pixel offset to lat/lon. Offset increases right and down // LonLat GoogleMapSource::tileCenterToLonLat( const int tileSize, const MapTileCoordinate& tile, const double offsetX, const double offsetY ) //------------------------------------------------------------------------- { double meterX, meterY; TileCenter( getTileSize( ), tile.getX( ), tile.getY( ), tile.getMagnification( ), meterX, meterY ); double pixelX, pixelY; MetersToPixels( meterX, meterY, tile.getMagnification( ), pixelX, pixelY ); pixelX += offsetX; pixelY -= offsetY; // google maps y coords increase up PixelsToMeters( pixelX, pixelY, tile.getMagnification( ), meterX, meterY ); double lon, lat; MetersToLonLat( meterX, meterY, lon, lat ); return LonLat( lon, lat ); }