double RasterProjection::FinePixelDistance(const GeoPoint &location, unsigned pixels) const { enum { /** * This factor is used to reduce fixed point rounding errors. * x_scale and y_scale are quite large numbers, and building their * reciprocals may lose a lot of precision. */ FACTOR = 256, }; // must have called Set() first otherwise this is invalid assert(x_scale != 0); assert(y_scale != 0); Angle distance = WidthToAngle(M_SQRT2 * FACTOR * pixels); GeoPoint p = GeoPoint(location.longitude + distance, location.latitude); auto x = location.DistanceS(p); distance = HeightToAngle(M_SQRT2 * FACTOR * pixels); p = GeoPoint(location.longitude, location.latitude + distance); auto y = location.DistanceS(p); return std::max(x, y) / FACTOR; }
gcc_pure GeoPoint UnprojectFine(const RasterLocation &coords) const { const Angle x = WidthToAngle(fixed((int)coords.x + left)); const Angle y = HeightToAngle(fixed(top - (int)coords.y)); return GeoPoint(x, y); }
fixed RasterProjection::FinePixelDistance(const GeoPoint &location, unsigned pixels) const { enum { /** * This factor is used to reduce fixed point rounding errors. * x_scale and y_scale are quite large numbers, and building their * reciprocals may lose a lot of precision. */ FACTOR = 256, }; Angle distance = WidthToAngle(fixed_sqrt_two * FACTOR * pixels); GeoPoint p = GeoPoint(location.longitude + distance, location.latitude); fixed x = location.Distance(p); distance = HeightToAngle(fixed_sqrt_two * FACTOR * pixels); p = GeoPoint(location.longitude, location.latitude + distance); fixed y = location.Distance(p); return std::max(x, y) / FACTOR; }