Exemplo n.º 1
0
int main(int argc, char* argv[]) {
    if (argc != 2) {
        std::cerr << "Usage: " << argv[0] << " INFILE\n";
        exit(1);
    }

    std::string output_format("SQLite");
    std::string input_filename(argv[1]);
    std::string output_filename("multipolygon.db");

    OGRDataSource* data_source = initialize_database(output_format, output_filename);

    osmium::area::ProblemReporterOGR problem_reporter(data_source);
    osmium::area::Assembler::config_type assembler_config(&problem_reporter);
    assembler_config.enable_debug_output();
    osmium::area::MultipolygonCollector<osmium::area::Assembler> collector(assembler_config);

    std::cerr << "Pass 1...\n";
    osmium::io::Reader reader1(input_filename);
    collector.read_relations(reader1);
    reader1.close();
    std::cerr << "Pass 1 done\n";

    index_type index_pos;
    index_type index_neg;
    location_handler_type location_handler(index_pos, index_neg);
    location_handler.ignore_errors();

    TestHandler test_handler(data_source);

    std::cerr << "Pass 2...\n";
    osmium::io::Reader reader2(input_filename);
    osmium::apply(reader2, location_handler, test_handler, collector.handler([&test_handler](const osmium::memory::Buffer& area_buffer) {
        osmium::apply(area_buffer, test_handler);
    }));
    reader2.close();
    std::cerr << "Pass 2 done\n";

    OGRDataSource::DestroyDataSource(data_source);
    OGRCleanupAll();
}
Exemplo n.º 2
0
int main(int argc, char* argv[]) {
    if (argc != 2) {
        std::cerr << "Usage: " << argv[0] << " INFILE\n";
        exit(1);
    }

    std::string output_format("SQLite");
    std::string input_filename(argv[1]);
    std::string output_filename("testdata-overview.db");
    ::unlink(output_filename.c_str());

    osmium::io::Reader reader(input_filename);

    index_type index;
    location_handler_type location_handler(index);
    location_handler.ignore_errors();

    TestOverviewHandler handler(output_format, output_filename);

    osmium::apply(reader, location_handler, handler);
    reader.close();
}
Exemplo n.º 3
0
int main(int argc, char* argv[]) {
    static struct option long_options[] = {
        {"help",   no_argument, 0, 'h'},
        {"format", required_argument, 0, 'f'},
        {0, 0, 0, 0}
    };

    std::string output_format("SQLite");

    while (true) {
        int c = getopt_long(argc, argv, "hf:", long_options, 0);
        if (c == -1) {
            break;
        }

        switch (c) {
        case 'h':
            print_help();
            exit(0);
        case 'f':
            output_format = optarg;
            break;
        default:
            exit(1);
        }
    }

    std::string input_filename;
    std::string output_filename("ogr_out");
    int remaining_args = argc - optind;
    if (remaining_args > 2) {
        std::cerr << "Usage: " << argv[0] << " [OPTIONS] [INFILE [OUTFILE]]" << std::endl;
        exit(1);
    } else if (remaining_args == 2) {
        input_filename =  argv[optind];
        output_filename = argv[optind+1];
    } else if (remaining_args == 1) {
        input_filename =  argv[optind];
    } else {
        input_filename = "-";
    }

    index_type index_pos;
    location_handler_type location_handler(index_pos);
    osmium::experimental::FlexReader<location_handler_type> exr(input_filename, location_handler, osmium::osm_entity_bits::object);

    MyOGRHandler ogr_handler(output_format, output_filename);

    while (auto buffer = exr.read()) {
        osmium::apply(buffer, ogr_handler);
    }

    exr.close();

    std::vector<const osmium::Relation*> incomplete_relations = exr.collector().get_incomplete_relations();
    if (!incomplete_relations.empty()) {
        std::cerr << "Warning! Some member ways missing for these multipolygon relations:";
        for (const auto* relation : incomplete_relations) {
            std::cerr << " " << relation->id();
        }
        std::cerr << "\n";
    }

    google::protobuf::ShutdownProtobufLibrary();
}
Exemplo n.º 4
0
/// Returns output format.
inline output_format get_output_format(std::ios_base& ios)
{ return output_format(get_flags(ios, ios_base_iword_mask::output_format)); }