コード例 #1
0
void add_segment(OGRLayer* layer, int change, const osmium::UndirectedSegment& segment) {
    OGRFeature* feature = OGRFeature::CreateFeature(layer->GetLayerDefn());

    auto linestring = new OGRLineString();
    linestring->addPoint(segment.first().lon(), segment.first().lat());
    linestring->addPoint(segment.second().lon(), segment.second().lat());

    feature->SetGeometryDirectly(linestring);
    feature->SetField("change", change);

    if (layer->CreateFeature(feature) != OGRERR_NONE) {
        std::cerr << "Failed to create feature on layer 'changes'.\n";
        exit(return_code_fatal);
    }

    OGRFeature::DestroyFeature(feature);
}
コード例 #2
0
bool y_range_overlap(const osmium::UndirectedSegment& s1, const osmium::UndirectedSegment& s2) {
    const int tmin = s1.first().y() < s1.second().y() ? s1.first().y( ) : s1.second().y();
    const int tmax = s1.first().y() < s1.second().y() ? s1.second().y() : s1.first().y();
    const int omin = s2.first().y() < s2.second().y() ? s2.first().y()  : s2.second().y();
    const int omax = s2.first().y() < s2.second().y() ? s2.second().y() : s2.first().y();
    if (tmin > omax || omin > tmax) {
        return false;
    }
    return true;
}
コード例 #3
0
bool outside_x_range(const osmium::UndirectedSegment& s1, const osmium::UndirectedSegment& s2) {
    if (s1.first().x() > s2.second().x()) {
        return true;
    }
    return false;
}