Skip to content

Commit c92ce45

Browse files
authored
Merge pull request #1969 from joto/new-database-middle
New database middle
2 parents c48168e + 70b792b commit c92ce45

File tree

17 files changed

+875
-75
lines changed

17 files changed

+875
-75
lines changed

.github/actions/ubuntu-prerequisites/action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ runs:
2424
libpotrace-dev \
2525
libpq-dev \
2626
libproj-dev \
27+
nlohmann-json3-dev \
2728
pandoc \
2829
postgresql-${POSTGRESQL_VERSION} \
2930
postgresql-${POSTGRESQL_VERSION}-postgis-${POSTGIS_VERSION} \

.github/actions/win-install/action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ runs:
1616
expat:x64-windows \
1717
libpq:x64-windows \
1818
lua:x64-windows \
19+
nlohmann-json:x64-windows \
1920
proj4:x64-windows \
2021
zlib:x64-windows
2122
shell: bash

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121

2222
- name: Install prerequisites
2323
run: |
24-
brew install lua boost postgis pandoc cimg potrace
24+
brew install lua boost postgis pandoc cimg potrace nlohmann-json
2525
pip3 install psycopg2 behave osmium
2626
pg_ctl -D /usr/local/var/postgres init
2727
pg_ctl -D /usr/local/var/postgres start

.github/workflows/test-install.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ jobs:
4848
libpotrace-dev \
4949
libpq-dev \
5050
libproj-dev \
51+
nlohmann-json3-dev \
5152
lua${LUA_VERSION} \
5253
pandoc \
5354
postgresql-${POSTGRESQL_VERSION} \

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,9 @@ include_directories(SYSTEM ${PostgreSQL_INCLUDE_DIRS})
201201

202202
find_package(Threads)
203203

204+
find_path(NLOHMANN_INCLUDE_DIR nlohmann/json.hpp)
205+
include_directories(SYSTEM ${NLOHMANN_INCLUDE_DIR})
206+
204207
find_path(POTRACE_INCLUDE_DIR potracelib.h)
205208
find_library(POTRACE_LIBRARY NAMES potrace)
206209

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ Required libraries are
4949
* [zlib](https://www.zlib.net/)
5050
* [Boost libraries](https://www.boost.org/), including geometry, system and
5151
filesystem
52+
* [nlohmann/json](https://json.nlohmann.me/)
5253
* [CImg](https://cimg.eu/) (Optional, for generalization only)
5354
* [potrace](https://potrace.sourceforge.net/) (Optional, for generalization only)
5455
* [PostgreSQL](https://www.postgresql.org/) client libraries

src/command-line-parser.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ struct option const long_options[] = {
7272
{"merc", no_argument, nullptr, 'm'},
7373
{"middle-schema", required_argument, nullptr, 215},
7474
{"middle-way-node-index-id-shift", required_argument, nullptr, 300},
75+
{"middle-database-format", required_argument, nullptr, 301},
76+
{"middle-with-nodes", no_argument, nullptr, 302},
7577
{"multi-geometry", no_argument, nullptr, 'G'},
7678
{"number-processes", required_argument, nullptr, 205},
7779
{"output", required_argument, nullptr, 'O'},
@@ -450,6 +452,11 @@ static void check_options(options_t *options)
450452
throw std::runtime_error{"--drop only makes sense with --slim."};
451453
}
452454

455+
if (options->append && options->middle_database_format != 1) {
456+
throw std::runtime_error{
457+
"Do not use --middle-database-format with --append."};
458+
}
459+
453460
if (options->hstore_mode == hstore_column::none &&
454461
options->hstore_columns.empty() && options->hstore_match_only) {
455462
log_warn("--hstore-match-only only makes sense with --hstore, "
@@ -722,6 +729,20 @@ options_t parse_command_line(int argc, char *argv[])
722729
case 300: // --middle-way-node-index-id-shift
723730
options.way_node_index_id_shift = atoi(optarg);
724731
break;
732+
case 301: // --middle-database-format
733+
if (optarg == std::string{"legacy"}) {
734+
options.middle_database_format = 1;
735+
} else if (optarg == std::string{"new"}) {
736+
options.middle_database_format = 2;
737+
} else {
738+
throw std::runtime_error{
739+
"Unknown value for --middle-database-format (Use 'legacy' "
740+
"or 'new')."};
741+
}
742+
break;
743+
case 302: // --middle-with-nodes
744+
options.middle_with_nodes = true;
745+
break;
725746
case 400: // --log-level=LEVEL
726747
parse_log_level_param(optarg);
727748
break;
@@ -771,5 +792,9 @@ options_t parse_command_line(int argc, char *argv[])
771792

772793
options.conninfo = build_conninfo(database_options);
773794

795+
if (!options.slim) {
796+
options.middle_database_format = 0;
797+
}
798+
774799
return options;
775800
}

0 commit comments

Comments
 (0)