diff --git a/lib/area.cc b/lib/area.cc index 6b4fb75c..3f75cc64 100644 --- a/lib/area.cc +++ b/lib/area.cc @@ -21,7 +21,7 @@ namespace { using MpManager = osmium::area::MultipolygonManager; -class AreaManagerSecondPassHandlerBase : public BaseHandler +class AreaManagerSecondPassHandlerBase : public pyosmium::BaseHandler { public: AreaManagerSecondPassHandlerBase(MpManager *mp_manager) @@ -69,7 +69,7 @@ class AreaManagerSecondPassHandler : public AreaManagerSecondPassHandlerBase private: py::args m_args; - HandlerChain m_handlers; + pyosmium::HandlerChain m_handlers; }; @@ -86,14 +86,14 @@ class AreaManagerBufferHandler : public AreaManagerSecondPassHandlerBase }; -class AreaManager : public BaseHandler +class AreaManager : public pyosmium::BaseHandler { public: AreaManager() : m_mp_manager(m_assembler_config) {} - BaseHandler *first_pass_handler() { return this; } + pyosmium::BaseHandler *first_pass_handler() { return this; } // first-pass-handler bool relation(osmium::Relation const *r) override @@ -119,16 +119,16 @@ class AreaManager : public BaseHandler osmium::area::MultipolygonManager m_mp_manager; }; -} +} // namespace PYBIND11_MODULE(_area, m) { - py::class_(m, + py::class_(m, "AreaManagerSecondPassHandler"); - py::class_(m, + py::class_(m, "AreaManagerBufferHandler"); - py::class_(m, "AreaManager", + py::class_(m, "AreaManager", "Object manager class that manages building area objects from " "ways and relations.") .def(py::init<>()) diff --git a/lib/base_handler.h b/lib/base_handler.h index 11359af3..18b9e8d5 100644 --- a/lib/base_handler.h +++ b/lib/base_handler.h @@ -10,6 +10,8 @@ #include +namespace pyosmium { + class BaseHandler : public osmium::handler::Handler { public: @@ -36,4 +38,6 @@ class BaseHandler : public osmium::handler::Handler virtual void flush() {} }; +} // namespace + #endif // PYOSMIUM_BASE_HANDLER_HPP diff --git a/lib/cast.h b/lib/cast.h index a56121e7..4ff547ff 100644 --- a/lib/cast.h +++ b/lib/cast.h @@ -2,7 +2,7 @@ * * This file is part of pyosmium. (https://osmcode.org/pyosmium/) * - * Copyright (C) 2023 Sarah Hoffmann and others. + * Copyright (C) 2024 Sarah Hoffmann and others. * For a full list of authors see the git log. */ #ifndef PYOSMIUM_CAST_H @@ -122,6 +122,6 @@ T const &cast_list(pybind11::object const &o) { return o.attr("_list").cast(); } -} +} // namespace #endif // PYOSMIUM_CAST_H diff --git a/lib/empty_tag_filter.cc b/lib/empty_tag_filter.cc index f1bc556b..fcf0b023 100644 --- a/lib/empty_tag_filter.cc +++ b/lib/empty_tag_filter.cc @@ -29,7 +29,7 @@ class EmptyTagFilter : public pyosmium::BaseFilter }; -} +} // namespace namespace pyosmium { diff --git a/lib/file_iterator.cc b/lib/file_iterator.cc index 7f0fc528..1923e612 100644 --- a/lib/file_iterator.cc +++ b/lib/file_iterator.cc @@ -63,7 +63,7 @@ class OsmFileIterator { auto *node = static_cast(entity); if (!m_pre_handler.handle_node(*node)) { - m_current = m_type_module.attr("Node")(COSMNode{node}); + m_current = m_type_module.attr("Node")(pyosmium::COSMNode{node}); m_current_type = osmium::item_type::node; return m_current; } @@ -73,7 +73,7 @@ class OsmFileIterator { auto *way = static_cast(entity); if (!m_pre_handler.handle_way(*way)) { - m_current = m_type_module.attr("Way")(COSMWay{way}); + m_current = m_type_module.attr("Way")(pyosmium::COSMWay{way}); m_current_type = osmium::item_type::way; return m_current; } @@ -83,7 +83,7 @@ class OsmFileIterator { auto *rel = static_cast(entity); if (!m_pre_handler.handle_relation(*rel)) { - m_current = m_type_module.attr("Relation")(COSMRelation{rel}); + m_current = m_type_module.attr("Relation")(pyosmium::COSMRelation{rel}); m_current_type = osmium::item_type::relation; return m_current; } @@ -93,7 +93,7 @@ class OsmFileIterator { auto *cs = static_cast(entity); if (!m_pre_handler.handle_changeset(*cs)) { - m_current = m_type_module.attr("Changeset")(COSMChangeset{cs}); + m_current = m_type_module.attr("Changeset")(pyosmium::COSMChangeset{cs}); m_current_type = osmium::item_type::changeset; return m_current; } @@ -112,16 +112,16 @@ class OsmFileIterator { switch (m_current_type) { case osmium::item_type::node: - m_current.attr("_pyosmium_data").template cast()->invalidate(); + m_current.attr("_pyosmium_data").template cast()->invalidate(); break; case osmium::item_type::way: - m_current.attr("_pyosmium_data").template cast()->invalidate(); + m_current.attr("_pyosmium_data").template cast()->invalidate(); break; case osmium::item_type::relation: - m_current.attr("_pyosmium_data").template cast()->invalidate(); + m_current.attr("_pyosmium_data").template cast()->invalidate(); break; case osmium::item_type::changeset: - m_current.attr("_pyosmium_data").template cast()->invalidate(); + m_current.attr("_pyosmium_data").template cast()->invalidate(); break; } m_current_type = osmium::item_type::undefined; @@ -133,12 +133,14 @@ class OsmFileIterator osmium::item_type m_current_type = osmium::item_type::undefined; pybind11::object m_current; - HandlerChain m_pre_handler; + pyosmium::HandlerChain m_pre_handler; pybind11::object m_type_module = pybind11::module_::import("osmium.osm.types"); }; -} +} // namespace + +namespace pyosmium { void init_osm_file_iterator(py::module &m) { @@ -151,3 +153,4 @@ void init_osm_file_iterator(py::module &m) ; } +} // namespace diff --git a/lib/filter.cc b/lib/filter.cc index 92d819e9..e3a9fec0 100644 --- a/lib/filter.cc +++ b/lib/filter.cc @@ -13,7 +13,7 @@ namespace py = pybind11; PYBIND11_MODULE(_filter, m) { - py::class_(m, "BaseFilter") + py::class_(m, "BaseFilter") .def("enable_for", &pyosmium::BaseFilter::enable_for, py::arg("entities"), "Set the OSM types this filter should be used for.") diff --git a/lib/geom.cc b/lib/geom.cc index b637f0aa..46670270 100644 --- a/lib/geom.cc +++ b/lib/geom.cc @@ -2,7 +2,7 @@ * * This file is part of pyosmium. (https://osmcode.org/pyosmium/) * - * Copyright (C) 2023 Sarah Hoffmann and others. + * Copyright (C) 2024 Sarah Hoffmann and others. * For a full list of authors see the git log. */ #include @@ -21,6 +21,8 @@ namespace py = pybind11; namespace og = osmium::geom; +namespace { + struct WKBFactory : osmium::geom::WKBFactory<> { public: @@ -46,7 +48,7 @@ void make_factory_class(py::module_ &m, char const *name, char const *doc) if (py::isinstance(o)) { return f.create_point(o.cast()); } - auto const *node = pyosmium::try_cast(o); + auto const *node = pyosmium::try_cast(o); if (node) { return f.create_point(*node->get()); } @@ -57,7 +59,7 @@ void make_factory_class(py::module_ &m, char const *name, char const *doc) "Create a point geometry from a :py:class:`osmium.osm.Node`.") .def("create_linestring", [](Factory &f, py::object const &o, og::use_nodes un, og::direction dir) { - auto const *way = pyosmium::try_cast(o); + auto const *way = pyosmium::try_cast(o); if (way) { return f.create_linestring(*way->get(), un, dir); } @@ -69,13 +71,15 @@ void make_factory_class(py::module_ &m, char const *name, char const *doc) "Create a LineString geometry from a :py:class:`osmium.osm.Way`.") .def("create_multipolygon", [](Factory &f, py::object const &o) { - return f.create_multipolygon(*pyosmium::cast(o).get()); + return f.create_multipolygon(*pyosmium::cast(o).get()); }, py::arg("area"), "Create a MultiPolygon geometry from a :py:class:`osmium.osm.Area`.") ; } +} // namespace + PYBIND11_MODULE(geom, m) { py::enum_(m, "use_nodes") diff --git a/lib/handler_chain.h b/lib/handler_chain.h index dad49ca2..e8fd455c 100644 --- a/lib/handler_chain.h +++ b/lib/handler_chain.h @@ -19,6 +19,8 @@ namespace py = pybind11; +namespace pyosmium { + class HandlerChain : public osmium::handler::Handler { public: @@ -109,4 +111,6 @@ class HandlerChain : public osmium::handler::Handler std::vector m_python_handlers; }; +} // namespace + #endif //PYOSMIUM_HANDLER_CHAIN_H diff --git a/lib/io.cc b/lib/io.cc index 5cbb7cb3..b8a48c3a 100644 --- a/lib/io.cc +++ b/lib/io.cc @@ -2,7 +2,7 @@ * * This file is part of pyosmium. (https://osmcode.org/pyosmium/) * - * Copyright (C) 2023 Sarah Hoffmann and others. + * Copyright (C) 2024 Sarah Hoffmann and others. * For a full list of authors see the git log. */ #include @@ -19,7 +19,7 @@ class FileBuffer : public osmium::io::File using osmium::io::File::File; }; -} +} // namespace PYBIND11_MODULE(io, m) diff --git a/lib/key_filter.cc b/lib/key_filter.cc index d65819a2..28ff394b 100644 --- a/lib/key_filter.cc +++ b/lib/key_filter.cc @@ -62,7 +62,7 @@ class KeyFilter : public pyosmium::BaseFilter std::vector m_keys; }; -} +} // namespace namespace pyosmium { diff --git a/lib/merge_input_reader.cc b/lib/merge_input_reader.cc index 1c4671fd..ad0902fb 100644 --- a/lib/merge_input_reader.cc +++ b/lib/merge_input_reader.cc @@ -62,7 +62,7 @@ class MergeInputReader public: void apply(py::args args, std::string const &idx, bool simplify) { - HandlerChain handler{args}; + pyosmium::HandlerChain handler{args}; if (idx.empty()) apply_without_location(handler, simplify); else @@ -128,7 +128,7 @@ class MergeInputReader } private: - void apply_without_location(HandlerChain& handler, bool simplify) + void apply_without_location(pyosmium::HandlerChain& handler, bool simplify) { if (simplify) { objects.sort(osmium::object_order_type_id_reverse_version()); @@ -150,7 +150,7 @@ class MergeInputReader changes.clear(); } - void apply_with_location(HandlerChain& handler, std::string const &idx, + void apply_with_location(pyosmium::HandlerChain& handler, std::string const &idx, bool simplify) { using Index_fab = @@ -199,7 +199,9 @@ class MergeInputReader osmium::ObjectPointerCollection objects; }; -} +} // namespace + +namespace pyosmium { void init_merge_input_reader(py::module &m) { @@ -240,3 +242,5 @@ void init_merge_input_reader(py::module &m) "safely discarded after the function has been called.") ; }; + +} // namespace diff --git a/lib/node_location_handler.cc b/lib/node_location_handler.cc index e164e3c8..61c56411 100644 --- a/lib/node_location_handler.cc +++ b/lib/node_location_handler.cc @@ -12,13 +12,14 @@ #include "base_handler.h" +namespace { + using LocationTable = osmium::index::map::Map; using NodeLocationHandler = osmium::handler::NodeLocationsForWays; - -class NodeLocationsForWays : public BaseHandler +class NodeLocationsForWays : public pyosmium::BaseHandler { public: NodeLocationsForWays(LocationTable &idx) @@ -50,8 +51,12 @@ class NodeLocationsForWays : public BaseHandler bool apply_nodes_to_ways = true; }; +} // namespace + namespace py = pybind11; +namespace pyosmium { + void init_node_location_handler(py::module &m) { py::class_(m, "NodeLocationsForWays") @@ -65,3 +70,5 @@ void init_node_location_handler(py::module &m) ; } + +} // namespace diff --git a/lib/osm.cc b/lib/osm.cc index 3db1f7e9..03e42183 100644 --- a/lib/osm.cc +++ b/lib/osm.cc @@ -2,7 +2,7 @@ * * This file is part of pyosmium. (https://osmcode.org/pyosmium/) * - * Copyright (C) 2023 Sarah Hoffmann and others. + * Copyright (C) 2024 Sarah Hoffmann and others. * For a full list of authors see the git log. */ #include @@ -15,9 +15,6 @@ namespace py = pybind11; -using TagIterator = osmium::TagList::const_iterator; -using MemberIterator = osmium::RelationMemberList::const_iterator; - #if PYBIND11_VERSION_MINOR >= 11 || PYBIND11_VERSION_MAJOR > 2 /* Work-around false positive added by pybind/pybind11@f701654 change: @@ -50,6 +47,11 @@ struct is_move_constructible> } // namespace pybind11 #endif +namespace { + +using TagIterator = osmium::TagList::const_iterator; +using MemberIterator = osmium::RelationMemberList::const_iterator; + static py::object tag_iterator_next(TagIterator &it, TagIterator const &cend) { if (it == cend) @@ -147,6 +149,8 @@ py::class_ make_osm_object_class(py::module_ &m, char const *class_n ; } +} // namespace + PYBIND11_MODULE(_osm, m) { py::enum_(m, "osm_entity_bits") @@ -246,68 +250,68 @@ PYBIND11_MODULE(_osm, m) { py::class_(m, "CInnerRingIterator"); - make_osm_object_class(m, "COSMNode") - .def("location", [](COSMNode const &o) { return o.get()->location(); }) + make_osm_object_class(m, "COSMNode") + .def("location", [](pyosmium::COSMNode const &o) { return o.get()->location(); }) ; - make_osm_object_class(m, "COSMWay") - .def("is_closed", [](COSMWay const &o) { return o.get()->is_closed(); }) - .def("ends_have_same_location", [](COSMWay const &o) { return o.get()->ends_have_same_location(); }) - .def("nodes", [](COSMWay const &o) { return &o.get()->nodes(); }, + make_osm_object_class(m, "COSMWay") + .def("is_closed", [](pyosmium::COSMWay const &o) { return o.get()->is_closed(); }) + .def("ends_have_same_location", [](pyosmium::COSMWay const &o) { return o.get()->ends_have_same_location(); }) + .def("nodes", [](pyosmium::COSMWay const &o) { return &o.get()->nodes(); }, py::return_value_policy::reference) ; - make_osm_object_class(m, "COSMRelation") - .def("members_size", [](COSMRelation const &o) { return o.get()->members().size(); }) - .def("members_begin", [](COSMRelation const &o) { return o.get()->members().cbegin(); }) - .def("members_next", [](COSMRelation const &o, MemberIterator &it) + make_osm_object_class(m, "COSMRelation") + .def("members_size", [](pyosmium::COSMRelation const &o) { return o.get()->members().size(); }) + .def("members_begin", [](pyosmium::COSMRelation const &o) { return o.get()->members().cbegin(); }) + .def("members_next", [](pyosmium::COSMRelation const &o, MemberIterator &it) { return member_iterator_next(it, o.get()->members().cend()); }) ; - make_osm_object_class(m, "COSMArea") - .def("from_way", [](COSMArea const &o) { return o.get()->from_way(); }) - .def("orig_id", [](COSMArea const &o) { return o.get()->orig_id(); }) - .def("is_multipolygon", [](COSMArea const &o) { return o.get()->is_multipolygon(); }) - .def("num_rings", [](COSMArea const &o) { return o.get()->num_rings(); }) - .def("outer_begin", [](COSMArea const &o) { return o.get()->outer_rings().cbegin(); }) - .def("outer_next", [](COSMArea const &o, OuterRingIterator &it) { + make_osm_object_class(m, "COSMArea") + .def("from_way", [](pyosmium::COSMArea const &o) { return o.get()->from_way(); }) + .def("orig_id", [](pyosmium::COSMArea const &o) { return o.get()->orig_id(); }) + .def("is_multipolygon", [](pyosmium::COSMArea const &o) { return o.get()->is_multipolygon(); }) + .def("num_rings", [](pyosmium::COSMArea const &o) { return o.get()->num_rings(); }) + .def("outer_begin", [](pyosmium::COSMArea const &o) { return o.get()->outer_rings().cbegin(); }) + .def("outer_next", [](pyosmium::COSMArea const &o, OuterRingIterator &it) { o.get(); return ring_iterator_next(it); }, py::return_value_policy::reference) - .def("inner_begin", [](COSMArea const &o, osmium::OuterRing const &ring) + .def("inner_begin", [](pyosmium::COSMArea const &o, osmium::OuterRing const &ring) { return o.get()->inner_rings(ring).cbegin(); }) - .def("inner_next", [](COSMArea const &o, InnerRingIterator &it) { + .def("inner_next", [](pyosmium::COSMArea const &o, InnerRingIterator &it) { o.get(); return ring_iterator_next(it); }, py::return_value_policy::reference) ; - py::class_(m, "COSMChangeset") - .def("id", [](COSMChangeset const &o) { return o.get()->id(); }) - .def("uid", [](COSMChangeset const &o) { return o.get()->uid(); }) - .def("created_at", [](COSMChangeset const &o) { return o.get()->created_at(); }) - .def("closed_at", [](COSMChangeset const &o) { return o.get()->closed_at(); }) - .def("open", [](COSMChangeset const &o) { return o.get()->open(); }) - .def("num_changes", [](COSMChangeset const &o) { return o.get()->num_changes(); }) - .def("user", [](COSMChangeset const &o) { return o.get()->user(); }) - .def("user_is_anonymous", [](COSMChangeset const &o) { return o.get()->user_is_anonymous(); }) - .def("bounds", [](COSMChangeset const &o) { return o.get()->bounds(); }) - .def("tags_size", [](COSMChangeset const &o) { return o.get()->tags().size(); }) - .def("tags_get_value_by_key", [](COSMChangeset const &o, char const *key, char const *def) + py::class_(m, "COSMChangeset") + .def("id", [](pyosmium::COSMChangeset const &o) { return o.get()->id(); }) + .def("uid", [](pyosmium::COSMChangeset const &o) { return o.get()->uid(); }) + .def("created_at", [](pyosmium::COSMChangeset const &o) { return o.get()->created_at(); }) + .def("closed_at", [](pyosmium::COSMChangeset const &o) { return o.get()->closed_at(); }) + .def("open", [](pyosmium::COSMChangeset const &o) { return o.get()->open(); }) + .def("num_changes", [](pyosmium::COSMChangeset const &o) { return o.get()->num_changes(); }) + .def("user", [](pyosmium::COSMChangeset const &o) { return o.get()->user(); }) + .def("user_is_anonymous", [](pyosmium::COSMChangeset const &o) { return o.get()->user_is_anonymous(); }) + .def("bounds", [](pyosmium::COSMChangeset const &o) { return o.get()->bounds(); }) + .def("tags_size", [](pyosmium::COSMChangeset const &o) { return o.get()->tags().size(); }) + .def("tags_get_value_by_key", [](pyosmium::COSMChangeset const &o, char const *key, char const *def) { return o.get()->tags().get_value_by_key(key, def); }) - .def("tags_has_key", [](COSMChangeset const &o, char const *key) + .def("tags_has_key", [](pyosmium::COSMChangeset const &o, char const *key) { return o.get()->tags().has_key(key); }) - .def("tags_begin", [](COSMChangeset const &o) { return o.get()->tags().cbegin(); }) - .def("tags_next", [](COSMChangeset const &o, TagIterator &it) + .def("tags_begin", [](pyosmium::COSMChangeset const &o) { return o.get()->tags().cbegin(); }) + .def("tags_next", [](pyosmium::COSMChangeset const &o, TagIterator &it) { return tag_iterator_next(it, o.get()->tags().cend()); }) - .def("is_valid", &COSMChangeset::is_valid) + .def("is_valid", &pyosmium::COSMChangeset::is_valid) ; - make_node_list(m, "CWayNodeList"); - make_node_list(m, "COuterRing"); - make_node_list(m, "CInnerRing"); + make_node_list(m, "CWayNodeList"); + make_node_list(m, "COuterRing"); + make_node_list(m, "CInnerRing"); } diff --git a/lib/osm_base_objects.h b/lib/osm_base_objects.h index bb48e39a..c1745c76 100644 --- a/lib/osm_base_objects.h +++ b/lib/osm_base_objects.h @@ -2,7 +2,7 @@ * * This file is part of pyosmium. (https://osmcode.org/pyosmium/) * - * Copyright (C) 2023 Sarah Hoffmann and others. + * Copyright (C) 2024 Sarah Hoffmann and others. * For a full list of authors see the git log. */ #ifndef PYOSMIUM_OSM_BASE_OBJECTS_HPP @@ -12,6 +12,8 @@ #include +namespace pyosmium { + template class COSMDerivedObject { public: @@ -38,5 +40,6 @@ using COSMRelation = COSMDerivedObject; using COSMArea = COSMDerivedObject; using COSMChangeset = COSMDerivedObject; +} // namespace #endif //PYOSMIUM_OSM_BASE_OBJECTS_HPP diff --git a/lib/osmium.cc b/lib/osmium.cc index 89e77148..499c7c4b 100644 --- a/lib/osmium.cc +++ b/lib/osmium.cc @@ -32,13 +32,13 @@ PYBIND11_MODULE(_osmium, m) { } }); - m.def("apply", [](osmium::io::Reader &rd, BaseHandler &h) + m.def("apply", [](osmium::io::Reader &rd, pyosmium::BaseHandler &h) { py::gil_scoped_release release; osmium::apply(rd, h); }, py::arg("reader"), py::arg("handler"), "Apply a single handler."); m.def("apply", [](osmium::io::Reader &rd, py::args args) { - HandlerChain handler{args}; + pyosmium::HandlerChain handler{args}; { py::gil_scoped_release release; osmium::apply(rd, handler); @@ -46,7 +46,7 @@ PYBIND11_MODULE(_osmium, m) { }, py::arg("reader"), "Apply a chain of handlers."); - m.def("apply", [](std::string fn, BaseHandler &h) + m.def("apply", [](std::string fn, pyosmium::BaseHandler &h) { py::gil_scoped_release release; osmium::io::Reader rd{fn}; @@ -56,7 +56,7 @@ PYBIND11_MODULE(_osmium, m) { "Apply a single handler."); m.def("apply", [](std::string fn, py::args args) { - HandlerChain handler{args}; + pyosmium::HandlerChain handler{args}; { py::gil_scoped_release release; osmium::io::Reader rd{fn}; @@ -66,7 +66,7 @@ PYBIND11_MODULE(_osmium, m) { py::arg("filename"), "Apply a chain of handlers."); - py::class_(m, "BaseHandler"); + py::class_(m, "BaseHandler"); py::class_(m, "BufferIterator", "Iterator interface for reading from a queue of buffers.") @@ -77,9 +77,9 @@ PYBIND11_MODULE(_osmium, m) { "Get the next OSM object from the buffer or raise an StopIteration.") ; - init_merge_input_reader(m); - init_write_handler(m); - init_simple_writer(m); - init_node_location_handler(m); - init_osm_file_iterator(m); + pyosmium::init_merge_input_reader(m); + pyosmium::init_write_handler(m); + pyosmium::init_simple_writer(m); + pyosmium::init_node_location_handler(m); + pyosmium::init_osm_file_iterator(m); }; diff --git a/lib/osmium_module.h b/lib/osmium_module.h index ac425591..9bf1aba6 100644 --- a/lib/osmium_module.h +++ b/lib/osmium_module.h @@ -10,10 +10,14 @@ #include +namespace pyosmium { + void init_merge_input_reader(pybind11::module &m); void init_write_handler(pybind11::module &m); void init_simple_writer(pybind11::module &m); void init_node_location_handler(pybind11::module &m); void init_osm_file_iterator(pybind11::module &m); +} // namespace + #endif // PYOSMIUM_OSMIUM_MODULE_H diff --git a/lib/replication.cc b/lib/replication.cc index 66520719..88a02320 100644 --- a/lib/replication.cc +++ b/lib/replication.cc @@ -2,7 +2,7 @@ * * This file is part of pyosmium. (https://osmcode.org/pyosmium/) * - * Copyright (C) 2023 Sarah Hoffmann and others. + * Copyright (C) 2024 Sarah Hoffmann and others. * For a full list of authors see the git log. */ #include @@ -15,6 +15,8 @@ namespace py = pybind11; +namespace { + struct LastChangeHandler : public osmium::handler::Handler { osmium::Timestamp last_change; @@ -27,6 +29,7 @@ struct LastChangeHandler : public osmium::handler::Handler } }; +} // namespace PYBIND11_MODULE(_replication, m) { diff --git a/lib/simple_writer.cc b/lib/simple_writer.cc index fab7eeab..1a355028 100644 --- a/lib/simple_writer.cc +++ b/lib/simple_writer.cc @@ -2,7 +2,7 @@ * * This file is part of pyosmium. (https://osmcode.org/pyosmium/) * - * Copyright (C) 2023 Sarah Hoffmann and others. + * Copyright (C) 2024 Sarah Hoffmann and others. * For a full list of authors see the git log. */ #include @@ -44,7 +44,7 @@ class SimpleWriter buffer.rollback(); - auto const *inode = pyosmium::try_cast(o); + auto const *inode = pyosmium::try_cast(o); if (inode) { buffer.add_item(*inode->get()); } else { @@ -57,7 +57,7 @@ class SimpleWriter } set_common_attributes(o, builder); - set_taglist(o, builder); + set_taglist(o, builder); } flush_buffer(); @@ -71,7 +71,7 @@ class SimpleWriter buffer.rollback(); - auto const *iobj = pyosmium::try_cast(o); + auto const *iobj = pyosmium::try_cast(o); if (iobj) { buffer.add_item(*iobj->get()); } else { @@ -79,7 +79,7 @@ class SimpleWriter set_common_attributes(o, builder); set_nodelist(o, &builder); - set_taglist(o, builder); + set_taglist(o, builder); } flush_buffer(); @@ -93,7 +93,7 @@ class SimpleWriter buffer.rollback(); - auto const *iobj = pyosmium::try_cast(o); + auto const *iobj = pyosmium::try_cast(o); if (iobj) { buffer.add_item(*iobj->get()); } else { @@ -101,7 +101,7 @@ class SimpleWriter set_common_attributes(o, builder); set_memberlist(o, &builder); - set_taglist(o, builder); + set_taglist(o, builder); } flush_buffer(); @@ -242,7 +242,7 @@ class SimpleWriter } // original memberlist - auto const &iobj = pyosmium::try_cast(o); + auto const &iobj = pyosmium::try_cast(o); if (iobj) { auto const &oml = iobj->get()->members(); if (oml.size() > 0) @@ -300,7 +300,9 @@ class SimpleWriter size_t buffer_size; }; -} +} // namespace + +namespace pyosmium { void init_simple_writer(pybind11::module &m) { @@ -335,3 +337,5 @@ void init_simple_writer(pybind11::module &m) "that the buffer memory can be freed.") ; } + +} // namespace diff --git a/lib/write_handler.cc b/lib/write_handler.cc index 427b4e95..a05b1a5d 100644 --- a/lib/write_handler.cc +++ b/lib/write_handler.cc @@ -15,7 +15,7 @@ namespace { -class WriteHandler : public BaseHandler +class WriteHandler : public pyosmium::BaseHandler { enum { BUFFER_WRAP = 4096 }; @@ -88,10 +88,12 @@ class WriteHandler : public BaseHandler osmium::memory::Buffer buffer; }; -} +} // namespace namespace py = pybind11; +namespace pyosmium { + void init_write_handler(pybind11::module &m) { py::class_(m, "WriteHandler", @@ -117,3 +119,5 @@ void init_write_handler(pybind11::module &m) "that the buffer memory can be freed.") ; } + +} // namespace