MCPcopy Create free account
hub / github.com/Project-OSRM/osrm-backend / coordinatesToTilePoint

Function coordinatesToTilePoint

src/engine/plugins/tile.cpp:204–221  ·  view source on GitHub ↗

* Converts lon/lat into coordinates inside a Mercator projection tile (x/y pixel values) * * @param point the lon/lat you want the tile coords for * @param tile_bbox the mercator boundaries of the tile * @return a point (x,y) on the tile defined by tile_bbox */

Source from the content-addressed store, hash-verified

202 * @return a point (x,y) on the tile defined by tile_bbox
203 */
204FixedPoint coordinatesToTilePoint(const util::Coordinate point, const BBox &tile_bbox)
205{
206 const FloatPoint geo_point{static_cast<double>(util::toFloating(point.lon)),
207 static_cast<double>(util::toFloating(point.lat))};
208
209 const double px_merc = geo_point.x * util::web_mercator::DEGREE_TO_PX;
210 const double py_merc = util::web_mercator::latToY(util::FloatLatitude{geo_point.y}) *
211 util::web_mercator::DEGREE_TO_PX;
212
213 const auto px = static_cast<std::int32_t>(std::round(
214 ((px_merc - tile_bbox.minx) * util::web_mercator::TILE_SIZE / tile_bbox.width()) *
215 util::vector_tile::EXTENT / util::web_mercator::TILE_SIZE));
216 const auto py = static_cast<std::int32_t>(std::round(
217 ((tile_bbox.maxy - py_merc) * util::web_mercator::TILE_SIZE / tile_bbox.height()) *
218 util::vector_tile::EXTENT / util::web_mercator::TILE_SIZE));
219
220 return FixedPoint{px, py};
221}
222
223std::vector<RTreeLeaf> getEdges(const DataFacadeBase &facade, unsigned x, unsigned y, unsigned z)
224{

Callers 1

encodeVectorTileFunction · 0.85

Calls 4

toFloatingFunction · 0.85
latToYFunction · 0.85
widthMethod · 0.80
heightMethod · 0.80

Tested by

no test coverage detected