int main(int argc, char *argv[]) { char *srcdir = getenv("srcdir"); if (srcdir == NULL) { std::cerr << "$srcdir not set!\n"; return 1; } std::string inputfile = std::string(srcdir) + std::string("/tests/test_multipolygon.osm"); options_t options; boost::shared_ptr<reprojection> projection(new reprojection(PROJ_SPHERE_MERC)); options.projection = projection; boost::shared_ptr<test_output_t> out_test(new test_output_t(options)); osmdata_t osmdata(boost::make_shared<test_middle_t>(), out_test); parse_xml2_t parser(0, false, projection, 0, 0, 0, 0); int ret = parser.streamFile(inputfile.c_str(), 0, &osmdata); if (ret != 0) { return ret; } assert_equal(out_test->sum_ids, 73514L); assert_equal(out_test->num_nodes, 353L); assert_equal(out_test->num_ways, 140L); assert_equal(out_test->num_relations, 40L); assert_equal(out_test->num_nds, 495L); assert_equal(out_test->num_members, 146L); return 0; }
int main(int argc, char *argv[]) { if(1 != bcm2835_init()) return FAIL; if(argc != 2) { uSage(); return FAIL; } if (0 == strcasecmp(argv[1], "out")) { out_test(); } else if (0 == strcasecmp(argv[1], "pud")) { pud_test(); } else if (0 == strcasecmp(argv[1], "edge")) { edge_test(); } else if(0 == strcasecmp(argv[1], "pwm")) { pwm_test(); } else if(0 == strcasecmp(argv[1], "i2c")) { i2c_test(); } else if(0 == strcasecmp(argv[1], "spi")) { spi_test(); } else { uSage(); return FAIL; } bcm2835_close(); return 0; }
int main(int argc, char *argv[]) { boost::scoped_ptr<pg::tempdb> db; try { db.reset(new pg::tempdb); } catch (const std::exception &e) { std::cerr << "Unable to setup database: " << e.what() << "\n"; return 77; // <-- code to skip this test. } try { boost::shared_ptr<middle_pgsql_t> mid_pgsql(new middle_pgsql_t()); options_t options; options.conninfo = db->conninfo().c_str(); options.num_procs = 1; options.prefix = "osm2pgsql_test"; options.tblsslim_index = "tablespacetest"; options.tblsslim_data = "tablespacetest"; options.slim = 1; boost::shared_ptr<geometry_processor> processor = geometry_processor::create("polygon", &options); export_list columns; { taginfo info; info.name = "building"; info.type = "text"; columns.add(OSMTYPE_WAY, info); } boost::shared_ptr<output_multi_t> out_test(new output_multi_t("foobar_buildings", processor, columns, mid_pgsql.get(), options)); osmdata_t osmdata(mid_pgsql, out_test); boost::scoped_ptr<parse_delegate_t> parser(new parse_delegate_t(options.extra_attributes, options.bbox, options.projection)); osmdata.start(); if (parser->streamFile("pbf", "tests/liechtenstein-2013-08-03.osm.pbf", options.sanitize, &osmdata) != 0) { throw std::runtime_error("Unable to read input file `tests/liechtenstein-2013-08-03.osm.pbf'."); } parser.reset(NULL); osmdata.stop(); // start a new connection to run tests on pg::conn_ptr test_conn = pg::conn::connect(db->conninfo()); check_count(test_conn, 1, "select count(*) from pg_catalog.pg_class where relname = 'osm2pgsql_test_foobar_buildings'"); check_count(test_conn, 0, "select count(*) from osm2pgsql_test_foobar_buildings where building is null"); check_count(test_conn, 3723, "select count(*) from osm2pgsql_test_foobar_buildings"); //check that we have the right spread check_count(test_conn, 1, "select count(*) from osm2pgsql_test_foobar_buildings where building='barn'"); check_count(test_conn, 1, "select count(*) from osm2pgsql_test_foobar_buildings where building='chapel'"); check_count(test_conn, 5, "select count(*) from osm2pgsql_test_foobar_buildings where building='church'"); check_count(test_conn, 3, "select count(*) from osm2pgsql_test_foobar_buildings where building='commercial'"); check_count(test_conn, 6, "select count(*) from osm2pgsql_test_foobar_buildings where building='farm'"); check_count(test_conn, 1, "select count(*) from osm2pgsql_test_foobar_buildings where building='garage'"); check_count(test_conn, 2, "select count(*) from osm2pgsql_test_foobar_buildings where building='glasshouse'"); check_count(test_conn, 1, "select count(*) from osm2pgsql_test_foobar_buildings where building='greenhouse'"); check_count(test_conn, 153, "select count(*) from osm2pgsql_test_foobar_buildings where building='house'"); check_count(test_conn, 4, "select count(*) from osm2pgsql_test_foobar_buildings where building='hut'"); check_count(test_conn, 8, "select count(*) from osm2pgsql_test_foobar_buildings where building='industrial'"); check_count(test_conn, 200, "select count(*) from osm2pgsql_test_foobar_buildings where building='residential'"); check_count(test_conn, 6, "select count(*) from osm2pgsql_test_foobar_buildings where building='roof'"); check_count(test_conn, 4, "select count(*) from osm2pgsql_test_foobar_buildings where building='school'"); check_count(test_conn, 2, "select count(*) from osm2pgsql_test_foobar_buildings where building='station'"); check_count(test_conn, 3, "select count(*) from osm2pgsql_test_foobar_buildings where building='warehouse'"); check_count(test_conn, 3323, "select count(*) from osm2pgsql_test_foobar_buildings where building='yes'"); return 0; } catch (const std::exception &e) { std::cerr << "ERROR: " << e.what() << std::endl; } catch (...) { std::cerr << "UNKNOWN ERROR" << std::endl; } return 1; }
int main(int argc, char *argv[]) { boost::scoped_ptr<pg::tempdb> db; try { db.reset(new pg::tempdb); } catch (const std::exception &e) { std::cerr << "Unable to setup database: " << e.what() << "\n"; return 77; // <-- code to skip this test. } try { boost::shared_ptr<middle_pgsql_t> mid_pgsql(new middle_pgsql_t()); options_t options; options.conninfo = db->conninfo().c_str(); options.num_procs = 1; options.prefix = "osm2pgsql_test"; options.tblsslim_index = "tablespacetest"; options.tblsslim_data = "tablespacetest"; options.slim = 1; boost::shared_ptr<geometry_processor> processor = geometry_processor::create("point", &options); export_list columns; { taginfo info; info.name = "amenity"; info.type = "text"; columns.add(OSMTYPE_NODE, info); } boost::shared_ptr<output_multi_t> out_test(new output_multi_t("foobar_amenities", processor, columns, mid_pgsql.get(), options)); osmdata_t osmdata(mid_pgsql, out_test); boost::scoped_ptr<parse_delegate_t> parser(new parse_delegate_t(options.extra_attributes, options.bbox, options.projection)); osmdata.start(); if (parser->streamFile("pbf", "tests/liechtenstein-2013-08-03.osm.pbf", options.sanitize, &osmdata) != 0) { throw std::runtime_error("Unable to read input file `tests/liechtenstein-2013-08-03.osm.pbf'."); } parser.reset(NULL); osmdata.stop(); // start a new connection to run tests on pg::conn_ptr test_conn = pg::conn::connect(db->conninfo()); check_count(test_conn, 1, "select count(*) from pg_catalog.pg_class " "where relname = 'osm2pgsql_test_foobar_amenities'"); check_count(test_conn, 244, "select count(*) from osm2pgsql_test_foobar_amenities"); check_count(test_conn, 36, "select count(*) from osm2pgsql_test_foobar_amenities where amenity='parking'"); check_count(test_conn, 34, "select count(*) from osm2pgsql_test_foobar_amenities where amenity='bench'"); check_count(test_conn, 1, "select count(*) from osm2pgsql_test_foobar_amenities where amenity='vending_machine'"); return 0; } catch (const std::exception &e) { std::cerr << "ERROR: " << e.what() << std::endl; } catch (...) { std::cerr << "UNKNOWN ERROR" << std::endl; } return 1; }
int main(int argc, char *argv[]) { boost::scoped_ptr<pg::tempdb> db; try { db.reset(new pg::tempdb); } catch (const std::exception &e) { std::cerr << "Unable to setup database: " << e.what() << "\n"; return 77; // <-- code to skip this test. } try { boost::shared_ptr<middle_pgsql_t> mid_pgsql(new middle_pgsql_t()); options_t options; options.conninfo = db->conninfo().c_str(); options.num_procs = 1; options.prefix = "osm2pgsql_test"; options.tblsslim_index = "tablespacetest"; options.tblsslim_data = "tablespacetest"; options.slim = 1; boost::shared_ptr<geometry_processor> processor = geometry_processor::create("line", &options); export_list columns; { taginfo info; info.name = "highway"; info.type = "text"; columns.add(OSMTYPE_WAY, info); } boost::shared_ptr<output_multi_t> out_test(new output_multi_t("foobar_highways", processor, columns, mid_pgsql.get(), options)); osmdata_t osmdata(mid_pgsql, out_test); boost::scoped_ptr<parse_delegate_t> parser(new parse_delegate_t(options.extra_attributes, options.bbox, options.projection)); osmdata.start(); if (parser->streamFile("pbf", "tests/liechtenstein-2013-08-03.osm.pbf", options.sanitize, &osmdata) != 0) { throw std::runtime_error("Unable to read input file `tests/liechtenstein-2013-08-03.osm.pbf'."); } parser.reset(NULL); osmdata.stop(); // start a new connection to run tests on pg::conn_ptr test_conn = pg::conn::connect(db->conninfo()); check_count(test_conn, 1, "select count(*) from pg_catalog.pg_class where relname = 'osm2pgsql_test_foobar_highways'"); check_count(test_conn, 2753, "select count(*) from osm2pgsql_test_foobar_highways"); //check that we have the right spread check_count(test_conn, 13, "select count(*) from osm2pgsql_test_foobar_highways where highway='bridleway'"); check_count(test_conn, 3, "select count(*) from osm2pgsql_test_foobar_highways where highway='construction'"); check_count(test_conn, 96, "select count(*) from osm2pgsql_test_foobar_highways where highway='cycleway'"); check_count(test_conn, 249, "select count(*) from osm2pgsql_test_foobar_highways where highway='footway'"); check_count(test_conn, 18, "select count(*) from osm2pgsql_test_foobar_highways where highway='living_street'"); check_count(test_conn, 171, "select count(*) from osm2pgsql_test_foobar_highways where highway='path'"); check_count(test_conn, 6, "select count(*) from osm2pgsql_test_foobar_highways where highway='pedestrian'"); check_count(test_conn, 81, "select count(*) from osm2pgsql_test_foobar_highways where highway='primary'"); check_count(test_conn, 842, "select count(*) from osm2pgsql_test_foobar_highways where highway='residential'"); check_count(test_conn, 3, "select count(*) from osm2pgsql_test_foobar_highways where highway='road'"); check_count(test_conn, 90, "select count(*) from osm2pgsql_test_foobar_highways where highway='secondary'"); check_count(test_conn, 1, "select count(*) from osm2pgsql_test_foobar_highways where highway='secondary_link'"); check_count(test_conn, 352, "select count(*) from osm2pgsql_test_foobar_highways where highway='service'"); check_count(test_conn, 34, "select count(*) from osm2pgsql_test_foobar_highways where highway='steps'"); check_count(test_conn, 33, "select count(*) from osm2pgsql_test_foobar_highways where highway='tertiary'"); check_count(test_conn, 597, "select count(*) from osm2pgsql_test_foobar_highways where highway='track'"); check_count(test_conn, 164, "select count(*) from osm2pgsql_test_foobar_highways where highway='unclassified'"); return 0; } catch (const std::exception &e) { std::cerr << "ERROR: " << e.what() << std::endl; } catch (...) { std::cerr << "UNKNOWN ERROR" << std::endl; } return 1; }
int main(int argc, char* argv[]){ //float beta; //int row,col; string file_name = FILE_NAME; HostMatrix<float> X; HostMatrix<float> X_test; HostMatrix<float> Y; HostMatrix<float> Y_test; HostMatrix<float> Input; HostMatrix<float> Target; std::map<string,int> Classes; std::map<int,string> ClassesLookup; readFile(file_name,Input,Target,Classes,ClassesLookup); int kfold = 1; int correct_instances = 0; int incorrect_instances = 0; int total_instances = 0; int **confusionMatrix; confusionMatrix = (int**) malloc(sizeof(int*)*Classes.size()); for(int i = 0; i < (int)Classes.size(); i++){ confusionMatrix[i] = (int*) malloc(sizeof(int)*Classes.size()); memset(confusionMatrix[i],0,sizeof(int)*Classes.size()); } float Pet_mean = 0; float Ped_mean = 0; unsigned int seed = (unsigned)time(0); /***************RUN INFORMATION*************/ writeHeader(Input,Classes.size(),seed); /*******************************************/ if(!InitCUDA()) { return 1; } culaStatus status; status = culaInitialize(); std::cout << "Starting " << std::endl; float center_time = 0; float width_time = 0; float weight_time = 0; float scaling_time = 0; unsigned int time_total = 0; unsigned int testing_time = 0; unsigned int training_time = 0; clock_t initialTimeTotal = clock(); do{ X = crossvalidationTrain(Input,KFOLDS,kfold); X_test = crossvalidationTest(Input,KFOLDS,kfold); Y = crossvalidationTrain(Target,KFOLDS,kfold); Y_test = crossvalidationTest(Target,KFOLDS,kfold); HostMatrix<float> Weights; HostMatrix<float> Centers; /*Train Network*/ clock_t initialTime = clock(); RadialBasisFunction RBF(NETWORK_SIZE,RNEIGHBOURS,SCALING_FACTOR,Classes.size()); RBF.SetSeed(seed); RBF.Train(X,Y); training_time = (clock() - initialTime); center_time += RBF.times[0]; width_time += RBF.times[1]; weight_time += RBF.times[2]; scaling_time += RBF.times[3]; /*Test Network*/ initialTime = clock(); std::cout << "Testing" << std::endl; HostMatrix<float> out_test; out_test = RBF.Test(X_test); for(int i = 0; i< X_test.Rows();i++){ float max = 0; float out_class = 0; for(int j = 0; j < (int) Classes.size(); j++){ if(out_test(i,j) > max){ out_class = (float)j; max = out_test(i,j); } } out_test(i,0) = out_class+1; } for (int i = 0; i < out_test.Rows(); i++) { out_test(i,0) = (float)round(out_test(i,0)); if(out_test(i,0) <= 0) out_test(i,0) = 1; if(out_test(i,0) > Classes.size()) out_test(i,0) = (float)Classes.size(); std::cout << Y_test(i,0) << " " << out_test(i,0) << std::endl; } correct_instances += out_test.Rows() - error_calc(Y_test,out_test); incorrect_instances += error_calc(Y_test,out_test); total_instances += out_test.Rows(); /*Add values to Confusion Matrix*/ for(int i = 0; i < Y_test.Rows(); i++){ confusionMatrix[((int)Y_test(i,0))-1][((int)out_test(i,0))-1] = confusionMatrix[((int)Y_test(i,0))-1][((int)out_test(i,0))-1] + 1; } testing_time = (clock() - initialTime); /*Increment fold number, for use in crossvalidation*/ kfold++; }while(kfold <= KFOLDS); time_total = (clock() - initialTimeTotal); /*****************MEASURES****************/ measures(correct_instances,total_instances,incorrect_instances,confusionMatrix,Classes,ClassesLookup); writeFooter(center_time,width_time,weight_time,scaling_time,training_time,testing_time,time_total); culaShutdown(); cudaThreadExit(); return 0; }