forked from osm2pgsql-dev/osm2pgsql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-output-multi-line-storage.cpp
More file actions
71 lines (55 loc) · 2.02 KB
/
Copy pathtest-output-multi-line-storage.cpp
File metadata and controls
71 lines (55 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <cassert>
#include <sstream>
#include <stdexcept>
#include <memory>
#include "middle-pgsql.hpp"
#include "options.hpp"
#include "osmdata.hpp"
#include "osmtypes.hpp"
#include "output-multi.hpp"
#include "taginfo_impl.hpp"
#include <sys/types.h>
#include <unistd.h>
#include <boost/lexical_cast.hpp>
#include "tests/middle-tests.hpp"
#include "tests/common-pg.hpp"
#include "tests/common.hpp"
int main(int argc, char *argv[]) {
(void)argc;
(void)argv;
std::unique_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 {
options_t options;
options.database_options = db->database_options;
options.num_procs = 1;
options.slim = true;
options.projection.reset(reprojection::create_projection(PROJ_LATLONG));
options.output_backend = "multi";
options.style = "tests/test_output_multi_line_trivial.style.json";
testing::run_osm2pgsql<middle_pgsql_t>(
options, "tests/test_output_multi_line_storage.osm", "xml");
db->check_count(1, "select count(*) from pg_catalog.pg_class where relname = 'test_line'");
db->check_count(3, "select count(*) from test_line");
//check that we have the number of vertexes in each linestring
db->check_count(3, "SELECT ST_NumPoints(way) FROM test_line WHERE osm_id = 1");
db->check_count(2, "SELECT ST_NumPoints(way) FROM test_line WHERE osm_id = 2");
db->check_count(2, "SELECT ST_NumPoints(way) FROM test_line WHERE osm_id = 3");
db->check_count(3, "SELECT COUNT(*) FROM test_line WHERE foo = 'bar'");
return 0;
} catch (const std::exception &e) {
std::cerr << "ERROR: " << e.what() << std::endl;
} catch (...) {
std::cerr << "UNKNOWN ERROR" << std::endl;
}
return 1;
}