handler_node *process_handler( char *handle, char *start, char *end ) { switch ( currentPass ) { case 1: return handler_pass1( handle, start, end ); break; case 2: return handler_pass2( handle, start, end ); break; default: bug("unexpected current pass number (%d) in process_handler\n", currentPass); } return NULL; }
int main(int argc, char *argv[]) { cfg.debug = false; cfg.attempt_repair = true; cfg.admin_levels.push_back(2); cfg.simplify_levels.push_back(0); cfg.simplify_levels.push_back(100); cfg.simplify_levels.push_back(10000); static struct option long_options[] = { {"debug", no_argument, 0, 'd'}, {"no-attempt_repair", no_argument, 0, 'R'}, {"simplify-levels", required_argument, 0, 'l'}, {"admin-levels", required_argument, 0, 'a'}, {0, 0, 0, 0} }; while (1) { int c = getopt_long(argc, argv, "dla", long_options, 0); if (c == -1) break; switch (c) { case 'd': { cfg.debug = true; break; } case 'R': { cfg.attempt_repair = false; break; } case 'l': { split_intlist(&cfg.simplify_levels, optarg); break; } case 'a': { split_intlist(&cfg.admin_levels, optarg); break; } } } if (optind != argc-3) { usage(argv[0]); return 1; } cfg.coastlinedb = argv[optind+0]; cfg.osmfile = argv[optind+1]; cfg.outfile = argv[optind+2]; std::cout << " Extracting boundaries from: " << cfg.osmfile << std::endl << " Matching against Coastlines from: " << cfg.coastlinedb << std::endl << " Writing results to: " << cfg.outfile << std::endl; Osmium::init(cfg.debug); Osmium::OSMFile infile(cfg.osmfile); // Output Handling OutputHandler out = OutputHandler(cfg.outfile); // Multipolygon Building Osmium::Handler::Multipolygon handler_multipolygon(cfg.attempt_repair, callbackPass2Handler); // first pass std::cout << "Scanning for Boundaries... 1st Pass" << std::endl; HandlerPass1 handler_pass1(&handler_multipolygon); infile.read(handler_pass1); std::cout << "Scanning for Boundaries... 1st Pass finished" << std::endl; // second pass std::cout << "Scanning for Boundaries... 2nd Pass" << std::endl; HandlerPass2 handler_pass2(&handler_multipolygon, &out); setPass2Handler(&handler_pass2); infile.read(handler_pass2); std::cout << "Scanning for Boundaries... 2nd Pass finished" << std::endl; std::cout << "Building Landmass-Shapes..." << std::endl; return 0; }