3#ifndef BOAT_GEOMETRY_RASTER_HPP
4#define BOAT_GEOMETRY_RASTER_HPP
6#include <boat/geometry/detail/fibonacci.hpp>
8#include <boost/qvm/map_vec_mat.hpp>
15 namespace qvm = boost::qvm;
16 auto&& [a, b] = mid_pixel;
17 auto scale = boost::geometry::distance(a, b);
18 return qvm::translation_mat(qvm::vec{{a.x(), a.y()}}) *
19 qvm::rotz_mat<3>(.5 * numbers::pi - boost::geometry::azimuth(a, b)) *
20 qvm::diag_mat(qvm::vec{{scale, -scale, 1.}}) *
21 qvm::translation_mat(-qvm::vec{{ext.x() * .5, ext.y() * .5}});
33 else if constexpr (
srs_spec<
decltype(crs)>)
38 return affine(ext, {a, b});
50 auto x = ext.x() * .5, y = ext.y() * .5;
54 auto area = 1LL * ext.x() * ext.y();
55 auto n = size_t(area * .5 * std::pow(length(*px) / meters, 2)) + 1;
57 auto points = inv(
box_interpolate(mbr,
size_t(2 * std::sqrt(n)) + 1, n));
61 for (
auto fib : fibonacci_levels) {
62 auto step = fib.step();
63 if (step < meters * numbers::inv_sqrt_2)
65 auto pred = [&](
auto& ll) {
return distance(ll, *points) <= step; };
66 auto indices = std::unordered_set<size_t>{};
67 for (
auto& p : *points)
68 for (
auto i : fib.nearests(p, pred)) {
69 if (!indices.insert(i).second)
71 ret[step].push_back(fib[i]);
81 auto ret = std::vector<cartesian::box>{};
84 auto a = ll.min_corner(), b = ll.max_corner();
85 if (a.x() <= -180. || b.x() >= 180. || a.y() <= -90. || b.y() >= 90.)
90 for (
auto& lvl : footprint | std::views::reverse) {
91 auto d = lvl.first * numbers::inv_sqrt_2;
92 if (d >= numbers::earth::sqrt_area / 4)
94 for (
auto& p : lvl.second) {
95 auto x = p.x(), y = p.y();
97 add({{x - dx, y - dy}, {x + dx, y + dy}});
Definition transform.hpp:29
Definition algorithm.hpp:10
d2< double, cs::geographic< boost::geometry::degree > > geographic
Definition vocabulary.hpp:103
bool transform(T1 const &geom1, T2 &geom2, Strategy const &strategy)
Collections succeed if any element succeeds; failed elements are omitted.
Definition transform.hpp:89
auto forward(matrix const &v)
Definition transform.hpp:64
auto make_boxes(geographic::grid const &footprint, srs_spec auto const &crs)
Definition raster.hpp:79
matrix affine(raster::point ext, cartesian::segment const &mid_pixel)
Maps pixels to spatial coordinates.
Definition raster.hpp:13
geographic::grid geographic_interpolate(raster::point ext, matrix const &mat, srs_spec auto const &crs, double meters)
Samples a fixed grid.
Definition raster.hpp:43
multi_point auto box_interpolate(T const &mbr, size_t edge_points, size_t area_points)
Definition algorithm.hpp:14
auto backward(matrix const &v)
Definition transform.hpp:76
auto transformation(srs_spec auto const &a, srs_spec auto const &b)
Definition transform.hpp:48
geographic::point add_meters(geographic::point const &p, double eastward, double northward)
Definition algorithm.hpp:90
constexpr auto meter
Approximate degrees per meter of latitude, or longitude at a given latitude.
Definition algorithm.hpp:57
d2< double, cs::cartesian > cartesian
Definition vocabulary.hpp:102
boost::qvm::mat< double, 3, 3 > matrix
Definition vocabulary.hpp:104
model::box< point > box
Definition vocabulary.hpp:71
std::map< double, multi_point > grid
Definition vocabulary.hpp:73
model::segment< point > segment
Definition vocabulary.hpp:72
model::d2::point_xy< int, cs::cartesian > point
Definition vocabulary.hpp:65