-
-
Notifications
You must be signed in to change notification settings - Fork 480
Expand file tree
/
Copy pathtest-options-projection.cpp
More file actions
96 lines (74 loc) · 2.2 KB
/
Copy pathtest-options-projection.cpp
File metadata and controls
96 lines (74 loc) · 2.2 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/**
* SPDX-License-Identifier: GPL-2.0-or-later
*
* This file is part of osm2pgsql (https://osm2pgsql.org/).
*
* Copyright (C) 2006-2026 by the osm2pgsql developer community.
* For a full list of authors see the git log.
*/
#include <catch.hpp>
#include <vector>
#include "common-import.hpp"
#include "command-line-parser.hpp"
#include "reprojection.hpp"
namespace {
testing::db::import_t db;
} // anonymous namespace
TEST_CASE("Projection setup")
{
char const *const style_file = OSM2PGSQLDATA_DIR "default.style";
std::vector<char const *> option_params = {"osm2pgsql", "--output=pgsql",
"-S", style_file,
"--number-processes=1"};
std::string proj_name;
char const *srid = "";
SECTION("No options")
{
proj_name = "Spherical Mercator";
srid = "3857";
}
SECTION("Latlong option")
{
option_params.push_back("-l");
proj_name = "Latlong";
srid = "4326";
}
SECTION("Mercator option")
{
option_params.push_back("-m");
proj_name = "Spherical Mercator";
srid = "3857";
}
#ifdef HAVE_GENERIC_PROJ
SECTION("Latlong with -E option")
{
proj_name = "Latlong";
srid = "4326";
option_params.push_back("-E");
option_params.push_back(srid);
}
SECTION("Mercator with -E option")
{
proj_name = "Spherical Mercator";
srid = "3857";
option_params.push_back("-E");
option_params.push_back(srid);
}
SECTION("Arbitrary projection with -E option")
{
srid = "32632";
option_params.push_back("-E");
option_params.push_back(srid);
}
#endif
option_params.push_back("foo");
auto const options = parse_command_line((int)option_params.size(),
(char **)option_params.data());
if (!proj_name.empty()) {
CHECK(options.projection->target_desc() == proj_name);
}
db.run_import(options, "n1 Tamenity=bar x0 y0");
auto conn = db.connect();
CHECK(conn.result_as_string(
"SELECT Find_SRID('public', 'planet_osm_roads', 'way')") == srid);
}