|
| 1 | +#ifndef OSM2PGSQL_GEOM_BOOST_ADAPTOR_HPP |
| 2 | +#define OSM2PGSQL_GEOM_BOOST_ADAPTOR_HPP |
| 3 | + |
| 4 | +/** |
| 5 | + * SPDX-License-Identifier: GPL-2.0-or-later |
| 6 | + * |
| 7 | + * This file is part of osm2pgsql (https://osm2pgsql.org/). |
| 8 | + * |
| 9 | + * Copyright (C) 2006-2022 by the osm2pgsql developer community. |
| 10 | + * For a full list of authors see the git log. |
| 11 | + */ |
| 12 | + |
| 13 | +#include "geom.hpp" |
| 14 | + |
| 15 | +#include <boost/geometry.hpp> |
| 16 | +#include <boost/geometry/geometries/register/linestring.hpp> |
| 17 | +#include <boost/geometry/geometries/register/multi_linestring.hpp> |
| 18 | +#include <boost/geometry/geometries/register/multi_point.hpp> |
| 19 | +#include <boost/geometry/geometries/register/multi_polygon.hpp> |
| 20 | +#include <boost/geometry/geometries/register/point.hpp> |
| 21 | +#include <boost/geometry/geometries/register/ring.hpp> |
| 22 | + |
| 23 | +BOOST_GEOMETRY_REGISTER_POINT_2D_GET_SET(geom::point_t, double, cs::cartesian, |
| 24 | + x, y, set_x, set_y) |
| 25 | +BOOST_GEOMETRY_REGISTER_LINESTRING(geom::linestring_t) |
| 26 | +BOOST_GEOMETRY_REGISTER_RING(geom::ring_t) |
| 27 | + |
| 28 | +BOOST_GEOMETRY_REGISTER_MULTI_POINT(geom::multipoint_t) |
| 29 | +BOOST_GEOMETRY_REGISTER_MULTI_LINESTRING(geom::multilinestring_t) |
| 30 | +BOOST_GEOMETRY_REGISTER_MULTI_POLYGON(geom::multipolygon_t) |
| 31 | + |
| 32 | +namespace boost { |
| 33 | +namespace geometry { |
| 34 | +namespace traits { |
| 35 | +template <> |
| 36 | +struct point_order<::geom::ring_t> |
| 37 | +{ |
| 38 | + static const order_selector value = counterclockwise; |
| 39 | +}; |
| 40 | + |
| 41 | +template <> |
| 42 | +struct tag<::geom::polygon_t> |
| 43 | +{ |
| 44 | + typedef polygon_tag type; |
| 45 | +}; |
| 46 | +template <> |
| 47 | +struct ring_const_type<::geom::polygon_t> |
| 48 | +{ |
| 49 | + typedef const ::geom::ring_t &type; |
| 50 | +}; |
| 51 | +template <> |
| 52 | +struct ring_mutable_type<::geom::polygon_t> |
| 53 | +{ |
| 54 | + typedef ::geom::ring_t &type; |
| 55 | +}; |
| 56 | +template <> |
| 57 | +struct interior_const_type<::geom::polygon_t> |
| 58 | +{ |
| 59 | + typedef const std::vector<::geom::ring_t> type; |
| 60 | +}; |
| 61 | +template <> |
| 62 | +struct interior_mutable_type<::geom::polygon_t> |
| 63 | +{ |
| 64 | + typedef std::vector<::geom::ring_t> type; |
| 65 | +}; |
| 66 | + |
| 67 | +template <> |
| 68 | +struct exterior_ring<::geom::polygon_t> |
| 69 | +{ |
| 70 | + static auto &get(::geom::polygon_t &p) { return p.outer(); } |
| 71 | + static auto &get(::geom::polygon_t const &p) { return p.outer(); } |
| 72 | +}; |
| 73 | + |
| 74 | +template <> |
| 75 | +struct interior_rings<::geom::polygon_t> |
| 76 | +{ |
| 77 | + static auto get(::geom::polygon_t &p) { return p.inners(); } |
| 78 | + static auto get(::geom::polygon_t const &p) { return p.inners(); } |
| 79 | +}; |
| 80 | +} // namespace traits |
| 81 | +} // namespace geometry |
| 82 | +} // namespace boost |
| 83 | + |
| 84 | +#endif // OSM2PGSQL_GEOM_BOOST_ADAPTOR_HPP |
0 commit comments