Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using area assembler without evaluating tags #194

Closed
lonvia opened this issue Feb 3, 2017 · 2 comments
Closed

Using area assembler without evaluating tags #194

lonvia opened this issue Feb 3, 2017 · 2 comments

Comments

@lonvia
Copy link
Member

lonvia commented Feb 3, 2017

For osm2pgsql we plan to switch from geos to libosmium for creating polygons. libosmium's area assembler is doing a good job but is actually doing too much for us as it is also evaluating tags. That might interfere with osm2pgsql's own tag evaluation. We actually need a function that just assembles areas from ways and relations if anyhow possible.

To solve that, I've added two functions to the area assembler that achieve exactly that:

bool make_area(const osmium::Way &way, osmium::memory::Buffer &out_buffer) {
    m_segment_list.extract_segments_from_way(m_config.problem_reporter, way, true);

    if (!create_rings()) {
        return false;
    }

    osmium::builder::AreaBuilder builder{out_buffer};
    builder.initialize_from_object(way);
    add_rings_to_area(builder);
    out_buffer.commit();
    return true;
}

bool make_area(const osmium::Relation &relation, osmium::memory::Buffer const &ways, osmium::memory::Buffer &out_buffer)
{
    for (auto const &w : ways.select<osmium::Way>()) {
        m_segment_list.extract_segments_from_way(m_config.problem_reporter, w, true);
    }

    if (!create_rings()) {
        return false;
    }

    osmium::builder::AreaBuilder builder{out_buffer};
    builder.initialize_from_object(relation);
    add_rings_to_area(builder);
    out_buffer.commit();
    return true;
}

That's working okay and I'd like to see something like this go into libosmium master. However, this particular implementation is specifically geared towards our use case. A different way to go about that, is to make a few functions public, so that the area assembler can be used with arbitrary input data. Given the code above, we'd need only three functions to be publicly accessible:

  • extract segments from way
  • create rings
  • add rings to area

I can provide PRs for both solutions if that helps. Any preferences?

For reference, the current state of the geometry assembly rewrite can be found here.

@lonvia
Copy link
Member Author

lonvia commented Feb 9, 2017

The split-assembler branch works for me and passes the osm2pgsql tests.

@joto
Copy link
Member

joto commented Feb 10, 2017

I have merged the split-assembler branch now.

@joto joto closed this as completed Feb 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants