MCPcopy Create free account
hub / github.com/OpenOrienteering/mapper / getClosestPointOnGrid

Method getClosestPointOnGrid

src/core/map_grid.cpp:155–167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

153}
154
155MapCoordF MapGrid::getClosestPointOnGrid(MapCoordF position, Map* map) const
156{
157 double final_horz_spacing, final_vert_spacing;
158 double final_horz_offset, final_vert_offset;
159 double final_rotation;
160 calculateFinalParameters(final_horz_spacing, final_vert_spacing, final_horz_offset, final_vert_offset, final_rotation, map);
161
162 position.rotate(final_rotation - M_PI / 2);
163 position.setX(qRound((position.x() - final_horz_offset) / final_horz_spacing) * final_horz_spacing + final_horz_offset);
164 position.setY(qRound((position.y() - final_vert_offset) / final_vert_spacing) * final_vert_spacing + final_vert_offset);
165 position.rotate(M_PI / 2 - final_rotation);
166 return position;
167}
168
169
170bool MapGrid::hasAlpha() const

Callers 1

snapToObjectMethod · 0.80

Calls 5

setXMethod · 0.80
xMethod · 0.80
setYMethod · 0.80
yMethod · 0.80
rotateMethod · 0.45

Tested by

no test coverage detected