mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-20 13:23:59 +00:00
Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run: git remote add om-historic [om-historic.git repo url] git fetch --tags om-historic git replace squashed-history historic-commits
This commit is contained in:
36
generator/routing_city_boundaries_processor.cpp
Normal file
36
generator/routing_city_boundaries_processor.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
#include "generator/routing_city_boundaries_processor.hpp"
|
||||
|
||||
#include "geometry/distance_on_sphere.hpp"
|
||||
#include "geometry/mercator.hpp"
|
||||
|
||||
#include "std/boost_geometry.hpp"
|
||||
#include <boost/geometry/geometries/point_xy.hpp>
|
||||
#include <boost/geometry/geometries/polygon.hpp>
|
||||
|
||||
namespace generator
|
||||
{
|
||||
|
||||
double AreaOnEarth(std::vector<m2::PointD> const & points)
|
||||
{
|
||||
namespace bg = boost::geometry;
|
||||
using LonLatCoords = bg::cs::spherical_equatorial<bg::degree>;
|
||||
bg::model::ring<bg::model::point<double, 2, LonLatCoords>> sphericalPolygon;
|
||||
|
||||
auto const addPoint = [&sphericalPolygon](auto const & point) {
|
||||
auto const latlon = mercator::ToLatLon(point);
|
||||
sphericalPolygon.emplace_back(latlon.m_lon, latlon.m_lat);
|
||||
};
|
||||
|
||||
sphericalPolygon.reserve(points.size());
|
||||
for (auto point : points)
|
||||
addPoint(point);
|
||||
|
||||
addPoint(points.front());
|
||||
|
||||
bg::strategy::area::spherical<> areaCalculationStrategy(ms::kEarthRadiusMeters);
|
||||
|
||||
double const area = bg::area(sphericalPolygon, areaCalculationStrategy);
|
||||
return fabs(area);
|
||||
}
|
||||
|
||||
} // namespace generator
|
||||
Reference in New Issue
Block a user