File: entity_filter.cc

package info (click to toggle)
pyosmium 4.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,584 kB
  • sloc: python: 4,400; cpp: 2,504; makefile: 20
file content (56 lines) | stat: -rw-r--r-- 1,406 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* SPDX-License-Identifier: BSD-2-Clause
 *
 * This file is part of pyosmium. (https://osmcode.org/pyosmium/)
 *
 * Copyright (C) 2024 Sarah Hoffmann <lonvia@denofr.de> and others.
 * For a full list of authors see the git log.
 */
#include <pybind11/pybind11.h>

#include <osmium/osm.hpp>

#include "base_filter.h"

namespace py = pybind11;

namespace {

class EntityFilter : public pyosmium::BaseFilter
{
public:
    EntityFilter(osmium::osm_entity_bits::type entities)
    : m_entities(entities)
    {}

    bool filter_node(pyosmium::PyOSMNode &) override
    { return !(m_entities & osmium::osm_entity_bits::node); }

    bool filter_way(pyosmium::PyOSMWay &) override
    { return !(m_entities & osmium::osm_entity_bits::way); }

    bool filter_relation(pyosmium::PyOSMRelation &) override
    { return !(m_entities & osmium::osm_entity_bits::relation); }

    bool filter_area(pyosmium::PyOSMArea &) override
    { return !(m_entities & osmium::osm_entity_bits::area); }

    bool filter_changeset(pyosmium::PyOSMChangeset &) override
    { return !(m_entities & osmium::osm_entity_bits::changeset); }


private:
    osmium::osm_entity_bits::type m_entities;
};

}

namespace pyosmium {

void init_entity_filter(pybind11::module &m)
{
    py::class_<EntityFilter, pyosmium::BaseFilter, BaseHandler>(m, "EntityFilter")
        .def(py::init<osmium::osm_entity_bits::type>())
    ;
}

} // namespace