diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8c30965f1..1d3faa49d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,6 +9,11 @@ jobs: steps: - uses: actions/checkout@v7 + - name: Turn on test-bin + run: | + cd osm-3s_testing + ./turn_testing_on.sh + - name: Automake run: | cd src @@ -17,6 +22,34 @@ jobs: - name: Configure & build run: | cd build - ../src/configure - make -j3 + # With _GLIBCXX_ASSERTIONS, out-of-bounds indexing into strings and + # vectors aborts instead of reading past the end unnoticed. + ../src/configure --prefix="$GITHUB_WORKSPACE" CXXFLAGS="-g -O2 -D_GLIBCXX_ASSERTIONS" + make -j"$(nproc)" install + + - name: Run the test suites + run: | + cd osm-3s_testing + ../test-bin/run_testsuite.sh 40 2>&1 | tee ../testsuite.log + echo "Tests reporting success: $(grep -c ' succeeded\.$' ../testsuite.log)" + if grep -q 'the tests haven.t compiled' ../testsuite.log \ + || ! grep -q ' succeeded\.$' ../testsuite.log; then + echo "::error::The test suites did not run" + exit 1 + fi + # Most suites report "Test X N FAILED." and diff -q's "Files A and B differ"; + # the attic, vlt and implicit areas suites only report the latter. + if grep -E " FAILED\.$| differ$|doesn't exist\.$|^In Test .*Unexpected file" ../testsuite.log; then + echo "::error::Some tests failed" + exit 1 + fi + - name: Upload the outputs of failed tests + if: failure() + uses: actions/upload-artifact@v7 + with: + name: failed-tests + path: | + testsuite.log + osm-3s_testing/run/ + if-no-files-found: ignore diff --git a/osm-3s_testing/.gitignore b/osm-3s_testing/.gitignore index 2e299e5d0..4673422f0 100644 --- a/osm-3s_testing/.gitignore +++ b/osm-3s_testing/.gitignore @@ -1,3 +1,4 @@ input/update_database/ run/ +result.osm diff --git a/osm-3s_testing/expected/area/area_bbox.err b/osm-3s_testing/expected/area/area_bbox.err index 43816ea16..ba861b591 100644 --- a/osm-3s_testing/expected/area/area_bbox.err +++ b/osm-3s_testing/expected/area/area_bbox.err @@ -1,2 +1,2 @@ encoding remark: Please enter your query and terminate it with CTRL+D. -runtime error: Filters too weak in query statement: specify in addition a bbox, a tag filter, or similar. +runtime remark: Timeout is 180 and maxsize is 536870912. diff --git a/osm-3s_testing/expected/area/area_tag.err b/osm-3s_testing/expected/area/area_tag.err index 54aa94a48..ba861b591 100644 --- a/osm-3s_testing/expected/area/area_tag.err +++ b/osm-3s_testing/expected/area/area_tag.err @@ -1 +1,2 @@ encoding remark: Please enter your query and terminate it with CTRL+D. +runtime remark: Timeout is 180 and maxsize is 536870912. diff --git a/osm-3s_testing/expected/area/is_in_101_et_al.err b/osm-3s_testing/expected/area/is_in_101_et_al.err index 54aa94a48..ba861b591 100644 --- a/osm-3s_testing/expected/area/is_in_101_et_al.err +++ b/osm-3s_testing/expected/area/is_in_101_et_al.err @@ -1 +1,2 @@ encoding remark: Please enter your query and terminate it with CTRL+D. +runtime remark: Timeout is 180 and maxsize is 536870912. diff --git a/osm-3s_testing/expected/area/is_in_201.err b/osm-3s_testing/expected/area/is_in_201.err index 54aa94a48..ba861b591 100644 --- a/osm-3s_testing/expected/area/is_in_201.err +++ b/osm-3s_testing/expected/area/is_in_201.err @@ -1 +1,2 @@ encoding remark: Please enter your query and terminate it with CTRL+D. +runtime remark: Timeout is 180 and maxsize is 536870912. diff --git a/osm-3s_testing/expected/area/is_in_202.err b/osm-3s_testing/expected/area/is_in_202.err index 54aa94a48..ba861b591 100644 --- a/osm-3s_testing/expected/area/is_in_202.err +++ b/osm-3s_testing/expected/area/is_in_202.err @@ -1 +1,2 @@ encoding remark: Please enter your query and terminate it with CTRL+D. +runtime remark: Timeout is 180 and maxsize is 536870912. diff --git a/osm-3s_testing/expected/area/is_in_204_205.err b/osm-3s_testing/expected/area/is_in_204_205.err index 54aa94a48..ba861b591 100644 --- a/osm-3s_testing/expected/area/is_in_204_205.err +++ b/osm-3s_testing/expected/area/is_in_204_205.err @@ -1 +1,2 @@ encoding remark: Please enter your query and terminate it with CTRL+D. +runtime remark: Timeout is 180 and maxsize is 536870912. diff --git a/osm-3s_testing/expected/area/is_in_n_101_et_al.err b/osm-3s_testing/expected/area/is_in_n_101_et_al.err index 54aa94a48..ba861b591 100644 --- a/osm-3s_testing/expected/area/is_in_n_101_et_al.err +++ b/osm-3s_testing/expected/area/is_in_n_101_et_al.err @@ -1 +1,2 @@ encoding remark: Please enter your query and terminate it with CTRL+D. +runtime remark: Timeout is 180 and maxsize is 536870912. diff --git a/osm-3s_testing/expected/area/is_in_n_201.err b/osm-3s_testing/expected/area/is_in_n_201.err index 54aa94a48..ba861b591 100644 --- a/osm-3s_testing/expected/area/is_in_n_201.err +++ b/osm-3s_testing/expected/area/is_in_n_201.err @@ -1 +1,2 @@ encoding remark: Please enter your query and terminate it with CTRL+D. +runtime remark: Timeout is 180 and maxsize is 536870912. diff --git a/osm-3s_testing/expected/area/is_in_n_202.err b/osm-3s_testing/expected/area/is_in_n_202.err index 54aa94a48..ba861b591 100644 --- a/osm-3s_testing/expected/area/is_in_n_202.err +++ b/osm-3s_testing/expected/area/is_in_n_202.err @@ -1 +1,2 @@ encoding remark: Please enter your query and terminate it with CTRL+D. +runtime remark: Timeout is 180 and maxsize is 536870912. diff --git a/osm-3s_testing/expected/area/is_in_n_204_205.err b/osm-3s_testing/expected/area/is_in_n_204_205.err index 54aa94a48..ba861b591 100644 --- a/osm-3s_testing/expected/area/is_in_n_204_205.err +++ b/osm-3s_testing/expected/area/is_in_n_204_205.err @@ -1 +1,2 @@ encoding remark: Please enter your query and terminate it with CTRL+D. +runtime remark: Timeout is 180 and maxsize is 536870912. diff --git a/osm-3s_testing/expected/area/is_in_nn_102.err b/osm-3s_testing/expected/area/is_in_nn_102.err index 54aa94a48..ba861b591 100644 --- a/osm-3s_testing/expected/area/is_in_nn_102.err +++ b/osm-3s_testing/expected/area/is_in_nn_102.err @@ -1 +1,2 @@ encoding remark: Please enter your query and terminate it with CTRL+D. +runtime remark: Timeout is 180 and maxsize is 536870912. diff --git a/osm-3s_testing/expected/area/is_in_nn_201_202.err b/osm-3s_testing/expected/area/is_in_nn_201_202.err index 54aa94a48..ba861b591 100644 --- a/osm-3s_testing/expected/area/is_in_nn_201_202.err +++ b/osm-3s_testing/expected/area/is_in_nn_201_202.err @@ -1 +1,2 @@ encoding remark: Please enter your query and terminate it with CTRL+D. +runtime remark: Timeout is 180 and maxsize is 536870912. diff --git a/osm-3s_testing/expected/area/pivot_a.err b/osm-3s_testing/expected/area/pivot_a.err index 54aa94a48..ba861b591 100644 --- a/osm-3s_testing/expected/area/pivot_a.err +++ b/osm-3s_testing/expected/area/pivot_a.err @@ -1 +1,2 @@ encoding remark: Please enter your query and terminate it with CTRL+D. +runtime remark: Timeout is 180 and maxsize is 536870912. diff --git a/osm-3s_testing/expected/area/pivot_a_default.err b/osm-3s_testing/expected/area/pivot_a_default.err index 54aa94a48..ba861b591 100644 --- a/osm-3s_testing/expected/area/pivot_a_default.err +++ b/osm-3s_testing/expected/area/pivot_a_default.err @@ -1 +1,2 @@ encoding remark: Please enter your query and terminate it with CTRL+D. +runtime remark: Timeout is 180 and maxsize is 536870912. diff --git a/osm-3s_testing/expected/area/pivot_a_set_b.err b/osm-3s_testing/expected/area/pivot_a_set_b.err index 54aa94a48..ba861b591 100644 --- a/osm-3s_testing/expected/area/pivot_a_set_b.err +++ b/osm-3s_testing/expected/area/pivot_a_set_b.err @@ -1 +1,2 @@ encoding remark: Please enter your query and terminate it with CTRL+D. +runtime remark: Timeout is 180 and maxsize is 536870912. diff --git a/osm-3s_testing/expected/area/pivot_default.err b/osm-3s_testing/expected/area/pivot_default.err index 54aa94a48..ba861b591 100644 --- a/osm-3s_testing/expected/area/pivot_default.err +++ b/osm-3s_testing/expected/area/pivot_default.err @@ -1 +1,2 @@ encoding remark: Please enter your query and terminate it with CTRL+D. +runtime remark: Timeout is 180 and maxsize is 536870912. diff --git a/osm-3s_testing/expected/area/way_101.err b/osm-3s_testing/expected/area/way_101.err index 54aa94a48..ba861b591 100644 --- a/osm-3s_testing/expected/area/way_101.err +++ b/osm-3s_testing/expected/area/way_101.err @@ -1 +1,2 @@ encoding remark: Please enter your query and terminate it with CTRL+D. +runtime remark: Timeout is 180 and maxsize is 536870912. diff --git a/osm-3s_testing/expected/area/way_101_r.err b/osm-3s_testing/expected/area/way_101_r.err index 54aa94a48..ba861b591 100644 --- a/osm-3s_testing/expected/area/way_101_r.err +++ b/osm-3s_testing/expected/area/way_101_r.err @@ -1 +1,2 @@ encoding remark: Please enter your query and terminate it with CTRL+D. +runtime remark: Timeout is 180 and maxsize is 536870912. diff --git a/osm-3s_testing/expected/area/way_101_w.err b/osm-3s_testing/expected/area/way_101_w.err index 54aa94a48..ba861b591 100644 --- a/osm-3s_testing/expected/area/way_101_w.err +++ b/osm-3s_testing/expected/area/way_101_w.err @@ -1 +1,2 @@ encoding remark: Please enter your query and terminate it with CTRL+D. +runtime remark: Timeout is 180 and maxsize is 536870912. diff --git a/osm-3s_testing/expected/area/way_102.err b/osm-3s_testing/expected/area/way_102.err index 54aa94a48..ba861b591 100644 --- a/osm-3s_testing/expected/area/way_102.err +++ b/osm-3s_testing/expected/area/way_102.err @@ -1 +1,2 @@ encoding remark: Please enter your query and terminate it with CTRL+D. +runtime remark: Timeout is 180 and maxsize is 536870912. diff --git a/osm-3s_testing/expected/area/way_103.err b/osm-3s_testing/expected/area/way_103.err index 54aa94a48..ba861b591 100644 --- a/osm-3s_testing/expected/area/way_103.err +++ b/osm-3s_testing/expected/area/way_103.err @@ -1 +1,2 @@ encoding remark: Please enter your query and terminate it with CTRL+D. +runtime remark: Timeout is 180 and maxsize is 536870912. diff --git a/osm-3s_testing/expected/area/way_201.err b/osm-3s_testing/expected/area/way_201.err index 54aa94a48..ba861b591 100644 --- a/osm-3s_testing/expected/area/way_201.err +++ b/osm-3s_testing/expected/area/way_201.err @@ -1 +1,2 @@ encoding remark: Please enter your query and terminate it with CTRL+D. +runtime remark: Timeout is 180 and maxsize is 536870912. diff --git a/osm-3s_testing/expected/area/way_202.err b/osm-3s_testing/expected/area/way_202.err index 54aa94a48..ba861b591 100644 --- a/osm-3s_testing/expected/area/way_202.err +++ b/osm-3s_testing/expected/area/way_202.err @@ -1 +1,2 @@ encoding remark: Please enter your query and terminate it with CTRL+D. +runtime remark: Timeout is 180 and maxsize is 536870912. diff --git a/osm-3s_testing/expected/area/way_203.err b/osm-3s_testing/expected/area/way_203.err index 54aa94a48..ba861b591 100644 --- a/osm-3s_testing/expected/area/way_203.err +++ b/osm-3s_testing/expected/area/way_203.err @@ -1 +1,2 @@ encoding remark: Please enter your query and terminate it with CTRL+D. +runtime remark: Timeout is 180 and maxsize is 536870912. diff --git a/osm-3s_testing/expected/area/way_204.err b/osm-3s_testing/expected/area/way_204.err index 54aa94a48..ba861b591 100644 --- a/osm-3s_testing/expected/area/way_204.err +++ b/osm-3s_testing/expected/area/way_204.err @@ -1 +1,2 @@ encoding remark: Please enter your query and terminate it with CTRL+D. +runtime remark: Timeout is 180 and maxsize is 536870912. diff --git a/osm-3s_testing/expected/area/way_205.err b/osm-3s_testing/expected/area/way_205.err index 54aa94a48..ba861b591 100644 --- a/osm-3s_testing/expected/area/way_205.err +++ b/osm-3s_testing/expected/area/way_205.err @@ -1 +1,2 @@ encoding remark: Please enter your query and terminate it with CTRL+D. +runtime remark: Timeout is 180 and maxsize is 536870912. diff --git a/osm-3s_testing/expected/area/way_311.err b/osm-3s_testing/expected/area/way_311.err index 54aa94a48..ba861b591 100644 --- a/osm-3s_testing/expected/area/way_311.err +++ b/osm-3s_testing/expected/area/way_311.err @@ -1 +1,2 @@ encoding remark: Please enter your query and terminate it with CTRL+D. +runtime remark: Timeout is 180 and maxsize is 536870912. diff --git a/osm-3s_testing/expected/area/way_312.err b/osm-3s_testing/expected/area/way_312.err index 54aa94a48..ba861b591 100644 --- a/osm-3s_testing/expected/area/way_312.err +++ b/osm-3s_testing/expected/area/way_312.err @@ -1 +1,2 @@ encoding remark: Please enter your query and terminate it with CTRL+D. +runtime remark: Timeout is 180 and maxsize is 536870912. diff --git a/osm-3s_testing/expected/area/way_313.err b/osm-3s_testing/expected/area/way_313.err index 54aa94a48..ba861b591 100644 --- a/osm-3s_testing/expected/area/way_313.err +++ b/osm-3s_testing/expected/area/way_313.err @@ -1 +1,2 @@ encoding remark: Please enter your query and terminate it with CTRL+D. +runtime remark: Timeout is 180 and maxsize is 536870912. diff --git a/osm-3s_testing/expected/area/way_314.err b/osm-3s_testing/expected/area/way_314.err index 54aa94a48..ba861b591 100644 --- a/osm-3s_testing/expected/area/way_314.err +++ b/osm-3s_testing/expected/area/way_314.err @@ -1 +1,2 @@ encoding remark: Please enter your query and terminate it with CTRL+D. +runtime remark: Timeout is 180 and maxsize is 536870912. diff --git a/osm-3s_testing/expected/area/way_321.err b/osm-3s_testing/expected/area/way_321.err index 54aa94a48..ba861b591 100644 --- a/osm-3s_testing/expected/area/way_321.err +++ b/osm-3s_testing/expected/area/way_321.err @@ -1 +1,2 @@ encoding remark: Please enter your query and terminate it with CTRL+D. +runtime remark: Timeout is 180 and maxsize is 536870912. diff --git a/osm-3s_testing/expected/area/way_322.err b/osm-3s_testing/expected/area/way_322.err index 54aa94a48..ba861b591 100644 --- a/osm-3s_testing/expected/area/way_322.err +++ b/osm-3s_testing/expected/area/way_322.err @@ -1 +1,2 @@ encoding remark: Please enter your query and terminate it with CTRL+D. +runtime remark: Timeout is 180 and maxsize is 536870912. diff --git a/osm-3s_testing/expected/area/way_323.err b/osm-3s_testing/expected/area/way_323.err index 54aa94a48..ba861b591 100644 --- a/osm-3s_testing/expected/area/way_323.err +++ b/osm-3s_testing/expected/area/way_323.err @@ -1 +1,2 @@ encoding remark: Please enter your query and terminate it with CTRL+D. +runtime remark: Timeout is 180 and maxsize is 536870912. diff --git a/osm-3s_testing/expected/area/way_324.err b/osm-3s_testing/expected/area/way_324.err index 54aa94a48..ba861b591 100644 --- a/osm-3s_testing/expected/area/way_324.err +++ b/osm-3s_testing/expected/area/way_324.err @@ -1 +1,2 @@ encoding remark: Please enter your query and terminate it with CTRL+D. +runtime remark: Timeout is 180 and maxsize is 536870912. diff --git a/osm-3s_testing/expected/osm3s_query_20/stderr.log b/osm-3s_testing/expected/osm3s_query_20/stderr.log index 7bcb082eb..cecbc051f 100644 --- a/osm-3s_testing/expected/osm3s_query_20/stderr.log +++ b/osm-3s_testing/expected/osm3s_query_20/stderr.log @@ -1,3 +1,4 @@ encoding remark: Please enter your query and terminate it with CTRL+D. encoding remark: Your input contains an 'osm-script' tag. Thus, a line with the datatype declaration is added. This shifts line numbering by -1 line(s). +runtime remark: Timeout is 3600 and maxsize is 1024. diff --git a/osm-3s_testing/expected/osm3s_query_21/stderr.log b/osm-3s_testing/expected/osm3s_query_21/stderr.log index 7bcb082eb..63261b624 100644 --- a/osm-3s_testing/expected/osm3s_query_21/stderr.log +++ b/osm-3s_testing/expected/osm3s_query_21/stderr.log @@ -1,3 +1,4 @@ encoding remark: Please enter your query and terminate it with CTRL+D. encoding remark: Your input contains an 'osm-script' tag. Thus, a line with the datatype declaration is added. This shifts line numbering by -1 line(s). +runtime remark: Timeout is 3600 and maxsize is 1073741824. diff --git a/osm-3s_testing/expected/osm3s_query_22/stderr.log b/osm-3s_testing/expected/osm3s_query_22/stderr.log index 7bcb082eb..05c8cf548 100644 --- a/osm-3s_testing/expected/osm3s_query_22/stderr.log +++ b/osm-3s_testing/expected/osm3s_query_22/stderr.log @@ -1,3 +1,4 @@ encoding remark: Please enter your query and terminate it with CTRL+D. encoding remark: Your input contains an 'osm-script' tag. Thus, a line with the datatype declaration is added. This shifts line numbering by -1 line(s). +runtime remark: Timeout is 1 and maxsize is 1073741824. diff --git a/osm-3s_testing/expected/osm3s_query_23/stderr.log b/osm-3s_testing/expected/osm3s_query_23/stderr.log index 7bcb082eb..cecbc051f 100644 --- a/osm-3s_testing/expected/osm3s_query_23/stderr.log +++ b/osm-3s_testing/expected/osm3s_query_23/stderr.log @@ -1,3 +1,4 @@ encoding remark: Please enter your query and terminate it with CTRL+D. encoding remark: Your input contains an 'osm-script' tag. Thus, a line with the datatype declaration is added. This shifts line numbering by -1 line(s). +runtime remark: Timeout is 3600 and maxsize is 1024. diff --git a/osm-3s_testing/expected/osm3s_query_24/stderr.log b/osm-3s_testing/expected/osm3s_query_24/stderr.log index 7bcb082eb..63261b624 100644 --- a/osm-3s_testing/expected/osm3s_query_24/stderr.log +++ b/osm-3s_testing/expected/osm3s_query_24/stderr.log @@ -1,3 +1,4 @@ encoding remark: Please enter your query and terminate it with CTRL+D. encoding remark: Your input contains an 'osm-script' tag. Thus, a line with the datatype declaration is added. This shifts line numbering by -1 line(s). +runtime remark: Timeout is 3600 and maxsize is 1073741824. diff --git a/osm-3s_testing/expected/osm3s_query_25/stderr.log b/osm-3s_testing/expected/osm3s_query_25/stderr.log index 7bcb082eb..05c8cf548 100644 --- a/osm-3s_testing/expected/osm3s_query_25/stderr.log +++ b/osm-3s_testing/expected/osm3s_query_25/stderr.log @@ -1,3 +1,4 @@ encoding remark: Please enter your query and terminate it with CTRL+D. encoding remark: Your input contains an 'osm-script' tag. Thus, a line with the datatype declaration is added. This shifts line numbering by -1 line(s). +runtime remark: Timeout is 1 and maxsize is 1073741824. diff --git a/osm-3s_testing/expected/osm3s_query_26/stderr.log b/osm-3s_testing/expected/osm3s_query_26/stderr.log index 6673062ce..ae3a75da6 100644 --- a/osm-3s_testing/expected/osm3s_query_26/stderr.log +++ b/osm-3s_testing/expected/osm3s_query_26/stderr.log @@ -1,5 +1,6 @@ encoding remark: Please enter your query and terminate it with CTRL+D. encoding remark: Your input contains an 'osm-script' tag. Thus, a line with the datatype declaration is added. This shifts line numbering by -1 line(s). -After 0h0m0s: in "query", part 9, on line 4. +runtime remark: Timeout is 3600 and maxsize is 1024. +After: in "query", part 9, on line 4. runtime error: Query run out of memory in "query" at line 4 using about 0 MB of RAM. diff --git a/osm-3s_testing/expected/osm3s_query_27/stderr.log b/osm-3s_testing/expected/osm3s_query_27/stderr.log index 7bcb082eb..63261b624 100644 --- a/osm-3s_testing/expected/osm3s_query_27/stderr.log +++ b/osm-3s_testing/expected/osm3s_query_27/stderr.log @@ -1,3 +1,4 @@ encoding remark: Please enter your query and terminate it with CTRL+D. encoding remark: Your input contains an 'osm-script' tag. Thus, a line with the datatype declaration is added. This shifts line numbering by -1 line(s). +runtime remark: Timeout is 3600 and maxsize is 1073741824. diff --git a/osm-3s_testing/expected/osm3s_query_29/stderr.log b/osm-3s_testing/expected/osm3s_query_29/stderr.log index 7bcb082eb..cecbc051f 100644 --- a/osm-3s_testing/expected/osm3s_query_29/stderr.log +++ b/osm-3s_testing/expected/osm3s_query_29/stderr.log @@ -1,3 +1,4 @@ encoding remark: Please enter your query and terminate it with CTRL+D. encoding remark: Your input contains an 'osm-script' tag. Thus, a line with the datatype declaration is added. This shifts line numbering by -1 line(s). +runtime remark: Timeout is 3600 and maxsize is 1024. diff --git a/osm-3s_testing/expected/osm3s_query_30/stderr.log b/osm-3s_testing/expected/osm3s_query_30/stderr.log index 7bcb082eb..63261b624 100644 --- a/osm-3s_testing/expected/osm3s_query_30/stderr.log +++ b/osm-3s_testing/expected/osm3s_query_30/stderr.log @@ -1,3 +1,4 @@ encoding remark: Please enter your query and terminate it with CTRL+D. encoding remark: Your input contains an 'osm-script' tag. Thus, a line with the datatype declaration is added. This shifts line numbering by -1 line(s). +runtime remark: Timeout is 3600 and maxsize is 1073741824. diff --git a/osm-3s_testing/expected/osm3s_query_32/stderr.log b/osm-3s_testing/expected/osm3s_query_32/stderr.log index bbdbb049d..a21871b20 100644 --- a/osm-3s_testing/expected/osm3s_query_32/stderr.log +++ b/osm-3s_testing/expected/osm3s_query_32/stderr.log @@ -1,5 +1,6 @@ encoding remark: Please enter your query and terminate it with CTRL+D. encoding remark: Your input contains an 'osm-script' tag. Thus, a line with the datatype declaration is added. This shifts line numbering by -1 line(s). -After 0h0m0s: in "bbox-query", part 0, on line 4. +runtime remark: Timeout is 3600 and maxsize is 1024. +After: in "bbox-query", part 0, on line 4. runtime error: Query run out of memory in "bbox-query" at line 4 using about 0 MB of RAM. diff --git a/osm-3s_testing/expected/osm3s_query_33/stderr.log b/osm-3s_testing/expected/osm3s_query_33/stderr.log index 7bcb082eb..63261b624 100644 --- a/osm-3s_testing/expected/osm3s_query_33/stderr.log +++ b/osm-3s_testing/expected/osm3s_query_33/stderr.log @@ -1,3 +1,4 @@ encoding remark: Please enter your query and terminate it with CTRL+D. encoding remark: Your input contains an 'osm-script' tag. Thus, a line with the datatype declaration is added. This shifts line numbering by -1 line(s). +runtime remark: Timeout is 3600 and maxsize is 1073741824. diff --git a/osm-3s_testing/expected/osm3s_query_35/stderr.log b/osm-3s_testing/expected/osm3s_query_35/stderr.log index 6cb415712..b2ee06a2b 100644 --- a/osm-3s_testing/expected/osm3s_query_35/stderr.log +++ b/osm-3s_testing/expected/osm3s_query_35/stderr.log @@ -1,5 +1,6 @@ encoding remark: Please enter your query and terminate it with CTRL+D. encoding remark: Your input contains an 'osm-script' tag. Thus, a line with the datatype declaration is added. This shifts line numbering by -1 line(s). -After 0h0m0s: in "recurse", part 0, on line 5. +runtime remark: Timeout is 3600 and maxsize is 80. +After: in "recurse", part 0, on line 5. runtime error: Query run out of memory in "recurse" at line 5 using about 0 MB of RAM. diff --git a/osm-3s_testing/expected/osm3s_query_36/stderr.log b/osm-3s_testing/expected/osm3s_query_36/stderr.log index 7bcb082eb..63261b624 100644 --- a/osm-3s_testing/expected/osm3s_query_36/stderr.log +++ b/osm-3s_testing/expected/osm3s_query_36/stderr.log @@ -1,3 +1,4 @@ encoding remark: Please enter your query and terminate it with CTRL+D. encoding remark: Your input contains an 'osm-script' tag. Thus, a line with the datatype declaration is added. This shifts line numbering by -1 line(s). +runtime remark: Timeout is 3600 and maxsize is 1073741824. diff --git a/osm-3s_testing/expected/osm3s_query_37/stderr.log b/osm-3s_testing/expected/osm3s_query_37/stderr.log index 7bcb082eb..05c8cf548 100644 --- a/osm-3s_testing/expected/osm3s_query_37/stderr.log +++ b/osm-3s_testing/expected/osm3s_query_37/stderr.log @@ -1,3 +1,4 @@ encoding remark: Please enter your query and terminate it with CTRL+D. encoding remark: Your input contains an 'osm-script' tag. Thus, a line with the datatype declaration is added. This shifts line numbering by -1 line(s). +runtime remark: Timeout is 1 and maxsize is 1073741824. diff --git a/osm-3s_testing/expected/osm3s_query_38/stderr.log b/osm-3s_testing/expected/osm3s_query_38/stderr.log index 6cb415712..b2ee06a2b 100644 --- a/osm-3s_testing/expected/osm3s_query_38/stderr.log +++ b/osm-3s_testing/expected/osm3s_query_38/stderr.log @@ -1,5 +1,6 @@ encoding remark: Please enter your query and terminate it with CTRL+D. encoding remark: Your input contains an 'osm-script' tag. Thus, a line with the datatype declaration is added. This shifts line numbering by -1 line(s). -After 0h0m0s: in "recurse", part 0, on line 5. +runtime remark: Timeout is 3600 and maxsize is 80. +After: in "recurse", part 0, on line 5. runtime error: Query run out of memory in "recurse" at line 5 using about 0 MB of RAM. diff --git a/osm-3s_testing/expected/osm3s_query_39/stderr.log b/osm-3s_testing/expected/osm3s_query_39/stderr.log index 7bcb082eb..63261b624 100644 --- a/osm-3s_testing/expected/osm3s_query_39/stderr.log +++ b/osm-3s_testing/expected/osm3s_query_39/stderr.log @@ -1,3 +1,4 @@ encoding remark: Please enter your query and terminate it with CTRL+D. encoding remark: Your input contains an 'osm-script' tag. Thus, a line with the datatype declaration is added. This shifts line numbering by -1 line(s). +runtime remark: Timeout is 3600 and maxsize is 1073741824. diff --git a/osm-3s_testing/expected/osm3s_query_40/stderr.log b/osm-3s_testing/expected/osm3s_query_40/stderr.log index 4a3217fe7..e806a5fd1 100644 --- a/osm-3s_testing/expected/osm3s_query_40/stderr.log +++ b/osm-3s_testing/expected/osm3s_query_40/stderr.log @@ -1,5 +1,6 @@ encoding remark: Please enter your query and terminate it with CTRL+D. encoding remark: Your input contains an 'osm-script' tag. Thus, a line with the datatype declaration is added. This shifts line numbering by -1 line(s). -After 0h0m2s: in "recurse", part 0, on line 11. Stack: 1 of 104 66 of 104 76 of 104 +runtime remark: Timeout is 1 and maxsize is 1073741824. +After: in "recurse", part 0, on line 11. runtime error: Query timed out in "recurse" at line 11 after 2 seconds. diff --git a/osm-3s_testing/expected/osm3s_query_41/stderr.log b/osm-3s_testing/expected/osm3s_query_41/stderr.log index 6cb415712..8a1f9b0dd 100644 --- a/osm-3s_testing/expected/osm3s_query_41/stderr.log +++ b/osm-3s_testing/expected/osm3s_query_41/stderr.log @@ -1,5 +1,6 @@ encoding remark: Please enter your query and terminate it with CTRL+D. encoding remark: Your input contains an 'osm-script' tag. Thus, a line with the datatype declaration is added. This shifts line numbering by -1 line(s). -After 0h0m0s: in "recurse", part 0, on line 5. +runtime remark: Timeout is 3600 and maxsize is 200. +After: in "recurse", part 0, on line 5. runtime error: Query run out of memory in "recurse" at line 5 using about 0 MB of RAM. diff --git a/osm-3s_testing/expected/osm3s_query_42/stderr.log b/osm-3s_testing/expected/osm3s_query_42/stderr.log index 7bcb082eb..63261b624 100644 --- a/osm-3s_testing/expected/osm3s_query_42/stderr.log +++ b/osm-3s_testing/expected/osm3s_query_42/stderr.log @@ -1,3 +1,4 @@ encoding remark: Please enter your query and terminate it with CTRL+D. encoding remark: Your input contains an 'osm-script' tag. Thus, a line with the datatype declaration is added. This shifts line numbering by -1 line(s). +runtime remark: Timeout is 3600 and maxsize is 1073741824. diff --git a/osm-3s_testing/expected/osm3s_query_43/stderr.log b/osm-3s_testing/expected/osm3s_query_43/stderr.log index 5cc1b0553..e806a5fd1 100644 --- a/osm-3s_testing/expected/osm3s_query_43/stderr.log +++ b/osm-3s_testing/expected/osm3s_query_43/stderr.log @@ -1,5 +1,6 @@ encoding remark: Please enter your query and terminate it with CTRL+D. encoding remark: Your input contains an 'osm-script' tag. Thus, a line with the datatype declaration is added. This shifts line numbering by -1 line(s). -After 0h0m2s: in "recurse", part 0, on line 11. Stack: 1 of 99 40 of 99 53 of 99 +runtime remark: Timeout is 1 and maxsize is 1073741824. +After: in "recurse", part 0, on line 11. runtime error: Query timed out in "recurse" at line 11 after 2 seconds. diff --git a/osm-3s_testing/expected/osm3s_query_44/stderr.log b/osm-3s_testing/expected/osm3s_query_44/stderr.log index 6cb415712..8a1f9b0dd 100644 --- a/osm-3s_testing/expected/osm3s_query_44/stderr.log +++ b/osm-3s_testing/expected/osm3s_query_44/stderr.log @@ -1,5 +1,6 @@ encoding remark: Please enter your query and terminate it with CTRL+D. encoding remark: Your input contains an 'osm-script' tag. Thus, a line with the datatype declaration is added. This shifts line numbering by -1 line(s). -After 0h0m0s: in "recurse", part 0, on line 5. +runtime remark: Timeout is 3600 and maxsize is 200. +After: in "recurse", part 0, on line 5. runtime error: Query run out of memory in "recurse" at line 5 using about 0 MB of RAM. diff --git a/osm-3s_testing/expected/osm3s_query_45/stderr.log b/osm-3s_testing/expected/osm3s_query_45/stderr.log index 7bcb082eb..63261b624 100644 --- a/osm-3s_testing/expected/osm3s_query_45/stderr.log +++ b/osm-3s_testing/expected/osm3s_query_45/stderr.log @@ -1,3 +1,4 @@ encoding remark: Please enter your query and terminate it with CTRL+D. encoding remark: Your input contains an 'osm-script' tag. Thus, a line with the datatype declaration is added. This shifts line numbering by -1 line(s). +runtime remark: Timeout is 3600 and maxsize is 1073741824. diff --git a/osm-3s_testing/expected/osm3s_query_46/stderr.log b/osm-3s_testing/expected/osm3s_query_46/stderr.log index b2b85c8db..4bc7c1b0b 100644 --- a/osm-3s_testing/expected/osm3s_query_46/stderr.log +++ b/osm-3s_testing/expected/osm3s_query_46/stderr.log @@ -1,5 +1,6 @@ encoding remark: Please enter your query and terminate it with CTRL+D. encoding remark: Your input contains an 'osm-script' tag. Thus, a line with the datatype declaration is added. This shifts line numbering by -1 line(s). -After 0h0m2s: in "recurse", part 0, on line 13. Stack: 1 of 4800 1 of 4800 401 of 4800 +runtime remark: Timeout is 1 and maxsize is 1073741824. +After: in "recurse", part 0, on line 13. runtime error: Query timed out in "recurse" at line 13 after 2 seconds. diff --git a/osm-3s_testing/expected/osm3s_query_47/stderr.log b/osm-3s_testing/expected/osm3s_query_47/stderr.log index 6cb415712..23ae55aa0 100644 --- a/osm-3s_testing/expected/osm3s_query_47/stderr.log +++ b/osm-3s_testing/expected/osm3s_query_47/stderr.log @@ -1,5 +1,6 @@ encoding remark: Please enter your query and terminate it with CTRL+D. encoding remark: Your input contains an 'osm-script' tag. Thus, a line with the datatype declaration is added. This shifts line numbering by -1 line(s). -After 0h0m0s: in "recurse", part 0, on line 5. +runtime remark: Timeout is 3600 and maxsize is 280. +After: in "recurse", part 0, on line 5. runtime error: Query run out of memory in "recurse" at line 5 using about 0 MB of RAM. diff --git a/osm-3s_testing/expected/osm3s_query_48/stderr.log b/osm-3s_testing/expected/osm3s_query_48/stderr.log index 7bcb082eb..63261b624 100644 --- a/osm-3s_testing/expected/osm3s_query_48/stderr.log +++ b/osm-3s_testing/expected/osm3s_query_48/stderr.log @@ -1,3 +1,4 @@ encoding remark: Please enter your query and terminate it with CTRL+D. encoding remark: Your input contains an 'osm-script' tag. Thus, a line with the datatype declaration is added. This shifts line numbering by -1 line(s). +runtime remark: Timeout is 3600 and maxsize is 1073741824. diff --git a/osm-3s_testing/expected/osm3s_query_49/stderr.log b/osm-3s_testing/expected/osm3s_query_49/stderr.log index daadbf6c6..99fdd4c3e 100644 --- a/osm-3s_testing/expected/osm3s_query_49/stderr.log +++ b/osm-3s_testing/expected/osm3s_query_49/stderr.log @@ -1,5 +1,6 @@ encoding remark: Please enter your query and terminate it with CTRL+D. encoding remark: Your input contains an 'osm-script' tag. Thus, a line with the datatype declaration is added. This shifts line numbering by -1 line(s). -After 0h0m2s: in "recurse", part 0, on line 20. Stack: 2 of 21 1 of 21 12 of 21 10 of 21 +runtime remark: Timeout is 1 and maxsize is 1073741824. +After: in "recurse", part 0, on line 20. runtime error: Query timed out in "recurse" at line 20 after 2 seconds. diff --git a/osm-3s_testing/expected/osm3s_query_50/stderr.log b/osm-3s_testing/expected/osm3s_query_50/stderr.log index 6cb415712..23ae55aa0 100644 --- a/osm-3s_testing/expected/osm3s_query_50/stderr.log +++ b/osm-3s_testing/expected/osm3s_query_50/stderr.log @@ -1,5 +1,6 @@ encoding remark: Please enter your query and terminate it with CTRL+D. encoding remark: Your input contains an 'osm-script' tag. Thus, a line with the datatype declaration is added. This shifts line numbering by -1 line(s). -After 0h0m0s: in "recurse", part 0, on line 5. +runtime remark: Timeout is 3600 and maxsize is 280. +After: in "recurse", part 0, on line 5. runtime error: Query run out of memory in "recurse" at line 5 using about 0 MB of RAM. diff --git a/osm-3s_testing/expected/osm3s_query_51/stderr.log b/osm-3s_testing/expected/osm3s_query_51/stderr.log index 7bcb082eb..63261b624 100644 --- a/osm-3s_testing/expected/osm3s_query_51/stderr.log +++ b/osm-3s_testing/expected/osm3s_query_51/stderr.log @@ -1,3 +1,4 @@ encoding remark: Please enter your query and terminate it with CTRL+D. encoding remark: Your input contains an 'osm-script' tag. Thus, a line with the datatype declaration is added. This shifts line numbering by -1 line(s). +runtime remark: Timeout is 3600 and maxsize is 1073741824. diff --git a/osm-3s_testing/expected/osm3s_query_52/stderr.log b/osm-3s_testing/expected/osm3s_query_52/stderr.log index 403fb7314..731c6087e 100644 --- a/osm-3s_testing/expected/osm3s_query_52/stderr.log +++ b/osm-3s_testing/expected/osm3s_query_52/stderr.log @@ -1,5 +1,6 @@ encoding remark: Please enter your query and terminate it with CTRL+D. encoding remark: Your input contains an 'osm-script' tag. Thus, a line with the datatype declaration is added. This shifts line numbering by -1 line(s). -After 0h0m2s: in "recurse", part 0, on line 17. Stack: 2 of 18 7 of 18 7 of 18 16 of 18 +runtime remark: Timeout is 1 and maxsize is 1073741824. +After: in "recurse", part 0, on line 17. runtime error: Query timed out in "recurse" at line 17 after 2 seconds. diff --git a/osm-3s_testing/expected/osm3s_query_53/stderr.log b/osm-3s_testing/expected/osm3s_query_53/stderr.log index 6cb415712..23ae55aa0 100644 --- a/osm-3s_testing/expected/osm3s_query_53/stderr.log +++ b/osm-3s_testing/expected/osm3s_query_53/stderr.log @@ -1,5 +1,6 @@ encoding remark: Please enter your query and terminate it with CTRL+D. encoding remark: Your input contains an 'osm-script' tag. Thus, a line with the datatype declaration is added. This shifts line numbering by -1 line(s). -After 0h0m0s: in "recurse", part 0, on line 5. +runtime remark: Timeout is 3600 and maxsize is 280. +After: in "recurse", part 0, on line 5. runtime error: Query run out of memory in "recurse" at line 5 using about 0 MB of RAM. diff --git a/osm-3s_testing/expected/osm3s_query_54/stderr.log b/osm-3s_testing/expected/osm3s_query_54/stderr.log index 7bcb082eb..63261b624 100644 --- a/osm-3s_testing/expected/osm3s_query_54/stderr.log +++ b/osm-3s_testing/expected/osm3s_query_54/stderr.log @@ -1,3 +1,4 @@ encoding remark: Please enter your query and terminate it with CTRL+D. encoding remark: Your input contains an 'osm-script' tag. Thus, a line with the datatype declaration is added. This shifts line numbering by -1 line(s). +runtime remark: Timeout is 3600 and maxsize is 1073741824. diff --git a/osm-3s_testing/expected/osm3s_query_55/stderr.log b/osm-3s_testing/expected/osm3s_query_55/stderr.log index a815142f9..f70db07bf 100644 --- a/osm-3s_testing/expected/osm3s_query_55/stderr.log +++ b/osm-3s_testing/expected/osm3s_query_55/stderr.log @@ -1,5 +1,6 @@ encoding remark: Please enter your query and terminate it with CTRL+D. encoding remark: Your input contains an 'osm-script' tag. Thus, a line with the datatype declaration is added. This shifts line numbering by -1 line(s). -After 0h0m2s: in "recurse", part 0, on line 18. Stack: 2 of 18 17 of 18 7 of 18 17 of 18 +runtime remark: Timeout is 1 and maxsize is 1073741824. +After: in "recurse", part 0, on line 18. runtime error: Query timed out in "recurse" at line 18 after 2 seconds. diff --git a/osm-3s_testing/expected/osm3s_query_56/stderr.log b/osm-3s_testing/expected/osm3s_query_56/stderr.log index 6cb415712..23ae55aa0 100644 --- a/osm-3s_testing/expected/osm3s_query_56/stderr.log +++ b/osm-3s_testing/expected/osm3s_query_56/stderr.log @@ -1,5 +1,6 @@ encoding remark: Please enter your query and terminate it with CTRL+D. encoding remark: Your input contains an 'osm-script' tag. Thus, a line with the datatype declaration is added. This shifts line numbering by -1 line(s). -After 0h0m0s: in "recurse", part 0, on line 5. +runtime remark: Timeout is 3600 and maxsize is 280. +After: in "recurse", part 0, on line 5. runtime error: Query run out of memory in "recurse" at line 5 using about 0 MB of RAM. diff --git a/osm-3s_testing/expected/osm3s_query_57/stderr.log b/osm-3s_testing/expected/osm3s_query_57/stderr.log index 7bcb082eb..63261b624 100644 --- a/osm-3s_testing/expected/osm3s_query_57/stderr.log +++ b/osm-3s_testing/expected/osm3s_query_57/stderr.log @@ -1,3 +1,4 @@ encoding remark: Please enter your query and terminate it with CTRL+D. encoding remark: Your input contains an 'osm-script' tag. Thus, a line with the datatype declaration is added. This shifts line numbering by -1 line(s). +runtime remark: Timeout is 3600 and maxsize is 1073741824. diff --git a/osm-3s_testing/expected/osm3s_query_58/stderr.log b/osm-3s_testing/expected/osm3s_query_58/stderr.log index 7bcb082eb..05c8cf548 100644 --- a/osm-3s_testing/expected/osm3s_query_58/stderr.log +++ b/osm-3s_testing/expected/osm3s_query_58/stderr.log @@ -1,3 +1,4 @@ encoding remark: Please enter your query and terminate it with CTRL+D. encoding remark: Your input contains an 'osm-script' tag. Thus, a line with the datatype declaration is added. This shifts line numbering by -1 line(s). +runtime remark: Timeout is 1 and maxsize is 1073741824. diff --git a/osm-3s_testing/expected/osm3s_query_59/stderr.log b/osm-3s_testing/expected/osm3s_query_59/stderr.log index 7bcb082eb..05c8cf548 100644 --- a/osm-3s_testing/expected/osm3s_query_59/stderr.log +++ b/osm-3s_testing/expected/osm3s_query_59/stderr.log @@ -1,3 +1,4 @@ encoding remark: Please enter your query and terminate it with CTRL+D. encoding remark: Your input contains an 'osm-script' tag. Thus, a line with the datatype declaration is added. This shifts line numbering by -1 line(s). +runtime remark: Timeout is 1 and maxsize is 1073741824. diff --git a/osm-3s_testing/expected/osm3s_query_60/stderr.log b/osm-3s_testing/expected/osm3s_query_60/stderr.log index 7bcb082eb..05c8cf548 100644 --- a/osm-3s_testing/expected/osm3s_query_60/stderr.log +++ b/osm-3s_testing/expected/osm3s_query_60/stderr.log @@ -1,3 +1,4 @@ encoding remark: Please enter your query and terminate it with CTRL+D. encoding remark: Your input contains an 'osm-script' tag. Thus, a line with the datatype declaration is added. This shifts line numbering by -1 line(s). +runtime remark: Timeout is 1 and maxsize is 1073741824. diff --git a/osm-3s_testing/expected/osm3s_query_61/stderr.log b/osm-3s_testing/expected/osm3s_query_61/stderr.log index 7bcb082eb..63261b624 100644 --- a/osm-3s_testing/expected/osm3s_query_61/stderr.log +++ b/osm-3s_testing/expected/osm3s_query_61/stderr.log @@ -1,3 +1,4 @@ encoding remark: Please enter your query and terminate it with CTRL+D. encoding remark: Your input contains an 'osm-script' tag. Thus, a line with the datatype declaration is added. This shifts line numbering by -1 line(s). +runtime remark: Timeout is 3600 and maxsize is 1073741824. diff --git a/osm-3s_testing/expected/osm3s_query_62/stderr.log b/osm-3s_testing/expected/osm3s_query_62/stderr.log index 0b0b223aa..e3c68d419 100644 --- a/osm-3s_testing/expected/osm3s_query_62/stderr.log +++ b/osm-3s_testing/expected/osm3s_query_62/stderr.log @@ -1,5 +1,6 @@ encoding remark: Please enter your query and terminate it with CTRL+D. encoding remark: Your input contains an 'osm-script' tag. Thus, a line with the datatype declaration is added. This shifts line numbering by -1 line(s). -After 0h0m2s: in "print", part 0, on line 12. Stack: 1 of 99 1 of 99 35 of 99 55 of 99 +runtime remark: Timeout is 1 and maxsize is 1073741824. +After: in "print", part 0, on line 12. runtime error: Query timed out in "print" at line 12 after 2 seconds. diff --git a/osm-3s_testing/expected/osm3s_query_63/stderr.log b/osm-3s_testing/expected/osm3s_query_63/stderr.log index c25a1fa7b..e3c68d419 100644 --- a/osm-3s_testing/expected/osm3s_query_63/stderr.log +++ b/osm-3s_testing/expected/osm3s_query_63/stderr.log @@ -1,5 +1,6 @@ encoding remark: Please enter your query and terminate it with CTRL+D. encoding remark: Your input contains an 'osm-script' tag. Thus, a line with the datatype declaration is added. This shifts line numbering by -1 line(s). -After 0h0m2s: in "print", part 0, on line 12. Stack: 1 of 99 4 of 99 26 of 99 47 of 99 +runtime remark: Timeout is 1 and maxsize is 1073741824. +After: in "print", part 0, on line 12. runtime error: Query timed out in "print" at line 12 after 2 seconds. diff --git a/osm-3s_testing/expected/osm3s_query_64/stderr.log b/osm-3s_testing/expected/osm3s_query_64/stderr.log index 29898b824..e3c68d419 100644 --- a/osm-3s_testing/expected/osm3s_query_64/stderr.log +++ b/osm-3s_testing/expected/osm3s_query_64/stderr.log @@ -1,5 +1,6 @@ encoding remark: Please enter your query and terminate it with CTRL+D. encoding remark: Your input contains an 'osm-script' tag. Thus, a line with the datatype declaration is added. This shifts line numbering by -1 line(s). -After 0h0m2s: in "print", part 0, on line 12. Stack: 1 of 99 9 of 99 24 of 99 59 of 99 +runtime remark: Timeout is 1 and maxsize is 1073741824. +After: in "print", part 0, on line 12. runtime error: Query timed out in "print" at line 12 after 2 seconds. diff --git a/osm-3s_testing/expected/osm3s_query_65/stderr.log b/osm-3s_testing/expected/osm3s_query_65/stderr.log index 7bcb082eb..63261b624 100644 --- a/osm-3s_testing/expected/osm3s_query_65/stderr.log +++ b/osm-3s_testing/expected/osm3s_query_65/stderr.log @@ -1,3 +1,4 @@ encoding remark: Please enter your query and terminate it with CTRL+D. encoding remark: Your input contains an 'osm-script' tag. Thus, a line with the datatype declaration is added. This shifts line numbering by -1 line(s). +runtime remark: Timeout is 3600 and maxsize is 1073741824. diff --git a/osm-3s_testing/expected/osm3s_query_68/stderr.log b/osm-3s_testing/expected/osm3s_query_68/stderr.log index 7bcb082eb..05c8cf548 100644 --- a/osm-3s_testing/expected/osm3s_query_68/stderr.log +++ b/osm-3s_testing/expected/osm3s_query_68/stderr.log @@ -1,3 +1,4 @@ encoding remark: Please enter your query and terminate it with CTRL+D. encoding remark: Your input contains an 'osm-script' tag. Thus, a line with the datatype declaration is added. This shifts line numbering by -1 line(s). +runtime remark: Timeout is 1 and maxsize is 1073741824. diff --git a/osm-3s_testing/expected/osm3s_query_69/stderr.log b/osm-3s_testing/expected/osm3s_query_69/stderr.log index 7bcb082eb..63261b624 100644 --- a/osm-3s_testing/expected/osm3s_query_69/stderr.log +++ b/osm-3s_testing/expected/osm3s_query_69/stderr.log @@ -1,3 +1,4 @@ encoding remark: Please enter your query and terminate it with CTRL+D. encoding remark: Your input contains an 'osm-script' tag. Thus, a line with the datatype declaration is added. This shifts line numbering by -1 line(s). +runtime remark: Timeout is 3600 and maxsize is 1073741824. diff --git a/osm-3s_testing/expected/regression_cgi_bbox_not_numeric/stderr.log b/osm-3s_testing/expected/regression_cgi_bbox_not_numeric/stderr.log new file mode 100644 index 000000000..e69de29bb diff --git a/osm-3s_testing/expected/regression_cgi_bbox_not_numeric/stdout.log b/osm-3s_testing/expected/regression_cgi_bbox_not_numeric/stdout.log new file mode 100644 index 000000000..123fb1281 --- /dev/null +++ b/osm-3s_testing/expected/regression_cgi_bbox_not_numeric/stdout.log @@ -0,0 +1,18 @@ +Status: 400 Bad Request +Content-type: text/html; charset=utf-8 + + + + + + + OSM3S Response + + + +

The data included in this document is from www.openstreetmap.org. The data is made available under ODbL.

+

Error: line 1: parse error: bbox requires four arguments

+ + + diff --git a/osm-3s_testing/expected/regression_cgi_custom_url_line_break/stderr.log b/osm-3s_testing/expected/regression_cgi_custom_url_line_break/stderr.log new file mode 100644 index 000000000..e69de29bb diff --git a/osm-3s_testing/expected/regression_cgi_custom_url_line_break/stdout.log b/osm-3s_testing/expected/regression_cgi_custom_url_line_break/stdout.log new file mode 100644 index 000000000..ca3df7028 --- /dev/null +++ b/osm-3s_testing/expected/regression_cgi_custom_url_line_break/stdout.log @@ -0,0 +1,18 @@ +Status: 400 Bad Request +Content-type: text/html; charset=utf-8 + + + + + + + OSM3S Response + + + +

The data included in this document is from www.openstreetmap.org. The data is made available under ODbL.

+

Error: encoding error: Parameter "url" must not contain line breaks.

+ + + diff --git a/osm-3s_testing/expected/regression_cgi_truncated_percent/stderr.log b/osm-3s_testing/expected/regression_cgi_truncated_percent/stderr.log new file mode 100644 index 000000000..e69de29bb diff --git a/osm-3s_testing/expected/regression_cgi_truncated_percent/stdout.log b/osm-3s_testing/expected/regression_cgi_truncated_percent/stdout.log new file mode 100644 index 000000000..f003706d0 --- /dev/null +++ b/osm-3s_testing/expected/regression_cgi_truncated_percent/stdout.log @@ -0,0 +1,21 @@ +Status: 400 Bad Request +Content-type: text/html; charset=utf-8 + + + + + + + OSM3S Response + + + +

The data included in this document is from www.openstreetmap.org. The data is made available under ODbL.

+

Error: line 1: parse error: Unknown type "%"

+

Error: line 1: parse error: An empty query is not allowed

+

Error: line 1: parse error: ';' expected - '%' found.

+

Error: line 1: parse error: Unexpected end of input.

+ + + diff --git a/osm-3s_testing/expected/regression_ql_nesting_limit/stderr.log b/osm-3s_testing/expected/regression_ql_nesting_limit/stderr.log new file mode 100644 index 000000000..69bea0599 --- /dev/null +++ b/osm-3s_testing/expected/regression_ql_nesting_limit/stderr.log @@ -0,0 +1,1031 @@ +encoding remark: Please enter your query and terminate it with CTRL+D. +line 1: parse error: Nesting of statements is limited to 1023 levels +line 1: parse error: Nesting of statements is limited to 1023 levels +line 1: parse error: Nesting of statements is limited to 1023 levels +line 1: parse error: ';' expected - '(' found. +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed +line 1: parse error: Unknown type ")" +line 1: parse error: An empty query is not allowed diff --git a/osm-3s_testing/expected/regression_ql_nesting_limit/stdout.log b/osm-3s_testing/expected/regression_ql_nesting_limit/stdout.log new file mode 100644 index 000000000..e69de29bb diff --git a/osm-3s_testing/expected/regression_user_touched_relations/stderr.log b/osm-3s_testing/expected/regression_user_touched_relations/stderr.log new file mode 100644 index 000000000..ba861b591 --- /dev/null +++ b/osm-3s_testing/expected/regression_user_touched_relations/stderr.log @@ -0,0 +1,2 @@ +encoding remark: Please enter your query and terminate it with CTRL+D. +runtime remark: Timeout is 180 and maxsize is 536870912. diff --git a/osm-3s_testing/expected/regression_user_touched_relations/stdout.log b/osm-3s_testing/expected/regression_user_touched_relations/stdout.log new file mode 100644 index 000000000..806ae27e3 --- /dev/null +++ b/osm-3s_testing/expected/regression_user_touched_relations/stdout.log @@ -0,0 +1,19 @@ + + +The data included in this document is from www.openstreetmap.org. The data is made available under ODbL. + + + + + + + + + + + + + + + + diff --git a/osm-3s_testing/expected/run_and_compare.sh_1/stderr.log b/osm-3s_testing/expected/run_and_compare.sh_1/stderr.log index 49e04fc87..98a93cc5c 100644 --- a/osm-3s_testing/expected/run_and_compare.sh_1/stderr.log +++ b/osm-3s_testing/expected/run_and_compare.sh_1/stderr.log @@ -1,9 +1,3 @@ -Reading XML file ... elapsed node 2795331. Flushing to database ...... done. -Reading XML file ... elapsed node 5590728. Flushing to database ...... done. -Reading XML file ... elapsed node 8386125. Flushing to database ...... done. -Reading XML file ... elapsed node 11181522. Flushing to database ...... done. -Reading XML file ... elapsed node 13976919. Flushing to database ...... done. -Reading XML file ... finished reading nodes. Flushing to database ...... done. -Reorganizing the database ... done. +Reading XML file ... finished reading nodes. Compute current ... ready. Flushing to database ...... done. compare_osm_base_maps: File error caught: 2 ./ways.bin File_Blocks::File_Blocks::1 compare_osm_base_maps: File error caught: 2 ./relations.bin File_Blocks::File_Blocks::1 diff --git a/osm-3s_testing/expected/run_and_compare.sh_1/stdout.log b/osm-3s_testing/expected/run_and_compare.sh_1/stdout.log index 9a215f2ff..5d6e6b2ca 100644 --- a/osm-3s_testing/expected/run_and_compare.sh_1/stdout.log +++ b/osm-3s_testing/expected/run_and_compare.sh_1/stdout.log @@ -1 +1 @@ -For 16000000 nodes their idx in bin matches their idx in map. +For 6400 nodes their idx in bin matches their idx in map. diff --git a/osm-3s_testing/expected/run_and_compare.sh_2/stderr.log b/osm-3s_testing/expected/run_and_compare.sh_2/stderr.log index cfbcc519a..a698dac1c 100644 --- a/osm-3s_testing/expected/run_and_compare.sh_2/stderr.log +++ b/osm-3s_testing/expected/run_and_compare.sh_2/stderr.log @@ -1,19 +1,4 @@ -Reading XML file ... elapsed node 2795331. Flushing to database ...... done. -Reading XML file ... elapsed node 5590728. Flushing to database ...... done. -Reading XML file ... elapsed node 8386125. Flushing to database ...... done. -Reading XML file ... elapsed node 11181522. Flushing to database ...... done. -Reading XML file ... elapsed node 13976919. Flushing to database ...... done. -Reading XML file ... finished reading nodes. Flushing to database ...... done. -Reorganizing the database ... done. -Reading XML file ... elapsed way 986772. Flushing to database ....... done. -Reading XML file ... elapsed way 1973566. Flushing to database ....... done. -Reading XML file ... elapsed way 2021162. Flushing to database ....... done. -Reading XML file ... elapsed way 3007957. Flushing to database ....... done. -Reading XML file ... elapsed way 3994752. Flushing to database ....... done. -Reading XML file ... elapsed way 4042347. Flushing to database ....... done. -Reading XML file ... elapsed way 5029142. Flushing to database ....... done. -Reading XML file ... elapsed way 6000030. Flushing to database ....... done. -Reading XML file ... finished reading ways. Flushing to database ....... done. -Reorganizing the database ... done. +Reading XML file ... finished reading nodes. Compute current ... ready. Flushing to database ...... done. +Reading XML file ... finished reading ways. Compute current ... ready. Flushing to database ...... done. compare_osm_base_maps: File error caught: 2 ./nodes.bin File_Blocks::File_Blocks::1 compare_osm_base_maps: File error caught: 2 ./relations.bin File_Blocks::File_Blocks::1 diff --git a/osm-3s_testing/expected/run_and_compare.sh_2/stdout.log b/osm-3s_testing/expected/run_and_compare.sh_2/stdout.log index 6a13b404e..a7d336212 100644 --- a/osm-3s_testing/expected/run_and_compare.sh_2/stdout.log +++ b/osm-3s_testing/expected/run_and_compare.sh_2/stdout.log @@ -1 +1 @@ -For 6002994 ways their idx in bin matches their idx in map. +For 2454 ways their idx in bin matches their idx in map. diff --git a/osm-3s_testing/expected/run_and_compare.sh_3/stderr.log b/osm-3s_testing/expected/run_and_compare.sh_3/stderr.log index a19722b3b..290260fe4 100644 --- a/osm-3s_testing/expected/run_and_compare.sh_3/stderr.log +++ b/osm-3s_testing/expected/run_and_compare.sh_3/stderr.log @@ -1,19 +1,5 @@ -Reading XML file ... elapsed node 2795331. Flushing to database ...... done. -Reading XML file ... elapsed node 5590728. Flushing to database ...... done. -Reading XML file ... elapsed node 8386125. Flushing to database ...... done. -Reading XML file ... elapsed node 11181522. Flushing to database ...... done. -Reading XML file ... elapsed node 13976919. Flushing to database ...... done. -Reading XML file ... finished reading nodes. Flushing to database ...... done. -Reorganizing the database ... done. -Reading XML file ... elapsed way 986772. Flushing to database ....... done. -Reading XML file ... elapsed way 1973566. Flushing to database ....... done. -Reading XML file ... elapsed way 2021162. Flushing to database ....... done. -Reading XML file ... elapsed way 3007957. Flushing to database ....... done. -Reading XML file ... elapsed way 3994752. Flushing to database ....... done. -Reading XML file ... elapsed way 4042347. Flushing to database ....... done. -Reading XML file ... elapsed way 5029142. Flushing to database ....... done. -Reading XML file ... elapsed way 6000030. Flushing to database ....... done. -Reading XML file ... finished reading ways. Flushing to database ....... done. -Reading XML file ... finished reading relations. Flushing to database ........ done. +Reading XML file ... finished reading nodes. Compute current ... ready. Flushing to database ...... done. +Reading XML file ... finished reading ways. Compute current ... ready. Flushing to database ...... done. +Reading XML file ... finished reading relations. Flushing to database ....... done. compare_osm_base_maps: File error caught: 2 ./nodes.bin File_Blocks::File_Blocks::1 compare_osm_base_maps: File error caught: 2 ./ways.bin File_Blocks::File_Blocks::1 diff --git a/osm-3s_testing/input/osm3s_query_22/stdin.log b/osm-3s_testing/input/osm3s_query_22/stdin.log index bc411caa6..b4241e113 100644 --- a/osm-3s_testing/input/osm3s_query_22/stdin.log +++ b/osm-3s_testing/input/osm3s_query_22/stdin.log @@ -3,8 +3,8 @@ - - + + diff --git a/osm-3s_testing/input/regression_cgi_bbox_not_numeric/env b/osm-3s_testing/input/regression_cgi_bbox_not_numeric/env new file mode 100644 index 000000000..04037d35e --- /dev/null +++ b/osm-3s_testing/input/regression_cgi_bbox_not_numeric/env @@ -0,0 +1,2 @@ +REQUEST_METHOD=GET +QUERY_STRING=data=node(bbox);out;&bbox=7,51,8);node(id:1,52 diff --git a/osm-3s_testing/input/regression_cgi_bbox_not_numeric/init.osm b/osm-3s_testing/input/regression_cgi_bbox_not_numeric/init.osm new file mode 100644 index 000000000..140a94367 --- /dev/null +++ b/osm-3s_testing/input/regression_cgi_bbox_not_numeric/init.osm @@ -0,0 +1,4 @@ + + + + diff --git a/osm-3s_testing/input/regression_cgi_custom_url_line_break/env b/osm-3s_testing/input/regression_cgi_custom_url_line_break/env new file mode 100644 index 000000000..8f939c879 --- /dev/null +++ b/osm-3s_testing/input/regression_cgi_custom_url_line_break/env @@ -0,0 +1,2 @@ +REQUEST_METHOD=GET +QUERY_STRING=data=[out:custom];node(1);out;&url=http://example.com/%0d%0aX-Injected:%201 diff --git a/osm-3s_testing/input/regression_cgi_custom_url_line_break/init.osm b/osm-3s_testing/input/regression_cgi_custom_url_line_break/init.osm new file mode 100644 index 000000000..140a94367 --- /dev/null +++ b/osm-3s_testing/input/regression_cgi_custom_url_line_break/init.osm @@ -0,0 +1,4 @@ + + + + diff --git a/osm-3s_testing/input/regression_cgi_truncated_percent/env b/osm-3s_testing/input/regression_cgi_truncated_percent/env new file mode 100644 index 000000000..1192b3b48 --- /dev/null +++ b/osm-3s_testing/input/regression_cgi_truncated_percent/env @@ -0,0 +1,2 @@ +REQUEST_METHOD=GET +QUERY_STRING=data=node(1);out;% diff --git a/osm-3s_testing/input/regression_ql_nesting_limit/stdin.log b/osm-3s_testing/input/regression_ql_nesting_limit/stdin.log new file mode 100644 index 000000000..0d6556594 --- /dev/null +++ b/osm-3s_testing/input/regression_ql_nesting_limit/stdin.log @@ -0,0 +1 @@ +((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((node(1););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););););); diff --git a/osm-3s_testing/input/regression_user_touched_relations/import.args b/osm-3s_testing/input/regression_user_touched_relations/import.args new file mode 100644 index 000000000..65d113bed --- /dev/null +++ b/osm-3s_testing/input/regression_user_touched_relations/import.args @@ -0,0 +1 @@ +--keep-attic diff --git a/osm-3s_testing/input/regression_user_touched_relations/init.osm b/osm-3s_testing/input/regression_user_touched_relations/init.osm new file mode 100644 index 000000000..5ec2fe3a9 --- /dev/null +++ b/osm-3s_testing/input/regression_user_touched_relations/init.osm @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/osm-3s_testing/input/regression_user_touched_relations/stdin.log b/osm-3s_testing/input/regression_user_touched_relations/stdin.log new file mode 100644 index 000000000..6e4af4f7b --- /dev/null +++ b/osm-3s_testing/input/regression_user_touched_relations/stdin.log @@ -0,0 +1,6 @@ +rel(1); +nwr._(uid_touched:999999999); +out count; +rel(1); +nwr._(uid_touched:1); +out count; diff --git a/osm-3s_testing/turn_testing_on.sh b/osm-3s_testing/turn_testing_on.sh index 493a8d17c..3f10e2042 100755 --- a/osm-3s_testing/turn_testing_on.sh +++ b/osm-3s_testing/turn_testing_on.sh @@ -1,14 +1,14 @@ #!/usr/bin/env bash cat ../src/Makefile.am | awk '{ if ($1 == "#SUBDIRS" && $3 != "") print substr($0,2); else if ($1 == "SUBDIRS" && $3 == "") print "#"$0; else print $0; }' >_ -if [[ -z $(diff -q _ ../src/Makefile.test.am) ]]; then +if [[ -f ../src/Makefile.test.am && -z $(diff -q _ ../src/Makefile.test.am) ]]; then mv ../src/Makefile.test.am ../src/Makefile.am else mv _ ../src/Makefile.am fi cat ../src/configure.ac | awk '{ if (substr($1,1,16) == "#AC_CONFIG_FILES" && $2 != "") print substr($0,2); else if (substr($1,1,15) == "AC_CONFIG_FILES" && $2 == "") print "#"$0; else print $0; }' >_ -if [[ -z $(diff -q _ ../src/configure.test.ac) ]]; then +if [[ -f ../src/configure.test.ac && -z $(diff -q _ ../src/configure.test.ac) ]]; then mv ../src/configure.test.ac ../src/configure.ac else mv _ ../src/configure.ac diff --git a/src/overpass_api/core/four_field_index.test.cc b/src/overpass_api/core/four_field_index.test.cc new file mode 100644 index 000000000..4f5bb29a4 --- /dev/null +++ b/src/overpass_api/core/four_field_index.test.cc @@ -0,0 +1,79 @@ +/** Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Roland Olbricht et al. + * + * This file is part of Overpass_API. + * + * Overpass_API is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Overpass_API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Overpass_API. If not, see . + */ + +#include "four_field_index.h" + +#include +#include + + +void check_result(const Four_Field_Index& idx, const std::string& expected) +{ + std::string result = idx.to_string(); + if (result == expected) + std::cout<<"OK"<<'\n'; + else + std::cout<<"failed: "<. + */ + +#include "index_computations.h" + +#include +#include +#include +#include + + +void cout_ranges(const Ranges< Uint31_Index >& result) +{ + std::cout<<"0x__80: "; + for (auto it = result.begin(); it != result.end(); ++it) + { + if ((it.lower_bound().val() & 0x80000000) && (it.lower_bound().val() & 0xff) == 0x80) + std::cout<(1, ll_upper(lat, 0) ^ 0x40000000))<<' '; + std::cout<<'\n'; + for (uint32 lat = 0; lat <= 0x1000000; lat += 0x100000) + std::cout<(1, ll_upper(lat, 0) ^ 0x40000000))<<' '; + std::cout<<'\n'; + for (uint32 lat = 0; lat <= 0x10000000; lat += 0x1000000) + std::cout<(1, ll_upper(lat, 0) ^ 0x40000000))<<' '; + std::cout<<'\n'; + for (uint32 lat = 0; lat < 0x80000000; lat += 0x10000000) + std::cout<(1, ll_upper(lat, 0) ^ 0x40000000))<<' '; + std::cout<<'\n'; + + for (int32 lon = 0; lon <= 0x100000; lon += 0x10000) + std::cout<(1, ll_upper(0, lon) ^ 0x40000000))<<' '; + std::cout<<'\n'; + for (int32 lon = 0; lon <= 0x1000000; lon += 0x100000) + std::cout<(1, ll_upper(0, lon) ^ 0x40000000))<<' '; + std::cout<<'\n'; + for (int32 lon = 0; lon <= 0x10000000; lon += 0x1000000) + std::cout<(1, ll_upper(0, lon) ^ 0x40000000))<<' '; + std::cout<<'\n'; + for (int32 lon = 0xffff8000; lon < (int32)0x8000; lon += 0x1000) + std::cout<(1, ll_upper(0, lon<<16) ^ 0x40000000))<<' '; + std::cout<<'\n'; + + std::cout<<"\nTest calc_index with 2 entries:\n"; + + for (uint32 lat = 0; lat <= 0x100000; lat += 0x10000) + { + std::vector< uint32 > idxs(1, 0x40000000); + idxs.push_back(ll_upper(lat, 0) ^ 0x40000000); + std::cout< idxs(1, 0x40000000); + idxs.push_back(ll_upper(lat, 0) ^ 0x40000000); + std::cout< idxs(1, 0x40000000); + idxs.push_back(ll_upper(lat, 0) ^ 0x40000000); + std::cout< idxs(1, 0x40000000); + idxs.push_back(ll_upper(lat, 0) ^ 0x40000000); + std::cout< idxs(1, 0x40000000); + idxs.push_back(ll_upper(0, lon) ^ 0x40000000); + std::cout< idxs(1, 0x40000000); + idxs.push_back(ll_upper(0, lon) ^ 0x40000000); + std::cout< idxs(1, 0x40000000); + idxs.push_back(ll_upper(0, lon) ^ 0x40000000); + std::cout< idxs(1, 0x40000000); + idxs.push_back(ll_upper(0, lon<<16) ^ 0x40000000); + std::cout< idxs(1, 0x40000000); + idxs.push_back(ll_upper(lat, 0) ^ 0x40000000); + std::cout<(1, calc_index(idxs)))<<' '; + } + std::cout<<'\n'; + for (uint32 lat = 0; lat <= 0x1000000; lat += 0x100000) + { + std::vector< uint32 > idxs(1, 0x40000000); + idxs.push_back(ll_upper(lat, 0) ^ 0x40000000); + std::cout<(1, calc_index(idxs)))<<' '; + } + std::cout<<'\n'; + for (uint32 lat = 0; lat <= 0x10000000; lat += 0x1000000) + { + std::vector< uint32 > idxs(1, 0x40000000); + idxs.push_back(ll_upper(lat, 0) ^ 0x40000000); + std::cout<(1, calc_index(idxs)))<<' '; + } + std::cout<<'\n'; + for (uint32 lat = 0; lat < 0x80000000; lat += 0x10000000) + { + std::vector< uint32 > idxs(1, 0x40000000); + idxs.push_back(ll_upper(lat, 0) ^ 0x40000000); + std::cout<(1, calc_index(idxs)))<<' '; + } + std::cout<<'\n'; + + for (int32 lon = 0; lon <= 0x100000; lon += 0x10000) + { + std::vector< uint32 > idxs(1, 0x40000000); + idxs.push_back(ll_upper(0, lon) ^ 0x40000000); + std::cout<(1, calc_index(idxs)))<<' '; + } + std::cout<<'\n'; + for (int32 lon = 0; lon <= 0x1000000; lon += 0x100000) + { + std::vector< uint32 > idxs(1, 0x40000000); + idxs.push_back(ll_upper(0, lon) ^ 0x40000000); + std::cout<(1, calc_index(idxs)))<<' '; + } + std::cout<<'\n'; + for (int32 lon = 0; lon <= 0x10000000; lon += 0x1000000) + { + std::vector< uint32 > idxs(1, 0x40000000); + idxs.push_back(ll_upper(0, lon) ^ 0x40000000); + std::cout<(1, calc_index(idxs)))<<' '; + } + std::cout<<'\n'; + for (int32 lon = 0xffff8000; lon < (int32)0x8000; lon += 0x1000) + { + std::vector< uint32 > idxs(1, 0x40000000); + idxs.push_back(ll_upper(0, lon<<16) ^ 0x40000000); + std::cout<(1, calc_index(idxs)))<<' '; + } + std::cout<<'\n'; + + std::cout<<"\nTest calc_index with an already cumulated and another entry:\n"; + + for (uint32 lat = 0; lat <= 0x100000; lat += 0x10000) + { + std::vector< uint32 > idxs(1, 0x40000000); + idxs.push_back(ll_upper(lat, 0) ^ 0x40000000); + idxs[1] = calc_index(idxs); + std::cout< idxs(1, 0x40000000); + idxs.push_back(ll_upper(lat, 0) ^ 0x40000000); + idxs[1] = calc_index(idxs); + std::cout< idxs(1, 0x40000000); + idxs.push_back(ll_upper(lat, 0) ^ 0x40000000); + idxs[1] = calc_index(idxs); + std::cout< idxs(1, 0x40000000); + idxs.push_back(ll_upper(lat, 0) ^ 0x40000000); + idxs[1] = calc_index(idxs); + std::cout< idxs(1, 0x40000000); + idxs.push_back(ll_upper(0, lon) ^ 0x40000000); + idxs[1] = calc_index(idxs); + std::cout< idxs(1, 0x40000000); + idxs.push_back(ll_upper(0, lon) ^ 0x40000000); + idxs[1] = calc_index(idxs); + std::cout< idxs(1, 0x40000000); + idxs.push_back(ll_upper(0, lon) ^ 0x40000000); + idxs[1] = calc_index(idxs); + std::cout< idxs(1, 0x40000000); + idxs.push_back(ll_upper(0, lon<<16) ^ 0x40000000); + idxs[1] = calc_index(idxs); + std::cout< idxs(2, 0x3f3f3f3f); + std::vector< Uint32_Index > result = calc_node_children(idxs); + for (std::vector< Uint32_Index >::const_iterator it = result.begin(); it != result.end(); ++it) + std::cout<val()<<' '; + std::cout<<'\n'; + } + { + std::vector< Uint32_Index > result = calc_node_children(std::vector< uint32 >(1, 0x40848400)); + for (std::vector< Uint32_Index >::const_iterator it = result.begin(); it != result.end(); ++it) + std::cout<val()<<' '; + std::cout<<'\n'; + } + { + std::vector< Uint32_Index > result = calc_node_children(std::vector< uint32 >(1, 0xc0848401)); + for (std::vector< Uint32_Index >::const_iterator it = result.begin(); it != result.end(); ++it) + std::cout<val()<<' '; + std::cout<<'\n'; + } + { + std::vector< Uint32_Index > result = calc_node_children(std::vector< uint32 >(1, 0xc0848402)); + for (std::vector< Uint32_Index >::const_iterator it = result.begin(); it != result.end(); ++it) + std::cout<val()<<' '; + std::cout<<'\n'; + } + { + std::vector< Uint32_Index > result = calc_node_children(std::vector< uint32 >(1, 0xc0848404)); + for (std::vector< Uint32_Index >::const_iterator it = result.begin(); it != result.end(); ++it) + std::cout<val()<<' '; + std::cout<<'\n'; + } + // Disabled due to their size. +/* { + std::vector< uint32 > result = calc_node_children(std::vector< uint32 >(1, 0xc0848008)); + for (std::vector< uint32 >::const_iterator it = result.begin(); it != result.end(); ++it) + std::cout< result = calc_node_children(std::vector< uint32 >(1, 0xc0840010)); + for (std::vector< uint32 >::const_iterator it = result.begin(); it != result.end(); ++it) + std::cout< result = calc_node_children(std::vector< uint32 >(1, 0xc0800020)); + for (std::vector< uint32 >::const_iterator it = result.begin(); it != result.end(); ++it) + std::cout< result = calc_node_children(std::vector< uint32 >(1, 0xc0000040)); + for (std::vector< uint32 >::const_iterator it = result.begin(); it != result.end(); ++it) + std::cout< idxs(2, 0x3f3f3f3f); + std::vector< Uint31_Index > result = calc_children(idxs); + for (std::vector< Uint31_Index >::const_iterator it = result.begin(); it != result.end(); ++it) + std::cout<val()<<' '; + std::cout<<'\n'; + } + { + std::vector< Uint31_Index > result = calc_children(std::vector< uint32 >(1, 0x40848400)); + for (std::vector< Uint31_Index >::const_iterator it = result.begin(); it != result.end(); ++it) + std::cout<val()<<' '; + std::cout<<'\n'; + } + { + std::vector< Uint31_Index > result = calc_children(std::vector< uint32 >(1, 0xc0848401)); + for (std::vector< Uint31_Index >::const_iterator it = result.begin(); it != result.end(); ++it) + std::cout<val()<<' '; + std::cout<<'\n'; + } + { + std::vector< Uint31_Index > result = calc_children(std::vector< uint32 >(1, 0xc0848402)); + for (std::vector< Uint31_Index >::const_iterator it = result.begin(); it != result.end(); ++it) + std::cout<val()<<' '; + std::cout<<'\n'; + } + { + std::vector< Uint31_Index > result = calc_children(std::vector< uint32 >(1, 0xc0848404)); + for (std::vector< Uint31_Index >::const_iterator it = result.begin(); it != result.end(); ++it) + std::cout<val()<<' '; + std::cout<<'\n'; + } + } + + if ((test_to_execute == "6") || (test_to_execute == "")) + { + std::cout<<"\nTest calc_parents:\n"; + + for (uint32 lat = 0; lat <= 0x100000; lat += 0x10000) + { + std::vector< uint32 > result = calc_parents(std::vector< uint32 >(1, ll_upper(lat, 0) ^ 0x40000000)); + for (std::vector< uint32 >::const_iterator it = result.begin(); it != result.end(); ++it) + std::cout< result = calc_parents(std::vector< uint32 >(1, ll_upper(lat, 0) ^ 0x40000000)); + for (std::vector< uint32 >::const_iterator it = result.begin(); it != result.end(); ++it) + std::cout< result = calc_parents(std::vector< uint32 >(1, ll_upper(lat, 0) ^ 0x40000000)); + for (std::vector< uint32 >::const_iterator it = result.begin(); it != result.end(); ++it) + std::cout< result = calc_parents(std::vector< uint32 >(1, ll_upper(lat, 0) ^ 0x40000000)); + for (std::vector< uint32 >::const_iterator it = result.begin(); it != result.end(); ++it) + std::cout< result = calc_parents(std::vector< uint32 >(1, ll_upper(0, lon) ^ 0x40000000)); + for (std::vector< uint32 >::const_iterator it = result.begin(); it != result.end(); ++it) + std::cout< result = calc_parents(std::vector< uint32 >(1, ll_upper(0, lon) ^ 0x40000000)); + for (std::vector< uint32 >::const_iterator it = result.begin(); it != result.end(); ++it) + std::cout< result = calc_parents(std::vector< uint32 >(1, ll_upper(0, lon) ^ 0x40000000)); + for (std::vector< uint32 >::const_iterator it = result.begin(); it != result.end(); ++it) + std::cout< result = calc_parents(std::vector< uint32 > + (1, ll_upper(0, (int32)lon) ^ 0x40000000)); + for (std::vector< uint32 >::const_iterator it = result.begin(); it != result.end(); ++it) + std::cout< result = calc_parents(std::vector< uint32 > + (1, ll_upper(0, (int32)lon) ^ 0x40000000)); + for (std::vector< uint32 >::const_iterator it = result.begin(); it != result.end(); ++it) + std::cout< input(ll_upper(lat, 0) ^ 0x40000000, (ll_upper(lat, 0) ^ 0x40000000) + 1); + cout_ranges(calc_parents(input)); + } + std::cout<<'\n'; + for (uint32 lat = 0x40000000; lat <= 0x41000000; lat += 0x100000) + { + Ranges< Uint32_Index > input(ll_upper(lat, 0) ^ 0x40000000, (ll_upper(lat, 0) ^ 0x40000000) + 1); + cout_ranges(calc_parents(input)); + } + std::cout<<'\n'; + for (uint32 lat = 0x40000000; lat <= 0x50000000; lat += 0x1000000) + { + Ranges< Uint32_Index > input(ll_upper(lat, 0) ^ 0x40000000, (ll_upper(lat, 0) ^ 0x40000000) + 1); + cout_ranges(calc_parents(input)); + } + std::cout<<'\n'; + for (uint32 lat = 0x40000000; lat < 0x80000000; lat += 0x10000000) + { + Ranges< Uint32_Index > input(ll_upper(lat, 0) ^ 0x40000000, (ll_upper(lat, 0) ^ 0x40000000) + 1); + cout_ranges(calc_parents(input)); + } + std::cout<<'\n'; + + for (int32 lon = 0; lon <= 0x100000; lon += 0x10000) + { + Ranges< Uint32_Index > input(ll_upper(0x40000000, lon) ^ 0x40000000, (ll_upper(0x40000000, lon) ^ 0x40000000) + 1); + cout_ranges(calc_parents(input)); + } + std::cout<<'\n'; + for (int32 lon = 0; lon <= 0x1000000; lon += 0x100000) + { + Ranges< Uint32_Index > input(ll_upper(0x40000000, lon) ^ 0x40000000, + (ll_upper(0x40000000, lon) ^ 0x40000000) + 1); + cout_ranges(calc_parents(input)); + } + std::cout<<'\n'; + for (int32 lon = 0; lon <= 0x10000000; lon += 0x1000000) + { + Ranges< Uint32_Index > input(ll_upper(0x40000000, lon) ^ 0x40000000, + (ll_upper(0x40000000, lon) ^ 0x40000000) + 1); + cout_ranges(calc_parents(input)); + } + std::cout<<'\n'; + for (uint32 lon = 0; (uint32)lon < (uint32)0x80000000; lon += 0x10000000) + { + Ranges< Uint32_Index > input(ll_upper(0x40000000ul, (int32)lon) ^ 0x40000000, + (ll_upper(0x40000000ul, (int32)lon) ^ 0x40000000) + 1); + cout_ranges(calc_parents(input)); + } + for (uint32 lon = 0x80000000; (uint32)lon != (uint32)0; lon += 0x10000000) + { + Ranges< Uint32_Index > input(ll_upper(0x40000000ul, (int32)lon) ^ 0x40000000, + (ll_upper(0x40000000ul, (int32)lon) ^ 0x40000000) + 1); + cout_ranges(calc_parents(input)); + } + std::cout<<'\n'; + { + std::cout<<"Size 1\n"; + Ranges< Uint32_Index > input(ll_upper(0x40010000, 0) ^ 0x40000000, (ll_upper(0x40010000, 0) ^ 0x40000000) + 1); + cout_ranges(calc_parents(input)); + } + std::cout<<'\n'; + { + std::cout<<"Size 2\n"; + Ranges< Uint32_Index > input(ll_upper(0x40020000, 0) ^ 0x40000000, (ll_upper(0x40030000, 0x10000) ^ 0x40000000) + 1); + cout_ranges(calc_parents(input)); + } + std::cout<<'\n'; + { + std::cout<<"Size 3\n"; + Ranges< Uint32_Index > input(ll_upper(0x40040000, 0) ^ 0x40000000, (ll_upper(0x40070000, 0x30000) ^ 0x40000000) + 1); + cout_ranges(calc_parents(input)); + } + std::cout<<'\n'; + { + std::cout<<"Size 4\n"; + Ranges< Uint32_Index > input(ll_upper(0x40080000, 0) ^ 0x40000000, (ll_upper(0x400f0000, 0x70000) ^ 0x40000000) + 1); + cout_ranges(calc_parents(input)); + } + std::cout<<'\n'; + { + std::cout<<"Size 5\n"; + Ranges< Uint32_Index > input(ll_upper(0x40100000, 0) ^ 0x40000000, (ll_upper(0x401f0000, 0xf0000) ^ 0x40000000) + 1); + cout_ranges(calc_parents(input)); + } + std::cout<<'\n'; + { + std::cout<<"Size 6\n"; + Ranges< Uint32_Index > input(ll_upper(0x40200000, 0) ^ 0x40000000, (ll_upper(0x403f0000, 0x1f0000) ^ 0x40000000) + 1); + cout_ranges(calc_parents(input)); + } + std::cout<<'\n'; + { + std::cout<<"Size 7\n"; + Ranges< Uint32_Index > input(ll_upper(0x40400000, 0) ^ 0x40000000, (ll_upper(0x407f0000, 0x3f0000) ^ 0x40000000) + 1); + cout_ranges(calc_parents(input)); + } + std::cout<<'\n'; + { + std::cout<<"Size 8\n"; + Ranges< Uint32_Index > input(ll_upper(0x40800000, 0) ^ 0x40000000, (ll_upper(0x40ff0000, 0x7f0000) ^ 0x40000000) + 1); + cout_ranges(calc_parents(input)); + } + std::cout<<'\n'; + { + std::cout<<"Size 9\n"; + Ranges< Uint32_Index > input(ll_upper(0x41000000, 0) ^ 0x40000000, (ll_upper(0x41ff0000, 0xff0000) ^ 0x40000000) + 1); + cout_ranges(calc_parents(input)); + } + std::cout<<'\n'; + { + std::cout<<"Size 10\n"; + Ranges< Uint32_Index > input(ll_upper(0x42000000, 0) ^ 0x40000000, (ll_upper(0x43ff0000, 0x1ff0000) ^ 0x40000000) + 1); + cout_ranges(calc_parents(input)); + } + std::cout<<'\n'; + { + std::cout<<"Size 11\n"; + Ranges< Uint32_Index > input(ll_upper(0x44000000, 0) ^ 0x40000000, (ll_upper(0x47ff0000, 0x3ff0000) ^ 0x40000000) + 1); + cout_ranges(calc_parents(input)); + } + std::cout<<'\n'; + { + std::cout<<"Size 12\n"; + Ranges< Uint32_Index > input(ll_upper(0x48000000, 0) ^ 0x40000000, (ll_upper(0x4fff0000, 0x7ff0000) ^ 0x40000000) + 1); + cout_ranges(calc_parents(input)); + } + std::cout<<'\n'; + { + std::cout<<"Size 13\n"; + Ranges< Uint32_Index > input(ll_upper(0x50000000, 0) ^ 0x40000000, (ll_upper(0x5fff0000, 0xfff0000) ^ 0x40000000) + 1); + cout_ranges(calc_parents(input)); + } + std::cout<<'\n'; + { + std::cout<<"Two Size 1\n"; + Ranges< Uint32_Index > input(ll_upper(0x3fff0000, 0x7fff0000) ^ 0x40000000, + (ll_upper(0x40000000, 0) ^ 0x40000000) + 1); + cout_ranges(calc_parents(input)); + } + std::cout<<'\n'; + { + std::cout<<"Size 1 + Size 2\n"; + Ranges< Uint32_Index > input(ll_upper(0x3fff0000, 0x7fff0000) ^ 0x40000000, + (ll_upper(0x40010000, 0x10000) ^ 0x40000000) + 1); + cout_ranges(calc_parents(input)); + } + std::cout<<'\n'; + { + std::cout<<"Size 1 + Size 2 + Size 1\n"; + Ranges< Uint32_Index > input(ll_upper(0x3fff0000, 0x7fff0000) ^ 0x40000000, + (ll_upper(0x40000000, 0x20000) ^ 0x40000000) + 1); + cout_ranges(calc_parents(input)); + } + std::cout<<'\n'; + { + std::cout<<"Size 3 + Size 2 + Size 1\n"; + Ranges< Uint32_Index > input(ll_upper(0x3ffc0000, 0x7ffc0000) ^ 0x40000000, + (ll_upper(0x40000000, 0x20000) ^ 0x40000000) + 1); + cout_ranges(calc_parents(input)); + } + std::cout<<'\n'; + { + std::cout<<"Size 4 + Size 2 + Size 1\n"; + Ranges< Uint32_Index > input(ll_upper(0x3ff80000, 0x7ff80000) ^ 0x40000000, + (ll_upper(0x40000000, 0x20000) ^ 0x40000000) + 1); + cout_ranges(calc_parents(input)); + } + std::cout<<'\n'; + } + + return 0; +} diff --git a/src/overpass_api/dispatch/consistency_check.cc b/src/overpass_api/dispatch/consistency_check.cc new file mode 100644 index 000000000..ba1fdd8e7 --- /dev/null +++ b/src/overpass_api/dispatch/consistency_check.cc @@ -0,0 +1,301 @@ +/** Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Roland Olbricht et al. + * + * This file is part of Overpass_API. + * + * Overpass_API is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Overpass_API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Overpass_API. If not, see . + */ + +#include "../../expat/expat_justparse_interface.h" +#include "../../template_db/dispatcher.h" +#include "../frontend/console_output.h" +#include "../frontend/user_interface.h" +#include "../statements/statement.h" +#include "resource_manager.h" +#include "scripting_core.h" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + + +template< class TIndex, class Id_Type > +struct Flat_Meta_Collector +{ + public: + Flat_Meta_Collector(Transaction& transaction, const File_Properties* meta_file_prop = 0); + + void reset(); + const OSM_Element_Metadata_Skeleton< Id_Type >* get(const TIndex& index, Id_Type ref); + + ~Flat_Meta_Collector() + { + if (meta_db) + { + delete db_it; + delete meta_db; + } + } + + private: + Block_Backend< TIndex, OSM_Element_Metadata_Skeleton< Id_Type > >* meta_db; + typename Block_Backend< TIndex, OSM_Element_Metadata_Skeleton< Id_Type > >::Flat_Iterator* + db_it; + TIndex* current_index; + std::map< OSM_Element_Metadata_Skeleton< Id_Type >, bool > current_objects; +}; + +/** Implementation --------------------------------------------------------- */ + +template< class TIndex, class Id_Type > +Flat_Meta_Collector< TIndex, Id_Type >::Flat_Meta_Collector + (Transaction& transaction, const File_Properties* meta_file_prop) + : meta_db(0), db_it(0), current_index(0) +{ + meta_db = new Block_Backend< TIndex, OSM_Element_Metadata_Skeleton< Id_Type > > + (transaction.data_index(meta_file_prop)); + + reset(); +} + +template< class TIndex, class Id_Type > +void Flat_Meta_Collector< TIndex, Id_Type >::reset() +{ + if (!meta_db) + return; + + if (db_it) + delete db_it; + if (current_index) + { + delete current_index; + current_index = 0; + } + + db_it = new typename Block_Backend< TIndex, OSM_Element_Metadata_Skeleton< Id_Type > > + ::Flat_Iterator(meta_db->flat_begin()); + + if (!(*db_it == meta_db->flat_end())) + current_index = new TIndex(db_it->index()); + while (!(*db_it == meta_db->flat_end()) && (*current_index == db_it->index())) + { + current_objects.insert(std::make_pair(db_it->object(), false)); + ++(*db_it); + } +} + +template< class TIndex, class Id_Type > +const OSM_Element_Metadata_Skeleton< Id_Type >* Flat_Meta_Collector< TIndex, Id_Type >::get + (const TIndex& index, Id_Type ref) +{ + if (!meta_db) + return 0; + + if ((current_index) && (*current_index < index)) + { + for (typename std::map< OSM_Element_Metadata_Skeleton< Id_Type >, bool >::const_iterator + it = current_objects.begin(); it != current_objects.end(); ++it) + { + if (!it->second) + std::cout<<"Skipping meta data of "<first.ref.val() + <<" at "<val()<<'\n'; + } + current_objects.clear(); + + while (!(*db_it == meta_db->flat_end()) && (db_it->index() < index)) + { + std::cout<<"Skipping meta data of "<object().ref.val() + <<" at "<index().val()<<'\n'; + ++(*db_it); + } + if (!(*db_it == meta_db->flat_end())) + *current_index = db_it->index(); + while (!(*db_it == meta_db->flat_end()) && (*current_index == db_it->index())) + { + current_objects.insert(std::make_pair(db_it->object(), false)); + ++(*db_it); + } + } + + typename std::map< OSM_Element_Metadata_Skeleton< Id_Type >, bool >::iterator it + = current_objects.find(OSM_Element_Metadata_Skeleton< Id_Type >(ref)); + it->second = true; + if (it != current_objects.end()) + return &it->first; + else + return 0; +} + +//----------------------------------------------------------------------------- + +int main(int argc, char *argv[]) +{ + // read command line arguments + std::string db_dir; + uint log_level = Error_Output::ASSISTING; + + int area_level = 0; + + int argpos = 1; + while (argpos < argc) + { + if (!(strncmp(argv[argpos], "--db-dir=", 9))) + { + db_dir = ((std::string)argv[argpos]).substr(9); + if ((db_dir.size() > 0) && (db_dir[db_dir.size()-1] != '/')) + db_dir += '/'; + } + else if (!(strcmp(argv[argpos], "--quiet"))) + log_level = Error_Output::QUIET; + else if (!(strcmp(argv[argpos], "--concise"))) + log_level = Error_Output::CONCISE; + else if (!(strcmp(argv[argpos], "--progress"))) + log_level = Error_Output::PROGRESS; + else if (!(strcmp(argv[argpos], "--verbose"))) + log_level = Error_Output::VERBOSE; + ++argpos; + } + + Error_Output* error_output(new Console_Output(log_level)); + Statement::set_error_output(error_output); + + // connect to dispatcher and get database dir + try + { + // open read transaction and log this. + Parsed_Query global_settings; + Dispatcher_Stub dispatcher( + db_dir, error_output, "-- consistency check --\n", area_level, + 24*60*60, 1024*1024*1024, global_settings); + Resource_Manager& rman = dispatcher.resource_manager(); + + // perform check + { + uint32 count = 0; + Flat_Meta_Collector< Uint32_Index, Node::Id_Type > meta_collector + (*rman.get_transaction(), meta_settings().NODES_META); + Block_Backend< Uint32_Index, Node_Skeleton > db + (rman.get_transaction()->data_index(osm_base_settings().NODES)); + for (Block_Backend< Uint32_Index, Node_Skeleton >::Flat_Iterator + it(db.flat_begin()); !(it == db.flat_end()); ++it) + { + if (++count >= 1000*1000) + { + dispatcher.ping(); + count = 0; + std::cout<<"Processed 1000000 nodes.\n"; + } + if (!meta_collector.get(it.index(), it.object().id)) + std::cout<<"Missing meta data of "<data_index(props); + std::cout<<"ways_meta address "<* index = +// dynamic_cast< Readonly_File_Blocks_Index< Uint31_Index >* >(index_base); + std::cout<<"ways_meta"; +// for (int i = 0; i < (int)index->get_void_blocks().size(); ++i) +// std::cout<<' '<get_void_blocks()[i].first<<' '<get_void_blocks()[i].second; +// std::cout<<'\n'; + Flat_Meta_Collector< Uint31_Index, Way::Id_Type > meta_collector + (*rman.get_transaction(), props); + Block_Backend< Uint31_Index, Way_Skeleton > db + (rman.get_transaction()->data_index(osm_base_settings().WAYS)); + for (Block_Backend< Uint31_Index, Way_Skeleton >::Flat_Iterator + it(db.flat_begin()); !(it == db.flat_end()); ++it) + { + if (++count >= 100*1000) + { + dispatcher.ping(); + count = 0; + std::cout<<"Processed 100000 ways.\n"; + } + if (!meta_collector.get(it.index(), it.object().id)) + std::cout<<"Missing meta data of "< meta_collector + (*rman.get_transaction(), meta_settings().RELATIONS_META); + Block_Backend< Uint31_Index, Relation_Skeleton > db + (rman.get_transaction()->data_index(osm_base_settings().RELATIONS)); + for (Block_Backend< Uint31_Index, Relation_Skeleton >::Flat_Iterator + it(db.flat_begin()); !(it == db.flat_end()); ++it) + { + if (++count >= 100*1000) + { + dispatcher.ping(); + count = 0; + std::cout<<"Processed 100000 relations.\n"; + } + if (!meta_collector.get(it.index(), it.object().id)) + std::cout<<"Missing meta data of "<runtime_error(temp.str()); + } + + return 1; + } + catch(Resource_Error e) + { + std::ostringstream temp; + if (e.timed_out) + temp<<"Query timed out in \""<runtime_error(temp.str()); + + return 2; + } + catch(Exit_Error e) + { + return 3; + } +} diff --git a/src/overpass_api/osm-backend/compare_osm_base_maps.test.cc b/src/overpass_api/osm-backend/compare_osm_base_maps.test.cc new file mode 100644 index 000000000..02c00ae7f --- /dev/null +++ b/src/overpass_api/osm-backend/compare_osm_base_maps.test.cc @@ -0,0 +1,223 @@ +/** Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Roland Olbricht et al. + * + * This file is part of Overpass_API. + * + * Overpass_API is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Overpass_API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Overpass_API. If not, see . + */ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "../../template_db/block_backend.h" +#include "../../template_db/random_file.h" +#include "../../template_db/transaction.h" +#include "../core/datatypes.h" +#include "../core/settings.h" + + +// not const - sorts its container first and clears it afterwards. +void clear_nodes_to_map(std::vector< std::pair< uint32, Uint32_Index > >& id_to_idx, + Nonsynced_Transaction& transaction) +{ + bool deviations_exist = false; + + sort(id_to_idx.begin(), id_to_idx.end()); + + Random_File< Node_Skeleton::Id_Type, Uint32_Index > random + (transaction.random_index(osm_base_settings().NODES)); + + for (std::vector< std::pair< uint32, Uint32_Index > >::const_iterator it(id_to_idx.begin()); + it != id_to_idx.end(); ++it) + { + if (!(random.get(it->first) == it->second)) + { + deviations_exist = true; + std::cout<<"Node "<first<<":\tmap = "<first).val() + <<",\tbin = "<second.val()<<'\n'; + } + } + + if (!deviations_exist) + std::cout<<"For "< > id_to_idx; + + Nonsynced_Transaction transaction(Access_Mode::readonly, false, db_dir, ""); + Block_Backend< Uint32_Index, Node_Skeleton > nodes_db + (transaction.data_index(osm_base_settings().NODES)); + for (Block_Backend< Uint32_Index, Node_Skeleton >::Flat_Iterator + it(nodes_db.flat_begin()); !(it == nodes_db.flat_end()); ++it) + { + id_to_idx.push_back(std::make_pair(it.object().id.val(), it.index())); + if (id_to_idx.size() > 16*1024*1024) + clear_nodes_to_map(id_to_idx, transaction); + } + clear_nodes_to_map(id_to_idx, transaction); +} + +// not const - sorts its container first and clears it afterwards. +void clear_ways_to_map(std::vector< std::pair< uint32, Uint31_Index > >& id_to_idx, + Nonsynced_Transaction& transaction) +{ + bool deviations_exist = false; + + sort(id_to_idx.begin(), id_to_idx.end()); + + Random_File< Way_Skeleton::Id_Type, Uint31_Index > random + (transaction.random_index(osm_base_settings().WAYS)); + + for (std::vector< std::pair< uint32, Uint31_Index > >::const_iterator it(id_to_idx.begin()); + it != id_to_idx.end(); ++it) + { + if (!(random.get(it->first) == it->second)) + { + deviations_exist = true; + std::cout<<"Way "<first<<":\tmap = "<first).val() + <<",\tbin = "<second.val()<<'\n'; + } + } + + if (!deviations_exist) + std::cout<<"For "< > id_to_idx; + + Nonsynced_Transaction transaction(Access_Mode::readonly, false, db_dir, ""); + Block_Backend< Uint31_Index, Way_Skeleton > ways_db + (transaction.data_index(osm_base_settings().WAYS)); + for (Block_Backend< Uint31_Index, Way_Skeleton >::Flat_Iterator + it(ways_db.flat_begin()); !(it == ways_db.flat_end()); ++it) + { + id_to_idx.push_back(std::make_pair(it.object().id.val(), it.index())); + if (id_to_idx.size() > 16*1024*1024) + clear_ways_to_map(id_to_idx, transaction); + } + clear_ways_to_map(id_to_idx, transaction); +} + +// not const - sorts its container first and clears it afterwards. +void clear_relations_to_map(std::vector< std::pair< uint32, Uint31_Index > >& id_to_idx, + Nonsynced_Transaction& transaction) +{ + bool deviations_exist = false; + + sort(id_to_idx.begin(), id_to_idx.end()); + + Random_File< Relation_Skeleton::Id_Type, Uint31_Index > random + (transaction.random_index(osm_base_settings().RELATIONS)); + + for (std::vector< std::pair< uint32, Uint31_Index > >::const_iterator it(id_to_idx.begin()); + it != id_to_idx.end(); ++it) + { + if (!(random.get(it->first) == it->second)) + { + deviations_exist = true; + std::cout<<"Relation "<first<<":\tmap = "<first).val() + <<",\tbin = "<second.val()<<'\n'; + } + } + + if (!deviations_exist) + std::cout<<"For "< > id_to_idx; + + Nonsynced_Transaction transaction(Access_Mode::readonly, false, db_dir, ""); + Block_Backend< Uint31_Index, Relation_Skeleton > relations_db + (transaction.data_index(osm_base_settings().RELATIONS)); + for (Block_Backend< Uint31_Index, Relation_Skeleton >::Flat_Iterator + it(relations_db.flat_begin()); !(it == relations_db.flat_end()); ++it) + { + id_to_idx.push_back(std::make_pair(it.object().id.val(), it.index())); + if (id_to_idx.size() > 16*1024*1024) + clear_relations_to_map(id_to_idx, transaction); + } + clear_relations_to_map(id_to_idx, transaction); +} + +int main(int argc, char* args[]) +{ + // read command line arguments + std::string db_dir; + + int argpos(1); + while (argpos < argc) + { + if (!(strncmp(args[argpos], "--db-dir=", 9))) + { + db_dir = ((std::string)args[argpos]).substr(9); + if ((db_dir.size() > 0) && (db_dir[db_dir.size()-1] != '/')) + db_dir += '/'; + } + ++argpos; + } + + try + { + dump_nodes(db_dir); + } + catch (File_Error e) + { + std::cerr<<"compare_osm_base_maps: File error caught: " + <. + */ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "../../template_db/block_backend.h" +#include "../../template_db/random_file.h" +#include "../../template_db/transaction.h" +#include "../core/datatypes.h" +#include "../core/settings.h" + + +struct Output_Sorter +{ + std::vector< std::string > output_per_index; + uint32 last_index; + + Output_Sorter() : last_index(0) {} + + void sort_and_output_if_index_changed(uint32 index) + { + if (index != last_index) + { + sort(output_per_index.begin(), output_per_index.end()); + for (std::vector< std::string >::const_iterator it(output_per_index.begin()); + it != output_per_index.end(); ++it) + std::cout<<*it; + output_per_index.clear(); + last_index = index; + } + } + + ~Output_Sorter() + { + sort(output_per_index.begin(), output_per_index.end()); + for (std::vector< std::string >::const_iterator it(output_per_index.begin()); + it != output_per_index.end(); ++it) + std::cout<<*it; + } +}; + +struct Output_Sorter_Kv +{ + std::vector< std::string > output_per_index; + std::pair< std::string, std::string > last_index; + + Output_Sorter_Kv() {} + + void sort_and_output_if_index_changed(const std::pair< std::string, std::string >& index) + { + if (index != last_index) + { + sort(output_per_index.begin(), output_per_index.end()); + for (std::vector< std::string >::const_iterator it(output_per_index.begin()); + it != output_per_index.end(); ++it) + std::cout<<*it; + output_per_index.clear(); + last_index = index; + } + } + + ~Output_Sorter_Kv() + { + sort(output_per_index.begin(), output_per_index.end()); + for (std::vector< std::string >::const_iterator it(output_per_index.begin()); + it != output_per_index.end(); ++it) + std::cout<<*it; + } +}; + +void dump_nodes(uint32 pattern_size, std::string db_dir) +{ + Output_Sorter output_sorter; + + Nonsynced_Transaction transaction(Access_Mode::readonly, false, db_dir, ""); + Block_Backend< Uint32_Index, Node_Skeleton > nodes_db + (transaction.data_index(osm_base_settings().NODES)); + for (Block_Backend< Uint32_Index, Node_Skeleton >::Flat_Iterator + it(nodes_db.flat_begin()); !(it == nodes_db.flat_end()); ++it) + { + output_sorter.sort_and_output_if_index_changed(it.index().val()); + std::ostringstream buf; + buf< nodes_local_db + (transaction.data_index(osm_base_settings().NODE_TAGS_LOCAL)); + for (Block_Backend< Tag_Index_Local, Uint32_Index >::Flat_Iterator + it(nodes_local_db.flat_begin()); + !(it == nodes_local_db.flat_end()); ++it) + { + output_sorter.sort_and_output_if_index_changed(it.index().index); + std::ostringstream buf; + buf< > nodes_global_db + (transaction.data_index(osm_base_settings().NODE_TAGS_GLOBAL)); + for (Block_Backend< Tag_Index_Global, Tag_Object_Global< Node_Skeleton::Id_Type > >::Flat_Iterator + it(nodes_global_db.flat_begin()); + !(it == nodes_global_db.flat_end()); ++it) + { + output_sorter.sort_and_output_if_index_changed + (std::make_pair(it.index().key, it.index().value)); + std::ostringstream buf; + buf< ways_db + (transaction.data_index(osm_base_settings().WAYS)); + for (Block_Backend< Uint31_Index, Way_Skeleton >::Flat_Iterator + it(ways_db.flat_begin()); !(it == ways_db.flat_end()); ++it) + { + output_sorter.sort_and_output_if_index_changed(it.index().val()); + std::ostringstream buf; + buf< ways_local_db + (transaction.data_index(osm_base_settings().WAY_TAGS_LOCAL)); + for (Block_Backend< Tag_Index_Local, Uint32_Index >::Flat_Iterator + it(ways_local_db.flat_begin()); + !(it == ways_local_db.flat_end()); ++it) + { + output_sorter.sort_and_output_if_index_changed(it.index().index); + std::ostringstream buf; + buf< > ways_global_db + (transaction.data_index(osm_base_settings().WAY_TAGS_GLOBAL)); + for (Block_Backend< Tag_Index_Global, Tag_Object_Global< Way_Skeleton::Id_Type > >::Flat_Iterator + it(ways_global_db.flat_begin()); + !(it == ways_global_db.flat_end()); ++it) + { + output_sorter.sort_and_output_if_index_changed + (std::make_pair(it.index().key, it.index().value)); + std::ostringstream buf; + buf< roles; + Block_Backend< Uint32_Index, String_Object > roles_db + (transaction.data_index(osm_base_settings().RELATION_ROLES)); + for (Block_Backend< Uint32_Index, String_Object >::Flat_Iterator + it(roles_db.flat_begin()); !(it == roles_db.flat_end()); ++it) + roles[it.index().val()] = it.object().val(); + + Block_Backend< Uint31_Index, Relation_Skeleton > relations_db + (transaction.data_index(osm_base_settings().RELATIONS)); + for (Block_Backend< Uint31_Index, Relation_Skeleton >::Flat_Iterator + it(relations_db.flat_begin()); !(it == relations_db.flat_end()); ++it) + { + output_sorter.sort_and_output_if_index_changed(it.index().val()); + std::ostringstream buf; + buf< relations_local_db + (transaction.data_index(osm_base_settings().RELATION_TAGS_LOCAL)); + for (Block_Backend< Tag_Index_Local, Uint32_Index >::Flat_Iterator + it(relations_local_db.flat_begin()); + !(it == relations_local_db.flat_end()); ++it) + { + output_sorter.sort_and_output_if_index_changed(it.index().index); + std::ostringstream buf; + buf< > relations_global_db + (transaction.data_index(osm_base_settings().RELATION_TAGS_GLOBAL)); + for (Block_Backend< Tag_Index_Global, Tag_Object_Global< Relation_Skeleton::Id_Type > >::Flat_Iterator + it(relations_global_db.flat_begin()); + !(it == relations_global_db.flat_end()); ++it) + { + output_sorter.sort_and_output_if_index_changed + (std::make_pair(it.index().key, it.index().value)); + std::ostringstream buf; + buf<. + */ + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "../../template_db/random_file.h" +#include "../../expat/expat_justparse_interface.h" +#include "../core/settings.h" +#include "../frontend/output.h" +#include "node_updater.h" +#include "relation_updater.h" +#include "way_updater.h" + + +uint32 osm_element_count; + +struct Ofstream_Collection +{ + std::vector< std::ofstream* > streams; + std::string prefix; + std::string postfix; + + Ofstream_Collection(std::string prefix_, std::string postfix_) + : prefix(prefix_), postfix(postfix_) {} + + std::ofstream* get(uint32 i) + { + while (streams.size() <= i) + { + std::ostringstream buf(""); + buf<::iterator it(streams.begin()); + it != streams.end(); ++it) + { + (*it)->close(); + delete (*it); + } + } +}; + +void dump_nodes(Transaction& transaction, const std::string& db_dir, uint64 divisor, bool attic) +{ + Ofstream_Collection node_db_out(db_dir + "after_node_", "_db.csv"); + Ofstream_Collection node_tags_local_out(db_dir + "after_node_tags_", "_local.csv"); + Ofstream_Collection node_tags_global_out(db_dir + "after_node_tags_", "_global.csv"); + + Block_Backend< Uint32_Index, Node_Skeleton > nodes_db + (transaction.data_index(osm_base_settings().NODES)); + for (Block_Backend< Uint32_Index, Node_Skeleton >::Flat_Iterator + it(nodes_db.flat_begin()); !(it == nodes_db.flat_end()); ++it) + { + std::ofstream* out(node_db_out.get(it.object().id.val() / divisor)); + (*out)< nodes_local_db + (transaction.data_index(osm_base_settings().NODE_TAGS_LOCAL)); + for (Block_Backend< Tag_Index_Local, Node_Skeleton::Id_Type >::Flat_Iterator + it(nodes_local_db.flat_begin()); + !(it == nodes_local_db.flat_end()); ++it) + { + std::ofstream* out(node_tags_local_out.get(it.object().val() / divisor)); + (*out)< > nodes_global_db + (transaction.data_index(osm_base_settings().NODE_TAGS_GLOBAL)); + for (Block_Backend< Tag_Index_Global, Tag_Object_Global< Node_Skeleton::Id_Type > >::Flat_Iterator + it(nodes_global_db.flat_begin()); + !(it == nodes_global_db.flat_end()); ++it) + { + std::ofstream* out(node_tags_global_out.get(it.object().id.val() / divisor)); + (*out)< > nodes_meta_db + (transaction.data_index(meta_settings().NODES_META)); + for (Block_Backend< Uint31_Index, OSM_Element_Metadata_Skeleton< Node_Skeleton::Id_Type > >::Flat_Iterator + it(nodes_meta_db.flat_begin()); !(it == nodes_meta_db.flat_end()); ++it) + { + std::ofstream* out(node_meta_db_out.get(it.object().ref.val() / divisor)); + (*out)<>26)<<' ' + <<((it.object().timestamp & 0x3c00000)>>22)<<' ' + <<((it.object().timestamp & 0x3e0000)>>17)<<' ' + <<((it.object().timestamp & 0x1f000)>>12)<<' ' + <<((it.object().timestamp & 0xfc0)>>6)<<' ' + <<(it.object().timestamp & 0x3f)<<'\t' + < > nodes_db + (transaction.data_index(attic_settings().NODES)); + for (Block_Backend< Uint31_Index, Attic< Node_Skeleton > >::Flat_Iterator + it(nodes_db.flat_begin()); !(it == nodes_db.flat_end()); ++it) + { + std::ofstream* out(node_attic_db_out.get(it.object().id.val() / divisor)); + (*out)<>26)<<' ' + <<((it.object().timestamp & 0x3c00000)>>22)<<' ' + <<((it.object().timestamp & 0x3e0000)>>17)<<' ' + <<((it.object().timestamp & 0x1f000)>>12)<<' ' + <<((it.object().timestamp & 0xfc0)>>6)<<' ' + <<(it.object().timestamp & 0x3f)<<'\t' + < > nodes_undeleted_db + (transaction.data_index(attic_settings().NODES_UNDELETED)); + for (Block_Backend< Uint31_Index, Attic< Node_Skeleton::Id_Type > >::Flat_Iterator + it(nodes_undeleted_db.flat_begin()); !(it == nodes_undeleted_db.flat_end()); ++it) + { + std::ofstream* out(node_undeleted_db_out.get(it.object().val() / divisor)); + (*out)<>26)<<' ' + <<((it.object().timestamp & 0x3c00000)>>22)<<' ' + <<((it.object().timestamp & 0x3e0000)>>17)<<' ' + <<((it.object().timestamp & 0x1f000)>>12)<<' ' + <<((it.object().timestamp & 0xfc0)>>6)<<' ' + <<(it.object().timestamp & 0x3f)<<'\t' + < idx_db + (transaction.data_index(attic_settings().NODE_IDX_LIST)); + for (Block_Backend< Node::Id_Type, Uint31_Index >::Flat_Iterator + it(idx_db.flat_begin()); !(it == idx_db.flat_end()); ++it) + { + std::ofstream* out(node_idx_list_out.get(it.index().val() / divisor)); + (*out)< > nodes_attic_meta_db + (transaction.data_index(attic_settings().NODES_META)); + for (Block_Backend< Uint31_Index, OSM_Element_Metadata_Skeleton< Node_Skeleton::Id_Type > >::Flat_Iterator + it(nodes_attic_meta_db.flat_begin()); !(it == nodes_attic_meta_db.flat_end()); ++it) + { + std::ofstream* out(node_attic_meta_db_out.get(it.object().ref.val() / divisor)); + (*out)<>26)<<' ' + <<((it.object().timestamp & 0x3c00000)>>22)<<' ' + <<((it.object().timestamp & 0x3e0000)>>17)<<' ' + <<((it.object().timestamp & 0x1f000)>>12)<<' ' + <<((it.object().timestamp & 0xfc0)>>6)<<' ' + <<(it.object().timestamp & 0x3f)<<'\t' + < > nodes_local_db + (transaction.data_index(attic_settings().NODE_TAGS_LOCAL)); + for (Block_Backend< Tag_Index_Local, Attic< Node_Skeleton::Id_Type > >::Flat_Iterator + it(nodes_local_db.flat_begin()); + !(it == nodes_local_db.flat_end()); ++it) + { + std::ofstream* out(node_attic_tags_local_out.get(it.object().val() / divisor)); + (*out)<>26)<<' ' + <<((it.object().timestamp & 0x3c00000)>>22)<<' ' + <<((it.object().timestamp & 0x3e0000)>>17)<<' ' + <<((it.object().timestamp & 0x1f000)>>12)<<' ' + <<((it.object().timestamp & 0xfc0)>>6)<<' ' + <<(it.object().timestamp & 0x3f)<<'\n'; + } + + Block_Backend< Tag_Index_Global, Attic< Tag_Object_Global< Node_Skeleton::Id_Type > > > nodes_global_db + (transaction.data_index(attic_settings().NODE_TAGS_GLOBAL)); + for (Block_Backend< Tag_Index_Global, Attic< Tag_Object_Global< Node_Skeleton::Id_Type > > >::Flat_Iterator + it(nodes_global_db.flat_begin()); + !(it == nodes_global_db.flat_end()); ++it) + { + std::ofstream* out(node_attic_tags_global_out.get(it.object().id.val() / divisor)); + (*out)<>26)<<' ' + <<((it.object().timestamp & 0x3c00000)>>22)<<' ' + <<((it.object().timestamp & 0x3e0000)>>17)<<' ' + <<((it.object().timestamp & 0x1f000)>>12)<<' ' + <<((it.object().timestamp & 0xfc0)>>6)<<' ' + <<(it.object().timestamp & 0x3f)<<'\n'; + } + } +} + +void check_nodes(Transaction& transaction) +{ + uint element_count = 0; + std::ofstream out("/dev/null"); + + Block_Backend< Uint32_Index, Node_Skeleton > nodes_db + (transaction.data_index(osm_base_settings().NODES)); + for (Block_Backend< Uint32_Index, Node_Skeleton >::Flat_Iterator + it(nodes_db.flat_begin()); !(it == nodes_db.flat_end()); ++it) + { + out< nodes_local_db + (transaction.data_index(osm_base_settings().NODE_TAGS_LOCAL)); + for (Block_Backend< Tag_Index_Local, Uint32_Index >::Flat_Iterator + it(nodes_local_db.flat_begin()); + !(it == nodes_local_db.flat_end()); ++it) + { + out< > nodes_global_db + (transaction.data_index(osm_base_settings().NODE_TAGS_GLOBAL)); + for (Block_Backend< Tag_Index_Global, Tag_Object_Global< Node_Skeleton::Id_Type > >::Flat_Iterator + it(nodes_global_db.flat_begin()); + !(it == nodes_global_db.flat_end()); ++it) + { + out< ways_db + (transaction.data_index(osm_base_settings().WAYS)); + for (Block_Backend< Uint31_Index, Way_Skeleton >::Flat_Iterator + it(ways_db.flat_begin()); !(it == ways_db.flat_end()); ++it) + { + std::ofstream* out(way_db_out.get(it.object().id.val() / divisor)); + (*out)< ways_local_db + (transaction.data_index(osm_base_settings().WAY_TAGS_LOCAL)); + for (Block_Backend< Tag_Index_Local, Uint32_Index >::Flat_Iterator + it(ways_local_db.flat_begin()); + !(it == ways_local_db.flat_end()); ++it) + { + std::ofstream* out(way_tags_local_out.get(it.object().val() / divisor)); + (*out)< > ways_global_db + (transaction.data_index(osm_base_settings().WAY_TAGS_GLOBAL)); + for (Block_Backend< Tag_Index_Global, Tag_Object_Global< Way_Skeleton::Id_Type > >::Flat_Iterator + it(ways_global_db.flat_begin()); + !(it == ways_global_db.flat_end()); ++it) + { + std::ofstream* out(way_tags_global_out.get(it.object().id.val() / divisor)); + (*out)< > ways_meta_db + (transaction.data_index(meta_settings().WAYS_META)); + for (Block_Backend< Uint31_Index, OSM_Element_Metadata_Skeleton< Way_Skeleton::Id_Type > >::Flat_Iterator + it(ways_meta_db.flat_begin()); !(it == ways_meta_db.flat_end()); ++it) + { + std::ofstream* out(way_meta_db_out.get(it.object().ref.val() / divisor)); + (*out)<>26)<<' ' + <<((it.object().timestamp & 0x3c00000)>>22)<<' ' + <<((it.object().timestamp & 0x3e0000)>>17)<<' ' + <<((it.object().timestamp & 0x1f000)>>12)<<' ' + <<((it.object().timestamp & 0xfc0)>>6)<<' ' + <<(it.object().timestamp & 0x3f)<<'\t' + < > ways_db + (transaction.data_index(attic_settings().WAYS)); + for (Block_Backend< Uint31_Index, Attic< Way_Delta > >::Flat_Iterator + it(ways_db.flat_begin()); !(it == ways_db.flat_end()); ++it) + { + std::ofstream* out(way_attic_db_out.get(it.object().id.val() / divisor)); + (*out)<>26)<<' ' + <<((it.object().timestamp & 0x3c00000)>>22)<<' ' + <<((it.object().timestamp & 0x3e0000)>>17)<<' ' + <<((it.object().timestamp & 0x1f000)>>12)<<' ' + <<((it.object().timestamp & 0xfc0)>>6)<<' ' + <<(it.object().timestamp & 0x3f)<<'\t' + < > ways_undeleted_db + (transaction.data_index(attic_settings().WAYS_UNDELETED)); + for (Block_Backend< Uint31_Index, Attic< Way_Skeleton::Id_Type > >::Flat_Iterator + it(ways_undeleted_db.flat_begin()); !(it == ways_undeleted_db.flat_end()); ++it) + { + std::ofstream* out(way_undeleted_db_out.get(it.object().val() / divisor)); + (*out)<>26)<<' ' + <<((it.object().timestamp & 0x3c00000)>>22)<<' ' + <<((it.object().timestamp & 0x3e0000)>>17)<<' ' + <<((it.object().timestamp & 0x1f000)>>12)<<' ' + <<((it.object().timestamp & 0xfc0)>>6)<<' ' + <<(it.object().timestamp & 0x3f)<<'\t' + < idx_db + (transaction.data_index(attic_settings().WAY_IDX_LIST)); + for (Block_Backend< Way::Id_Type, Uint31_Index >::Flat_Iterator + it(idx_db.flat_begin()); !(it == idx_db.flat_end()); ++it) + { + std::ofstream* out(way_idx_list_out.get(it.index().val() / divisor)); + (*out)< > ways_attic_meta_db + (transaction.data_index(attic_settings().WAYS_META)); + for (Block_Backend< Uint31_Index, OSM_Element_Metadata_Skeleton< Way_Skeleton::Id_Type > >::Flat_Iterator + it(ways_attic_meta_db.flat_begin()); !(it == ways_attic_meta_db.flat_end()); ++it) + { + std::ofstream* out(way_attic_meta_db_out.get(it.object().ref.val() / divisor)); + (*out)<>26)<<' ' + <<((it.object().timestamp & 0x3c00000)>>22)<<' ' + <<((it.object().timestamp & 0x3e0000)>>17)<<' ' + <<((it.object().timestamp & 0x1f000)>>12)<<' ' + <<((it.object().timestamp & 0xfc0)>>6)<<' ' + <<(it.object().timestamp & 0x3f)<<'\t' + < > ways_local_db + (transaction.data_index(attic_settings().WAY_TAGS_LOCAL)); + for (Block_Backend< Tag_Index_Local, Attic< Way_Skeleton::Id_Type > >::Flat_Iterator + it(ways_local_db.flat_begin()); + !(it == ways_local_db.flat_end()); ++it) + { + std::ofstream* out(way_attic_tags_local_out.get(it.object().val() / divisor)); + (*out)<>26)<<' ' + <<((it.object().timestamp & 0x3c00000)>>22)<<' ' + <<((it.object().timestamp & 0x3e0000)>>17)<<' ' + <<((it.object().timestamp & 0x1f000)>>12)<<' ' + <<((it.object().timestamp & 0xfc0)>>6)<<' ' + <<(it.object().timestamp & 0x3f)<<'\n'; + } + + Block_Backend< Tag_Index_Global, Attic< Tag_Object_Global< Way_Skeleton::Id_Type > > > ways_global_db + (transaction.data_index(attic_settings().WAY_TAGS_GLOBAL)); + for (Block_Backend< Tag_Index_Global, Attic< Tag_Object_Global< Way_Skeleton::Id_Type > > >::Flat_Iterator + it(ways_global_db.flat_begin()); + !(it == ways_global_db.flat_end()); ++it) + { + std::ofstream* out(way_attic_tags_global_out.get(it.object().id.val() / divisor)); + (*out)<>26)<<' ' + <<((it.object().timestamp & 0x3c00000)>>22)<<' ' + <<((it.object().timestamp & 0x3e0000)>>17)<<' ' + <<((it.object().timestamp & 0x1f000)>>12)<<' ' + <<((it.object().timestamp & 0xfc0)>>6)<<' ' + <<(it.object().timestamp & 0x3f)<<'\n'; + } + } +} + +void check_ways(Transaction& transaction) +{ + uint element_count = 0; + std::ofstream out("/dev/null"); + + // check update_members - compare both files for the result + Block_Backend< Uint31_Index, Way_Skeleton > ways_db + (transaction.data_index(osm_base_settings().WAYS)); + for (Block_Backend< Uint31_Index, Way_Skeleton >::Flat_Iterator + it(ways_db.flat_begin()); !(it == ways_db.flat_end()); ++it) + { + out< ways_local_db + (transaction.data_index(osm_base_settings().WAY_TAGS_LOCAL)); + for (Block_Backend< Tag_Index_Local, Uint32_Index >::Flat_Iterator + it(ways_local_db.flat_begin()); + !(it == ways_local_db.flat_end()); ++it) + { + out< > ways_global_db + (transaction.data_index(osm_base_settings().WAY_TAGS_GLOBAL)); + for (Block_Backend< Tag_Index_Global, Tag_Object_Global< Way_Skeleton::Id_Type > >::Flat_Iterator + it(ways_global_db.flat_begin()); + !(it == ways_global_db.flat_end()); ++it) + { + out< roles; + Block_Backend< Uint32_Index, String_Object > roles_db + (transaction.data_index(osm_base_settings().RELATION_ROLES)); + for (Block_Backend< Uint32_Index, String_Object >::Flat_Iterator + it(roles_db.flat_begin()); !(it == roles_db.flat_end()); ++it) + roles[it.index().val()] = it.object().val(); + + // check update_members - compare both files for the result + Block_Backend< Uint31_Index, Relation_Skeleton > relations_db + (transaction.data_index(osm_base_settings().RELATIONS)); + for (Block_Backend< Uint31_Index, Relation_Skeleton >::Flat_Iterator + it(relations_db.flat_begin()); !(it == relations_db.flat_end()); ++it) + { + std::ofstream* out(relation_db_out.get(it.object().id.val() / divisor)); + (*out)< relations_local_db + (transaction.data_index(osm_base_settings().RELATION_TAGS_LOCAL)); + for (Block_Backend< Tag_Index_Local, Uint32_Index >::Flat_Iterator + it(relations_local_db.flat_begin()); + !(it == relations_local_db.flat_end()); ++it) + { + std::ofstream* out(relation_tags_local_out.get(it.object().val() / divisor)); + (*out)< > relations_global_db + (transaction.data_index(osm_base_settings().RELATION_TAGS_GLOBAL)); + for (Block_Backend< Tag_Index_Global, Tag_Object_Global< Relation_Skeleton::Id_Type > >::Flat_Iterator + it(relations_global_db.flat_begin()); + !(it == relations_global_db.flat_end()); ++it) + { + std::ofstream* out(relation_tags_global_out.get(it.object().id.val() / divisor)); + (*out)< roles; + Block_Backend< Uint32_Index, String_Object > roles_db + (transaction.data_index(osm_base_settings().RELATION_ROLES)); + for (Block_Backend< Uint32_Index, String_Object >::Flat_Iterator + it(roles_db.flat_begin()); !(it == roles_db.flat_end()); ++it) + roles[it.index().val()] = it.object().val(); + + // check update_members - compare both files for the result + Block_Backend< Uint31_Index, Relation_Skeleton > relations_db + (transaction.data_index(osm_base_settings().RELATIONS)); + for (Block_Backend< Uint31_Index, Relation_Skeleton >::Flat_Iterator + it(relations_db.flat_begin()); !(it == relations_db.flat_end()); ++it) + { + out< relations_local_db + (transaction.data_index(osm_base_settings().RELATION_TAGS_LOCAL)); + for (Block_Backend< Tag_Index_Local, Uint32_Index >::Flat_Iterator + it(relations_local_db.flat_begin()); + !(it == relations_local_db.flat_end()); ++it) + { + out< > relations_global_db + (transaction.data_index(osm_base_settings().RELATION_TAGS_GLOBAL)); + for (Block_Backend< Tag_Index_Global, Tag_Object_Global< Relation_Skeleton::Id_Type > >::Flat_Iterator + it(relations_global_db.flat_begin()); + !(it == relations_global_db.flat_end()); ++it) + { + out<. + */ + +#include +#include +#include +#include +#include +#include + + +typedef unsigned int uint; +typedef unsigned long long uint64; + +template < typename T > +struct V : public std::vector< T > +{ + V(const T& t) : std::vector< T >(1, t) {} + V& operator()(const T& t) + { + this->push_back(t); + return *this; + } +}; + +struct Data_Modifier +{ + virtual ~Data_Modifier() {} + + virtual bool admit_node(uint id) const = 0; + virtual bool admit_node_skeleton(uint id) const = 0; + virtual bool admit_node_tags(uint id) const = 0; + virtual bool admit_way(uint id) const = 0; + virtual bool admit_way_skeleton(uint id) const = 0; + virtual bool admit_way_tags(uint id) const = 0; + virtual bool admit_relation(uint id) const = 0; + virtual bool admit_relation_skeleton(uint id) const = 0; + virtual bool admit_relation_tags(uint id) const = 0; +}; + +struct Accept_All_Tags : public Data_Modifier +{ + virtual bool admit_node_skeleton(uint id) const { return true; } + virtual bool admit_node_tags(uint id) const { return true; } + virtual bool admit_way_skeleton(uint id) const { return true; } + virtual bool admit_way_tags(uint id) const { return true; } + virtual bool admit_relation_skeleton(uint id) const { return true; } + virtual bool admit_relation_tags(uint id) const { return true; } +}; + +struct Accept_All : public Accept_All_Tags +{ + virtual bool admit_node(uint id) const { return true; } + virtual bool admit_node_skeleton(uint id) const { return true; } + virtual bool admit_node_tags(uint id) const { return true; } + virtual bool admit_way(uint id) const { return true; } + virtual bool admit_way_skeleton(uint id) const { return true; } + virtual bool admit_way_tags(uint id) const { return true; } + virtual bool admit_relation(uint id) const { return true; } + virtual bool admit_relation_skeleton(uint id) const { return true; } + virtual bool admit_relation_tags(uint id) const { return true; } +}; + +struct Accept_Print_1 : public Accept_All_Tags +{ + virtual bool admit_node(uint id) const { return (id % 10000 == 0); } + virtual bool admit_way(uint id) const { return (id % 1000 == 0); } + virtual bool admit_relation(uint id) const { return (id % 4 == 0); } +}; + +struct Accept_Print_2 : public Data_Modifier +{ + virtual bool admit_node(uint id) const { return (id % 10000 == 0); } + virtual bool admit_node_skeleton(uint id) const { return true; } + virtual bool admit_node_tags(uint id) const { return false; } + virtual bool admit_way(uint id) const { return (id % 1000 == 0); } + virtual bool admit_way_skeleton(uint id) const { return true; } + virtual bool admit_way_tags(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return (id % 4 == 0); } + virtual bool admit_relation_skeleton(uint id) const { return true; } + virtual bool admit_relation_tags(uint id) const { return false; } +}; + +struct Accept_Print_3 : public Data_Modifier +{ + virtual bool admit_node(uint id) const { return (id % 10000 == 0); } + virtual bool admit_node_skeleton(uint id) const { return false; } + virtual bool admit_node_tags(uint id) const { return false; } + virtual bool admit_way(uint id) const { return (id % 1000 == 0); } + virtual bool admit_way_skeleton(uint id) const { return false; } + virtual bool admit_way_tags(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return (id % 4 == 0); } + virtual bool admit_relation_skeleton(uint id) const { return false; } + virtual bool admit_relation_tags(uint id) const { return false; } +}; + +struct Accept_Recurse_1 : public Accept_All_Tags +{ + Accept_Recurse_1(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const + { return ((id > pattern_size) && (id <= pattern_size*3/2+1)); } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Recurse_2 : public Accept_All_Tags +{ + Accept_Recurse_2(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const + { return ((id % pattern_size == pattern_size/2+1) + && (id < 2*pattern_size*pattern_size)); } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Recurse_3 : public Accept_All_Tags +{ + Accept_Recurse_3(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Recurse_4 : public Accept_All_Tags +{ + Accept_Recurse_4(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const + { return (id == pattern_size*pattern_size - pattern_size/2); } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Recurse_5 : public Accept_All_Tags +{ + Accept_Recurse_5(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const + { return (id <= pattern_size*(pattern_size/2-1)); } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Recurse_6 : public Accept_All_Tags +{ + Accept_Recurse_6(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const + { return ((id == 1) || (id == 2) + || (id == pattern_size+1) || (id == pattern_size+2) + || (id == pattern_size*pattern_size)); } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Recurse_7 : public Accept_All_Tags +{ + Accept_Recurse_7(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const + { return ((id == 2) || (id == 8) || (id == 10) || (id == 11)); } +}; + +struct Accept_Recurse_8 : public Accept_All_Tags +{ + Accept_Recurse_8(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const + { return ((id == 1) || (id == 2) + || (id == pattern_size/2*(pattern_size/2-1) + 1) + || (id == pattern_size/2*(pattern_size/2+1) + 1)); } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Recurse_9 : public Accept_All_Tags +{ + Accept_Recurse_9(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const + { return ((id == 6) || (id == 8) || (id == 10)); } +}; + +struct Accept_Recurse_10 : public Accept_All_Tags +{ + Accept_Recurse_10(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const + { return ((id == 1) || (id == 2)); } +}; + +struct Accept_Recurse_11 : public Accept_All_Tags +{ + Accept_Recurse_11(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const + { return ((id == 9) || (id == 10)); } +}; + +struct Accept_Recurse_12 : public Accept_All_Tags +{ + Accept_Recurse_12(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const + { + return (id == 1 || id == pattern_size + 2); + } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Recurse_13 : public Accept_All_Tags +{ + Accept_Recurse_13(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const + { + return (id == 2 + || id == pattern_size + 1 || id == pattern_size + 2 || id == pattern_size + 3 + || id == 2*pattern_size + 4 || id == 3*pattern_size + 4); + } + virtual bool admit_way(uint id) const + { + return (id == 1 || id == 2 + || id == pattern_size*pattern_size/4 - pattern_size/2 + 1 + || id == pattern_size*pattern_size/4 + pattern_size/2 + 1); + } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Recurse_14 : public Accept_All_Tags +{ + Accept_Recurse_14(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const + { + return (id == 1 || id == 2 || id == pattern_size + || id == pattern_size + 1 || id == pattern_size + 2 || id == pattern_size + 3 + || id == 2*pattern_size + 4 || id == 3*pattern_size + 4 + || id == pattern_size*pattern_size/4 + || id == pattern_size*pattern_size - pattern_size + || id == pattern_size*pattern_size); + } + virtual bool admit_way(uint id) const + { + return (id == 1 || id == 2 + || id == pattern_size*pattern_size/4 - pattern_size/2 + 1 + || id == pattern_size*pattern_size/4 + pattern_size/2 + 1); + } + virtual bool admit_relation(uint id) const + { + return ((id >= 1 && id <= 6) || id == 9); + } + +private: + uint pattern_size; +}; + +struct Accept_Recurse_15 : public Accept_All_Tags +{ + Accept_Recurse_15(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const + { + return (id == 1 || id == 2 + || id == pattern_size + 1 || id == pattern_size + 2 || id == pattern_size + 3 + || id == 2*pattern_size + 4 || id == 3*pattern_size + 4); + } + virtual bool admit_way(uint id) const + { + return (id == 1 || id == 2 + || id == pattern_size*pattern_size/4 - pattern_size/2 + 1 + || id == pattern_size*pattern_size/4 + pattern_size/2 + 1); + } + virtual bool admit_relation(uint id) const + { + return (id == 1 || id == 2 || id == 10); + } + +private: + uint pattern_size; +}; + +struct Accept_Recurse_16 : public Accept_All_Tags +{ + Accept_Recurse_16(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const + { + return (id == 1 || id == 2 + || id == pattern_size*pattern_size/4 - pattern_size/2 + 1 + || id == pattern_size*pattern_size/4); + } + virtual bool admit_relation(uint id) const + { + return (id == 1 || id == 2 || id == 6 || id == 8 || id == 10 || id == 11); + } + +private: + uint pattern_size; +}; + +struct Accept_Recurse_17 : public Accept_All_Tags +{ + Accept_Recurse_17(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const + { + return (id == 6 || id == 8 || id == 10); + } +}; + +struct Accept_Recurse_18 : public Accept_All_Tags +{ + Accept_Recurse_18(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const + { + return (id == pattern_size*pattern_size/4 - pattern_size/2 + 1); + } + virtual bool admit_relation(uint id) const + { + return (id == 2 || id == 6 || id == 8 || id == 9 || id == 10 || id == 11); + } + +private: + uint pattern_size; +}; + +struct Accept_Recurse_19 : public Accept_All_Tags +{ + Accept_Recurse_19(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const + { + return (id == 6 || id == 8 || id == 9 || id == 10); + } +}; + +struct Accept_Recurse_20 : public Accept_All_Tags +{ + Accept_Recurse_20(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const + { + return (id == 1 || id == 9 || id == 10); + } +}; + +struct Accept_Recurse_21 : public Accept_All_Tags +{ + Accept_Recurse_21(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const + { + return (id == pattern_size + 1 || id == pattern_size + 2); + } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Recurse_23 : public Accept_All_Tags +{ + Accept_Recurse_23(uint pattern_size_) {} + + virtual bool admit_node(uint id) const + { + return (id == 1); + } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Recurse_24 : public Accept_All_Tags +{ + Accept_Recurse_24(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const + { + return (id == 11); + } +}; + +struct Accept_Recurse_25 : public Accept_All_Tags +{ + Accept_Recurse_25(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const + { + return (id == pattern_size*(pattern_size/2-1) + 1); + } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Recurse_26 : public Accept_All_Tags +{ + Accept_Recurse_26(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const + { + return (id == 6 || id == 8 || id == 10); + } +}; + +struct Accept_Recurse_27 : public Accept_All_Tags +{ + Accept_Recurse_27(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const + { + return (id == 3); + } +}; + +struct Accept_Recurse_28 : public Accept_All_Tags +{ + Accept_Recurse_28(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const + { + return (id == 9); + } +}; + +struct Accept_Recurse_29 : public Accept_All_Tags +{ + Accept_Recurse_29(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const { return id == 2 || (pattern_size + 1 <= id && id <= pattern_size + 4); } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Recurse_30 : public Accept_All_Tags +{ + Accept_Recurse_30(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const { return id == pattern_size + 3; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Recurse_31 : public Accept_All_Tags +{ + Accept_Recurse_31(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Recurse_34 : public Accept_All_Tags +{ + Accept_Recurse_34(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const { return id == pattern_size/2 + 1 || id == pattern_size/2 + 2 + || id == pattern_size*pattern_size - pattern_size/2 + 1 || id == pattern_size*pattern_size - pattern_size/2 + 2 + || id == pattern_size*pattern_size/2 + 1 || id == pattern_size*pattern_size/2 + pattern_size + || id == pattern_size*pattern_size/2 + pattern_size + 1 || id == pattern_size*pattern_size/2 + 2*pattern_size; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Recurse_35 : public Accept_All_Tags +{ + Accept_Recurse_35(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const { return + ((pattern_size*pattern_size/2 + 2 <= id && id <= pattern_size*pattern_size/2 + 2*pattern_size - 1) + || (pattern_size < id && id < pattern_size*(pattern_size - 1) && + (id % pattern_size == pattern_size/2 + 1 || id % pattern_size == pattern_size/2 + 2))) + && id != pattern_size*pattern_size/2 + pattern_size/2 + 1 + && id != pattern_size*pattern_size/2 + pattern_size/2 + 2 + && id != pattern_size*pattern_size/2 + pattern_size + && id != pattern_size*pattern_size/2 + pattern_size + 1 + && id != pattern_size*pattern_size/2 + 3*pattern_size/2 + 1 + && id != pattern_size*pattern_size/2 + 3*pattern_size/2 + 2; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Recurse_36 : public Accept_All_Tags +{ + Accept_Recurse_36(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const { return id == pattern_size*pattern_size/2 + pattern_size/2 + 1 + || id == pattern_size*pattern_size/2 + pattern_size/2 + 2 + || id == pattern_size*pattern_size/2 + 3*pattern_size/2 + 1 + || id == pattern_size*pattern_size/2 + 3*pattern_size/2 + 2; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Bbox_Query_1 : public Accept_All_Tags +{ + Accept_Bbox_Query_1(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const + { return ((id > pattern_size*pattern_size) + && (id <= pattern_size*pattern_size*6/5) + && (id % pattern_size > 0) + && (id % pattern_size <= pattern_size/5)); } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Bbox_Query_2 : public Accept_All_Tags +{ + Accept_Bbox_Query_2(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const + { return ((id > pattern_size*pattern_size) + && (id <= pattern_size*pattern_size*11/10) + && (id % pattern_size > 0) + && (id % pattern_size <= pattern_size/10)); } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Bbox_Query_3 : public Accept_All_Tags +{ + Accept_Bbox_Query_3(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const + { return ((id > pattern_size*pattern_size) + && (id <= pattern_size*pattern_size*11/10) + && ((id-1) % pattern_size >= pattern_size*9/10)); } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Bbox_Query_4 : public Accept_All_Tags +{ + Accept_Bbox_Query_4(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const + { return ((id > pattern_size*pattern_size) + && (id <= pattern_size*pattern_size*11/10) + && ((id % pattern_size > pattern_size*9/10) + || (id % pattern_size <= pattern_size/10))); } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Bbox_Query_5 : public Accept_All_Tags +{ + Accept_Bbox_Query_5(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Bbox_Query_6 : public Accept_All_Tags +{ + Accept_Bbox_Query_6(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const + { return ((id > pattern_size*pattern_size) + && (id <= pattern_size*pattern_size*11/10) + && (id % pattern_size == 1)); } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Bbox_Query_8 : public Accept_All_Tags +{ + Accept_Bbox_Query_8(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const + { return ((id > pattern_size*pattern_size) + && (id <= pattern_size*pattern_size + pattern_size) + && ((id-1) % pattern_size < pattern_size/10)); } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_1 : public Accept_All_Tags +{ + Accept_Query_1(uint pattern_size_) {} + + virtual bool admit_node(uint id) const + { return (id == 11); } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Query_2 : public Accept_All_Tags +{ + Accept_Query_2(uint pattern_size_) {} + + virtual bool admit_node(uint id) const + { return (id % 5 == 0); } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Query_3 : public Accept_All_Tags +{ + Accept_Query_3(uint pattern_size_) {} + + virtual bool admit_node(uint id) const + { return (id % 11 == 0); } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Query_4 : public Accept_All_Tags +{ + Accept_Query_4(uint pattern_size_) {} + + virtual bool admit_node(uint id) const + { return (id % 15 == 0); } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Query_5 : public Accept_All_Tags +{ + Accept_Query_5(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Query_6 : public Accept_All_Tags +{ + Accept_Query_6(uint pattern_size_) {} + + virtual bool admit_node(uint id) const + { return (id == 77); } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Query_7 : public Accept_All_Tags +{ + Accept_Query_7(uint pattern_size_) {} + + virtual bool admit_node(uint id) const + { return (id % 105 == 0); } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Query_8 : public Accept_All_Tags +{ + Accept_Query_8(uint pattern_size_) {} + + virtual bool admit_node(uint id) const + { return (id == 11); } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Query_9 : public Accept_All_Tags +{ + Accept_Query_9(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const + { return ((id > pattern_size*pattern_size) + && (id <= pattern_size*pattern_size*11/10) + && (id % pattern_size > 0) + && (id % pattern_size <= pattern_size/10) + && (id % 5 == 0)); } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_10 : public Accept_All_Tags +{ + Accept_Query_10(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const + { return ((id > pattern_size*pattern_size) + && (id <= pattern_size*pattern_size*11/10) + && (id % pattern_size > 0) + && (id % pattern_size <= pattern_size/10) + && (id % 7 == 0)); } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_11 : public Accept_All_Tags +{ + Accept_Query_11(uint pattern_size_) {} + + virtual bool admit_node(uint id) const + { return (id % 105 == 0); } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Query_12 : public Accept_All_Tags +{ + Accept_Query_12(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const + { return (id == 11); } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Query_13 : public Accept_All_Tags +{ + Accept_Query_13(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const + { return (id % 5 == 0); } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Query_14 : public Accept_All_Tags +{ + Accept_Query_14(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return (id % 11 == 0); } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Query_15 : public Accept_All_Tags +{ + Accept_Query_15(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return (id % 15 == 0); } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Query_17 : public Accept_All_Tags +{ + Accept_Query_17(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return (id == 77); } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Query_18 : public Accept_All_Tags +{ + Accept_Query_18(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return (id % 105 == 0); } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Query_19 : public Accept_All_Tags +{ + Accept_Query_19(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return (id % 105 == 0); } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Query_20 : public Accept_All_Tags +{ + Accept_Query_20(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return (id == 11); } +}; + +struct Accept_Query_21 : public Accept_All_Tags +{ + Accept_Query_21(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return (id % 4 == 1); } +}; + +struct Accept_Query_22 : public Accept_All_Tags +{ + Accept_Query_22(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return (id % 4 != 3); } +}; + +struct Accept_Query_23 : public Accept_All_Tags +{ + Accept_Query_23(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return (id % 5 == 0); } +}; + +struct Accept_Query_25 : public Accept_All_Tags +{ + Accept_Query_25(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return (id % 10 == 0); } +}; + +struct Accept_Query_28 : public Accept_All_Tags +{ + Accept_Query_28(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const + { + if (id % 5 != 0) + return false; + if (id / (2*(pattern_size/2+1)*(pattern_size/2-1) + pattern_size/2) != 1) + return false; + uint remainder = id % (2*(pattern_size/2+1)*(pattern_size/2-1) + pattern_size/2); + if (remainder <= pattern_size/2*(pattern_size/4-1)) + return false; + if (remainder <= pattern_size/2*(pattern_size/2-1)) + return true; + if (remainder <= (pattern_size/2-1)*(pattern_size/4-1) + pattern_size/2*(pattern_size/2-1)) + return false; + if (remainder <= 2*pattern_size/2*(pattern_size/2-1)) + return true; + if (remainder > pattern_size/2*(pattern_size/2-1)*2 + pattern_size/2*2-2) + return true; + return false; + } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_29 : public Accept_All_Tags +{ + Accept_Query_29(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const + { + if (id % 5 != 0) + return false; + if (id / (2*(pattern_size/2+1)*(pattern_size/2-1) + pattern_size/2) != 1) + return false; + uint remainder = id % (2*(pattern_size/2+1)*(pattern_size/2-1) + pattern_size/2); + if (remainder <= 2*pattern_size/2*(pattern_size/2-1) + pattern_size/4-1) + return false; + if (remainder <= 2*pattern_size/2*(pattern_size/2-1) + pattern_size/2-1) + return true; + if (remainder <= 2*pattern_size/2*(pattern_size/2-1) + pattern_size/2-1 + pattern_size/4-1) + return false; + if (remainder <= pattern_size/2*(pattern_size/2-1)*2 + pattern_size/2*2-2) + return true; + return false; + } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_30 : public Accept_All_Tags +{ + Accept_Query_30(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const + { + if (id == 18) + return true; + return (id == 22 && pattern_size <= 360); + } + +private: + uint pattern_size; +}; + +struct Accept_Query_31 : public Accept_All_Tags +{ + Accept_Query_31(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const + { + if (id == 14) + return true; + return (id == 22 && pattern_size <= 200); + } + +private: + uint pattern_size; +}; + +struct Accept_Query_37 : public Accept_All_Tags +{ + Accept_Query_37(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const + { + return (id == 2*(2*(pattern_size/2+1)*(pattern_size/2-1) + pattern_size/2) - pattern_size + 1 + || id == 2*(2*(pattern_size/2+1)*(pattern_size/2-1) + pattern_size/2) - 1); + } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_38 : public Accept_All_Tags +{ + Accept_Query_38(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const + { + return (id == 2*(2*(pattern_size/2+1)*(pattern_size/2-1) + pattern_size/2)); + } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_39 : public Accept_All_Tags +{ + Accept_Query_39(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const + { + return ((id >= 12 && id <= 15) || id == 17 || id == 19 || id == 21 || id == 22); + } +}; + +struct Accept_Query_40 : public Accept_All_Tags +{ + Accept_Query_40(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const + { + return (id == 18 || id == 22); + } +}; + +struct Accept_Query_41 : public Accept_All_Tags +{ + Accept_Query_41(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const + { + return (id == pattern_size*pattern_size + 1 || id == pattern_size*pattern_size + 2 + || id == pattern_size*pattern_size + pattern_size + 1 + || id == pattern_size*pattern_size + pattern_size + 2 + || id == pattern_size*pattern_size + pattern_size + 3 + || id == pattern_size*pattern_size + 2*pattern_size + 1 + || id == pattern_size*pattern_size + 2*pattern_size + 2); + } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_42 : public Accept_All_Tags +{ + Accept_Query_42(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const + { + return ((id >= 2*(pattern_size*pattern_size/2 - 2) + 1 + && id <= 2*(pattern_size*pattern_size/2 - 2) + pattern_size/2) + || id == 2*(pattern_size*pattern_size/2 - 2 + pattern_size/2) - 1 + || id == 2*(pattern_size*pattern_size/2 - 2 + pattern_size/2)); + } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_43 : public Accept_All_Tags +{ + Accept_Query_43(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const + { + return (id == pattern_size*pattern_size + pattern_size/2*pattern_size/2 - pattern_size + || id == pattern_size*pattern_size + pattern_size/2*pattern_size/2 - 1 + || id == pattern_size*pattern_size + pattern_size/2*pattern_size/2 + || id == pattern_size*pattern_size + pattern_size/2*pattern_size/2 + pattern_size); + } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_44 : public Accept_All_Tags +{ + Accept_Query_44(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const + { + return (id == pattern_size*pattern_size/2 - 2 + pattern_size/2 + 1 + || id == pattern_size*pattern_size/2 - 2 + pattern_size/2 + 2 + || id == pattern_size*pattern_size/2 - 2 + pattern_size/2 + 3 + || id == pattern_size*pattern_size/2 - 2 + 2*pattern_size/2 + 3 + || id == pattern_size*pattern_size/2 - 2 + 2*pattern_size/2 + 4 + || id == pattern_size*pattern_size/2 - 2 + 3*pattern_size/2 + 3 + || id == pattern_size*pattern_size/2 - 2 + 3*pattern_size/2 + 4 + || id == pattern_size*pattern_size/2 - 2 + pattern_size/2*(pattern_size/2) + 1 + || id == pattern_size*pattern_size/2 - 2 + pattern_size/2*(pattern_size/2) + 2 + || id == pattern_size*pattern_size/2 - 2 + pattern_size/2*(pattern_size/2+1) + || id == pattern_size*pattern_size/2 - 2 + pattern_size/2*(pattern_size/2+1) + 1 + || id == pattern_size*pattern_size/2 - 2 + pattern_size/2*(pattern_size/2+1) + 2 + || id == pattern_size*pattern_size/2 - 2 + pattern_size/2*(pattern_size/2+2) + 1 + || id == pattern_size*pattern_size/2 - 2 + pattern_size/2*(pattern_size/2+3)); + } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_45 : public Accept_All_Tags +{ + Accept_Query_45(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return (id % 21 != 14); } +}; + +struct Accept_Query_46 : public Accept_All_Tags +{ + Accept_Query_46(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return (id < 100 && id % 21 != 0); } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Query_47 : public Accept_All_Tags +{ + Accept_Query_47(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return (id % 21 != 14 && id % 21 != 0); } +}; + +struct Accept_Query_51 : public Accept_All_Tags +{ + Accept_Query_51(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const + { + return (id > pattern_size*(pattern_size/2) && id <= pattern_size*(pattern_size/2+1)); + } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_52 : public Accept_All_Tags +{ + Accept_Query_52(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const + { + return (id > pattern_size*(pattern_size/2) && id <= pattern_size*(pattern_size/2+1) + && id % 5 == 0); + } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_53 : public Accept_All_Tags +{ + Accept_Query_53(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const + { + return (id > (pattern_size+1)*(pattern_size/2) && id <= pattern_size*(pattern_size/2+1)); + } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_54 : public Accept_All_Tags +{ + Accept_Query_54(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const + { + return (id > (pattern_size+1)*(pattern_size/2) && id <= pattern_size*(pattern_size/2+1) + && id % 5 == 0); + } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_55 : public Accept_All_Tags +{ + Accept_Query_55(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const + { + return (id == pattern_size*(pattern_size/2+1) - 1); + } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_56 : public Accept_All_Tags +{ + Accept_Query_56(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const + { + return (id <= pattern_size*pattern_size && id <= 32767); + } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_57 : public Accept_All_Tags +{ + Accept_Query_57(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const + { + return (id <= pattern_size*pattern_size && id <= 32767 && id % 5 == 0); + } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_58 : public Accept_All_Tags +{ + Accept_Query_58(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const + { + return (id > pattern_size*pattern_size/2 && id <= pattern_size*pattern_size + && (id % pattern_size > pattern_size/2 || id % pattern_size == 0) + && id <= 32767); + } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_59 : public Accept_All_Tags +{ + Accept_Query_59(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const + { + return (id > pattern_size*pattern_size/2 && id <= pattern_size*pattern_size + && (id % pattern_size > pattern_size/2 || id % pattern_size == 0) + && id <= 32767 && id % 5 == 0); + } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_60 : public Accept_All_Tags +{ + Accept_Query_60(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const + { + return (id == 1 || id == pattern_size + 2); + } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_61 : public Accept_All_Tags +{ + Accept_Query_61(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const + { + return (id == 1 || id == 2 || id == pattern_size/2*(pattern_size/2-1) + 1 + || id == pattern_size/2*(pattern_size/2-1) + pattern_size + 1); + } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_62 : public Accept_All_Tags +{ + Accept_Query_62(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const + { + return ((id == 1 || id == pattern_size/2*(pattern_size/2-1) + 1 + || id == pattern_size/2*(pattern_size/2-1) + pattern_size + 1) && id % 4 == 1); + } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_63 : public Accept_All_Tags +{ + Accept_Query_63(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const + { + return (id == 1 || id == 2 || id == pattern_size/2*(pattern_size/2-1) + 1); + } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_64 : public Accept_All_Tags +{ + Accept_Query_64(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const + { + return ((id == 1 || id == pattern_size/2*(pattern_size/2-1) + 1) && id % 4 == 1); + } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_65 : public Accept_All_Tags +{ + Accept_Query_65(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const + { + return (id == 1 || id == 2 || id == pattern_size/2*(pattern_size/2-1) + 1 + || id == pattern_size/2*(pattern_size/2-1) + pattern_size + 1); + } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_66 : public Accept_All_Tags +{ + Accept_Query_66(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const + { + return (id <= 6); + } +}; + +struct Accept_Query_67 : public Accept_All_Tags +{ + Accept_Query_67(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const + { + return (id <= 6 && id % 2 == 0); + } +}; + +struct Accept_Query_68 : public Accept_All_Tags +{ + Accept_Query_68(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const + { + return (id == 3 || id == 4); + } +}; + +struct Accept_Query_69 : public Accept_All_Tags +{ + Accept_Query_69(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const + { + return (id == 4); + } +}; + +struct Accept_Query_70 : public Accept_All_Tags +{ + Accept_Query_70(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const + { + return (id == 1 || id == 2); + } +}; + +struct Accept_Query_71 : public Accept_All_Tags +{ + Accept_Query_71(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const + { + return (id >= (pattern_size+1)*(pattern_size/2-1) - 3 + && id <= (pattern_size+1)*(pattern_size/2-1)); + } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_72 : public Accept_All_Tags +{ + Accept_Query_72(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const + { + return (id == (pattern_size+1)*(pattern_size/2-1) - 3 + || id == (pattern_size+1)*(pattern_size/2-1) - 1); + } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_73 : public Accept_All_Tags +{ + Accept_Query_73(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const + { + return (id == (pattern_size+1)*(pattern_size/2-1) - 1 + || id == (pattern_size+1)*(pattern_size/2-1)); + } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_74 : public Accept_All_Tags +{ + Accept_Query_74(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const + { + return (id == (pattern_size+1)*(pattern_size/2-1) - 1); + } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_75 : public Accept_All_Tags +{ + Accept_Query_75(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const + { + return (id == (pattern_size+1)*(pattern_size/2-1) - 3 + || id == (pattern_size+1)*(pattern_size/2-1) - 2); + } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_76 : public Accept_All_Tags +{ + Accept_Query_76(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const + { + return (id == 1 || id == 2 || id == 4 || id == 8 || id == 10 || id == 11); + } +}; + +struct Accept_Query_77 : public Accept_All_Tags +{ + Accept_Query_77(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const + { + return (id == 2 || id == 4 || id == 8 || id == 10); + } +}; + +struct Accept_Query_78 : public Accept_All_Tags +{ + Accept_Query_78(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const + { + return (id == 4 || (id == 11 && pattern_size*pattern_size < 32768)); + } + +private: + uint pattern_size; +}; + +struct Accept_Query_79 : public Accept_All_Tags +{ + Accept_Query_79(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const + { + return (id == 4); + } +}; + +struct Accept_Query_80 : public Accept_All_Tags +{ + Accept_Query_80(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const + { + return (id == 4 || (id == 11 && pattern_size*pattern_size < 32768)); + } + +private: + uint pattern_size; +}; + +struct Accept_Query_81 : public Accept_All_Tags +{ + Accept_Query_81(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const + { + return (id == 6 || id == 8 || id == 10); + } +}; + +struct Accept_Query_82 : public Accept_All_Tags +{ + Accept_Query_82(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const + { + return (id == 10); + } +}; + +struct Accept_Query_83 : public Accept_All_Tags +{ + Accept_Query_83(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const + { + return (id == 6 || id == 8 || id == 10); + } +}; + +struct Accept_Query_84 : public Accept_All_Tags +{ + Accept_Query_84(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const + { + return (id == 10); + } +}; + +struct Accept_Query_85 : public Accept_All_Tags +{ + Accept_Query_85(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const + { + return (id == 6 || id == 8 || id == 10); + } +}; + +struct Accept_Query_86 : public Accept_All_Tags +{ + Accept_Query_86(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const + { + return (id == 9 || id == 10); + } +}; + +struct Accept_Query_87 : public Accept_All_Tags +{ + Accept_Query_87(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const + { + return (id == 10); + } +}; + +struct Accept_Query_88 : public Accept_All_Tags +{ + Accept_Query_88(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const + { + return (id == 10); + } +}; + +struct Accept_Query_89 : public Accept_All_Tags +{ + Accept_Query_89(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const + { + return (id == 10); + } +}; + +struct Accept_Query_90 : public Accept_All_Tags +{ + Accept_Query_90(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const + { + return (id == 9 || id == 10); + } +}; + +struct Accept_Query_91 : public Accept_All_Tags +{ + Accept_Query_91(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return (id <= 10); } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Query_92 : public Accept_All_Tags +{ + Accept_Query_92(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return (id == 5 || id == 10); } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Query_93 : public Accept_All_Tags +{ + Accept_Query_93(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return (id <= 5); } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Query_94 : public Accept_All_Tags +{ + Accept_Query_94(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return (id == 5); } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Query_95 : public Accept_All_Tags +{ + Accept_Query_95(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return (id == 9 || id == 10); } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Query_96 : public Accept_All_Tags +{ + Accept_Query_96(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return (id <= 10); } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Query_97 : public Accept_All_Tags +{ + Accept_Query_97(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return (id == 5 || id == 10); } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Query_98 : public Accept_All_Tags +{ + Accept_Query_98(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return (id <= 5); } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Query_99 : public Accept_All_Tags +{ + Accept_Query_99(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return (id == 5); } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Query_100 : public Accept_All_Tags +{ + Accept_Query_100(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return (id == 9 || id == 10); } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Query_101 : public Accept_All_Tags +{ + Accept_Query_101(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return (id <= 10); } +}; + +struct Accept_Query_102 : public Accept_All_Tags +{ + Accept_Query_102(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return (id == 5 || id == 10); } +}; + +struct Accept_Query_103 : public Accept_All_Tags +{ + Accept_Query_103(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return (id <= 10 && id != 5 && id != 9); } +}; + +struct Accept_Query_104 : public Accept_All_Tags +{ + Accept_Query_104(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return (id == 10); } +}; + +struct Accept_Query_105 : public Accept_All_Tags +{ + Accept_Query_105(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return (id == 9 || id == 10); } +}; + +struct Accept_Query_106 : public Accept_All_Tags +{ + Accept_Query_106(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const + { + return (id == 1 || id == 2 + || id == pattern_size + 1 || id == pattern_size + 2 || id == pattern_size + 3 + || id == 2*pattern_size + 4 || id == 3*pattern_size + 4); + } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_107 : public Accept_All_Tags +{ + Accept_Query_107(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const + { + return (id == 1 || id == 2 + || id == pattern_size*pattern_size/4 - pattern_size/2 + 1 + || id == pattern_size*pattern_size/4 + pattern_size/2 + 1); + } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_108 : public Accept_All_Tags +{ + Accept_Query_108(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Query_109 : public Accept_All_Tags +{ + Accept_Query_109(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const + { + return (id == 1 || id == 2 || id == pattern_size + || id == pattern_size + 1 || id == pattern_size + 2 || id == pattern_size + 3 + || id == 2*pattern_size + 4 || id == 3*pattern_size + 4 + || id == pattern_size*pattern_size/4 + || id == pattern_size*pattern_size - pattern_size + || id == pattern_size*pattern_size); + } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_110 : public Accept_All_Tags +{ + Accept_Query_110(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const + { + return (id == 1 || id == 2 + || id == pattern_size*pattern_size/4 - pattern_size/2 + 1 + || id == pattern_size*pattern_size/4 + pattern_size/2 + 1); + } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_111 : public Accept_All_Tags +{ + Accept_Query_111(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const + { + return ((id >= 1 && id <= 6) || id == 9); + } +}; + +struct Accept_Query_113 : public Accept_All_Tags +{ + Accept_Query_113(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const + { + return (id == pattern_size*pattern_size/4 - pattern_size/2 + 1); + } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_114 : public Accept_All_Tags +{ + Accept_Query_114(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const + { + return (id == 2 || (id >= 6 && id <= 8) || id == 10 || id == 11); + } +}; + +struct Accept_Query_117 : public Accept_All_Tags +{ + Accept_Query_117(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const + { + return (id == 2 || (id >= 6 && id <= 11)); + } +}; + +struct Accept_Query_118 : public Accept_All_Tags +{ + Accept_Query_118(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const + { + return (3*pattern_size*pattern_size < id && + id <= 3*pattern_size*pattern_size + pattern_size && + id % 35 == 0); + } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_119 : public Accept_All_Tags +{ + Accept_Query_119(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const + { + return (3*pattern_size*pattern_size < id && + id <= 3*pattern_size*pattern_size + pattern_size && + id % 7 == 0); + } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_122 : public Accept_All_Tags +{ + Accept_Query_122(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const + { + return (3*pattern_size*pattern_size < id && + id <= 3*pattern_size*pattern_size + pattern_size && + id % 7 == 0 && id % 3 != 0); + } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_124 : public Accept_All_Tags +{ + Accept_Query_124(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const + { + return (3*pattern_size*pattern_size < id && + id <= 3*pattern_size*pattern_size + pattern_size && + id % 7 == 0 && id % 11 != 0); + } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_125 : public Accept_All_Tags +{ + Accept_Query_125(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const + { + return (3*pattern_size*pattern_size < id && + id <= 3*pattern_size*pattern_size + pattern_size && + id % 7 == 0 && id % 3 == 0); + } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_139 : public Accept_All_Tags +{ + Accept_Query_139(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return (id % 11 == 0 && id >= 99 && id <= 1078); } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Query_140 : public Accept_All_Tags +{ + Accept_Query_140(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return (id % 55 == 0 && id >= 99 && id <= 1078); } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Query_141 : public Accept_All_Tags +{ + Accept_Query_141(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return (id % 22 == 0 && id >= 99 && id <= 1078); } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Query_142 : public Accept_All_Tags +{ + Accept_Query_142(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return (id % 110 == 0 && id >= 99 && id <= 1078); } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Query_143 : public Accept_All_Tags +{ + Accept_Query_143(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return (id % 11 == 0 && id % 4 != 3 && id >= 99 && id <= 1078); } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Query_144 : public Accept_All_Tags +{ + Accept_Query_144(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return (id % 55 == 0 && id % 4 != 3 && id >= 99 && id <= 1078); } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Query_145 : public Accept_All_Tags +{ + Accept_Query_145(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const + { + return (id % 11 == 0 && id >= 99 && id <= 1078 && id <= pattern_size*pattern_size/2); + } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_146 : public Accept_All_Tags +{ + Accept_Query_146(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const + { + return (id % 55 == 0 && id >= 99 && id <= 1078 && id <= pattern_size*pattern_size/2); + } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_147 : public Accept_All_Tags +{ + Accept_Query_147(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const + { + return (id % 22 == 0 && id >= 99 && id <= 1078 && + (id <= (pattern_size+1)*(pattern_size/2-1) + || (id > (pattern_size+2)*(pattern_size/2-1) && id <= (pattern_size+3)*(pattern_size/2-1)+1))); + } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_148 : public Accept_All_Tags +{ + Accept_Query_148(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const + { + return (id % 110 == 0 && id >= 99 && id <= 1078 && + (id <= (pattern_size+1)*(pattern_size/2-1) + || (id > (pattern_size+2)*(pattern_size/2-1) && id <= (pattern_size+3)*(pattern_size/2-1)+1))); + } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_149 : public Accept_All_Tags +{ + Accept_Query_149(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const + { + return (id % 11 == 0 && id % 4 != 3 && id >= 99 && id <= 1078 && + (id <= (pattern_size+1)*(pattern_size/2-1) + || (id > (pattern_size+2)*(pattern_size/2-1) && id <= (pattern_size+3)*(pattern_size/2-1)+1))); + } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_150 : public Accept_All_Tags +{ + Accept_Query_150(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const + { + return (id % 55 == 0 && id % 4 != 3 && id >= 99 && id <= 1078 && + (id <= (pattern_size+1)*(pattern_size/2-1) + || (id > (pattern_size+2)*(pattern_size/2-1) && id <= (pattern_size+3)*(pattern_size/2-1)+1))); + } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_151 : public Accept_All_Tags +{ + Accept_Query_151(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const + { + return id % 5 == 0 && pattern_size*pattern_size/4*5 < id && id < pattern_size*pattern_size/2*3 + && id % pattern_size <= pattern_size/2 && id % pattern_size > 0; + } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_153 : public Accept_All_Tags +{ + Accept_Query_153(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return id == 18 || (id == 22 && pattern_size <= 362); } + +private: + uint pattern_size; +}; + +struct Accept_Query_154 : public Accept_All_Tags +{ + Accept_Query_154(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return id % 5 == 0 && id < 100; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Query_155 : public Accept_All_Tags +{ + Accept_Query_155(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return id % 5 == 0 && id < 100; } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Query_156 : public Accept_All_Tags +{ + Accept_Query_156(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return id % 5 == 0 && id % 4 != 3; } +}; + +struct Accept_Query_157 : public Accept_All_Tags +{ + Accept_Query_157(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return id == 11; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Query_158 : public Accept_All_Tags +{ + Accept_Query_158(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return id == 11; } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Query_159 : public Accept_All_Tags +{ + Accept_Query_159(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return id == 11; } +}; + +struct Accept_Query_160 : public Accept_All_Tags +{ + Accept_Query_160(uint pattern_size_, bool node_one_, bool node_two_, + bool way_two_, bool way_three_, bool rel_zero_, bool rel_three_) + : pattern_size(pattern_size_), node_one(node_one_), node_two(node_two_), + way_two(way_two_), way_three(way_three_), rel_zero(rel_zero_), rel_three(rel_three_) {} + + virtual bool admit_node(uint id) const + { return (node_one && id == 1) || (node_two && id == 2) + || (node_one && id == pattern_size + 1) || (node_two && id == pattern_size + 2); } + virtual bool admit_way(uint id) const { return (way_three && id == 2) + || (way_two && (id == 1 + || id == pattern_size*pattern_size/4 - pattern_size/2 + 1 + || id == pattern_size*pattern_size/4 + pattern_size/2 + 1)); } + virtual bool admit_relation(uint id) const { return (rel_three && id == 1) || (rel_zero && id == 2); } + +private: + uint pattern_size; + bool node_one, node_two, way_two, way_three, rel_zero, rel_three; +}; + +struct Accept_Query_170 : public Accept_All_Tags +{ + Accept_Query_170(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return id % 15 == 0; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Query_171 : public Accept_All_Tags +{ + Accept_Query_171(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return id == 10; } + virtual bool admit_way(uint id) const { return id == 10; } + virtual bool admit_relation(uint id) const { return id == 10; } +}; + +struct Accept_Query_172 : public Accept_All_Tags +{ + Accept_Query_172(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return id == 10; } + virtual bool admit_way(uint id) const { return id == 10; } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Query_173 : public Accept_All_Tags +{ + Accept_Query_173(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return id == 10; } + virtual bool admit_relation(uint id) const { return id == 10; } +}; + +struct Accept_Query_174 : public Accept_All_Tags +{ + Accept_Query_174(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return id == 10; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return id == 10; } +}; + +struct Accept_Query_175 : public Accept_All_Tags +{ + Accept_Query_175(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const { return id == (pattern_size+1)*pattern_size/2 + 1; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_177 : public Accept_All_Tags +{ + Accept_Query_177(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const { return (id != (pattern_size+1)*pattern_size/2 + 1 && + ((pattern_size*pattern_size/2 + 2 <= id && id <= pattern_size*(pattern_size/2 + 1) - 1) + || (id % pattern_size == pattern_size/2 + 1 && pattern_size < id && id < pattern_size*(pattern_size-1)))); + } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Query_178 : public Accept_All_Tags +{ + Accept_Query_178(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const { return id == (pattern_size+1)*pattern_size/2 + 2 + || id == (pattern_size+3)*pattern_size/2 + 1; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Foreach_1 : public Accept_All_Tags +{ + Accept_Foreach_1(uint pattern_size_) + { + way_id_offset = (2*(pattern_size_/2+1)*(pattern_size_/2-1) + pattern_size_/2); + } + + virtual bool admit_node(uint id) const + { return ((id == 1) || (id == 2) || (id == 3)); } + virtual bool admit_way(uint id) const + { return ((id % way_id_offset == 1) && (id / way_id_offset <= 3) && (id != 1)); } + virtual bool admit_relation(uint id) const + { return (/*(id == 10) || */(id == 21) || (id == 32)); } + +private: + uint way_id_offset; +}; + +struct Accept_Foreach_2 : public Accept_All_Tags +{ + Accept_Foreach_2(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Union_1 : public Accept_All_Tags +{ + Accept_Union_1(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return (id == 2); } + virtual bool admit_way(uint id) const { return (id == 11); } + virtual bool admit_relation(uint id) const + { return ((id == 2) || (id == 8) || (id == 10) || (id == 11)); } +}; + +struct Accept_Union_2 : public Accept_All_Tags +{ + Accept_Union_2(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return ((id == 1) || (id == 2)); } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Union_4 : public Accept_All_Tags +{ + Accept_Union_4(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return (id == 1); } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Union_5 : public Accept_All_Tags +{ + Accept_Union_5(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return (id == 2); } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Union_6 : public Accept_All_Tags +{ + Accept_Union_6(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const + { return ((id == 2) || (id == 8) || (id == 10) || (id == 11)); } +}; + +struct Accept_Difference_1 : public Accept_All_Tags +{ + Accept_Difference_1(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Difference_2 : public Accept_All_Tags +{ + Accept_Difference_2(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return (id == 2); } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Difference_4 : public Accept_All_Tags +{ + Accept_Difference_4(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return (id == 1 || id == 4); } + virtual bool admit_relation(uint id) const { return (id == 1 || id == 4); } +}; + +struct Accept_Difference_5 : public Accept_All_Tags +{ + Accept_Difference_5(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return (id == 1 || id == 4); } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Difference_6 : public Accept_All_Tags +{ + Accept_Difference_6(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return (id == 1); } + virtual bool admit_relation(uint id) const { return false; } +}; + +struct Accept_Complete_1 : public Accept_All_Tags +{ + Accept_Complete_1(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return id == 1; } + virtual bool admit_way(uint id) const { return id == 2; } + virtual bool admit_relation(uint id) const { return id == 3; } +}; + +struct Accept_Complete_6 : public Accept_All_Tags +{ + Accept_Complete_6(uint pattern_size_, bool admit_node_4_) : admit_node_4(admit_node_4_) {} + + virtual bool admit_node(uint id) const { return id == 1 || (id == 4 && admit_node_4); } + virtual bool admit_way(uint id) const { return id == 2; } + virtual bool admit_relation(uint id) const { return id == 3; } + +private: + bool admit_node_4; +}; + +struct Accept_Complete_7 : public Accept_All_Tags +{ + Accept_Complete_7(uint pattern_size_, uint iteration_) : pattern_size(pattern_size_), iteration(iteration_) {} + + virtual bool admit_node(uint id) const { return id == 1; } + virtual bool admit_way(uint id) const + { + if (iteration == 0) + return id == 2; + + if (id <= pattern_size/2*9) + return (id % (pattern_size/2) != 0 + && id % (pattern_size/2) <= 10 + && id % (pattern_size/2) + (id/(pattern_size/2)) < iteration + 3 + && id / (pattern_size/2) < iteration); + + if (id <= (pattern_size/2)*(pattern_size/2 - 1)) + return false; + + uint delta = id - (pattern_size/2)*(pattern_size/2 - 1); + + if (delta >= (pattern_size/2 - 1)*10) + return false; + + return (delta % (pattern_size/2 - 1) != 0 + && delta % (pattern_size/2 - 1) <= 9 + && delta % (pattern_size/2 - 1) < iteration + 2 + && delta % (pattern_size/2 - 1) + (delta / (pattern_size/2 - 1)) < iteration + 3 + && delta / (pattern_size/2 - 1) < iteration + 1); + } + virtual bool admit_relation(uint id) const { return id == 3; } + +private: + uint pattern_size; + uint iteration; +}; + +struct Accept_If : public Accept_All_Tags +{ + Accept_If(uint target_way_id_) : target_way_id(target_way_id_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return id == target_way_id; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint target_way_id; +}; + +struct Accept_Polygon_1 : public Accept_All_Tags +{ + Accept_Polygon_1(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const + { + return ((id >= pattern_size*pattern_size*3 + pattern_size*5 + 8 + && id <= pattern_size*pattern_size*3 + pattern_size*5 + 10) + || (id >= pattern_size*pattern_size*3 + pattern_size*6 + 7 + && id <= pattern_size*pattern_size*3 + pattern_size*6 + 11) + || (id >= pattern_size*pattern_size*3 + pattern_size*7 + 6 + && id <= pattern_size*pattern_size*3 + pattern_size*7 + 12) + || (id >= pattern_size*pattern_size*3 + pattern_size*8 + 6 + && id <= pattern_size*pattern_size*3 + pattern_size*8 + 12) + || (id >= pattern_size*pattern_size*3 + pattern_size*9 + 6 + && id <= pattern_size*pattern_size*3 + pattern_size*9 + 12) + || (id >= pattern_size*pattern_size*3 + pattern_size*10 + 7 + && id <= pattern_size*pattern_size*3 + pattern_size*10 + 11) + || (id >= pattern_size*pattern_size*3 + pattern_size*11 + 8 + && id <= pattern_size*pattern_size*3 + pattern_size*11 + 10)); + } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Polygon_2 : public Accept_All_Tags +{ + Accept_Polygon_2(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const + { + return (id == pattern_size*pattern_size*2 + || id == pattern_size*pattern_size*4 - pattern_size + 1); + } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Polygon_3 : public Accept_All_Tags +{ + Accept_Polygon_3(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const + { + return (id % 5 == 0 && + ((id >= pattern_size*pattern_size*3 + pattern_size*5 + 8 + && id <= pattern_size*pattern_size*3 + pattern_size*5 + 10) + || (id >= pattern_size*pattern_size*3 + pattern_size*6 + 7 + && id <= pattern_size*pattern_size*3 + pattern_size*6 + 11) + || (id >= pattern_size*pattern_size*3 + pattern_size*7 + 6 + && id <= pattern_size*pattern_size*3 + pattern_size*7 + 12) + || (id >= pattern_size*pattern_size*3 + pattern_size*8 + 6 + && id <= pattern_size*pattern_size*3 + pattern_size*8 + 12) + || (id >= pattern_size*pattern_size*3 + pattern_size*9 + 6 + && id <= pattern_size*pattern_size*3 + pattern_size*9 + 12) + || (id >= pattern_size*pattern_size*3 + pattern_size*10 + 7 + && id <= pattern_size*pattern_size*3 + pattern_size*10 + 11) + || (id >= pattern_size*pattern_size*3 + pattern_size*11 + 8 + && id <= pattern_size*pattern_size*3 + pattern_size*11 + 10))); + } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Polygon_4 : public Accept_All_Tags +{ + Accept_Polygon_4(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const + { + return ((id >= pattern_size*pattern_size - pattern_size/2 - 1 + && id <= pattern_size*pattern_size - pattern_size/4 - 2) + || (id >= pattern_size*pattern_size + pattern_size/2 - 3 + && id <= pattern_size*pattern_size + pattern_size/4*3 - 3)); + } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + +struct Accept_Polygon_5 : public Accept_All_Tags +{ + Accept_Polygon_5(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const + { + return (id == 18 || id == 22); + } +}; + +struct Accept_All_But_5 : public Accept_All_Tags +{ + Accept_All_But_5(uint pattern_size_) {} + + virtual bool admit_node(uint id) const + { return (id != 5); } + virtual bool admit_way(uint id) const + { return (id != 5); } + virtual bool admit_relation(uint id) const + { return (id != 5); } +}; + +double great_circle_dist(double lat1, double lon1, double lat2, double lon2) +{ + double scalar_prod = + sin(lat1/90.0*acos(0))*sin(lat2/90.0*acos(0)) + + cos(lat1/90.0*acos(0))*sin(lon1/90.0*acos(0))*cos(lat2/90.0*acos(0))*sin(lon2/90.0*acos(0)) + + cos(lat1/90.0*acos(0))*cos(lon1/90.0*acos(0))*cos(lat2/90.0*acos(0))*cos(lon2/90.0*acos(0)); + if (scalar_prod > 1) + scalar_prod = 1; + return acos(scalar_prod)*(10*1000*1000/acos(0)); +} + +struct Accept_Around_1 : public Accept_All_Tags +{ + Accept_Around_1(uint pattern_size_, double radius_, bool northeast_ = false, uint divisor_ = 0) + : pattern_size(pattern_size_), radius(radius_), northeast(northeast_), divisor(divisor_) + { + north = 48.1; + south = 47.9; + west = -0.2; + east = 0.2; + + lat = (north - south)/pattern_size*0.5 + south; + lon = (east - west)/pattern_size*0.5 + west; + + lat_ne = (north - south)/pattern_size*(-0.5 + pattern_size) + south; + lon_ne = (east - west)/pattern_size*(-0.5 + pattern_size) + west; + } + + virtual bool admit_node(uint id) const + { + if ((id > 3*pattern_size*pattern_size) || (id <= 2*pattern_size*pattern_size)) + return false; + + if (divisor > 0) + { + if ((divisor == 11) && (id % 11 != 0)) + return false; + if ((divisor == 7) && (id % 21 != 7)) + return false; + } + + int i = (id-2*pattern_size*pattern_size-1) / pattern_size; + int j = (id-2*pattern_size*pattern_size-1) % pattern_size; + double arg_lat = (north - south)/pattern_size*(0.5 + i) + south; + double arg_lon = (east - west)/pattern_size*(0.5 + j) + west; + + if (great_circle_dist(lat, lon, arg_lat, arg_lon) <= radius) + return true; + if (!northeast) + return false; + return (great_circle_dist(lat_ne, lon_ne, arg_lat, arg_lon) <= radius); + } + + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; + double radius; + bool northeast; + uint divisor; + double lat, lon, lat_ne, lon_ne; + double north, south, west, east; +}; + + +struct Accept_Around_10 : public Accept_All_Tags +{ + Accept_Around_10(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const + { return id == 1 || id == 2 || id == 3 || id == pattern_size + 1 || id == pattern_size + 2 + || id == 2*pattern_size + 1; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + + +struct Accept_Around_11 : public Accept_All_Tags +{ + Accept_Around_11(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const + { return id == 1 || id == 2 || id == 3 || id == pattern_size + 1 || id == pattern_size + 2; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + + +struct Accept_Around_17 : public Accept_All_Tags +{ + Accept_Around_17(uint pattern_size_) : pattern_size(pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const + { return id == 1 || id == 2 || id == pattern_size/2+1 + || id == pattern_size*pattern_size/4 - pattern_size/2 + 1 + || id == pattern_size*pattern_size/4 - pattern_size/2 + 2 + || id == pattern_size*pattern_size/4; } + virtual bool admit_relation(uint id) const { return false; } + +private: + uint pattern_size; +}; + + +struct Accept_Around_18 : public Accept_All_Tags +{ + Accept_Around_18(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return false; } + virtual bool admit_relation(uint id) const + { return id <= 11 && id != 5 && id != 7 && id != 9; } +}; + + +struct Accept_Around_19 : public Accept_All_Tags +{ + Accept_Around_19(uint pattern_size_) {} + + virtual bool admit_node(uint id) const { return false; } + virtual bool admit_way(uint id) const { return id == 1; } + virtual bool admit_relation(uint id) const { return false; } +}; + + +std::vector< std::pair< std::string, std::string > > collect_tags(std::string prefix, uint id) +{ + std::vector< std::pair< std::string, std::string > > tags; + if (id < 100) + tags.push_back(std::make_pair< std::string, std::string > + (prefix + "_key", prefix + "_few")); + if (id % 11 == 0) + { + std::ostringstream buf; + buf< + (prefix + "_key_11", buf.str())); + } + if (id % 15 == 0) + tags.push_back(std::make_pair< std::string, std::string > + (prefix + "_key_15", prefix + "_value_15")); + if ((id % 2 == 0) && ((prefix == "way") || (prefix == "relation"))) + tags.push_back(std::make_pair< std::string, std::string > + (prefix + "_key_2/4", prefix + "_value_0")); + if ((id % 4 == 1) && ((prefix == "way") || (prefix == "relation"))) + tags.push_back(std::make_pair< std::string, std::string > + (prefix + "_key_2/4", prefix + "_value_1")); + if (id % 5 == 0) + tags.push_back(std::make_pair< std::string, std::string > + (prefix + "_key_5", prefix + "_value_5")); + if (id % 7 == 0) + { + std::ostringstream buf; + buf< + (prefix + "_key_7", buf.str())); + } + if (id == 2310) + tags.push_back(std::make_pair< std::string, std::string > + (prefix + "_unique", prefix + "_2310")); + return tags; +} + +void fill_bbox_with_nodes + (double south, double north, double west, double east, + uint begin_id, uint end_id, uint64 global_node_offset, + const Data_Modifier* modifier) +{ + int sqrt_ = sqrt(end_id - begin_id); + for (int i = 0; i < sqrt_; ++i) + { + for (int j = 0; j < sqrt_; ++j) + { + if (!modifier->admit_node(begin_id + i*sqrt_ + j)) + continue; + if (!modifier->admit_node_skeleton(begin_id + i*sqrt_ + j) && + !modifier->admit_node_tags(begin_id + i*sqrt_ + j)) + { + std::cout<<" \n"; + continue; + } + std::cout<<" > tags + = collect_tags("node", begin_id + i*sqrt_ + j); + if ((tags.empty()) || !modifier->admit_node_tags(begin_id + i*sqrt_ + j)) + std::cout<<"/>\n"; + else + { + std::cout<<">\n"; + for (std::vector< std::pair< std::string, std::string > >::const_iterator + it = tags.begin(); it != tags.end(); ++it) + std::cout<<" first<<"\" v=\""<second<<"\"/>\n"; + std::cout<<" \n"; + } + } + } +} + +void create_way + (uint id, uint start_node_ref, uint end_node_ref, uint stepping, uint64 global_node_offset, + const Data_Modifier* modifier) +{ + if (!modifier->admit_way(id)) + return; + if (!modifier->admit_way_skeleton(id) && !modifier->admit_way_tags(id)) + { + std::cout<<" \n"; + return; + } + std::cout<<" \n"; + if (start_node_ref < end_node_ref) + { + for (uint ref = start_node_ref; ref <= end_node_ref; ref += stepping) + std::cout<<" \n"; + } + else + { + for (uint ref = start_node_ref; (int)ref >= (int)end_node_ref; ref -= stepping) + std::cout<<" \n"; + } + if (modifier->admit_way_tags(id)) + { + std::vector< std::pair< std::string, std::string > > tags = collect_tags("way", id); + for (std::vector< std::pair< std::string, std::string > >::const_iterator + it = tags.begin(); it != tags.end(); ++it) + std::cout<<" first<<"\" v=\""<second<<"\"/>\n"; + } + std::cout<<" \n"; +} + +void create_relation + (uint id, const std::vector< uint >& refs, uint64 global_node_offset, const std::vector< uint >& types, + const Data_Modifier* modifier) +{ + if (!modifier->admit_relation(id)) + return; + if (!modifier->admit_relation_skeleton(id) && + !modifier->admit_relation_tags(id)) + { + std::cout<<" \n"; + return; + } + + std::vector< std::string > roles = V< std::string >("zero")("one")("two")("three"); + std::vector< std::string > typenames = V< std::string >("node")("way")("relation"); + + std::cout<<" \n"; + for (uint i = 0; i < refs.size(); ++i) + { + std::cout<<" \n"; + } + if (modifier->admit_relation_tags(id)) + { + std::vector< std::pair< std::string, std::string > > tags = collect_tags("relation", id); + for (std::vector< std::pair< std::string, std::string > >::const_iterator + it = tags.begin(); it != tags.end(); ++it) + std::cout<<" first<<"\" v=\""<second<<"\"/>\n"; + } + std::cout<<" \n"; +} + +void create_node_test_pattern + (double south, double north, double west, double east, uint id, uint size, uint64 global_node_offset, + const Data_Modifier* modifier) +{ + fill_bbox_with_nodes + (south, north, west, east, + id*size*size + 1, (id+1)*size*size + 1, global_node_offset, modifier); +} + +void create_way_test_pattern(uint id, uint size, uint64 global_node_offset, const Data_Modifier* modifier) +{ + uint way_id_offset = id * (2*(size/2+1)*(size/2-1) + size/2); + uint node_id_offset = id*size*size; + + // Draw a rectangular mesh of streets of length 1 segment. + for (uint i = 1; i < size/2; ++i) + for (uint j = 1; j <= size/2; ++j) + create_way(way_id_offset + (i-1)*size/2 + j, + node_id_offset + i*size + j, node_id_offset + i*size + j + 1, 1, global_node_offset, + modifier); + way_id_offset += size/2*(size/2-1); + for (uint i = 1; i <= size/2; ++i) + for (uint j = 1; j < size/2; ++j) + create_way(way_id_offset + (i-1)*(size/2-1) + j, + node_id_offset + (i-1)*size + j + 1, + node_id_offset + i*size + j + 1, size, global_node_offset, modifier); + + way_id_offset += size/2*(size/2-1); + + // Draw long straight ways from south to north. + for (uint j = size/2+1; j < size; ++j) + create_way(way_id_offset + j - size/2, + node_id_offset + j, + node_id_offset + size*(size-1) + j, size, global_node_offset, modifier); + way_id_offset += size/2-1; + // Draw long straight ways from east to west. + for (uint i = size/2+1; i < size; ++i) + create_way(way_id_offset + i - size/2, + node_id_offset + size*i, + node_id_offset + size*(i-1) + 1, 1, global_node_offset, modifier); + + way_id_offset += size/2-1; + // Draw diagonal ways from northwest to southeast + for (uint i = 0; i < size/2; ++i) + create_way(way_id_offset + i + 1, + node_id_offset + size*(i+size/2) + 1, + node_id_offset + i+size/2 + 1, (size-1)*(i+size/2), global_node_offset, modifier); +} + +void create_relation_test_pattern(uint id, uint size, uint64 global_node_offset, const Data_Modifier* modifier) +{ + uint way_id_offset = id * (2*(size/2+1)*(size/2-1) + size/2); + uint node_id_offset = id*size*size; + uint relation_id_offset = id*11; + + //create three small and two big relations based only on nodes + create_relation(relation_id_offset + 1, + V< uint >(node_id_offset + 1)(node_id_offset + size + 2), global_node_offset, + V< uint >(0)(0), modifier); + create_relation + (relation_id_offset + 2, + V< uint >(node_id_offset + 1)(node_id_offset + 2) + (node_id_offset + size + 2)(node_id_offset + size + 1)(node_id_offset + 1), global_node_offset, + V< uint >(0)(0)(0)(0)(0), modifier); + create_relation(relation_id_offset + 3, + V< uint >(node_id_offset + 1)(node_id_offset + size*size), global_node_offset, + V< uint >(0)(0), modifier); + create_relation + (relation_id_offset + 4, + V< uint >(node_id_offset + 1)(node_id_offset + size) + (node_id_offset + size*size)(node_id_offset + size*(size-1)), global_node_offset, + V< uint >(0)(0)(0)(0), modifier); + create_relation(relation_id_offset + 5, + V< uint >(node_id_offset + size/2*size/2), global_node_offset, + V< uint >(0), modifier); + + //create one small and one big relation based only on ways + create_relation + (relation_id_offset + 6, + V< uint >(way_id_offset + 1)(way_id_offset + 2) + (way_id_offset + size/2*(size/2-1) + 1)(way_id_offset + size/2*(size/2+1) + 1), global_node_offset, + V< uint >(1)(1)(1)(1), modifier); + create_relation + (relation_id_offset + 7, + V< uint >(way_id_offset + size*(size/2-1) + 1) + (way_id_offset + size*(size/2-1) + size/2) + (way_id_offset + size*(size/2-1) + size - 1), global_node_offset, + V< uint >(1)(1)(1), modifier); + + // mixed + create_relation + (relation_id_offset + 8, + V< uint >(node_id_offset + 1) + (way_id_offset + 1) + (node_id_offset + 2) + (way_id_offset + 2) + (node_id_offset + size + 2) + (way_id_offset + size/2*(size/2-1) + 1) + (node_id_offset + size + 1) + (way_id_offset + size/2*(size/2+1) + 1) + (node_id_offset + 1), global_node_offset, + V< uint >(0)(1)(0)(1)(0)(1)(0)(1)(0), modifier); + + // relations on relations + create_relation + (relation_id_offset + 9, + V< uint >(relation_id_offset + 1)(relation_id_offset + 2)(relation_id_offset + 3) + (relation_id_offset + 4)(relation_id_offset + 5)(relation_id_offset + 6), global_node_offset, + V< uint >(2)(2)(2)(2)(2)(2), modifier); + create_relation + (relation_id_offset + 10, + V< uint >(relation_id_offset + 1) + (node_id_offset + 1) + (way_id_offset + 1) + (node_id_offset + 2) + (way_id_offset + 2) + (node_id_offset + size + 2) + (way_id_offset + size/2*(size/2-1) + 1) + (node_id_offset + size + 1) + (way_id_offset + size/2*(size/2+1) + 1) + (node_id_offset + 1) + (relation_id_offset + 2), global_node_offset, + V< uint >(2)(0)(1)(0)(1)(0)(1)(0)(1)(0)(2), modifier); + + // a big relation + std::vector< uint > refs, types; + int max_num_node_members = size*size; + if (max_num_node_members > 32767) + max_num_node_members = 32767; + for (int i = 0; i < max_num_node_members; ++i) + { + refs.push_back(node_id_offset + i + 1); + types.push_back(0); + } + for (int i = 0; i < max_num_node_members; ++i) + { + refs.push_back(node_id_offset + i + 1); + types.push_back(0); + } + create_relation(relation_id_offset + 11, refs, global_node_offset, types, modifier); +} + + +std::string lat_lon_of_node(unsigned int id, unsigned int pattern_size) +{ + std::ostringstream out; + out< 1) + pattern_size = atoi(args[1]); + Data_Modifier* modifier = 0; + if (argc > 2) + { + if (std::string(args[2]) == "print_1") + modifier = new Accept_Print_1; + else if (std::string(args[2]) == "print_2") + modifier = new Accept_Print_2; + else if (std::string(args[2]) == "print_3") + modifier = new Accept_Print_3; + else if (std::string(args[2]) == "print_4") + modifier = new Accept_Print_1; //print_1 and print_4 are equal + else if (std::string(args[2]) == "recurse_1") + modifier = new Accept_Recurse_1(pattern_size); + else if (std::string(args[2]) == "recurse_2") + modifier = new Accept_Recurse_2(pattern_size); + else if (std::string(args[2]) == "recurse_3") + modifier = new Accept_Recurse_3(pattern_size); + else if (std::string(args[2]) == "recurse_4") + modifier = new Accept_Recurse_4(pattern_size); + else if (std::string(args[2]) == "recurse_5") + modifier = new Accept_Recurse_5(pattern_size); + else if (std::string(args[2]) == "recurse_6") + modifier = new Accept_Recurse_6(pattern_size); + else if (std::string(args[2]) == "recurse_7") + modifier = new Accept_Recurse_7(pattern_size); + else if (std::string(args[2]) == "recurse_8") + modifier = new Accept_Recurse_8(pattern_size); + else if (std::string(args[2]) == "recurse_9") + modifier = new Accept_Recurse_9(pattern_size); + else if (std::string(args[2]) == "recurse_10") + modifier = new Accept_Recurse_10(pattern_size); + else if (std::string(args[2]) == "recurse_11") + modifier = new Accept_Recurse_11(pattern_size); + else if (std::string(args[2]) == "recurse_12") + modifier = new Accept_Recurse_12(pattern_size); + else if (std::string(args[2]) == "recurse_13") + modifier = new Accept_Recurse_13(pattern_size); + else if (std::string(args[2]) == "recurse_14") + modifier = new Accept_Recurse_14(pattern_size); + else if (std::string(args[2]) == "recurse_15") + modifier = new Accept_Recurse_15(pattern_size); + else if (std::string(args[2]) == "recurse_16") + modifier = new Accept_Recurse_16(pattern_size); + else if (std::string(args[2]) == "recurse_17") + modifier = new Accept_Recurse_17(pattern_size); + else if (std::string(args[2]) == "recurse_18") + modifier = new Accept_Recurse_18(pattern_size); + else if (std::string(args[2]) == "recurse_19") + modifier = new Accept_Recurse_19(pattern_size); + else if (std::string(args[2]) == "recurse_20") + modifier = new Accept_Recurse_20(pattern_size); + else if (std::string(args[2]) == "recurse_21") + modifier = new Accept_Recurse_21(pattern_size); + else if (std::string(args[2]) == "recurse_22") + modifier = new Accept_Recurse_21(pattern_size); //recurse_21 and recurse_22 are equal + else if (std::string(args[2]) == "recurse_23") + modifier = new Accept_Recurse_23(pattern_size); + else if (std::string(args[2]) == "recurse_24") + modifier = new Accept_Recurse_24(pattern_size); + else if (std::string(args[2]) == "recurse_25") + modifier = new Accept_Recurse_25(pattern_size); + else if (std::string(args[2]) == "recurse_26") + modifier = new Accept_Recurse_26(pattern_size); + else if (std::string(args[2]) == "recurse_27") + modifier = new Accept_Recurse_27(pattern_size); + else if (std::string(args[2]) == "recurse_28") + modifier = new Accept_Recurse_28(pattern_size); + else if (std::string(args[2]) == "recurse_29") + modifier = new Accept_Recurse_29(pattern_size); + else if (std::string(args[2]) == "recurse_30") + modifier = new Accept_Recurse_30(pattern_size); + else if (std::string(args[2]) == "recurse_31") + modifier = new Accept_Recurse_31(pattern_size); + else if (std::string(args[2]) == "recurse_32") + modifier = new Accept_Recurse_29(pattern_size); + else if (std::string(args[2]) == "recurse_33") + modifier = new Accept_Recurse_30(pattern_size); + else if (std::string(args[2]) == "recurse_34") + modifier = new Accept_Recurse_34(pattern_size); + else if (std::string(args[2]) == "recurse_35") + modifier = new Accept_Recurse_35(pattern_size); + else if (std::string(args[2]) == "recurse_36") + modifier = new Accept_Recurse_36(pattern_size); + else if (std::string(args[2]) == "bbox_query_1") + modifier = new Accept_Bbox_Query_1(pattern_size); + else if (std::string(args[2]) == "bbox_query_2") + modifier = new Accept_Bbox_Query_2(pattern_size); + else if (std::string(args[2]) == "bbox_query_3") + modifier = new Accept_Bbox_Query_3(pattern_size); + else if (std::string(args[2]) == "bbox_query_4") + modifier = new Accept_Bbox_Query_4(pattern_size); + else if (std::string(args[2]) == "bbox_query_5") + modifier = new Accept_Bbox_Query_5(pattern_size); + else if (std::string(args[2]) == "bbox_query_6") + modifier = new Accept_Bbox_Query_6(pattern_size); + else if (std::string(args[2]) == "bbox_query_7") + // bbox-query five and bboy-query seven shall both return an empty std::set. + modifier = new Accept_Bbox_Query_5(pattern_size); + else if (std::string(args[2]) == "bbox_query_8") + modifier = new Accept_Bbox_Query_8(pattern_size); + else if (std::string(args[2]) == "query_1") + modifier = new Accept_Query_1(pattern_size); + else if (std::string(args[2]) == "query_2") + modifier = new Accept_Query_2(pattern_size); + else if (std::string(args[2]) == "query_3") + modifier = new Accept_Query_3(pattern_size); + else if (std::string(args[2]) == "query_4") + modifier = new Accept_Query_4(pattern_size); + else if (std::string(args[2]) == "query_5") + modifier = new Accept_Query_5(pattern_size); + else if (std::string(args[2]) == "query_6") + modifier = new Accept_Query_6(pattern_size); + else if (std::string(args[2]) == "query_7") + modifier = new Accept_Query_7(pattern_size); + else if (std::string(args[2]) == "query_8") + modifier = new Accept_Query_8(pattern_size); + else if (std::string(args[2]) == "query_9") + modifier = new Accept_Query_9(pattern_size); + else if (std::string(args[2]) == "query_10") + modifier = new Accept_Query_10(pattern_size); + else if (std::string(args[2]) == "query_11") + modifier = new Accept_Query_11(pattern_size); + else if (std::string(args[2]) == "query_12") + modifier = new Accept_Query_12(pattern_size); + else if (std::string(args[2]) == "query_13") + modifier = new Accept_Query_13(pattern_size); + else if (std::string(args[2]) == "query_14") + modifier = new Accept_Query_14(pattern_size); + else if (std::string(args[2]) == "query_15") + modifier = new Accept_Query_15(pattern_size); + else if (std::string(args[2]) == "query_16") + // query 16 and query 5 shall both return an empty std::set. + modifier = new Accept_Query_5(pattern_size); + else if (std::string(args[2]) == "query_17") + modifier = new Accept_Query_17(pattern_size); + else if (std::string(args[2]) == "query_18") + modifier = new Accept_Query_18(pattern_size); + else if (std::string(args[2]) == "query_19") + modifier = new Accept_Query_19(pattern_size); + else if (std::string(args[2]) == "query_20") + modifier = new Accept_Query_20(pattern_size); + else if (std::string(args[2]) == "query_21") + modifier = new Accept_Query_21(pattern_size); + else if (std::string(args[2]) == "query_22") + modifier = new Accept_Query_22(pattern_size); + else if (std::string(args[2]) == "query_23") + modifier = new Accept_Query_23(pattern_size); + else if (std::string(args[2]) == "query_24") + // query 24 and query 5 shall both return an empty std::set. + modifier = new Accept_Query_5(pattern_size); + else if (std::string(args[2]) == "query_25") + modifier = new Accept_Query_25(pattern_size); + else if (std::string(args[2]) == "query_26") + modifier = new Accept_Around_1(pattern_size, 200.1, false, 11); + else if (std::string(args[2]) == "query_27") + modifier = new Accept_Around_1(pattern_size, 200.1, false, 7); + else if (std::string(args[2]) == "query_28") + modifier = new Accept_Query_28(pattern_size); + else if (std::string(args[2]) == "query_29") + modifier = new Accept_Query_29(pattern_size); + else if (std::string(args[2]) == "query_30") + modifier = new Accept_Query_30(pattern_size); + else if (std::string(args[2]) == "query_31") + modifier = new Accept_Query_31(pattern_size); + else if (std::string(args[2]) == "query_32") + modifier = new Accept_Query_1(pattern_size); + else if (std::string(args[2]) == "query_33") + modifier = new Accept_Query_1(pattern_size); + else if (std::string(args[2]) == "query_34") + modifier = new Accept_Query_25(pattern_size); + else if (std::string(args[2]) == "query_35") + modifier = new Accept_Query_25(pattern_size); + else if (std::string(args[2]) == "query_36") + modifier = new Accept_Query_17(pattern_size); + else if (std::string(args[2]) == "query_37") + modifier = new Accept_Query_37(pattern_size); + else if (std::string(args[2]) == "query_38") + modifier = new Accept_Query_38(pattern_size); + else if (std::string(args[2]) == "query_39") + modifier = new Accept_Query_39(pattern_size); + else if (std::string(args[2]) == "query_40") + modifier = new Accept_Query_40(pattern_size); + else if (std::string(args[2]) == "query_41") + modifier = new Accept_Query_41(pattern_size); + else if (std::string(args[2]) == "query_42") + modifier = new Accept_Query_42(pattern_size); + else if (std::string(args[2]) == "query_43") + modifier = new Accept_Query_43(pattern_size); + else if (std::string(args[2]) == "query_44") + modifier = new Accept_Query_44(pattern_size); + else if (std::string(args[2]) == "query_45") + modifier = new Accept_Query_45(pattern_size); + else if (std::string(args[2]) == "query_46") + modifier = new Accept_Query_46(pattern_size); + else if (std::string(args[2]) == "query_47") + modifier = new Accept_Query_47(pattern_size); + else if (std::string(args[2]) == "query_48") + modifier = new Accept_Query_45(pattern_size); + else if (std::string(args[2]) == "query_49") + modifier = new Accept_Query_46(pattern_size); + else if (std::string(args[2]) == "query_50") + modifier = new Accept_Query_47(pattern_size); + else if (std::string(args[2]) == "query_51") + modifier = new Accept_Query_51(pattern_size); + else if (std::string(args[2]) == "query_52") + modifier = new Accept_Query_52(pattern_size); + else if (std::string(args[2]) == "query_53") + modifier = new Accept_Query_53(pattern_size); + else if (std::string(args[2]) == "query_54") + modifier = new Accept_Query_54(pattern_size); + else if (std::string(args[2]) == "query_55") + modifier = new Accept_Query_55(pattern_size); + else if (std::string(args[2]) == "query_56") + modifier = new Accept_Query_56(pattern_size); + else if (std::string(args[2]) == "query_57") + modifier = new Accept_Query_57(pattern_size); + else if (std::string(args[2]) == "query_58") + modifier = new Accept_Query_58(pattern_size); + else if (std::string(args[2]) == "query_59") + modifier = new Accept_Query_59(pattern_size); + else if (std::string(args[2]) == "query_60") + modifier = new Accept_Query_60(pattern_size); + else if (std::string(args[2]) == "query_61") + modifier = new Accept_Query_61(pattern_size); + else if (std::string(args[2]) == "query_62") + modifier = new Accept_Query_62(pattern_size); + else if (std::string(args[2]) == "query_63") + modifier = new Accept_Query_63(pattern_size); + else if (std::string(args[2]) == "query_64") + modifier = new Accept_Query_64(pattern_size); + else if (std::string(args[2]) == "query_65") + modifier = new Accept_Query_65(pattern_size); + else if (std::string(args[2]) == "query_66") + modifier = new Accept_Query_66(pattern_size); + else if (std::string(args[2]) == "query_67") + modifier = new Accept_Query_67(pattern_size); + else if (std::string(args[2]) == "query_68") + modifier = new Accept_Query_68(pattern_size); + else if (std::string(args[2]) == "query_69") + modifier = new Accept_Query_69(pattern_size); + else if (std::string(args[2]) == "query_70") + modifier = new Accept_Query_70(pattern_size); + else if (std::string(args[2]) == "query_71") + modifier = new Accept_Query_71(pattern_size); + else if (std::string(args[2]) == "query_72") + modifier = new Accept_Query_72(pattern_size); + else if (std::string(args[2]) == "query_73") + modifier = new Accept_Query_73(pattern_size); + else if (std::string(args[2]) == "query_74") + modifier = new Accept_Query_74(pattern_size); + else if (std::string(args[2]) == "query_75") + modifier = new Accept_Query_75(pattern_size); + else if (std::string(args[2]) == "query_76") + modifier = new Accept_Query_76(pattern_size); + else if (std::string(args[2]) == "query_77") + modifier = new Accept_Query_77(pattern_size); + else if (std::string(args[2]) == "query_78") + modifier = new Accept_Query_78(pattern_size); + else if (std::string(args[2]) == "query_79") + modifier = new Accept_Query_79(pattern_size); + else if (std::string(args[2]) == "query_80") + modifier = new Accept_Query_80(pattern_size); + else if (std::string(args[2]) == "query_81") + modifier = new Accept_Query_81(pattern_size); + else if (std::string(args[2]) == "query_82") + modifier = new Accept_Query_82(pattern_size); + else if (std::string(args[2]) == "query_83") + modifier = new Accept_Query_83(pattern_size); + else if (std::string(args[2]) == "query_84") + modifier = new Accept_Query_84(pattern_size); + else if (std::string(args[2]) == "query_85") + modifier = new Accept_Query_85(pattern_size); + else if (std::string(args[2]) == "query_86") + modifier = new Accept_Query_86(pattern_size); + else if (std::string(args[2]) == "query_87") + modifier = new Accept_Query_87(pattern_size); + else if (std::string(args[2]) == "query_88") + modifier = new Accept_Query_88(pattern_size); + else if (std::string(args[2]) == "query_89") + modifier = new Accept_Query_89(pattern_size); + else if (std::string(args[2]) == "query_90") + modifier = new Accept_Query_90(pattern_size); + else if (std::string(args[2]) == "query_91") + modifier = new Accept_Query_91(pattern_size); + else if (std::string(args[2]) == "query_92") + modifier = new Accept_Query_92(pattern_size); + else if (std::string(args[2]) == "query_93") + modifier = new Accept_Query_93(pattern_size); + else if (std::string(args[2]) == "query_94") + modifier = new Accept_Query_94(pattern_size); + else if (std::string(args[2]) == "query_95") + modifier = new Accept_Query_95(pattern_size); + else if (std::string(args[2]) == "query_96") + modifier = new Accept_Query_96(pattern_size); + else if (std::string(args[2]) == "query_97") + modifier = new Accept_Query_97(pattern_size); + else if (std::string(args[2]) == "query_98") + modifier = new Accept_Query_98(pattern_size); + else if (std::string(args[2]) == "query_99") + modifier = new Accept_Query_99(pattern_size); + else if (std::string(args[2]) == "query_100") + modifier = new Accept_Query_100(pattern_size); + else if (std::string(args[2]) == "query_101") + modifier = new Accept_Query_101(pattern_size); + else if (std::string(args[2]) == "query_102") + modifier = new Accept_Query_102(pattern_size); + else if (std::string(args[2]) == "query_103") + modifier = new Accept_Query_103(pattern_size); + else if (std::string(args[2]) == "query_104") + modifier = new Accept_Query_104(pattern_size); + else if (std::string(args[2]) == "query_105") + modifier = new Accept_Query_105(pattern_size); + else if (std::string(args[2]) == "query_106") + modifier = new Accept_Query_106(pattern_size); + else if (std::string(args[2]) == "query_107") + modifier = new Accept_Query_107(pattern_size); + else if (std::string(args[2]) == "query_108") + modifier = new Accept_Query_108(pattern_size); + else if (std::string(args[2]) == "query_109") + modifier = new Accept_Query_109(pattern_size); + else if (std::string(args[2]) == "query_110") + modifier = new Accept_Query_110(pattern_size); + else if (std::string(args[2]) == "query_111") + modifier = new Accept_Query_111(pattern_size); + else if (std::string(args[2]) == "query_112") + // query 112 and query 5 shall both return an empty std::set. + modifier = new Accept_Query_5(pattern_size); + else if (std::string(args[2]) == "query_113") + modifier = new Accept_Query_113(pattern_size); + else if (std::string(args[2]) == "query_114") + modifier = new Accept_Query_114(pattern_size); + else if (std::string(args[2]) == "query_115") + // query 115 and query 5 shall both return an empty std::set. + modifier = new Accept_Query_5(pattern_size); + else if (std::string(args[2]) == "query_116") + // query 116 and 113 shall return the same result + modifier = new Accept_Query_113(pattern_size); + else if (std::string(args[2]) == "query_117") + modifier = new Accept_Query_117(pattern_size); + else if (std::string(args[2]) == "query_118") + modifier = new Accept_Query_118(pattern_size); + else if (std::string(args[2]) == "query_119") + modifier = new Accept_Query_119(pattern_size); + else if (std::string(args[2]) == "query_120") + modifier = new Accept_Query_118(pattern_size); + else if (std::string(args[2]) == "query_121") + modifier = new Accept_Query_118(pattern_size); + else if (std::string(args[2]) == "query_122") + modifier = new Accept_Query_122(pattern_size); + else if (std::string(args[2]) == "query_123") + modifier = new Accept_Query_122(pattern_size); + else if (std::string(args[2]) == "query_124") + modifier = new Accept_Query_124(pattern_size); + else if (std::string(args[2]) == "query_125") + modifier = new Accept_Query_125(pattern_size); + else if (std::string(args[2]) == "query_126") + modifier = new Accept_Query_125(pattern_size); + else if (std::string(args[2]) == "query_127") + modifier = new Accept_Around_1(pattern_size, 200.1, false, 11); + else if (std::string(args[2]) == "query_128") + modifier = new Accept_Around_1(pattern_size, 200.1, false, 7); + else if (std::string(args[2]) == "query_129") + modifier = new Accept_Query_37(pattern_size); + else if (std::string(args[2]) == "query_130") + modifier = new Accept_Query_38(pattern_size); + else if (std::string(args[2]) == "query_131") + modifier = new Accept_Query_39(pattern_size); + else if (std::string(args[2]) == "query_132") + modifier = new Accept_Query_40(pattern_size); + else if (std::string(args[2]) == "query_133") + modifier = new Accept_Recurse_23(pattern_size); + else if (std::string(args[2]) == "query_134") + modifier = new Accept_Recurse_25(pattern_size); + else if (std::string(args[2]) == "query_135") + modifier = new Accept_Recurse_27(pattern_size); + else if (std::string(args[2]) == "query_136") + modifier = new Accept_Recurse_24(pattern_size); + else if (std::string(args[2]) == "query_137") + modifier = new Accept_Recurse_26(pattern_size); + else if (std::string(args[2]) == "query_138") + modifier = new Accept_Recurse_28(pattern_size); + else if (std::string(args[2]) == "query_139") + modifier = new Accept_Query_139(pattern_size); + else if (std::string(args[2]) == "query_140") + modifier = new Accept_Query_140(pattern_size); + else if (std::string(args[2]) == "query_141") + modifier = new Accept_Query_141(pattern_size); + else if (std::string(args[2]) == "query_142") + modifier = new Accept_Query_142(pattern_size); + else if (std::string(args[2]) == "query_143") + modifier = new Accept_Query_143(pattern_size); + else if (std::string(args[2]) == "query_144") + modifier = new Accept_Query_144(pattern_size); + else if (std::string(args[2]) == "query_145") + modifier = new Accept_Query_145(pattern_size); + else if (std::string(args[2]) == "query_146") + modifier = new Accept_Query_146(pattern_size); + else if (std::string(args[2]) == "query_147") + modifier = new Accept_Query_147(pattern_size); + else if (std::string(args[2]) == "query_148") + modifier = new Accept_Query_148(pattern_size); + else if (std::string(args[2]) == "query_149") + modifier = new Accept_Query_149(pattern_size); + else if (std::string(args[2]) == "query_150") + modifier = new Accept_Query_150(pattern_size); + else if (std::string(args[2]) == "query_151") + modifier = new Accept_Query_151(pattern_size); + else if (std::string(args[2]) == "query_152") + modifier = new Accept_Query_28(pattern_size); + else if (std::string(args[2]) == "query_153") + modifier = new Accept_Query_153(pattern_size); + else if (std::string(args[2]) == "query_154") + modifier = new Accept_Query_154(pattern_size); + else if (std::string(args[2]) == "query_155") + modifier = new Accept_Query_155(pattern_size); + else if (std::string(args[2]) == "query_156") + modifier = new Accept_Query_156(pattern_size); + else if (std::string(args[2]) == "query_157") + modifier = new Accept_Query_157(pattern_size); + else if (std::string(args[2]) == "query_158") + modifier = new Accept_Query_158(pattern_size); + else if (std::string(args[2]) == "query_159") + modifier = new Accept_Query_159(pattern_size); + else if (std::string(args[2]) == "query_160") + modifier = new Accept_Query_160(pattern_size, true, true, true, true, true, true); + else if (std::string(args[2]) == "query_161") + modifier = new Accept_Query_160(pattern_size, false, true, true, false, false, false); + else if (std::string(args[2]) == "query_162") + modifier = new Accept_Query_160(pattern_size, false, false, false, true, false, true); + else if (std::string(args[2]) == "query_163") + modifier = new Accept_Query_160(pattern_size, true, true, true, true, false, false); + else if (std::string(args[2]) == "query_164") + modifier = new Accept_Query_160(pattern_size, false, true, true, false, false, false); + else if (std::string(args[2]) == "query_165") + modifier = new Accept_Query_160(pattern_size, false, false, true, true, true, true); + else if (std::string(args[2]) == "query_166") + modifier = new Accept_Query_160(pattern_size, false, false, false, true, false, true); + else if (std::string(args[2]) == "query_167") + modifier = new Accept_Query_160(pattern_size, true, true, false, false, true, true); + else if (std::string(args[2]) == "query_168") + modifier = new Accept_Query_160(pattern_size, true, false, false, false, false, false); + else if (std::string(args[2]) == "query_169") + modifier = new Accept_Query_160(pattern_size, false, false, false, false, true, false); + else if (std::string(args[2]) == "query_170") + modifier = new Accept_Query_170(pattern_size); + else if (std::string(args[2]) == "query_171") + modifier = new Accept_Query_171(pattern_size); + else if (std::string(args[2]) == "query_172") + modifier = new Accept_Query_172(pattern_size); + else if (std::string(args[2]) == "query_173") + modifier = new Accept_Query_173(pattern_size); + else if (std::string(args[2]) == "query_174") + modifier = new Accept_Query_174(pattern_size); + else if (std::string(args[2]) == "query_175") + modifier = new Accept_Query_175(pattern_size); + else if (std::string(args[2]) == "query_176") + modifier = new Accept_Query_175(pattern_size); + else if (std::string(args[2]) == "query_177") + modifier = new Accept_Query_177(pattern_size); + else if (std::string(args[2]) == "query_178") + modifier = new Accept_Query_178(pattern_size); + else if (std::string(args[2]) == "foreach_1") + modifier = new Accept_Foreach_1(pattern_size); + else if (std::string(args[2]) == "foreach_2") + modifier = new Accept_Foreach_2(pattern_size); + else if (std::string(args[2]) == "foreach_3") + // query 1 and 3 shall both return the same set. + modifier = new Accept_Foreach_1(pattern_size); + else if (std::string(args[2]) == "foreach_4") + // query 1 and 4 shall both return the same set. + modifier = new Accept_Foreach_1(pattern_size); + else if (std::string(args[2]) == "union_1") + modifier = new Accept_Union_1(pattern_size); + else if (std::string(args[2]) == "union_2") + modifier = new Accept_Union_2(pattern_size); + else if (std::string(args[2]) == "union_3") + // query 1 and 3 shall return the same result + modifier = new Accept_Union_1(pattern_size); + else if (std::string(args[2]) == "union_4") + modifier = new Accept_Union_4(pattern_size); + else if (std::string(args[2]) == "union_5") + modifier = new Accept_Union_5(pattern_size); + else if (std::string(args[2]) == "union_6") + modifier = new Accept_Union_6(pattern_size); + else if (std::string(args[2]) == "difference_1") + modifier = new Accept_Difference_1(pattern_size); + else if (std::string(args[2]) == "difference_2") + modifier = new Accept_Difference_2(pattern_size); + else if (std::string(args[2]) == "difference_3") + modifier = new Accept_Difference_1(pattern_size); + else if (std::string(args[2]) == "difference_4") + modifier = new Accept_Difference_4(pattern_size); + else if (std::string(args[2]) == "difference_5") + modifier = new Accept_Difference_5(pattern_size); + else if (std::string(args[2]) == "difference_6") + modifier = new Accept_Difference_6(pattern_size); + else if (std::string(args[2]) == "complete_1") + modifier = new Accept_Complete_1(pattern_size); + else if (std::string(args[2]) == "complete_2") + modifier = new Accept_Complete_1(pattern_size); + else if (std::string(args[2]) == "complete_3") + modifier = new Accept_Complete_1(pattern_size); + else if (std::string(args[2]) == "complete_4") + modifier = new Accept_Complete_1(pattern_size); + else if (std::string(args[2]) == "complete_5") + modifier = new Accept_Complete_1(pattern_size); + else if (std::string(args[2]) == "complete_6") + modifier = new Accept_Complete_6(pattern_size, false); + else if (std::string(args[2]) == "complete_7") + modifier = new Accept_Complete_7(pattern_size, 0); + else if (std::string(args[2]) == "if_1") + modifier = new Accept_If(2); + else if (std::string(args[2]) == "if_2") + modifier = new Accept_If(1); + else if (std::string(args[2]) == "if_3") + modifier = new Accept_If(2); + else if (std::string(args[2]) == "if_4") + modifier = new Accept_If(3); + else if (std::string(args[2]) == "if_5") + modifier = new Accept_If(2); + else if (std::string(args[2]) == "if_6") + modifier = new Accept_If(4); + else if (std::string(args[2]) == "around_1") + modifier = new Accept_Around_1(pattern_size, 20.01); + else if (std::string(args[2]) == "around_2") + modifier = new Accept_Around_1(pattern_size, 200.1); + else if (std::string(args[2]) == "around_3") + modifier = new Accept_Around_1(pattern_size, 2001); + else if (std::string(args[2]) == "around_4") + modifier = new Accept_Around_1(pattern_size, 200.1); + else if (std::string(args[2]) == "around_5") + modifier = new Accept_Around_1(pattern_size, 200.1); + else if (std::string(args[2]) == "around_6") + modifier = new Accept_Around_1(pattern_size, 200.1, true); + else if (std::string(args[2]) == "around_7") + modifier = new Accept_Around_1(pattern_size, 20.01); + else if (std::string(args[2]) == "around_8") + modifier = new Accept_Around_1(pattern_size, 200.1); + else if (std::string(args[2]) == "around_9") + modifier = new Accept_Around_1(pattern_size, 2001); + else if (std::string(args[2]) == "around_10" || std::string(args[2]) == "around_14" + || std::string(args[2]) == "around_15" || std::string(args[2]) == "around_16" ) + modifier = new Accept_Around_10(pattern_size); + else if (std::string(args[2]) == "around_11" || std::string(args[2]) == "around_12" + || std::string(args[2]) == "around_13") + modifier = new Accept_Around_11(pattern_size); + else if (std::string(args[2]) == "around_17") + modifier = new Accept_Around_17(pattern_size); + else if (std::string(args[2]) == "around_18") + modifier = new Accept_Around_18(pattern_size); + else if (std::string(args[2]) == "around_19") + modifier = new Accept_Around_19(pattern_size); + else if (std::string(args[2]) == "polygon_query_1") + modifier = new Accept_Polygon_1(pattern_size); + else if (std::string(args[2]) == "polygon_query_2") + modifier = new Accept_Polygon_2(pattern_size); + else if (std::string(args[2]) == "polygon_query_3") + modifier = new Accept_Polygon_3(pattern_size); + else if (std::string(args[2]) == "polygon_query_4") + modifier = new Accept_Polygon_4(pattern_size); + else if (std::string(args[2]) == "polygon_query_5") + modifier = new Accept_Polygon_5(pattern_size); + else if (std::string(args[2]) == "diff_do") + modifier = new Accept_All; + else if (std::string(args[2]) == "diff_compare") + modifier = new Accept_All_But_5(pattern_size); + else if (std::string(args[2]) == "") + modifier = new Accept_All; + else + // return an empty osm file otherwise + modifier = new Accept_Bbox_Query_5(pattern_size); + } + else + modifier = new Accept_All; + + if (argc > 3) + global_node_offset = atoll(args[3]); + + if ((argc > 2) && (std::string(args[2]) == "diff_do")) + { + std::cout<< + "\n" + "\n"; + + std::cout<< + " \n" + " \n" + " \n"; + + std::cout<<"\n"; + create_node_test_pattern(-10.0, 80.0, -15.0, 105.0, 1, pattern_size, global_node_offset, modifier); + std::cout<<"\n"; + + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n"; + + std::cout<<"\n"; + create_way_test_pattern(1, pattern_size, global_node_offset, modifier); + std::cout<<"\n"; + + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n"; + + std::cout<<"\n"; + create_relation_test_pattern(1, pattern_size, global_node_offset, modifier); + std::cout<<"\n"; + + std::cout<<"\n"; + } + else if ((argc > 2) && (std::string(args[2]) == "diff_compare")) + { + std::cout<< + "\n" + "\n"; + + create_node_test_pattern(51.0, 52.0, 7.0, 8.0, 0, pattern_size, global_node_offset, modifier); + create_node_test_pattern(47.9, 48.1, -0.2, 0.2, 2, pattern_size, global_node_offset, modifier); + create_node_test_pattern(30.0, 50.0, -120.0, -60.0, 3, pattern_size, global_node_offset, modifier); + + std::cout<< + " \n" + " \n" + " \n"; + + create_way_test_pattern(0, pattern_size, global_node_offset, modifier); + create_way_test_pattern(2, pattern_size, global_node_offset, modifier); + + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n"; + + create_relation_test_pattern(0, pattern_size, global_node_offset, modifier); + create_relation_test_pattern(2, pattern_size, global_node_offset, modifier); + + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n"; + + std::cout<<"\n"; + } + else if ((argc > 2) && (std::string(args[2]).substr(0, 5) == "make_")) + { + std::cout<< + "\n" + "\n"; + + if (std::string(args[2]) == "make_1") + std::cout<<" \n"; + if (std::string(args[2]) == "make_2") + std::cout<<" \n"; + if (std::string(args[2]) == "make_3") + std::cout<<" \n"; + if (std::string(args[2]) == "make_4") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_5") + std::cout<< + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_6") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_7") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_8") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_9") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_10") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_11") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_12") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_13") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_14") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_15") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_16") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_17") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_18") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_19") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_20") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_21") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_22") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_23") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_24") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_25") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_26") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_27") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_28") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_29") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_30") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_31") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_32") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_33") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_34") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_35") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_36") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_37") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_38") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_39") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_40") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_41") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_42") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_43") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_44") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_45") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_46") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_47") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_48") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_49") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_50") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_51") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_52") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_53") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_54") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_55") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_56") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_57") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_58") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_59") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_60") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_61") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_62") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_63") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_64") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_65") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_66") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_67") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_68" || std::string(args[2]) == "make_69") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_70" || std::string(args[2]) == "make_71") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_72" || std::string(args[2]) == "make_73") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_74" || std::string(args[2]) == "make_75") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_76") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_77") + std::cout<< + " \n"; + if (std::string(args[2]) == "make_78") + std::cout<< + " \n"; + if (std::string(args[2]) == "make_79") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_80") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_81") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_82") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_83") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_84") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_85") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_86") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_87" || std::string(args[2]) == "make_88") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_89") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_90") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_91") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_92") + std::cout<< + " \n"; + if (std::string(args[2]) == "make_93") + std::cout<< + " \n"; + if (std::string(args[2]) == "make_94") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_95") + std::cout<< + " \n" + " \n"; + if (std::string(args[2]) == "make_96") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_97") + std::cout<< + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_98") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_99") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_100") + std::cout<< + " \n" + " \n"; + if (std::string(args[2]) == "make_101") + std::cout<< + " \n" + " \n"; + if (std::string(args[2]) == "make_102") + std::cout<< + " \n" + " \n"; + if (std::string(args[2]) == "make_103") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_104" || std::string(args[2]) == "make_105" + || std::string(args[2]) == "make_106") + { + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_106") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + std::cout<< + " \n"; + } + if (std::string(args[2]) == "make_107") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_108") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_109") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_110") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_111") + std::cout<< + "
\n" + " \n" + "
\n"; + if (std::string(args[2]) == "make_112") + std::cout<< + "
\n" + " \n" + "
\n"; + if (std::string(args[2]) == "make_113") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_114") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_115") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_116") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_117") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_118") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_119") + std::cout<< + " \n"; + if (std::string(args[2]) == "make_120") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_121") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_122") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_123") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_124") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_125") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_126") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_127") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_128") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_129") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_130") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_131") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_132") + std::cout<< + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "make_133") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + + std::cout<<"
\n"; + } + else if ((argc > 2) && (std::string(args[2]).substr(0, 8) == "convert_")) + { + std::cout<< + "\n" + "\n"; + + if (std::string(args[2]) == "convert_1" || std::string(args[2]) == "convert_3") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "convert_4" || std::string(args[2]) == "convert_5") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "convert_6") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "convert_7") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "convert_8") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "convert_9") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "convert_10") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "convert_11") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "convert_12") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "convert_13") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "convert_14") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + if (std::string(args[2]) == "convert_15") + std::cout<< + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + + std::cout<<"\n"; + } + else if ((argc > 2) && (std::string(args[2]) == "complete_6")) + { + std::cout<< + "\n" + "\n"; + + create_node_test_pattern(51.0, 52.0, 7.0, 8.0, 0, pattern_size, global_node_offset, modifier); + create_way_test_pattern(0, pattern_size, global_node_offset, modifier); + create_relation_test_pattern(0, pattern_size, global_node_offset, modifier); + + delete modifier; + modifier = new Accept_Complete_6(pattern_size, true); + + create_node_test_pattern(51.0, 52.0, 7.0, 8.0, 0, pattern_size, global_node_offset, modifier); + create_way_test_pattern(0, pattern_size, global_node_offset, modifier); + create_relation_test_pattern(0, pattern_size, global_node_offset, modifier); + + delete modifier; + modifier = new Accept_Complete_6(pattern_size, true); + + create_node_test_pattern(51.0, 52.0, 7.0, 8.0, 0, pattern_size, global_node_offset, modifier); + create_way_test_pattern(0, pattern_size, global_node_offset, modifier); + create_relation_test_pattern(0, pattern_size, global_node_offset, modifier); + + std::cout<<"\n"; + } + else if ((argc > 2) && (std::string(args[2]) == "complete_7")) + { + std::cout<< + "\n" + "\n"; + + for (uint i = 1; i <= 18; ++i) + { + create_node_test_pattern(51.0, 52.0, 7.0, 8.0, 0, pattern_size, global_node_offset, modifier); + create_way_test_pattern(0, pattern_size, global_node_offset, modifier); + create_relation_test_pattern(0, pattern_size, global_node_offset, modifier); + + delete modifier; + modifier = new Accept_Complete_7(pattern_size, i); + } + + std::cout<<"\n"; + } + else + { + std::cout<< + "\n" + "\n"; + + create_node_test_pattern(51.0, 52.0, 7.0, 8.0, 0, pattern_size, global_node_offset, modifier); + create_node_test_pattern(-10.0, 80.0, -15.0, 105.0, 1, pattern_size, global_node_offset, modifier); + create_node_test_pattern(47.9, 48.1, -0.2, 0.2, 2, pattern_size, global_node_offset, modifier); + create_node_test_pattern(30.0, 50.0, -120.0, -60.0, 3, pattern_size, global_node_offset, modifier); + + for (uint i = 0; i < 3; ++i) + create_way_test_pattern(i, pattern_size, global_node_offset, modifier); + + for (uint i = 0; i < 3; ++i) + create_relation_test_pattern(i, pattern_size, global_node_offset, modifier); + + std::cout<<"\n"; + } + + delete modifier; +} diff --git a/src/overpass_api/osm-backend/generate_test_file_areas.cc b/src/overpass_api/osm-backend/generate_test_file_areas.cc new file mode 100644 index 000000000..9457e1932 --- /dev/null +++ b/src/overpass_api/osm-backend/generate_test_file_areas.cc @@ -0,0 +1,618 @@ +/** Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Roland Olbricht et al. + * + * This file is part of Overpass_API. + * + * Overpass_API is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Overpass_API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Overpass_API. If not, see . + */ + +#include +#include +#include +#include +#include +#include + + +typedef unsigned int uint; + +template < typename T > +struct V : public std::vector< T > +{ + V(const T& t) : std::vector< T >(1, t) {} + V& operator()(const T& t) + { + this->push_back(t); + return *this; + } +}; + +struct Data_Modifier +{ + virtual bool admit_node(uint id) const = 0; + virtual bool admit_node_skeleton(uint id) const = 0; + virtual bool admit_node_tags(uint id) const = 0; + virtual bool admit_way(uint id) const = 0; + virtual bool admit_way_skeleton(uint id) const = 0; + virtual bool admit_way_tags(uint id) const = 0; + virtual bool admit_relation(uint id) const = 0; + virtual bool admit_relation_skeleton(uint id) const = 0; + virtual bool admit_relation_tags(uint id) const = 0; +}; + +struct Accept_All_Tags : public Data_Modifier +{ + virtual bool admit_node_skeleton(uint id) const { return true; } + virtual bool admit_node_tags(uint id) const { return true; } + virtual bool admit_way_skeleton(uint id) const { return true; } + virtual bool admit_way_tags(uint id) const { return true; } + virtual bool admit_relation_skeleton(uint id) const { return true; } + virtual bool admit_relation_tags(uint id) const { return true; } +}; + +struct Accept_All : public Accept_All_Tags +{ + virtual bool admit_node(uint id) const { return true; } + virtual bool admit_node_skeleton(uint id) const { return true; } + virtual bool admit_node_tags(uint id) const { return true; } + virtual bool admit_way(uint id) const { return true; } + virtual bool admit_way_skeleton(uint id) const { return true; } + virtual bool admit_way_tags(uint id) const { return true; } + virtual bool admit_relation(uint id) const { return true; } + virtual bool admit_relation_skeleton(uint id) const { return true; } + virtual bool admit_relation_tags(uint id) const { return true; } +}; + +std::vector< std::pair< std::string, std::string > > collect_tags(std::string prefix, uint id) +{ + std::vector< std::pair< std::string, std::string > > tags; + if (id < 100) + tags.push_back(std::make_pair< std::string, std::string > + (prefix + "_key", prefix + "_few")); + if (id % 11 == 0) + { + std::ostringstream buf; + buf< + (prefix + "_key_11", buf.str())); + } + if (id % 15 == 0) + tags.push_back(std::make_pair< std::string, std::string > + (prefix + "_key_15", prefix + "_value_15")); + if ((id % 2 == 0) && ((prefix == "way") || (prefix == "relation"))) + tags.push_back(std::make_pair< std::string, std::string > + (prefix + "_key_2/4", prefix + "_value_0")); + if ((id % 4 == 1) && ((prefix == "way") || (prefix == "relation"))) + tags.push_back(std::make_pair< std::string, std::string > + (prefix + "_key_2/4", prefix + "_value_1")); + if (id % 5 == 0) + tags.push_back(std::make_pair< std::string, std::string > + (prefix + "_key_5", prefix + "_value_5")); + if (id % 7 == 0) + { + std::ostringstream buf; + buf< + (prefix + "_key_7", buf.str())); + } + if (id == 2310) + tags.push_back(std::make_pair< std::string, std::string > + (prefix + "_unique", prefix + "_2310")); + return tags; +} + +void create_node + (uint id, double lat, double lon) +{ + std::cout<<" \n"; +} + +void create_way + (uint id, uint start_node_ref, uint end_node_ref, uint stepping, + const std::vector< std::pair< std::string, std::string > >& tags) +{ + std::cout<<" \n"; + if (start_node_ref < end_node_ref) + { + for (uint ref = start_node_ref; ref <= end_node_ref; ref += stepping) + std::cout<<" \n"; + } + else + { + for (uint ref = start_node_ref; (int)ref >= (int)end_node_ref; ref -= stepping) + std::cout<<" \n"; + } + for (std::vector< std::pair< std::string, std::string > >::const_iterator + it = tags.begin(); it != tags.end(); ++it) + std::cout<<" first<<"\" v=\""<second<<"\"/>\n"; + std::cout<<" \n"; +} + +void create_way + (uint id, const std::vector< uint >& refs, + const std::vector< std::pair< std::string, std::string > >& tags) +{ + std::cout<<" \n"; + for (std::vector< uint >::const_iterator it(refs.begin()); it != refs.end(); ++it) + std::cout<<" \n"; + for (std::vector< std::pair< std::string, std::string > >::const_iterator + it = tags.begin(); it != tags.end(); ++it) + std::cout<<" first<<"\" v=\""<second<<"\"/>\n"; + std::cout<<" \n"; +} + +void create_relation + (uint id, const std::vector< uint >& refs, const std::vector< uint >& types, + const std::vector< std::pair< std::string, std::string > >& tags) +{ + std::vector< std::string > roles = V< std::string >("zero")("one")("two")("three"); + std::vector< std::string > typenames = V< std::string >("node")("way")("relation"); + + std::cout<<" \n"; + for (uint i = 0; i < refs.size(); ++i) + { + std::cout<<" \n"; + } + for (std::vector< std::pair< std::string, std::string > >::const_iterator + it = tags.begin(); it != tags.end(); ++it) + std::cout<<" first<<"\" v=\""<second<<"\"/>\n"; + std::cout<<" \n"; +} + +void create_node_test_rectangle + (uint id, double south, double north, double west, double east) +{ + create_node(id, south, west); + create_node(id + 1, north, west); + create_node(id + 2, north, east); + create_node(id + 3, south, east); +} + +void create_way_test_rectangle + (uint id, uint node_ref, const std::vector< std::pair< std::string, std::string > >& tags) +{ + create_way(id, node_ref, node_ref + 3, 1, tags); +} + +void create_triangle_test_pattern_nodes + (uint id, double lat, double lon, double scale) +{ + create_node(id, lat + 1*scale, lon + 1*scale); + create_node(id + 1, lat + 5*scale, lon + 1*scale); + create_node(id + 2, lat + 1*scale, lon + 5*scale); + + create_node(id + 3, lat + 1*scale, lon + 7*scale); + create_node(id + 4, lat + 1*scale, lon + 11*scale); + create_node(id + 5, lat + 5*scale, lon + 7*scale); + + create_node(id + 6, lat + 1*scale, lon + 13*scale); + create_node(id + 7, lat + 1*scale, lon + 15*scale); + create_node(id + 8, lat + 5*scale, lon + 13*scale); + + create_node(id + 9, lat + 1*scale, lon + 19*scale); + create_node(id + 10, lat + 1*scale, lon + 23*scale); + create_node(id + 11, lat + 3*scale, lon + 19*scale); + + create_node(id + 12, lat + 1*scale, lon + 25*scale); + create_node(id + 13, lat + 5*scale, lon + 29*scale); + create_node(id + 14, lat + 1*scale, lon + 29*scale); + + create_node(id + 15, lat + 1*scale, lon + 31*scale); + create_node(id + 16, lat + 1*scale, lon + 35*scale); + create_node(id + 17, lat + 5*scale, lon + 35*scale); + + create_node(id + 18, lat + 1*scale, lon + 39*scale); + create_node(id + 19, lat + 1*scale, lon + 41*scale); + create_node(id + 20, lat + 5*scale, lon + 41*scale); + + create_node(id + 21, lat + 1*scale, lon + 43*scale); + create_node(id + 22, lat + 1*scale, lon + 47*scale); + create_node(id + 23, lat + 3*scale, lon + 47*scale); +} + +void create_triangle_test_pattern_ways(uint id, uint node_ref, double scale) +{ + for (uint i = 1; i <= 8; ++i) + { + std::vector< std::pair< std::string, std::string > > tags; + std::ostringstream v_dr, v_scale; + v_dr<("triangle", v_dr.str())); + v_scale<("scale", v_scale.str())); + create_way(id + i - 1, + V< uint >(node_ref + 3*i-3)(node_ref + 3*i-2)(node_ref + 3*i-1) + (node_ref + 3*i-3), tags); + } +} + +void create_shapes_test_pattern_nodes + (uint id, double lat, double lon, double scale, bool restricted = false) +{ + create_node(id, lat + 1*scale, lon + 2*scale); + create_node(id + 1, lat + 2*scale, lon + 2*scale); + create_node(id + 2, lat + 2*scale, lon + 1*scale); + create_node(id + 3, lat + 3*scale, lon + 1*scale); + create_node(id + 4, lat + 3*scale, lon + 2*scale); + create_node(id + 5, lat + 4*scale, lon + 2*scale); + create_node(id + 6, lat + 4*scale, lon + 3*scale); + create_node(id + 7, lat + 3*scale, lon + 3*scale); + create_node(id + 8, lat + 3*scale, lon + 4*scale); + create_node(id + 9, lat + 2*scale, lon + 4*scale); + create_node(id + 10, lat + 2*scale, lon + 3*scale); + create_node(id + 11, lat + 1*scale, lon + 3*scale); + + if (restricted) + return; + + for (uint i = 0; i < 4; ++i) + { + create_node(id + 12 + 2*i, lat + 1*scale, lon + (6+i)*scale); + create_node(id + 13 + 2*i, lat + 2*scale, lon + (6+i)*scale); + } +} + +void create_shapes_test_pattern_ways(uint id, uint node_ref, double scale) +{ + std::vector< std::pair< std::string, std::string > > tags; + std::ostringstream v_scale; + v_scale<("scale", v_scale.str())); + + tags.push_back(std::make_pair< std::string, std::string >("shapes", "1")); + create_way(id, V< uint >(node_ref)(node_ref + 1)(node_ref + 2) + (node_ref + 3)(node_ref + 4)(node_ref + 5)(node_ref + 6)(node_ref + 7) + (node_ref + 8)(node_ref + 9)(node_ref + 10)(node_ref + 11)(node_ref), tags); + tags.pop_back(); + + tags.push_back(std::make_pair< std::string, std::string >("shapes", "2")); + create_way(id + 1, V< uint >(node_ref + 12)(node_ref + 14)(node_ref + 16) + (node_ref + 18)(node_ref + 19)(node_ref + 17)(node_ref + 15)(node_ref + 13) + (node_ref + 12), tags); +} + +void create_area_way_ways(uint id, uint node_ref) +{ + std::vector< std::pair< std::string, std::string > > tags; + tags.push_back(std::make_pair< std::string, std::string >("shapes", "3")); + + create_way(id, V< uint >(node_ref + 43)(node_ref + 45)(node_ref + 85)(node_ref + 47) + (node_ref + 208)(node_ref + 207)(node_ref + 204)(node_ref + 243)(node_ref + 43), tags); + + tags.pop_back(); + tags.push_back(std::make_pair< std::string, std::string >("inner_point", "middle")); + + create_way(id + 1, V< uint >(node_ref + 121)(node_ref + 125)(node_ref + 129), tags); + + tags.pop_back(); + tags.push_back(std::make_pair< std::string, std::string >("inner_point", "first")); + + create_way(id + 2, V< uint >(node_ref + 125)(node_ref + 129)(node_ref + 133), tags); + + tags.pop_back(); + tags.push_back(std::make_pair< std::string, std::string >("inner_point", "last")); + + create_way(id + 3, V< uint >(node_ref + 121)(node_ref + 122)(node_ref + 125), tags); + + tags.pop_back(); + tags.push_back(std::make_pair< std::string, std::string >("inner_point", "total")); + + create_way(id + 4, V< uint >(node_ref + 124)(node_ref + 125)(node_ref + 126), tags); + + tags.pop_back(); + tags.push_back(std::make_pair< std::string, std::string >("touch_point", "middle")); + + create_way(id + 11, V< uint >(node_ref + 242)(node_ref + 243)(node_ref + 244), tags); + + tags.pop_back(); + tags.push_back(std::make_pair< std::string, std::string >("touch_point", "first")); + + create_way(id + 12, V< uint >(node_ref + 205)(node_ref + 246)(node_ref + 285), tags); + + tags.pop_back(); + tags.push_back(std::make_pair< std::string, std::string >("touch_point", "last")); + + create_way(id + 13, V< uint >(node_ref + 284)(node_ref + 281)(node_ref + 43), tags); + + tags.pop_back(); + tags.push_back(std::make_pair< std::string, std::string >("touch_point", "multiple_1")); + + create_way(id + 14, V< uint >(node_ref + 4)(node_ref + 45)(node_ref + 47)(node_ref + 8), tags); + + tags.pop_back(); + tags.push_back(std::make_pair< std::string, std::string >("touch_point", "multiple_2")); + + create_way(id + 15, V< uint >(node_ref + 201)(node_ref + 243)(node_ref + 208)(node_ref + 209), tags); + + tags.pop_back(); + tags.push_back(std::make_pair< std::string, std::string >("intersect", "middle_segment")); + + create_way(id + 21, V< uint >(node_ref + 81)(node_ref + 122)(node_ref + 88)(node_ref + 129), tags); + + tags.pop_back(); + tags.push_back(std::make_pair< std::string, std::string >("intersect", "first_segment")); + + create_way(id + 22, V< uint >(node_ref + 4)(node_ref + 244)(node_ref + 284), tags); + + tags.pop_back(); + tags.push_back(std::make_pair< std::string, std::string >("intersect", "last_segment")); + + create_way(id + 23, V< uint >(node_ref + 1)(node_ref + 2)(node_ref + 248), tags); + + tags.pop_back(); + tags.push_back(std::make_pair< std::string, std::string >("intersect", "single_segment")); + + create_way(id + 24, V< uint >(node_ref + 41)(node_ref + 49), tags); + + tags.pop_back(); + tags.push_back(std::make_pair< std::string, std::string >("intersect", "lat_segment")); + + create_way(id + 25, V< uint >(node_ref + 121)(node_ref + 129), tags); + + tags.pop_back(); + tags.push_back(std::make_pair< std::string, std::string >("intersect", "lon_segment")); + + create_way(id + 26, V< uint >(node_ref + 7)(node_ref + 287), tags); + + tags.pop_back(); + tags.push_back(std::make_pair< std::string, std::string >("intersect", "lat_boundary")); + + create_way(id + 27, V< uint >(node_ref + 204)(node_ref + 207), tags); + + tags.pop_back(); + tags.push_back(std::make_pair< std::string, std::string >("intersect", "lon_boundary")); + + create_way(id + 28, V< uint >(node_ref + 43)(node_ref + 203), tags); + + tags.pop_back(); + tags.push_back(std::make_pair< std::string, std::string >("through", "first_segment")); + + create_way(id + 31, V< uint >(node_ref + 43)(node_ref + 85)(node_ref + 6), tags); + + tags.pop_back(); + tags.push_back(std::make_pair< std::string, std::string >("through", "middle_segment")); + + create_way(id + 32, V< uint >(node_ref + 6)(node_ref + 85)(node_ref + 208)(node_ref + 248), tags); + + tags.pop_back(); + tags.push_back(std::make_pair< std::string, std::string >("through", "last_segment")); + + create_way(id + 33, V< uint >(node_ref + 281)(node_ref + 243)(node_ref + 85), tags); + + tags.pop_back(); + tags.push_back(std::make_pair< std::string, std::string >("through", "single_segment")); + + create_way(id + 34, V< uint >(node_ref + 243)(node_ref + 85), tags); + + tags.pop_back(); + tags.push_back(std::make_pair< std::string, std::string >("touch_segment", "multiple_segments")); + + create_way(id + 41, V< uint >(node_ref + 43)(node_ref + 45)(node_ref + 85)(node_ref + 47) + (node_ref + 208)(node_ref + 207)(node_ref + 204)(node_ref + 243)(node_ref + 43), tags); +} + + +void create_area_relation_relations(uint id, uint node_ref, uint way_ref) +{ + std::vector< std::pair< std::string, std::string > > tags; + tags.push_back(std::make_pair< std::string, std::string >("nodes", "outside")); + + create_relation(id + 1, V< uint >(node_ref + 245), V< uint >(0), tags); + + tags.pop_back(); + tags.push_back(std::make_pair< std::string, std::string >("nodes", "inside")); + + create_relation(id + 2, V< uint >(node_ref + 165), V< uint >(0), tags); + + tags.pop_back(); + tags.push_back(std::make_pair< std::string, std::string >("ways", "outside")); + + create_relation(id + 11, V< uint >(way_ref + 11), V< uint >(1), tags); + + tags.pop_back(); + tags.push_back(std::make_pair< std::string, std::string >("ways", "inside")); + + create_relation(id + 12, V< uint >(way_ref + 31), V< uint >(1), tags); + + tags.pop_back(); + tags.push_back(std::make_pair< std::string, std::string >("ways", "touch")); + + create_relation(id + 13, V< uint >(way_ref + 41), V< uint >(1), tags); + + tags.pop_back(); + tags.push_back(std::make_pair< std::string, std::string >("multiple", "last_inside")); + + create_relation(id + 21, V< uint >(node_ref + 245)(node_ref + 286) + (way_ref + 11)(way_ref + 11)(way_ref + 31), V< uint >(0)(0)(1)(1)(1), tags); +} + + +void create_multpolys_test_pattern_nodes + (uint id, double lat, double lon, double scale) +{ + for (uint i = 0; i < 4; ++i) + { + create_node(id + 2*i, lat + 1*scale, lon + (1+i)*scale); + create_node(id + 1 + 2*i, lat + 2*scale, lon + (1+i)*scale); + } + + create_node(id + 11, lat + 1*scale, lon + 6*scale); + create_node(id + 12, lat + 1*scale, lon + 8*scale); + create_node(id + 13, lat + 3*scale, lon + 6*scale); + create_node(id + 14, lat + 3*scale, lon + 8*scale); + create_node(id + 15, lat + 2*scale, lon + 7*scale); +} + +void create_multpolys_test_pattern_ways(uint id, uint node_ref, double scale) +{ + std::vector< std::pair< std::string, std::string > > tags; + for (uint i = 0; i < 3; ++i) + { + create_way(id + 2*i, V< uint >(node_ref + 2*i)(node_ref + 2 + 2*i), tags); + create_way(id + 2*i + 1, V< uint >(node_ref + 1 + 2*i)(node_ref + 3 + 2*i), tags); + } + create_way(id + 6, V< uint >(node_ref)(node_ref + 1), tags); + create_way(id + 7, V< uint >(node_ref + 6)(node_ref + 7), tags); + + create_way(id + 11, V< uint >(node_ref + 11)(node_ref + 12)(node_ref + 14), tags); + create_way(id + 12, V< uint >(node_ref + 11)(node_ref + 13)(node_ref + 14), tags); + create_way(id + 13, V< uint >(node_ref + 11)(node_ref + 15), tags); + create_way(id + 14, V< uint >(node_ref + 15)(node_ref + 14), tags); +} + +void create_multpolys_test_pattern_relations(uint id, uint way_ref, double scale) +{ + std::vector< std::pair< std::string, std::string > > tags; + std::ostringstream v_scale; + v_scale<("scale", v_scale.str())); + + tags.push_back(std::make_pair< std::string, std::string >("multpoly", "1")); + create_relation(id, V< uint >(way_ref)(way_ref + 1)(way_ref + 2)(way_ref + 3) + (way_ref + 4)(way_ref + 5)(way_ref + 6)(way_ref + 7), + V< uint >(1)(1)(1)(1)(1)(1)(1)(1), tags); + tags.pop_back(); + + tags.push_back(std::make_pair< std::string, std::string >("multpoly", "2")); + create_relation(id + 1, V< uint >(way_ref + 11)(way_ref + 13)(way_ref + 14), + V< uint >(1)(1)(1), tags); + tags.pop_back(); + + tags.push_back(std::make_pair< std::string, std::string >("multpoly", "3")); + create_relation(id + 2, V< uint >(way_ref + 12)(way_ref + 13)(way_ref + 14), + V< uint >(1)(1)(1), tags); + tags.pop_back(); + + tags.push_back(std::make_pair< std::string, std::string >("multpoly", "4")); + create_relation(id + 3, V< uint >(way_ref + 11)(way_ref + 12), V< uint >(1)(1), tags); + tags.pop_back(); +} + +void create_node_grid + (uint id, double south, double north, double west, double east, int pattern_size) +{ + for (int i = 0; i <= pattern_size; ++i) + { + for (int j = 0; j <= pattern_size; ++j) + create_node(id + i*(pattern_size + 1) + j, + south + (north-south)/pattern_size*i, + west + (east-west)/pattern_size*j); + } +} + +void create_node_grid_result +(uint id, double south, double north, double west, double east, int pattern_size) +{ + create_shapes_test_pattern_nodes(1201, 11.0, 10.0, 0.01, true); + + for (int i = 0; i <= pattern_size; ++i) + { + for (int j = 0; j <= pattern_size; ++j) + { + if (i < pattern_size/5) + continue; + else if (i < pattern_size*2/5) + { + if ((j < pattern_size*2/5) || (j > pattern_size*3/5)) + continue; + } + else if (i <= pattern_size*3/5) + { + if ((j < pattern_size/5) || (j > pattern_size*4/5)) + continue; + } + else if (i <= pattern_size*4/5) + { + if ((j < pattern_size*2/5) || (j > pattern_size*3/5)) + continue; + } + else + continue; + + create_node(id + i*(pattern_size + 1) + j, + south + (north-south)/pattern_size*i, + west + (east-west)/pattern_size*j); + } + } +} + +int main(int argc, char* args[]) +{ + std::string task; + uint pattern_size = 20; + if (argc > 2) + { + pattern_size = atoi(args[1]); + task = args[2]; + } + + if (task != "result") + { + std::cout<< + "\n" + "\n"; + + create_triangle_test_pattern_nodes( 1, 0.0, 0.0, 1.0); + create_triangle_test_pattern_nodes(101, 10.0, 0.0, 0.1); + create_triangle_test_pattern_nodes(201, 11.0, 0.0, 0.01); + create_triangle_test_pattern_nodes(301, 11.1, 0.0, 0.001); + create_triangle_test_pattern_nodes(401, 11.11, 0.0, 0.0001); + create_triangle_test_pattern_nodes(501, 11.111, 0.0, 0.00001); + create_triangle_test_pattern_nodes(601, 11.1111, 0.0, 0.000001); + + create_shapes_test_pattern_nodes(1001, 0.0, 50.0, 1.0); + create_shapes_test_pattern_nodes(1101, 10.0, 10.0, 0.1); + create_shapes_test_pattern_nodes(1201, 11.0, 10.0, 0.01); + create_shapes_test_pattern_nodes(1301, 11.1, 10.0, 0.001); + create_shapes_test_pattern_nodes(1401, 11.11, 10.0, 0.0001); + create_shapes_test_pattern_nodes(1501, 11.111, 10.0, 0.00001); + create_shapes_test_pattern_nodes(1601, 11.1111, 10.0, 0.000001); + + create_multpolys_test_pattern_nodes(2001, 10.0, 20.0, 0.1); + + create_node_grid(10001, 11.0, 11.05, 10.0, 10.05, pattern_size); + + create_node_grid(3000000001u, 30.0, 30.975, 0.0, 0.975, 39); + + create_triangle_test_pattern_ways( 1, 1, 1.0); + create_triangle_test_pattern_ways(11, 101, 0.1); + create_triangle_test_pattern_ways(21, 201, 0.01); + create_triangle_test_pattern_ways(31, 301, 0.001); + create_triangle_test_pattern_ways(41, 401, 0.0001); + create_triangle_test_pattern_ways(51, 501, 0.00001); + create_triangle_test_pattern_ways(61, 601, 0.000001); + + create_shapes_test_pattern_ways(101, 1001, 1.0); + create_shapes_test_pattern_ways(111, 1101, 0.1); + create_shapes_test_pattern_ways(121, 1201, 0.01); + create_shapes_test_pattern_ways(131, 1301, 0.001); + create_shapes_test_pattern_ways(141, 1401, 0.0001); + create_shapes_test_pattern_ways(151, 1501, 0.00001); + create_shapes_test_pattern_ways(161, 1601, 0.000001); + + create_multpolys_test_pattern_ways(201, 2001, 0.1); + + create_area_way_ways(300, 3000000000u); + + create_multpolys_test_pattern_relations(1, 201, 0.1); + + create_area_relation_relations(10, 3000000000u, 300); + + std::cout<<"\n"; + } + else + create_node_grid_result(10001, 11.0, 11.05, 10.0, 10.05, pattern_size); +} diff --git a/src/overpass_api/osm-backend/generate_test_file_interpreter.cc b/src/overpass_api/osm-backend/generate_test_file_interpreter.cc new file mode 100644 index 000000000..7693cdc67 --- /dev/null +++ b/src/overpass_api/osm-backend/generate_test_file_interpreter.cc @@ -0,0 +1,1321 @@ +/** Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Roland Olbricht et al. + * + * This file is part of Overpass_API. + * + * Overpass_API is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Overpass_API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Overpass_API. If not, see . + */ + +#include "../core/settings.h" + +#include +#include +#include + + +double way_1_south(unsigned int pattern_size) +{ + return 51. + 1.5/pattern_size; +} + +double way_1_north(unsigned int pattern_size) +{ + return 51. + 1.5/pattern_size; +} + +double way_1_west(unsigned int pattern_size) +{ + return 7. + .5/pattern_size; +} + +double way_1_east(unsigned int pattern_size) +{ + return 7. + 1.5/pattern_size; +} + +unsigned int way_1_zoom(unsigned int pattern_size) +{ + if (pattern_size < 80) + return 13; + else if (pattern_size < 120) + return 14; + return 15; +} + +double way_2_south(unsigned int pattern_size) +{ + return 51. + 1.5/pattern_size; +} + +double way_2_north(unsigned int pattern_size) +{ + return 51. + 1.5/pattern_size; +} + +double way_2_west(unsigned int pattern_size) +{ + return 7. + 1.5/pattern_size; +} + +double way_2_east(unsigned int pattern_size) +{ + return 7. + 2.5/pattern_size; +} + +unsigned int way_2_zoom(unsigned int pattern_size) +{ + if (pattern_size < 80) + return 13; + else if (pattern_size < 120) + return 14; + return 15; +} + +double relation_1_south(unsigned int pattern_size) +{ + return 51. + .5 / pattern_size; +} + +double relation_1_north(unsigned int pattern_size) +{ + return 51. + 1.5 / pattern_size; +} + +double relation_1_west(unsigned int pattern_size) +{ + return 7. + .5 / pattern_size; +} + +double relation_1_east(unsigned int pattern_size) +{ + return 7. + 1.5 / pattern_size; +} + +unsigned int relation_1_zoom(unsigned int pattern_size) +{ + if (pattern_size < 80) + return 13; + else if (pattern_size < 120) + return 14; + return 15; +} + +double way_meta_south(unsigned int pattern_size) +{ + if (pattern_size > 440) + return 9.99752956; + else if (pattern_size > 120) + return 9.9909760; + else if (pattern_size > 60) + return 10.0040832; + else + return 9.9778688; +} + +double way_meta_north(unsigned int pattern_size) +{ + if (pattern_size > 440) + return 10.00408306; + else if (pattern_size > 120) + return 10.0171903; + else if (pattern_size > 60) + return 10.0302975; + else + return 10.0827263; +} + +double way_meta_west(unsigned int pattern_size) +{ + return 0.9961472; +} + +double way_meta_east(unsigned int pattern_size) +{ + if (pattern_size > 440) + return 1.0027007; + else if (pattern_size > 60) + return 1.0223615; + else + return 1.1010047; +} + +unsigned int way_meta_zoom(unsigned int pattern_size) +{ + if (pattern_size > 440) + return 14; + else if (pattern_size > 60) + return 13; + else + return 11; +} + +double relation_meta_south(unsigned int pattern_size) +{ + if (pattern_size > 440) + return 9.99752956; + else if (pattern_size > 120) + return 9.9909760; + else if (pattern_size > 60) + return 10.0040832; + else + return 9.9778688; +} + +double relation_meta_north(unsigned int pattern_size) +{ + if (pattern_size > 440) + return 10.00408306; + else if (pattern_size > 120) + return 10.0171903; + else if (pattern_size > 60) + return 10.0302975; + else + return 10.0827263; +} + +double relation_meta_west(unsigned int pattern_size) +{ + return 0.9961472; +} + +double relation_meta_east(unsigned int pattern_size) +{ + if (pattern_size > 440) + return 1.0027007; + else if (pattern_size > 60) + return 1.0223615; + else + return 1.1010047; +} + +unsigned int relation_meta_zoom(unsigned int pattern_size) +{ + if (pattern_size > 440) + return 14; + else if (pattern_size > 60) + return 13; + else + return 11; +} + + +void print_applicable_tags(unsigned int id) +{ + bool frame_printed = false; + + if (id % 11 == 0) + { + if (!frame_printed) + std::cout<<",\n \"tags\": {\n"; + else + std::cout<<",\n"; + frame_printed = true; + + std::cout<<" \"way_key_11\": \"way_value_"<<(id / 11 + 1)<<"\""; + } + if (id % 15 == 0) + { + if (!frame_printed) + std::cout<<",\n \"tags\": {\n"; + else + std::cout<<",\n"; + frame_printed = true; + + std::cout<<" \"way_key_15\": \"way_value_15\""; + } + if (id % 2 == 0) + { + if (!frame_printed) + std::cout<<",\n \"tags\": {\n"; + else + std::cout<<",\n"; + frame_printed = true; + + std::cout<<" \"way_key_2/4\": \"way_value_0\""; + } + if (id % 4 == 1) + { + if (!frame_printed) + std::cout<<",\n \"tags\": {\n"; + else + std::cout<<",\n"; + frame_printed = true; + + std::cout<<" \"way_key_2/4\": \"way_value_1\""; + } + if (id % 5 == 0) + { + if (!frame_printed) + std::cout<<",\n \"tags\": {\n"; + else + std::cout<<",\n"; + frame_printed = true; + + std::cout<<" \"way_key_5\": \"way_value_5\""; + } + if (id % 7 == 0) + { + if (!frame_printed) + std::cout<<",\n \"tags\": {\n"; + else + std::cout<<",\n"; + frame_printed = true; + + std::cout<<" \"way_key_7\": \"way_value_"<<(id % 21 / 7)<<"\""; + } + + if (frame_printed) + std::cout<<"\n }"; +} + + +int main(int argc, char* args[]) +{ + if (argc < 3) + { + std::cout<<"Usage: "< 1) + pattern_size = atoi(args[1]); + + if (std::string(args[2]) == "interpreter_1" || std::string(args[2]) == "interpreter_2") + std::cout<< + "Content-type: application/osm3s+xml\n" + "\n" + "\n" + "\n" + "The data included in this document is from www.openstreetmap.org. " + "The data is made available under ODbL.\n" + "\n" + "\n" + "\n" + "\n"; + else if (std::string(args[2]) == "interpreter_3" || std::string(args[2]) == "interpreter_4" + || std::string(args[2]) == "interpreter_5" || std::string(args[2]) == "interpreter_6" + || std::string(args[2]) == "interpreter_7" || std::string(args[2]) == "interpreter_8" + || std::string(args[2]) == "interpreter_9" || std::string(args[2]) == "interpreter_10") + { + std::cout<< + "Status: 400 Bad Request\n" + "Content-type: text/html; charset=utf-8\n" + "\n" + "\n" + "\n" + "\n" + "\n" + " \n" + " OSM3S Response\n" + "\n" + "\n" + "\n" + "

The data included in this document is from www.openstreetmap.org. " + "The data is made available under ODbL.

\n"; + if (std::string(args[2]) == "interpreter_3") + std::cout<< + "

Error: line 1: parse error: Unknown type "foo"

\n" + "

Error: line 1: parse error: An empty query is not allowed

\n"; + else if (std::string(args[2]) == "interpreter_4") + std::cout<< + "

Error: line 3: static error: Unknown tag "foo" in line 3.

\n"; + else if (std::string(args[2]) == "interpreter_5") + std::cout<< + "

Error: line 1: parse error: Unknown type "foo"

\n" + "

Error: line 1: parse error: An empty query is not allowed

\n"; + else if (std::string(args[2]) == "interpreter_6") + std::cout<< + "

Error: line 2: parse error: Unknown type "foo"

\n" + "

Error: line 2: parse error: An empty query is not allowed

\n"; + else if (std::string(args[2]) == "interpreter_7") + std::cout<< + "

Error: line 1: parse error: Unknown type "foo"

\n" + "

Error: line 1: parse error: An empty query is not allowed

\n" + "

Error: line 2: parse error: Unknown type "foo"

\n" + "

Error: line 2: parse error: An empty query is not allowed

\n"; + else if (std::string(args[2]) == "interpreter_8") + std::cout<< + "

Error: line 3: static error: Unknown tag "foo" in line 3.

\n"; + else if (std::string(args[2]) == "interpreter_9") + std::cout<< + "

Error: line 4: static error: Unknown tag "foo" in line 4.

\n"; + else if (std::string(args[2]) == "interpreter_10") + std::cout<< + "

Error: line 3: static error: Unknown tag "foo" in line 3.

\n" + "

Error: line 4: static error: Unknown tag "foo" in line 4.

\n"; + std::cout<< + "\n" + "\n" + "\n"; + } + else if (std::string(args[2]) == "interpreter_11" || std::string(args[2]) == "interpreter_12" + || std::string(args[2]) == "interpreter_13" || std::string(args[2]) == "interpreter_14" + || std::string(args[2]) == "interpreter_15" || std::string(args[2]) == "interpreter_16" + || std::string(args[2]) == "interpreter_17" || std::string(args[2]) == "interpreter_18" + || std::string(args[2]) == "interpreter_19" || std::string(args[2]) == "interpreter_20" + || std::string(args[2]) == "interpreter_21" || std::string(args[2]) == "interpreter_22" + || std::string(args[2]) == "interpreter_23" || std::string(args[2]) == "interpreter_38" + || std::string(args[2]) == "interpreter_45") + { + std::cout<< + "Content-type: application/json\n" + "\n"; + if (std::string(args[2]) == "interpreter_38") + std::cout<<"foo("; + std::cout<< + "{\n" + " \"version\": 0.6,\n" + " \"generator\": \"Overpass API "< pattern_size*pattern_size/2; --i) + std::cout<<",\n "<\n" + "\n" + "\n" + "\n" + " \n" + " OSM3S Response\n" + "\n"; + if (std::string(args[2]) == "interpreter_24") + std::cout<<"\n"; + else + std::cout<<"\n"; + std::cout<< + "\n" + "

The data included in this document is from www.openstreetmap.org. " + "The data is made available under ODbL.

\n" + "

Data included until: mock-up-init

\n"; + if (std::string(args[2]) == "interpreter_24") + std::cout<<"

No results found.

\n"; + else + { + std::cout<< + " \n" + " \n" + " \n" + "\n"; + if (std::string(args[2]) == "interpreter_25" || std::string(args[2]) == "interpreter_27" + || std::string(args[2]) == "interpreter_29") + std::cout<<"

1 results found

\n"; + else if (std::string(args[2]) == "interpreter_26" || std::string(args[2]) == "interpreter_28" + || std::string(args[2]) == "interpreter_30" || std::string(args[2]) == "interpreter_31" + || std::string(args[2]) == "interpreter_32" || std::string(args[2]) == "interpreter_33") + std::cout<<"

2 results found

\n"; + else + std::cout<<"

3 results found

\n"; + std::cout<< + "\n" + "\n"; + if (std::string(args[2]) == "interpreter_25" || std::string(args[2]) == "interpreter_26" + || std::string(args[2]) == "interpreter_31" || std::string(args[2]) == "interpreter_32" + || std::string(args[2]) == "interpreter_34" || std::string(args[2]) == "interpreter_36" + || std::string(args[2]) == "interpreter_37") + { + std::cout<< + "\n" + "
\n" + "
\n" + "
Loading data ...
\n" + "
\n" + " \n" + " \n" + " \n" + " \n" + "
\n" + "
\n" + "\n" + "

Node 1, lat: "<\n"; + if (std::string(args[2]) != "interpreter_36") + std::cout<< + "node_key = node_few
\n"; + std::cout<< + "\n" + "Browse on openstreetmap.org

\n" + "
\n"; + } + if (std::string(args[2]) == "interpreter_35") + std::cout<< + "\n" + "
\n" + "\n" + "\n" + "

Node 1,
\n" + "\n" + "Browse on openstreetmap.org

\n" + "
\n"; + if (std::string(args[2]) == "interpreter_26") + std::cout<< + "\n" + "
\n" + "
\n" + "
Loading data ...
\n" + "
\n" + " \n" + " \n" + " \n" + " \n" + "
\n" + "
\n" + "\n" + "

Node "<<3*pattern_size + 3<<", lat: "<\n" + "\n" + "Browse on openstreetmap.org

\n" + "
\n"; + if (std::string(args[2]) == "interpreter_27" || std::string(args[2]) == "interpreter_28" + || std::string(args[2]) == "interpreter_31" || std::string(args[2]) == "interpreter_33" + || std::string(args[2]) == "interpreter_34") + { + std::cout<< + "\n" + "
\n" + "
\n" + "
Loading data ...
\n" + "
\n" + " \n" + " \n" + " \n" + " \n" + "
\n" + "
\n" + "\n" + "

Way 1, bounding box south: "<\n"; + if (std::string(args[2]) != "interpreter_36") + std::cout<< + "way_key = way_few
\n" + "way_key_2/4 = way_value_1
\n"; + std::cout<< + " members: "<\n" + "Browse on openstreetmap.org

\n" + "
\n"; + } + if (std::string(args[2]) == "interpreter_35") + std::cout<< + "\n" + "
\n" + "\n" + "\n" + "

Way 1, no geographic reference
\n" + "
\n" + "Browse on openstreetmap.org

\n" + "
\n"; + if (std::string(args[2]) == "interpreter_36") + std::cout<< + "\n" + "
\n" + "\n" + "\n" + "

Way 1, no geographic reference
\n" + " members: "<\n" + "Browse on openstreetmap.org

\n" + "
\n"; + if (std::string(args[2]) == "interpreter_37") + std::cout<< + "\n" + "
\n" + "\n" + "\n" + "

Way 1, no geographic reference
\n" + "way_key = way_few
\n" + "way_key_2/4 = way_value_1
\n" + " members: "<\n" + "Browse on openstreetmap.org

\n" + "
\n"; + if (std::string(args[2]) == "interpreter_28") + std::cout<< + "\n" + "
\n" + "
\n" + "
Loading data ...
\n" + "
\n" + " \n" + " \n" + " \n" + " \n" + "
\n" + "
\n" + "\n" + "

Way 2, bounding box south: "<\n" + "way_key = way_few
\n" + "way_key_2/4 = way_value_0
\n" + " members: "<\n" + "Browse on openstreetmap.org

\n" + "
\n"; + if (std::string(args[2]) == "interpreter_30" + || std::string(args[2]) == "interpreter_32" || std::string(args[2]) == "interpreter_33" + || std::string(args[2]) == "interpreter_34") + { + std::cout<< + "\n" + "
\n" + "
\n" + "
Loading data ...
\n" + "
\n" + " \n" + " \n" + " \n" + " \n" + "
\n" + "
\n" + "\n" + "

Relation 1, bounding box south: "<\n"; + if (std::string(args[2]) != "interpreter_36") + std::cout<< + "relation_key = relation_few
\n" + "relation_key_2/4 = relation_value_1
\n"; + std::cout<< + " members: node 1 "one", node "< "two"
\n" + "Browse on openstreetmap.org

\n" + "
\n"; + } + if (std::string(args[2]) == "interpreter_35") + std::cout<< + "\n" + "
\n" + "\n" + "\n" + "

Relation 1, no geographic reference
\n" + "
\n" + "Browse on openstreetmap.org

\n" + "
\n"; + if (std::string(args[2]) == "interpreter_36") + std::cout<< + "\n" + "
\n" + "\n" + "\n" + "

Relation 1, no geographic reference
\n" + " members: node 1 "one", node "< "two"
\n" + "Browse on openstreetmap.org

\n" + "
\n"; + if (std::string(args[2]) == "interpreter_29" || std::string(args[2]) == "interpreter_37") + std::cout<< + "\n" + "
\n" + "\n" + "\n" + "

Relation 1, no geographic reference
\n" + "relation_key = relation_few
\n" + "relation_key_2/4 = relation_value_1
\n" + " members: node 1 "one", node "< "two"
\n" + "Browse on openstreetmap.org

\n" + "
\n"; + if (std::string(args[2]) == "interpreter_30") + std::cout<< + "\n" + "
\n" + "\n" + "\n" + "

Relation 9, no geographic reference
\n" + "relation_key = relation_few
\n" + "relation_key_2/4 = relation_value_1
\n" + " members: relation 1 "three", relation 2 "zero", relation 3 "one", relation 4 "two", relation 5 "three", relation 6 "zero"
\n" + "Browse on openstreetmap.org

\n" + "
\n"; + } + std::cout<< + "\n" + "\n" + "\n"; + } + else if (std::string(args[2]) == "interpreter_42" || std::string(args[2]) == "interpreter_43" + || std::string(args[2]) == "interpreter_44") + { + std::cout<< + "Content-type: text/html; charset=utf-8\n" + "\n" + "\n" + "\n" + "\n" + "\n" + " \n" + " OSM3S Response\n" + "\n" + "\n" + "\n" + "

The data included in this document is from www.openstreetmap.org. " + "The data is made available under ODbL.

\n" + "

Data included until: mock-up-init

\n"; + if (std::string(args[2]) == "interpreter_42") + std::cout<<"

1 results found

\n"; + else if (std::string(args[2]) == "interpreter_43") + std::cout<<"

3 results found

\n"; + if (std::string(args[2]) == "interpreter_44") + std::cout<<"

6 results found

\n"; + std::cout<< + "\n" + "\n" + "\n" + "

Node 1, lat: "<\n" + "node_key = node_few
\n" + "\n" + "Browse on openstreetmap.org

\n" + "\n"; + if (std::string(args[2]) == "interpreter_44") + std::cout<< + "

Node "<<3*pattern_size + 3<<", lat: "<\n" + "\n" + "Browse on openstreetmap.org

\n" + "\n"; + if (std::string(args[2]) == "interpreter_43" || std::string(args[2]) == "interpreter_44") + std::cout<< + "

Way 1, bounding box south: "<\n" + "way_key = way_few
\n" + "way_key_2/4 = way_value_1
\n" + " members: "<\n" + "Browse on openstreetmap.org

\n" + "\n"; + if (std::string(args[2]) == "interpreter_44") + std::cout<< + "

Way 2, bounding box south: "<\n" + "way_key = way_few
\n" + "way_key_2/4 = way_value_0
\n" + " members: "<\n" + "Browse on openstreetmap.org

\n" + "\n"; + if (std::string(args[2]) == "interpreter_43" || std::string(args[2]) == "interpreter_44") + std::cout<< + "

Relation 1, bounding box south: "<\n" + "relation_key = relation_few
\n" + "relation_key_2/4 = relation_value_1
\n" + " members: node 1 "one", node "< "two"
\n" + "Browse on openstreetmap.org

\n" + "\n"; + if (std::string(args[2]) == "interpreter_44") + std::cout<< + "

Relation 9, no geographic reference
\n" + "relation_key = relation_few
\n" + "relation_key_2/4 = relation_value_1
\n" + " members: relation 1 "three", relation 2 "zero", relation 3 "one", relation 4 "two", relation 5 "three", relation 6 "zero"
\n" + "Browse on openstreetmap.org

\n" + "\n"; + std::cout<< + "\n" + "\n"; + } + else if (std::string(args[2]) == "interpreter_46") + { + std::cout<< + "Content-type: application/json\n" + "\n" + "{\n" + " \"version\": 0.6,\n" + " \"generator\": \"Overpass API "<\n" + "\n" + "\n" + "\n" + " \n" + " OSM3S Response\n" + "\n" + "\n" + "\n" + "

The data included in this document is from www.openstreetmap.org. " + "The data is made available under ODbL.

\n" + "

Data included until: mock-up-init

\n" + " \n" + " \n" + " \n" + "\n" + "

3 results found

\n" + "\n" + "\n" + "\n" + "
\n" + "
\n" + "
Loading data ...
\n" + "
\n" + " \n" + " \n" + " \n" + " \n" + "
\n" + "
\n" + "\n" + "

Node 7, lat: "<\n" + "foo = bar
\n" + "\n" + "Browse on openstreetmap.org

\n" + "
\n" + "\n" + "
\n" + "\n" + "\n" + "

Way 1, no geographic reference
\n" + " members: 1, 2
\n" + "Browse on openstreetmap.org

\n" + "
\n" + "\n" + "
\n" + "\n" + "\n" + "

Relation 1, no geographic reference
\n" + " members: node 1 "one", node 2 "two"
\n" + "Browse on openstreetmap.org

\n" + "
\n" + "\n" + "\n" + "\n"; + } +} diff --git a/src/overpass_api/osm-backend/generate_test_file_meta.cc b/src/overpass_api/osm-backend/generate_test_file_meta.cc new file mode 100644 index 000000000..1a3b2563e --- /dev/null +++ b/src/overpass_api/osm-backend/generate_test_file_meta.cc @@ -0,0 +1,451 @@ +/** Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Roland Olbricht et al. + * + * This file is part of Overpass_API. + * + * Overpass_API is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Overpass_API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Overpass_API. If not, see . + */ + +#include "../core/settings.h" + +#include +#include +#include +#include +#include +#include + + +typedef unsigned int uint; + +template < typename T > +struct V : public std::vector< T > +{ + V(const T& t) : std::vector< T >(1, t) {} + V& operator()(const T& t) + { + this->push_back(t); + return *this; + } +}; + +struct Print_Control +{ + Print_Control() : uid(0), tags_allowed_only(false) {} + Print_Control(uint pattern_size_, uint uid_, const std::string& timestamp_, bool tags_allowed_only_, bool bbox_limited_) + : pattern_size(pattern_size_), uid(uid_), timestamp(timestamp_), + tags_allowed_only(tags_allowed_only_), bbox_limited(bbox_limited_) {} + + void meta_data(uint id, int variant) const; + bool print_allowed(uint id, int variant) const; + + private: + uint pattern_size; + uint uid; + std::string timestamp; + bool tags_allowed_only; + bool bbox_limited; +}; + +void Print_Control::meta_data(uint id, int variant) const +{ + std::cout<<" version=\""<<((id + variant) % 256 + 1)<<"\"" + " timestamp=\"20"< pattern_size*pattern_size/2 || (id-1) % pattern_size >= pattern_size/2) + return false; + } + else if (variant == 2 || variant == 5) + { + if (id > pattern_size*pattern_size/2 || id % pattern_size > pattern_size/2) + return false; + } + else if (variant == 3 || variant == 6) + { + if (id > pattern_size) + return false; + } + } + + if (timestamp != "") + { + std::ostringstream buf; + buf<<"20"<= timestamp); + } + + if (uid == 0) + return true; + + return (uid == ((id/100 + variant) % 9990 + 10)); +} + + +void create_node(uint id, double lat, double lon, + const Print_Control& print_control, bool after_altered = false, bool more_tags = false) +{ + std::cout<<" \n"; + if (more_tags && id % 2 == 0) + tags += " \n"; + if (more_tags && id % 100 == 0) + tags += " \n"; + + if (tags == "") + std::cout<<"/>\n"; + else + std::cout<<">\n"<\n"; +} + + +void fill_bbox_with_nodes + (double south, double north, double west, double east, + uint begin_id, uint end_id, const Print_Control& print_control, + bool after_altered = false, bool more_tags = false) +{ + int sqrt_ = sqrt(end_id - begin_id); + for (int i = 0; i < sqrt_; ++i) + { + for (int j = 0; j < sqrt_; ++j) + { + if (print_control.print_allowed(begin_id + i*sqrt_ + j, after_altered ? 4 : 1)) + create_node(begin_id + i*sqrt_ + j, + (north - south)/sqrt_*(0.5 + i) + south, + (east - west)/sqrt_*(0.5 + j) + west, + print_control, after_altered, more_tags); + } + } +} + +void create_way + (uint id, uint start_node_ref, uint end_node_ref, uint stepping, + const Print_Control& print_control, bool after_altered = false, bool more_tags = false) +{ + if (!print_control.print_allowed(id, after_altered ? 5 : 2)) + return; + + std::cout<<" \n"; + if (start_node_ref < end_node_ref) + { + for (uint ref = start_node_ref; ref <= end_node_ref; ref += stepping) + std::cout<<" \n"; + } + else + { + for (uint ref = start_node_ref; (int)ref >= (int)end_node_ref; ref -= stepping) + std::cout<<" \n"; + } + if (id % 7 == 0) + std::cout<<" \n"; + if (more_tags && id % 2 == 0) + std::cout<<" \n"; + if (more_tags && id % 100 == 0) + std::cout<<" \n"; + std::cout<<" \n"; +} + +void create_relation + (uint id, const std::vector< uint >& refs, const std::vector< uint >& types, + const Print_Control& print_control, bool after_altered = false, bool more_tags = false) +{ + if (!print_control.print_allowed(id, after_altered ? 6 : 3)) + return; + + std::vector< std::string > roles = V< std::string >("zero")("one")("two")("three"); + std::vector< std::string > typenames = V< std::string >("node")("way")("relation"); + + std::cout<<" \n"; + for (uint i = 0; i < refs.size(); ++i) + { + std::cout<<" \n"; + } + if (id % 7 == 0) + std::cout<<" \n"; + if (more_tags && id % 2 == 0) + std::cout<<" \n"; + if (more_tags && id % 100 == 0) + std::cout<<" \n"; + std::cout<<" \n"; +} + +void create_node_test_pattern + (double south, double north, double west, double east, uint id, uint size, + const Print_Control& print_control, bool after_altered = false, bool more_tags = false) +{ + fill_bbox_with_nodes + (south, north, west, east, + id*size*size + 1, (id+1)*size*size + 1, print_control, after_altered, more_tags); +} + +void create_way_test_pattern(uint id, uint size, + const Print_Control& print_control, + bool pos_altered = false, bool after_altered = false, bool more_tags = false) +{ + if (pos_altered) + { + for (uint i = 0; i < size*size-1; ++i) + create_way(id*size*size + i+1, id*size*size + (i%size)+1, id*size*size + (i%size)+2, 1, + print_control, after_altered, more_tags); + } + else + { + for (uint i = id*size*size + 1; i < (id+1)*size*size; ++i) + create_way(i, i, i+1, 1, print_control, after_altered, more_tags); + } +} + +void create_relation_test_pattern(uint id, uint size, + const Print_Control& print_control, + bool pos_altered = false, bool after_altered = false, bool more_tags = false) +{ + if (pos_altered) + { + create_relation(id*size + 1, + V< uint >((id+1)*size*size - 1)((id+1)*size*size - 2), + V< uint >(0)(0), print_control, after_altered, more_tags); + create_relation(id*size + 2, + V< uint >((id+1)*size*size - 1)((id+1)*size*size - 2), + V< uint >(1)(1), print_control, after_altered, more_tags); + create_relation(id*size + 3, + V< uint >((id+1)*size*size - 1)((id+1)*size*size - 2), + V< uint >(0)(1), print_control, after_altered, more_tags); + } + else + { + create_relation(id*size + 1, + V< uint >(id*size*size + 1)(id*size*size + 2), + V< uint >(0)(0), print_control, after_altered, more_tags); + create_relation(id*size + 2, + V< uint >(id*size*size + 1)(id*size*size + 2), + V< uint >(1)(1), print_control, after_altered, more_tags); + create_relation(id*size + 3, + V< uint >(id*size*size + 1)(id*size*size + 2), + V< uint >(0)(1), print_control, after_altered, more_tags); + } +} + +int main(int argc, char* args[]) +{ + uint pattern_size = 2; + uint uid = 0; + std::string timestamp; + bool tags_allowed_only = false; + bool bbox_limited = false; + bool more_tags = false; + if (argc > 1) + pattern_size = atoi(args[1]); + enum { before, diff, after, augmented } pattern = before; + if (argc > 2) + { + if (std::string(args[2]) == "diff") + pattern = diff; + else if (std::string(args[2]) == "after") + pattern = after; + else if (std::string(args[2]) == "augmented") + pattern = augmented; + else if (std::string(args[2]) == "more_tags") + more_tags = true; + } + if (argc > 3) + { + if (std::string(args[3]).substr(0, 4) == "uid=") + uid = atoll(args[3] + 4); + else if (std::string(args[3]).substr(0, 10) == "timestamp=") + timestamp = std::string(args[3] + 10); + } + if (argc > 4) + { + if (std::string(args[4]) == "tags") + tags_allowed_only = true; + if (std::string(args[4]) == "bbox") + bbox_limited = true; + if (std::string(args[4]) == "tags_bbox") + { + bbox_limited = true; + tags_allowed_only = true; + } + } + + Print_Control print_control(pattern_size, uid, timestamp, tags_allowed_only, bbox_limited); + + std::cout<< + "\n" + "\n" + "The data included in this document is from www.openstreetmap.org. " + "The data is made available under ODbL.\n" + "\n\n"; + + if (bbox_limited) + std::cout<<" \n\n"; + + if (pattern == before) + { + create_node_test_pattern(10.0, 11.0, 1.0, 2.0, 0, pattern_size, print_control, false, more_tags); + create_node_test_pattern(10.0, 11.0, 2.0, 3.0, 1, pattern_size, print_control, false, more_tags); + create_node_test_pattern(10.0, 11.0, 3.0, 4.0, 2, pattern_size, print_control, false, more_tags); + create_node_test_pattern(10.0, 11.0, 4.0, 5.0, 3, pattern_size, print_control, false, more_tags); + create_node_test_pattern(10.0, 11.0, 5.0, 6.0, 4, pattern_size, print_control, false, more_tags); + create_node_test_pattern(10.0, 11.0, 6.0, 7.0, 5, pattern_size, print_control, false, more_tags); + create_node_test_pattern(10.0, 11.0, 6.0, 7.0, 6, pattern_size, print_control, false, more_tags); + create_node_test_pattern(10.0, 11.0, 6.0, 7.0, 7, pattern_size, print_control, false, more_tags); + create_node_test_pattern(10.0, 11.0, 6.0, 7.0, 8, pattern_size, print_control, false, more_tags); + + for (uint i = 0; i < 6; ++i) + create_way_test_pattern(i, pattern_size, print_control, false, false, more_tags); + + create_way(pattern_size*pattern_size*6, + 1, pattern_size*pattern_size*2 + 1, pattern_size*pattern_size*2, print_control, + false, more_tags); + + for (uint i = 0; i < 6; ++i) + create_relation_test_pattern(i, pattern_size, print_control, false, false, more_tags); + } + else if (pattern == diff) + { + create_node_test_pattern(10.0, 11.0, 2.0, 3.0, 1, pattern_size, print_control, true); + create_node_test_pattern(11.0, 12.0, 3.0, 4.0, 2, pattern_size, print_control); + std::cout<<"\n"; + create_node_test_pattern(10.0, 11.0, 4.0, 5.0, 3, pattern_size, print_control); + std::cout<<"\n"; + create_node_test_pattern(10.0, 11.0, 5.0, 6.0, 4, pattern_size, print_control); + create_node_test_pattern(10.0, 11.0, 6.0, 7.0, 5, pattern_size, print_control); + std::cout<<"\n"; + create_node_test_pattern(10.0, 11.0, 7.0, 8.0, 6, pattern_size, print_control); + create_node_test_pattern(10.0, 11.0, 8.0, 9.0, 7, pattern_size, print_control); + create_node_test_pattern(10.0, 11.0, 9.0, 10.0, 8, pattern_size, print_control); + std::cout<<"\n"; + + create_way_test_pattern(1, pattern_size, print_control, false, true); + std::cout<<"\n"; + create_way_test_pattern(3, pattern_size, print_control); + std::cout<<"\n"; + create_way_test_pattern(4, pattern_size, print_control, true, false); + + create_relation_test_pattern(1, pattern_size, print_control, false, true); + std::cout<<"\n"; + create_relation_test_pattern(3, pattern_size, print_control); + std::cout<<"\n"; + create_relation_test_pattern(5, pattern_size, print_control, true, false); + } + else if (pattern == after) + { + create_node_test_pattern(10.0, 11.0, 1.0, 2.0, 0, pattern_size, print_control); + create_node_test_pattern(10.0, 11.0, 2.0, 3.0, 1, pattern_size, print_control, true); + create_node_test_pattern(11.0, 12.0, 3.0, 4.0, 2, pattern_size, print_control); + // nodes 3 deleted + create_node_test_pattern(10.0, 11.0, 5.0, 6.0, 4, pattern_size, print_control); + create_node_test_pattern(10.0, 11.0, 6.0, 7.0, 5, pattern_size, print_control); + // nodes 6 to 8 deleted + + create_way_test_pattern(0, pattern_size, print_control); + create_way_test_pattern(1, pattern_size, print_control, false, true); + create_way_test_pattern(2, pattern_size, print_control); + create_way_test_pattern(4, pattern_size, print_control, true, false); + create_way_test_pattern(5, pattern_size, print_control); + + create_way(pattern_size*pattern_size*6, + 1, pattern_size*pattern_size*2 + 1, pattern_size*pattern_size*2, print_control); + + create_relation_test_pattern(0, pattern_size, print_control); + create_relation_test_pattern(1, pattern_size, print_control, false, true); + create_relation_test_pattern(2, pattern_size, print_control); + create_relation_test_pattern(4, pattern_size, print_control); + create_relation_test_pattern(5, pattern_size, print_control, true, false); + } + else if (pattern == augmented) + { + std::cout<<"\n"; + create_node_test_pattern(10.0, 11.0, 2.0, 3.0, 1, pattern_size, print_control); + create_node_test_pattern(10.0, 11.0, 3.0, 4.0, 2, pattern_size, print_control); + create_node_test_pattern(10.0, 11.0, 4.0, 5.0, 3, pattern_size, print_control); + create_node_test_pattern(10.0, 11.0, 5.0, 6.0, 4, pattern_size, print_control); + create_node_test_pattern(10.0, 11.0, 6.0, 7.0, 5, pattern_size, print_control); + create_node_test_pattern(10.0, 11.0, 6.0, 7.0, 6, pattern_size, print_control); + create_node_test_pattern(10.0, 11.0, 6.0, 7.0, 7, pattern_size, print_control); + create_node_test_pattern(10.0, 11.0, 6.0, 7.0, 8, pattern_size, print_control); + std::cout<<"\n"; + std::cout<<"\n"; + create_node(1, 10.0 + 0.5/pattern_size, 1.0 + 0.5/pattern_size, print_control); + std::cout<<"\n"; + std::cout<<"\n"; + create_node_test_pattern(10.0, 11.0, 2.0, 3.0, 1, pattern_size, print_control, true); + create_node_test_pattern(11.0, 12.0, 3.0, 4.0, 2, pattern_size, print_control); + create_node_test_pattern(10.0, 11.0, 5.0, 6.0, 4, pattern_size, print_control); + create_node_test_pattern(10.0, 11.0, 6.0, 7.0, 5, pattern_size, print_control); + std::cout<<"\n"; + + std::cout<<"\n"; + create_way_test_pattern(1, pattern_size, print_control); + create_way_test_pattern(3, pattern_size, print_control); + create_way_test_pattern(4, pattern_size, print_control); + std::cout<<"\n"; + std::cout<<"\n"; + create_way_test_pattern(2, pattern_size, print_control); + create_way_test_pattern(5, pattern_size, print_control); + create_way(pattern_size*pattern_size*6, + 1, pattern_size*pattern_size*2 + 1, pattern_size*pattern_size*2, print_control); + std::cout<<"\n"; + std::cout<<"\n"; + create_way_test_pattern(1, pattern_size, print_control, false, true); + create_way_test_pattern(4, pattern_size, print_control, true, false); + std::cout<<"\n"; + + std::cout<<"\n"; + create_relation_test_pattern(1, pattern_size, print_control); + create_relation_test_pattern(3, pattern_size, print_control); + create_relation_test_pattern(5, pattern_size, print_control); + std::cout<<"\n"; + std::cout<<"\n"; + create_relation_test_pattern(2, pattern_size, print_control); + create_relation_test_pattern(4, pattern_size, print_control); + std::cout<<"\n"; + std::cout<<"\n"; + create_relation_test_pattern(1, pattern_size, print_control, false, true); + create_relation_test_pattern(5, pattern_size, print_control, true, false); + std::cout<<"\n"; + } + + std::cout<<"\n\n"; +} diff --git a/src/overpass_api/osm-backend/node_updater.test.cc b/src/overpass_api/osm-backend/node_updater.test.cc new file mode 100644 index 000000000..bcb507ffd --- /dev/null +++ b/src/overpass_api/osm-backend/node_updater.test.cc @@ -0,0 +1,218 @@ +/** Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Roland Olbricht et al. + * + * This file is part of Overpass_API. + * + * Overpass_API is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Overpass_API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Overpass_API. If not, see . + */ + +#include +#include +#include +#include + +#include +#include +#include + +#include "../../expat/expat_justparse_interface.h" +#include "../../template_db/random_file.h" +#include "../../template_db/transaction.h" +#include "../core/settings.h" +#include "../frontend/output.h" +#include "node_updater.h" + + +/** + * Tests the library node_updater with a sample OSM file + */ + +Node_Updater* node_updater; +Node current_node; +//std::vector< std::pair< uint32, uint32 > > id_idxs; +std::ofstream* coord_source_out; +std::ofstream* tags_source_out; +Osm_Backend_Callback* callback; +uint32 DEBUG_nodes_count, DEBUG_update_count, DEBUG_nodes_8, DEBUG_nodes_64; + +uint32 osm_element_count; + +void start(const char *el, const char **attr) +{ + if (!strcmp(el, "tag")) + { + if (current_node.id.val() > 0) + { + std::string key(""), value(""); + for (unsigned int i(0); attr[i]; i += 2) + { + if (!strcmp(attr[i], "k")) + key = attr[i+1]; + if (!strcmp(attr[i], "v")) + value = attr[i+1]; + } + current_node.tags.push_back(std::make_pair(key, value)); + + *tags_source_out<set_node(current_node); + + if (osm_element_count >= 4*1024*1024) + { + callback->node_elapsed(current_node.id); + node_updater->update(callback, 0, true); + callback->parser_started(); + osm_element_count = 0; + } + + current_node.id = Node::Id_Type(); + } + ++osm_element_count; +} + +void cleanup_files(const File_Properties& file_properties, std::string db_dir, + bool cleanup_map) +{ +// remove((db_dir + file_properties.get_file_name_trunk() + +// file_properties.get_data_suffix() + +// file_properties.get_index_suffix()).c_str()); +// remove((db_dir + file_properties.get_file_name_trunk() + +// file_properties.get_data_suffix()).c_str()); +// if (cleanup_map) +// { +// remove((db_dir + file_properties.get_file_name_trunk() + +// file_properties.get_id_suffix()).c_str()); +// remove((db_dir + file_properties.get_file_name_trunk() + +// file_properties.get_id_suffix() + file_properties.get_index_suffix()).c_str()); +// } +} + +int main(int argc, char* args[]) +{ + std::string db_dir("./"); + + try + { + std::ofstream coord_db_out((db_dir + "coord_db.csv").c_str()); + std::ofstream tags_local_out((db_dir + "tags_local.csv").c_str()); + std::ofstream tags_global_out((db_dir + "tags_global.csv").c_str()); + { + Node_Updater node_updater_("./", Database_Meta_State::only_data); + node_updater = &node_updater_; + + coord_source_out = new std::ofstream((db_dir + "coord_source.csv").c_str()); + tags_source_out = new std::ofstream((db_dir + "tags_source.csv").c_str()); + + callback = get_verbatim_callback(); + + DEBUG_nodes_count = 0; + DEBUG_update_count = 0; + DEBUG_nodes_8 = 0; + DEBUG_nodes_64 = 0; + osm_element_count = 0; + //reading the main document + callback->parser_started(); + parse(stdin, start, end); + + callback->nodes_finished(); + node_updater->update(callback, 0, false); + + delete coord_source_out; + delete tags_source_out; + } + + // check update_node_ids +/* uint32 false_count(0); + Random_File< Uint32_Index > random(de_osm3s_file_ids::NODES, true); + for (std::vector< std::pair< uint32, uint32 > >::const_iterator it(id_idxs.begin()); + it != id_idxs.end(); ++it) + { + if (it->second != random.get(it->first).val()) + { + std::cout<first<<'\t'<second<<'\t' + <first).val()<<'\n'; + ++false_count; + } + } + std::cout<<'('< nodes_db + (transaction.data_index(osm_base_settings().NODES)); + for (Block_Backend< Uint32_Index, Node_Skeleton >::Flat_Iterator + it(nodes_db.flat_begin()); !(it == nodes_db.flat_end()); ++it) + { + coord_db_out< nodes_local_db + (transaction.data_index(osm_base_settings().NODE_TAGS_LOCAL)); + for (Block_Backend< Tag_Index_Local, Uint32_Index >::Flat_Iterator + it(nodes_local_db.flat_begin()); !(it == nodes_local_db.flat_end()); ++it) + { + tags_local_out< > nodes_global_db + (transaction.data_index(osm_base_settings().NODE_TAGS_GLOBAL)); + for (Block_Backend< Tag_Index_Global, Tag_Object_Global< Node_Skeleton::Id_Type > >::Flat_Iterator + it(nodes_global_db.flat_begin()); !(it == nodes_global_db.flat_end()); ++it) + { + tags_global_out<. + */ + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "../../expat/expat_justparse_interface.h" +#include "../../template_db/random_file.h" +#include "../core/settings.h" +#include "../frontend/output.h" +#include "node_updater.h" +#include "relation_updater.h" +#include "way_updater.h" + + +/** + * Tests the library relation_updater with a sample OSM file + */ + +Node_Updater* node_updater; +Node current_node; +Way_Updater* way_updater; +Way current_way; +Relation_Updater* relation_updater; +Relation current_relation; +int state; +const int IN_NODES = 1; +const int IN_WAYS = 2; +const int IN_RELATIONS = 3; +std::ofstream* member_source_out; +std::ofstream* tags_source_out; +Osm_Backend_Callback* callback; + +uint32 osm_element_count; + +void start(const char *el, const char **attr) +{ + if (!strcmp(el, "tag")) + { + std::string key(""), value(""); + for (unsigned int i(0); attr[i]; i += 2) + { + if (!strcmp(attr[i], "k")) + key = attr[i+1]; + if (!strcmp(attr[i], "v")) + value = attr[i+1]; + } + if (current_node.id.val() > 0) + current_node.tags.push_back(std::make_pair(key, value)); + else if (current_way.id.val() > 0) + current_way.tags.push_back(std::make_pair(key, value)); + else if (current_relation.id.val() > 0) + { + current_relation.tags.push_back(std::make_pair(key, value)); + *tags_source_out< 0) + { + unsigned int ref(0); + for (unsigned int i(0); attr[i]; i += 2) + { + if (!strcmp(attr[i], "ref")) + ref = atoll(attr[i+1]); + } + current_way.nds.push_back(ref); + } + } + else if (!strcmp(el, "member")) + { + if (current_relation.id.val() > 0) + { + unsigned int ref(0); + std::string type, role; + for (unsigned int i(0); attr[i]; i += 2) + { + if (!strcmp(attr[i], "ref")) + ref = atoll(attr[i+1]); + if (!strcmp(attr[i], "type")) + type = attr[i+1]; + if (!strcmp(attr[i], "role")) + role = attr[i+1]; + } + Relation_Entry entry; + entry.ref = ref; + if (type == "node") + entry.type = Relation_Entry::NODE; + else if (type == "way") + entry.type = Relation_Entry::WAY; + else if (type == "relation") + entry.type = Relation_Entry::RELATION; + entry.role = relation_updater->get_role_id(role); + current_relation.members.push_back(entry); + + *member_source_out<nodes_finished(); + node_updater->update(callback, 0, false); + callback->parser_started(); + osm_element_count = 0; + state = IN_WAYS; + } + + unsigned int id(0); + for (unsigned int i(0); attr[i]; i += 2) + { + if (!strcmp(attr[i], "id")) + id = atoll(attr[i+1]); + } + current_way = Way(id); + } + else if (!strcmp(el, "relation")) + { + if (state == IN_NODES) + { + callback->nodes_finished(); + node_updater->update(callback, 0, false); + callback->parser_started(); + osm_element_count = 0; + state = IN_RELATIONS; + } + else if (state == IN_WAYS) + { + callback->ways_finished(); + way_updater->update(callback, 0, false, + node_updater->get_new_skeletons(), node_updater->get_attic_skeletons(), + node_updater->get_new_attic_skeletons()); + callback->parser_started(); + osm_element_count = 0; + state = IN_RELATIONS; + } + + unsigned int id(0); + for (unsigned int i(0); attr[i]; i += 2) + { + if (!strcmp(attr[i], "id")) + id = atoll(attr[i+1]); + } + current_relation = Relation(id); + + *member_source_out<set_node(current_node); + + if (osm_element_count >= 4*1024*1024) + { + callback->node_elapsed(current_node.id); + node_updater->update(callback, 0, true); + callback->parser_started(); + osm_element_count = 0; + } + current_node.id = Node::Id_Type(); + } + else if (!strcmp(el, "way")) + { + way_updater->set_way(current_way); + + if (osm_element_count >= 4*1024*1024) + { + callback->way_elapsed(current_way.id); + way_updater->update(callback, 0, false, + node_updater->get_new_skeletons(), node_updater->get_attic_skeletons(), + node_updater->get_new_attic_skeletons()); + callback->parser_started(); + osm_element_count = 0; + } + current_way.id = 0u; + } + else if (!strcmp(el, "relation")) + { + relation_updater->set_relation(current_relation); + + *member_source_out<<'\n'; + + if (osm_element_count >= 4*1024*1024) + { + callback->relation_elapsed(current_relation.id); + relation_updater->update(callback, 0, + node_updater->get_new_skeletons(), node_updater->get_attic_skeletons(), + node_updater->get_new_attic_skeletons(), + way_updater->get_new_skeletons(), way_updater->get_attic_skeletons(), + way_updater->get_new_attic_skeletons()); + callback->parser_started(); + osm_element_count = 0; + } + current_relation.id = 0u; + } + ++osm_element_count; +} + +void cleanup_files(const File_Properties& file_properties, std::string db_dir, + bool cleanup_map) +{ + remove((db_dir + file_properties.get_file_name_trunk() + + file_properties.get_data_suffix() + file_properties.get_index_suffix()).c_str()); + remove((db_dir + file_properties.get_file_name_trunk() + + file_properties.get_data_suffix()).c_str()); + if (cleanup_map) + { + remove((db_dir + file_properties.get_file_name_trunk() + + file_properties.get_id_suffix()).c_str()); + remove((db_dir + file_properties.get_file_name_trunk() + + file_properties.get_id_suffix() + file_properties.get_index_suffix()).c_str()); + } +} + +int main(int argc, char* args[]) +{ + std::string db_dir("./"); + + try + { + std::ofstream member_db_out((db_dir + "member_db.csv").c_str()); + std::ofstream tags_local_out((db_dir + "tags_local.csv").c_str()); + std::ofstream tags_global_out((db_dir + "tags_global.csv").c_str()); + { + Node_Updater node_updater_("./", Database_Meta_State::only_data); + node_updater = &node_updater_; + Way_Updater way_updater_("./", Database_Meta_State::only_data); + way_updater = &way_updater_; + Relation_Updater relation_updater_("./", Database_Meta_State::only_data); + relation_updater = &relation_updater_; + + member_source_out = new std::ofstream((db_dir + "member_source.csv").c_str()); + tags_source_out = new std::ofstream((db_dir + "tags_source.csv").c_str()); + + callback = get_verbatim_callback(); + + osm_element_count = 0; + state = 0; + //reading the main document + callback->parser_started(); + parse(stdin, start, end); + + if (state == IN_NODES) + { + callback->nodes_finished(); + node_updater->update(callback, 0, false); + } + else if (state == IN_WAYS) + { + callback->ways_finished(); + way_updater->update(callback, 0, false, + node_updater->get_new_skeletons(), node_updater->get_attic_skeletons(), + node_updater->get_new_attic_skeletons()); + } + else if (state == IN_RELATIONS) + { + callback->relations_finished(); + relation_updater->update(callback, 0, + node_updater->get_new_skeletons(), node_updater->get_attic_skeletons(), + node_updater->get_new_attic_skeletons(), + way_updater->get_new_skeletons(), way_updater->get_attic_skeletons(), + way_updater->get_new_attic_skeletons()); + } + + delete member_source_out; + delete tags_source_out; + } + + Nonsynced_Transaction transaction(Access_Mode::readonly, false, "./", ""); + + // prepare check update_members - load roles + std::map< uint32, std::string > roles; + Block_Backend< Uint32_Index, String_Object > roles_db + (transaction.data_index(osm_base_settings().RELATION_ROLES)); + for (Block_Backend< Uint32_Index, String_Object >::Flat_Iterator + it(roles_db.flat_begin()); !(it == roles_db.flat_end()); ++it) + roles[it.index().val()] = it.object().val(); + + // check update_members - compare both files for the result + Block_Backend< Uint31_Index, Relation_Skeleton > relations_db + (transaction.data_index(osm_base_settings().RELATIONS)); + for (Block_Backend< Uint31_Index, Relation_Skeleton >::Flat_Iterator + it(relations_db.flat_begin()); !(it == relations_db.flat_end()); ++it) + { + member_db_out< relations_local_db + (transaction.data_index(osm_base_settings().RELATION_TAGS_LOCAL)); + for (Block_Backend< Tag_Index_Local, Uint32_Index >::Flat_Iterator + it(relations_local_db.flat_begin()); + !(it == relations_local_db.flat_end()); ++it) + { + tags_local_out< > relations_global_db + (transaction.data_index(osm_base_settings().RELATION_TAGS_GLOBAL)); + for (Block_Backend< Tag_Index_Global, Tag_Object_Global< Relation_Skeleton::Id_Type > >::Flat_Iterator + it(relations_global_db.flat_begin()); + !(it == relations_global_db.flat_end()); ++it) + { + tags_global_out<. + */ + +#include +#include +#include +#include + +#include + +#include "../../expat/expat_justparse_interface.h" +#include "../../template_db/random_file.h" +#include "../core/settings.h" +#include "../frontend/output.h" +#include "node_updater.h" +#include "way_updater.h" + + +/** + * Tests the library way_updater with a sample OSM file + */ + +Node_Updater* node_updater; +Node current_node; +Way_Updater* way_updater; +Way current_way; +int state; +const int IN_NODES = 1; +const int IN_WAYS = 2; +std::ofstream* member_source_out; +std::ofstream* tags_source_out; +Osm_Backend_Callback* callback; + +uint32 osm_element_count; + +void start(const char *el, const char **attr) +{ + if (!strcmp(el, "tag")) + { + std::string key(""), value(""); + for (unsigned int i(0); attr[i]; i += 2) + { + if (!strcmp(attr[i], "k")) + key = attr[i+1]; + if (!strcmp(attr[i], "v")) + value = attr[i+1]; + } + if (current_node.id.val() > 0) + current_node.tags.push_back(std::make_pair(key, value)); + else if (current_way.id.val() > 0) + { + current_way.tags.push_back(std::make_pair(key, value)); + + *tags_source_out< 0) + { + unsigned int ref(0); + for (unsigned int i(0); attr[i]; i += 2) + { + if (!strcmp(attr[i], "ref")) + ref = atoll(attr[i+1]); + } + current_way.nds.push_back(ref); + + *member_source_out<nodes_finished(); + node_updater->update(callback, 0, false); + callback->parser_started(); + osm_element_count = 0; + state = IN_WAYS; + } + + unsigned int id(0); + for (unsigned int i(0); attr[i]; i += 2) + { + if (!strcmp(attr[i], "id")) + id = atoll(attr[i+1]); + } + current_way = Way(id); + + *member_source_out<set_node(current_node); + + if (osm_element_count >= 4*1024*1024) + { + callback->node_elapsed(current_node.id); + node_updater->update(callback, 0, true); + callback->parser_started(); + osm_element_count = 0; + } + current_node.id = Node::Id_Type(); + } + else if (!strcmp(el, "way")) + { + way_updater->set_way(current_way); + + *member_source_out<<'\n'; + + if (osm_element_count >= 4*1024*1024) + { + callback->way_elapsed(current_way.id); + way_updater->update(callback, 0, true, + node_updater->get_new_skeletons(), node_updater->get_attic_skeletons(), + node_updater->get_new_attic_skeletons()); + callback->parser_started(); + osm_element_count = 0; + } + current_way.id = 0u; + } + ++osm_element_count; +} + +void cleanup_files(const File_Properties& file_properties, std::string db_dir, + bool cleanup_map) +{ + remove((db_dir + file_properties.get_file_name_trunk() + + file_properties.get_data_suffix() + file_properties.get_index_suffix()).c_str()); + remove((db_dir + file_properties.get_file_name_trunk() + + file_properties.get_data_suffix()).c_str()); + + if (cleanup_map) + { + remove((db_dir + file_properties.get_file_name_trunk() + + file_properties.get_id_suffix()).c_str()); + remove((db_dir + file_properties.get_file_name_trunk() + + file_properties.get_id_suffix() + file_properties.get_index_suffix()).c_str()); + } +} + +int main(int argc, char* args[]) +{ + std::string db_dir("./"); + + try + { + std::ofstream member_db_out((db_dir + "member_db.csv").c_str()); + std::ofstream tags_local_out((db_dir + "tags_local.csv").c_str()); + std::ofstream tags_global_out((db_dir + "tags_global.csv").c_str()); + { + Node_Updater node_updater_("./", Database_Meta_State::only_data); + node_updater = &node_updater_; + Way_Updater way_updater_("./", Database_Meta_State::only_data); + way_updater = &way_updater_; + + member_source_out = new std::ofstream((db_dir + "member_source.csv").c_str()); + tags_source_out = new std::ofstream((db_dir + "tags_source.csv").c_str()); + callback = get_verbatim_callback(); + + osm_element_count = 0; + state = 0; + //reading the main document + callback->parser_started(); + parse(stdin, start, end); + + if (state == IN_NODES) + { + callback->nodes_finished(); + node_updater->update(callback, 0, false); + } + else if (state == IN_WAYS) + { + callback->ways_finished(); + way_updater->update(callback, 0, false, + node_updater->get_new_skeletons(), node_updater->get_attic_skeletons(), + node_updater->get_new_attic_skeletons()); + } + + delete member_source_out; + delete tags_source_out; + } + + Nonsynced_Transaction transaction(Access_Mode::readonly, false, "./", ""); + + // check update_members - compare both files for the result + Block_Backend< Uint31_Index, Way_Skeleton > ways_db + (transaction.data_index(osm_base_settings().WAYS)); + for (Block_Backend< Uint31_Index, Way_Skeleton >::Flat_Iterator + it(ways_db.flat_begin()); !(it == ways_db.flat_end()); ++it) + { + member_db_out< ways_local_db + (transaction.data_index(osm_base_settings().WAY_TAGS_LOCAL)); + for (Block_Backend< Tag_Index_Local, Uint32_Index >::Flat_Iterator + it(ways_local_db.flat_begin()); !(it == ways_local_db.flat_end()); ++it) + { + tags_local_out< > ways_global_db + (transaction.data_index(osm_base_settings().WAY_TAGS_GLOBAL)); + for (Block_Backend< Tag_Index_Global, Tag_Object_Global< Way_Skeleton::Id_Type > >::Flat_Iterator + it(ways_global_db.flat_begin()); !(it == ways_global_db.flat_end()); ++it) + { + tags_global_out<. + */ + +#include +#include +#include "../../template_db/block_backend.h" +#include "../core/index_computations.h" +#include "../core/settings.h" +#include "../frontend/console_output.h" +#include "area_query.h" +#include "bbox_query.h" +#include "coord_query.h" +#include "print.h" +#include "query.h" +#include "union.h" + + +void draw_item(std::vector< std::string >& visual, uint32 index, const Node_Skeleton& node, char c) +{ + uint i(::lat(index, node.ll_lower) * 2000 - 102315); + uint j(::lon(index, node.ll_lower) * 2500 - 17495); + if ((visual[i][j] != '.') && (visual[i][j] != c)) + visual[i][j] = '#'; + else + visual[i][j] = c; +} + +void comp_sets(Resource_Manager& rman, const std::string& set_1, const std::string& set_2) +{ + Set s1; + rman.swap_set(set_1, s1); + Set s2; + rman.swap_set(set_2, s2); + + std::map< Uint32_Index, std::vector< Node_Skeleton > >::iterator it1(s1.nodes.begin()); + std::map< Uint32_Index, std::vector< Node_Skeleton > >::iterator it2(s2.nodes.begin()); + std::vector< std::string > visual(600, std::string(1000, '.')); + + while ((it1 != s1.nodes.end()) && (it2 != s2.nodes.end())) + { + if (it1->first == it2->first) + { + std::sort(it1->second.begin(), it1->second.end()); + std::sort(it2->second.begin(), it2->second.end()); + + std::vector< Node_Skeleton >::const_iterator itn1(it1->second.begin()); + std::vector< Node_Skeleton >::const_iterator itn2(it2->second.begin()); + + while ((itn1 != it1->second.end()) && (itn2 != it2->second.end())) + { + if (itn1->id == itn2->id) + { + //draw_item(visual, it1->first.val(), *itn1, ':'); + ++itn1; + ++itn2; + } + else if (itn1->id < itn2->id) + { + std::cout<<"a\t"<id.val()<<'\t' + <<::lat(it1->first.val(), itn1->ll_lower)<<'\t' + <<::lon(it1->first.val(), itn1->ll_lower)<<'\n'; + draw_item(visual, it1->first.val(), *itn1, 'a'); + ++itn1; + } + else + { + std::cout<<"b\t"<id.val()<<'\t' + <<::lat(it2->first.val(), itn2->ll_lower)<<'\t' + <<::lon(it2->first.val(), itn2->ll_lower)<<'\n'; + draw_item(visual, it2->first.val(), *itn2, 'b'); + ++itn2; + } + } + while (itn1 != it1->second.end()) + { + std::cout<<"a\t"<id.val()<<'\t' + <<::lat(it1->first.val(), itn1->ll_lower)<<'\t' + <<::lon(it1->first.val(), itn1->ll_lower)<<'\n'; + draw_item(visual, it1->first.val(), *itn1, 'a'); + ++itn1; + } + while (itn2 != it2->second.end()) + { + std::cout<<"b\t"<id.val()<<'\t' + <<::lat(it2->first.val(), itn2->ll_lower)<<'\t' + <<::lon(it2->first.val(), itn2->ll_lower)<<'\n'; + draw_item(visual, it2->first.val(), *itn2, 'b'); + ++itn2; + } + + ++it1; + ++it2; + } + else if (it1->first < it2->first) + { + for (std::vector< Node_Skeleton >::const_iterator it(it1->second.begin()); + it != it1->second.end(); ++it) + { + std::cout<<"a\t"<id.val()<<'\t' + <<::lat(it1->first.val(), it->ll_lower)<<'\t' + <<::lon(it1->first.val(), it->ll_lower)<<'\n'; + draw_item(visual, it1->first.val(), *it, 'a'); + } + ++it1; + } + else + { + for (std::vector< Node_Skeleton >::const_iterator it(it2->second.begin()); + it != it2->second.end(); ++it) + { + std::cout<<"b\t"<id.val()<<'\t' + <<::lat(it2->first.val(), it->ll_lower)<<'\t' + <<::lon(it2->first.val(), it->ll_lower)<<'\n'; + draw_item(visual, it2->first.val(), *it, 'b'); + } + ++it2; + } + } + while (it1 != s1.nodes.end()) + { + for (std::vector< Node_Skeleton >::const_iterator it(it1->second.begin()); + it != it1->second.end(); ++it) + { + std::cout<<"a\t"<id.val()<<'\t' + <<::lat(it1->first.val(), it->ll_lower)<<'\t' + <<::lon(it1->first.val(), it->ll_lower)<<'\n'; + draw_item(visual, it1->first.val(), *it, 'a'); + } + ++it1; + } + while (it2 != s2.nodes.end()) + { + for (std::vector< Node_Skeleton >::const_iterator it(it2->second.begin()); + it != it2->second.end(); ++it) + { + std::cout<<"b\t"<id.val()<<'\t' + <<::lat(it2->first.val(), it->ll_lower)<<'\t' + <<::lon(it2->first.val(), it->ll_lower)<<'\n'; + draw_item(visual, it2->first.val(), *it, 'b'); + } + ++it2; + } + + for (std::vector< std::string >::const_iterator it(visual.begin()); it != visual.end(); ++it) + std::cout<<*it<<'\n'; + + rman.swap_set(set_1, s1); + rman.swap_set(set_2, s2); +} + + +int main(int argc, char* args[]) +{ +// Great_Circle gc(Point_Double(51.25, 179.), Point_Double(51.5, -179.)); +// std::cout<<"gc "< segs; + + Error_Output* error_output(new Console_Output(false)); + Statement::set_error_output(error_output); + + Nonsynced_Transaction transaction(false, false, "./", ""); + Resource_Manager rman(transaction); + + Parsed_Query global_settings; + + { + const char* attributes[] = { "into", "comp", 0 }; + Union_Statement* stmt1 = new Union_Statement(0, convert_c_pairs(attributes), global_settings); + { + const char* attributes[] = { "s", "51.1675", "n", "51.1725", "w", "7.134", "e", "7.138", 0 }; + Bbox_Query_Statement* stmt2 = new Bbox_Query_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->add_statement(stmt2, ""); + } + { + const char* attributes[] = { "s", "51.1725", "n", "51.1775", "w", "7.126", "e", "7.150", 0 }; + Bbox_Query_Statement* stmt2 = new Bbox_Query_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->add_statement(stmt2, ""); + } + { + const char* attributes[] = { "s", "51.1775", "n", "51.1825", "w", "7.126", "e", "7.150", 0 }; + Bbox_Query_Statement* stmt2 = new Bbox_Query_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->add_statement(stmt2, ""); + } + { + const char* attributes[] = { "s", "51.1825", "n", "51.1875", "w", "7.114", "e", "7.146", 0 }; + Bbox_Query_Statement* stmt2 = new Bbox_Query_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->add_statement(stmt2, ""); + } + { + const char* attributes[] = { "s", "51.1875", "n", "51.1925", "w", "7.110", "e", "7.142", 0 }; + Bbox_Query_Statement* stmt2 = new Bbox_Query_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->add_statement(stmt2, ""); + } + { + const char* attributes[] = { "s", "51.1925", "n", "51.1975", "w", "7.106", "e", "7.154", 0 }; + Bbox_Query_Statement* stmt2 = new Bbox_Query_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->add_statement(stmt2, ""); + } + { + const char* attributes[] = { "s", "51.1975", "n", "51.2025", "w", "7.106", "e", "7.158", 0 }; + Bbox_Query_Statement* stmt2 = new Bbox_Query_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->add_statement(stmt2, ""); + } + { + const char* attributes[] = { "s", "51.2025", "n", "51.2075", "w", "7.106", "e", "7.162", 0 }; + Bbox_Query_Statement* stmt2 = new Bbox_Query_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->add_statement(stmt2, ""); + } + { + const char* attributes[] = { "s", "51.2075", "n", "51.2125", "w", "7.046", "e", "7.050", 0 }; + Bbox_Query_Statement* stmt2 = new Bbox_Query_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->add_statement(stmt2, ""); + } + { + const char* attributes[] = { "s", "51.2075", "n", "51.2125", "w", "7.106", "e", "7.166", 0 }; + Bbox_Query_Statement* stmt2 = new Bbox_Query_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->add_statement(stmt2, ""); + } + { + const char* attributes[] = { "s", "51.2075", "n", "51.2125", "w", "7.266", "e", "7.302", 0 }; + Bbox_Query_Statement* stmt2 = new Bbox_Query_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->add_statement(stmt2, ""); + } + { + const char* attributes[] = { "s", "51.2125", "n", "51.2175", "w", "7.038", "e", "7.062", 0 }; + Bbox_Query_Statement* stmt2 = new Bbox_Query_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->add_statement(stmt2, ""); + } + { + const char* attributes[] = { "s", "51.2125", "n", "51.2175", "w", "7.102", "e", "7.206", 0 }; + Bbox_Query_Statement* stmt2 = new Bbox_Query_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->add_statement(stmt2, ""); + } + { + const char* attributes[] = { "s", "51.2125", "n", "51.2175", "w", "7.262", "e", "7.298", 0 }; + Bbox_Query_Statement* stmt2 = new Bbox_Query_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->add_statement(stmt2, ""); + } + { + const char* attributes[] = { "s", "51.2175", "n", "51.2225", "w", "7.038", "e", "7.082", 0 }; + Bbox_Query_Statement* stmt2 = new Bbox_Query_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->add_statement(stmt2, ""); + } + { + const char* attributes[] = { "s", "51.2175", "n", "51.2225", "w", "7.094", "e", "7.218", 0 }; + Bbox_Query_Statement* stmt2 = new Bbox_Query_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->add_statement(stmt2, ""); + } + { + const char* attributes[] = { "s", "51.2175", "n", "51.2225", "w", "7.254", "e", "7.294", 0 }; + Bbox_Query_Statement* stmt2 = new Bbox_Query_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->add_statement(stmt2, ""); + } + { + const char* attributes[] = { "s", "51.2225", "n", "51.2275", "w", "7.042", "e", "7.234", 0 }; + Bbox_Query_Statement* stmt2 = new Bbox_Query_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->add_statement(stmt2, ""); + } + { + const char* attributes[] = { "s", "51.2225", "n", "51.2275", "w", "7.238", "e", "7.302", 0 }; + Bbox_Query_Statement* stmt2 = new Bbox_Query_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->add_statement(stmt2, ""); + } + { + const char* attributes[] = { "s", "51.2275", "n", "51.2325", "w", "7.042", "e", "7.046", 0 }; + Bbox_Query_Statement* stmt2 = new Bbox_Query_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->add_statement(stmt2, ""); + } + { + const char* attributes[] = { "s", "51.2275", "n", "51.2325", "w", "7.050", "e", "7.310", 0 }; + Bbox_Query_Statement* stmt2 = new Bbox_Query_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->add_statement(stmt2, ""); + } + { + const char* attributes[] = { "s", "51.2325", "n", "51.2375", "w", "7.038", "e", "7.310", 0 }; + Bbox_Query_Statement* stmt2 = new Bbox_Query_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->add_statement(stmt2, ""); + } + { + const char* attributes[] = { "s", "51.2375", "n", "51.2425", "w", "7.030", "e", "7.306", 0 }; + Bbox_Query_Statement* stmt2 = new Bbox_Query_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->add_statement(stmt2, ""); + } + { + const char* attributes[] = { "s", "51.2425", "n", "51.2475", "w", "7.014", "e", "7.298", 0 }; + Bbox_Query_Statement* stmt2 = new Bbox_Query_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->add_statement(stmt2, ""); + } + { + const char* attributes[] = { "s", "51.2475", "n", "51.2525", "w", "7.038", "e", "7.282", 0 }; + Bbox_Query_Statement* stmt2 = new Bbox_Query_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->add_statement(stmt2, ""); + } + { + const char* attributes[] = { "s", "51.2475", "n", "51.2525", "w", "7.290", "e", "7.306", 0 }; + Bbox_Query_Statement* stmt2 = new Bbox_Query_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->add_statement(stmt2, ""); + } + { + const char* attributes[] = { "s", "51.2525", "n", "51.2575", "w", "7.042", "e", "7.278", 0 }; + Bbox_Query_Statement* stmt2 = new Bbox_Query_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->add_statement(stmt2, ""); + } + { + const char* attributes[] = { "s", "51.2575", "n", "51.2625", "w", "7.062", "e", "7.266", 0 }; + Bbox_Query_Statement* stmt2 = new Bbox_Query_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->add_statement(stmt2, ""); + } + { + const char* attributes[] = { "s", "51.2625", "n", "51.2675", "w", "7.070", "e", "7.270", 0 }; + Bbox_Query_Statement* stmt2 = new Bbox_Query_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->add_statement(stmt2, ""); + } + { + const char* attributes[] = { "s", "51.2675", "n", "51.2725", "w", "7.074", "e", "7.274", 0 }; + Bbox_Query_Statement* stmt2 = new Bbox_Query_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->add_statement(stmt2, ""); + } + { + const char* attributes[] = { "s", "51.2725", "n", "51.2775", "w", "7.078", "e", "7.274", 0 }; + Bbox_Query_Statement* stmt2 = new Bbox_Query_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->add_statement(stmt2, ""); + } + { + const char* attributes[] = { "s", "51.2775", "n", "51.2825", "w", "7.082", "e", "7.270", 0 }; + Bbox_Query_Statement* stmt2 = new Bbox_Query_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->add_statement(stmt2, ""); + } + { + const char* attributes[] = { "s", "51.2825", "n", "51.2875", "w", "7.098", "e", "7.258", 0 }; + Bbox_Query_Statement* stmt2 = new Bbox_Query_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->add_statement(stmt2, ""); + } + { + const char* attributes[] = { "s", "51.2825", "n", "51.2875", "w", "7.262", "e", "7.266", 0 }; + Bbox_Query_Statement* stmt2 = new Bbox_Query_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->add_statement(stmt2, ""); + } + { + const char* attributes[] = { "s", "51.2875", "n", "51.2925", "w", "7.098", "e", "7.258", 0 }; + Bbox_Query_Statement* stmt2 = new Bbox_Query_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->add_statement(stmt2, ""); + } + { + const char* attributes[] = { "s", "51.2925", "n", "51.2975", "w", "7.098", "e", "7.194", 0 }; + Bbox_Query_Statement* stmt2 = new Bbox_Query_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->add_statement(stmt2, ""); + } + { + const char* attributes[] = { "s", "51.2925", "n", "51.2975", "w", "7.198", "e", "7.262", 0 }; + Bbox_Query_Statement* stmt2 = new Bbox_Query_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->add_statement(stmt2, ""); + } + { + const char* attributes[] = { "s", "51.2975", "n", "51.3025", "w", "7.102", "e", "7.174", 0 }; + Bbox_Query_Statement* stmt2 = new Bbox_Query_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->add_statement(stmt2, ""); + } + { + const char* attributes[] = { "s", "51.2975", "n", "51.3025", "w", "7.206", "e", "7.262", 0 }; + Bbox_Query_Statement* stmt2 = new Bbox_Query_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->add_statement(stmt2, ""); + } + { + const char* attributes[] = { "s", "51.3025", "n", "51.3075", "w", "7.130", "e", "7.182", 0 }; + Bbox_Query_Statement* stmt2 = new Bbox_Query_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->add_statement(stmt2, ""); + } + { + const char* attributes[] = { "s", "51.3025", "n", "51.3075", "w", "7.222", "e", "7.262", 0 }; + Bbox_Query_Statement* stmt2 = new Bbox_Query_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->add_statement(stmt2, ""); + } + { + const char* attributes[] = { "s", "51.3075", "n", "51.3125", "w", "7.162", "e", "7.174", 0 }; + Bbox_Query_Statement* stmt2 = new Bbox_Query_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->add_statement(stmt2, ""); + } + { + const char* attributes[] = { "s", "51.3075", "n", "51.3125", "w", "7.238", "e", "7.266", 0 }; + Bbox_Query_Statement* stmt2 = new Bbox_Query_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->add_statement(stmt2, ""); + } + { + const char* attributes[] = { "s", "51.3125", "n", "51.3175", "w", "7.254", "e", "7.266", 0 }; + Bbox_Query_Statement* stmt2 = new Bbox_Query_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->add_statement(stmt2, ""); + } + stmt1->execute(rman); + } + { + const char* attributes[] = { "ref", "3600062478", 0 }; + Area_Query_Statement* stmt1 = new Area_Query_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->execute(rman); + } + { + Print_Statement* stmt1 = new Print_Statement(0, convert_c_pairs(attributes), global_settings); + const char* attributes[] = { "mode", "ids_only", "from", "_", 0 }; + stmt1->set_attributes(attributes); + stmt1->execute(rman); + } + comp_sets(rman, "comp", "_"); + + { + const char* attributes[] = { "type", "node", "into", "comp", 0 }; + Query_Statement* stmt1 = new Query_Statement(0, convert_c_pairs(attributes), global_settings); + { + const char* attributes[] = { "k", "highway", "v", "bus_stop", 0 }; + Has_Kv_Statement* stmt2 = new Has_Kv_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->add_statement(stmt2, ""); + } + { + const char* attributes[] = { "ref", "3600062478", 0 }; + Area_Query_Statement* stmt2 = new Area_Query_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->add_statement(stmt2, ""); + } + stmt1->execute(rman); + } + comp_sets(rman, "comp", "_"); + + { + const char* attributes[] = { "type", "node", 0 }; + Query_Statement* stmt1 = new Query_Statement(0, convert_c_pairs(attributes), global_settings); + { + const char* attributes[] = { "k", "highway", "v", "bus_stop", 0 }; + Has_Kv_Statement* stmt2 = new Has_Kv_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->add_statement(stmt2, ""); + } + { + const char* attributes[] = { "s", "51.1675", "n", "51.3175", "w", "7.014", "e", "7.310", 0 }; + Bbox_Query_Statement* stmt2 = new Bbox_Query_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->add_statement(stmt2, ""); + } + stmt1->execute(rman); + } + comp_sets(rman, "comp", "_"); +*/ + + return 0; +} diff --git a/src/overpass_api/statements/around.test.cc b/src/overpass_api/statements/around.test.cc new file mode 100644 index 000000000..532aa034c --- /dev/null +++ b/src/overpass_api/statements/around.test.cc @@ -0,0 +1,225 @@ +/** Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Roland Olbricht et al. + * + * This file is part of Overpass_API. + * + * Overpass_API is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Overpass_API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Overpass_API. If not, see . + */ + +#include +#include +#include "../../template_db/block_backend.h" +#include "../core/settings.h" +#include "../output_formats/output_xml.h" +#include "around.h" +#include "binary_operators.h" +#include "filter.h" +#include "id_query.h" +#include "print.h" +#include "query.h" +#include "tag_value.h" +#include "testing_tools.h" +#include "union.h" + + + +void perform_around_print(uint pattern_size, std::string radius, uint64 global_node_offset, + Transaction& transaction) +{ + Parsed_Query global_settings; + global_settings.set_output_handler(Output_Handler_Parser::get_format_parser("xml"), 0, 0); + try + { + Resource_Manager rman(transaction, &global_settings); + Id_Query_Statement(0, Attr()("type", "node")("ref", to_string( + 2*pattern_size*pattern_size + 1 + global_node_offset)).kvs(), global_settings).execute(rman); + Around_Statement(0, Attr()("radius", radius).kvs(), global_settings).execute(rman); + Print_Statement(0, Attr()("order", "id").kvs(), global_settings).execute(rman); + } + catch (File_Error e) + { + std::cerr<<"File error caught: "<\n" + "\n"; + + if ((test_to_execute == "") || (test_to_execute == "1")) + perform_around_print(pattern_size, "20.01", global_node_offset, transaction); + if ((test_to_execute == "") || (test_to_execute == "2")) + perform_around_print(pattern_size, "200.1", global_node_offset, transaction); + if ((test_to_execute == "") || (test_to_execute == "3")) + perform_around_print(pattern_size, "2001", global_node_offset, transaction); + if ((test_to_execute == "") || (test_to_execute == "4")) + { + Resource_Manager rman(transaction, &global_settings); + Id_Query_Statement(0, Attr()("type", "node")("into", "foo")("ref", to_string( + 2*pattern_size*pattern_size + 1 + global_node_offset)).kvs(), global_settings).execute(rman); + Around_Statement(0, Attr()("radius", "200.1")("from", "foo").kvs(), global_settings).execute(rman); + Print_Statement(0, Attr()("order", "id").kvs(), global_settings).execute(rman); + } + if ((test_to_execute == "") || (test_to_execute == "5")) + { + Resource_Manager rman(transaction, &global_settings); + Id_Query_Statement(0, Attr()("type", "node")("ref", to_string( + 2*pattern_size*pattern_size + 1 + global_node_offset)).kvs(), global_settings).execute(rman); + Around_Statement(0, Attr()("radius", "200.1")("into", "foo").kvs(), global_settings).execute(rman); + Print_Statement(0, Attr()("order", "id")("from", "foo").kvs(), global_settings).execute(rman); + } + if ((test_to_execute == "") || (test_to_execute == "6")) + { + Resource_Manager rman(transaction, &global_settings); + Statement_Container stmt_cont(global_settings); + { + Union_Statement stmt1(0, Attr().kvs(), global_settings); + stmt_cont.add_stmt(new Id_Query_Statement(0, Attr()("type", "node")("ref", to_string( + 2*pattern_size*pattern_size + 1 + global_node_offset)).kvs(), global_settings), &stmt1); + stmt_cont.add_stmt(new Id_Query_Statement(0, Attr()("type", "node")("ref", to_string( + 3*pattern_size*pattern_size + global_node_offset)).kvs(), global_settings), &stmt1); + stmt1.execute(rman); + } + Around_Statement(0, Attr()("radius", "200.1").kvs(), global_settings).execute(rman); + Print_Statement(0, Attr()("order", "id").kvs(), global_settings).execute(rman); + } + + if ((test_to_execute == "") || (test_to_execute == "7")) + perform_coord_print(pattern_size, "20.01", global_node_offset, transaction); + if ((test_to_execute == "") || (test_to_execute == "8")) + perform_coord_print(pattern_size, "200.1", global_node_offset, transaction); + if ((test_to_execute == "") || (test_to_execute == "9")) + perform_coord_print(pattern_size, "2001", global_node_offset, transaction); + if ((test_to_execute == "") || (test_to_execute == "10")) + perform_polyline_print(pattern_size, "51.1,6.9,50.9,7.1", global_node_offset, transaction); + if ((test_to_execute == "") || (test_to_execute == "11")) + perform_polyline_print(pattern_size, "51.,7.,50.9,6.9", global_node_offset, transaction); + if ((test_to_execute == "") || (test_to_execute == "12")) + perform_polyline_print(pattern_size, "50.95,6.9,51.,7.,50.9,6.95", global_node_offset, transaction); + if ((test_to_execute == "") || (test_to_execute == "13")) + perform_polyline_print(pattern_size, "50.9,6.9,51.,7.", global_node_offset, transaction); + if ((test_to_execute == "") || (test_to_execute == "14")) + perform_polyline_print(pattern_size, "51.1,6.9,50.9,7.1,50.8,7.1,50.7,7.05", global_node_offset, transaction); + if ((test_to_execute == "") || (test_to_execute == "15")) + perform_polyline_print(pattern_size, "51.1,6.8,51.1,6.9,50.9,7.1,50.8,7.1", global_node_offset, transaction); + if ((test_to_execute == "") || (test_to_execute == "16")) + perform_polyline_print(pattern_size, "51.05,6.7,51.1,6.8,51.1,6.9,50.9,7.1", global_node_offset, transaction); + if ((test_to_execute == "") || (test_to_execute == "17")) + perform_polyline_in_query_print(pattern_size, to_string(200000./pattern_size), "way", "51.1,6.9,50.9,7.1", + global_node_offset, transaction); + if ((test_to_execute == "") || (test_to_execute == "18")) + perform_polyline_in_query_print(pattern_size, to_string(200000./pattern_size), "relation", "51.1,6.9,50.9,7.1", + global_node_offset, transaction); + if ((test_to_execute == "") || (test_to_execute == "19")) + perform_polyline_in_query_print(pattern_size, "0.", "way", + to_string(51.+1./pattern_size) + "," + to_string(7.+1./pattern_size) + "," + + to_string(51.+2./pattern_size) + "," + to_string(7.+1./pattern_size), + global_node_offset, transaction); + + std::cout<<"\n"; + return 0; +} diff --git a/src/overpass_api/statements/bbox_query.test.cc b/src/overpass_api/statements/bbox_query.test.cc new file mode 100644 index 000000000..234518d6d --- /dev/null +++ b/src/overpass_api/statements/bbox_query.test.cc @@ -0,0 +1,102 @@ +/** Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Roland Olbricht et al. + * + * This file is part of Overpass_API. + * + * Overpass_API is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Overpass_API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Overpass_API. If not, see . + */ + +#include +#include +#include +#include "../../template_db/block_backend.h" +#include "../core/settings.h" +#include "../output_formats/output_xml.h" +#include "bbox_query.h" +#include "print.h" + + +void perform_bbox_print(std::string south, std::string north, std::string west, std::string east, + Transaction& transaction) +{ + Parsed_Query global_settings; + global_settings.set_output_handler(Output_Handler_Parser::get_format_parser("xml"), 0, 0); + try + { + // Select a bbox from the testset that contains one quarter + // of only one bbox. + Resource_Manager rman(transaction, &global_settings); + Bbox_Query_Statement( + 0, { { "s", south }, { "n", north }, { "w", west }, { "e", east } }, global_settings).execute(rman); + Print_Statement(0, { { "mode", "body" }, { "order", "id" } }, global_settings).execute(rman); + } + catch (File_Error e) + { + std::cerr<<"File error caught: " + <\n" + "\n"; + + if ((test_to_execute == "") || (test_to_execute == "1")) + perform_bbox_print("-10.0", "8.0", "-15.0", "9.0", transaction); + if ((test_to_execute == "") || (test_to_execute == "2")) + perform_bbox_print("-10.0", "-1.0", "-15.0", "-3.0", transaction); + if ((test_to_execute == "") || (test_to_execute == "3")) + perform_bbox_print("-10.0", "-1.0", "93.0", "105.0", transaction); + if ((test_to_execute == "") || (test_to_execute == "4")) + perform_bbox_print("-10.0", "-1.0", "93.0", "-3.0", transaction); + if ((test_to_execute == "") || (test_to_execute == "5")) + perform_bbox_print("-10.0", "-1.0", "-15.0", "-15.0", transaction); + if ((test_to_execute == "") || (test_to_execute == "6")) + { + double lon_offset = (105.0-(-15.0))/pattern_size/2; + std::ostringstream west_ss; + west_ss<\n"; + return 0; +} + +// Test cases are: +// - bbox with positive lon, with negative lon, both, lon wrap +// ew line, ns line, point diff --git a/src/overpass_api/statements/complete.test.cc b/src/overpass_api/statements/complete.test.cc new file mode 100644 index 000000000..a0f363ac6 --- /dev/null +++ b/src/overpass_api/statements/complete.test.cc @@ -0,0 +1,363 @@ +/** Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Roland Olbricht et al. + * + * This file is part of Overpass_API. + * + * Overpass_API is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Overpass_API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Overpass_API. If not, see . + */ + +#include +#include +#include "../../template_db/block_backend.h" +#include "../core/settings.h" +#include "../output_formats/output_xml.h" +#include "bbox_query.h" +#include "complete.h" +#include "id_query.h" +#include "item.h" +#include "print.h" +#include "query.h" +#include "recurse.h" +#include "union.h" + + +template< typename T > +std::string to_string_(T val) +{ + std::ostringstream buf; + buf<\n" + "\n"; + + if ((test_to_execute == "") || (test_to_execute == "1")) + { + // An empty complete must copy the input set to the output set + + try + { + { + Nonsynced_Transaction transaction(Access_Mode::readonly, false, args[3], ""); + Resource_Manager rman(transaction, &global_settings); + + fill_set_with_all_types(rman, global_node_offset, global_settings, "a"); + + { + const char* attributes[] = { "from", "a", "into", "b", 0 }; + Complete_Statement stmt(0, convert_c_pairs(attributes), global_settings); + stmt.execute(rman); + } + { + const char* attributes[] = { "from", "b", 0 }; + Print_Statement stmt(0, convert_c_pairs(attributes), global_settings); + stmt.execute(rman); + } + } + } + catch (File_Error e) + { + std::cerr<<"File error caught: " + <\n"; + return 0; +} diff --git a/src/overpass_api/statements/convert.test.cc b/src/overpass_api/statements/convert.test.cc new file mode 100644 index 000000000..c096e543d --- /dev/null +++ b/src/overpass_api/statements/convert.test.cc @@ -0,0 +1,528 @@ +/** Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Roland Olbricht et al. + * + * This file is part of Overpass_API. + * + * Overpass_API is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Overpass_API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Overpass_API. If not, see . + */ + +#include "../data/utils.h" +#include "aggregators.h" +#include "binary_operators.h" +#include "id_query.h" +#include "convert.h" +#include "explicit_geometry.h" +#include "geometry_endomorphisms.h" +#include "item_geometry.h" +#include "make.h" +#include "per_member.h" +#include "print.h" +#include "set_prop.h" +#include "tag_value.h" +#include "testing_tools.h" +#include "union.h" + + +void prepare_value_test(Parsed_Query& global_settings, Resource_Manager& rman, + std::string from, uint64 ref1, uint64 ref2, std::string derived_num, uint64 global_node_offset) +{ + Union_Statement union_(0, (from == "_" ? Attr() : Attr()("into", from)).kvs(), global_settings); + + Id_Query_Statement stmt1(0, Attr()("type", "node")("ref", to_string(ref1 + global_node_offset)).kvs(), + global_settings); + union_.add_statement(&stmt1, ""); + Id_Query_Statement stmt2(0, Attr()("type", "way")("ref", to_string(ref1)).kvs(), global_settings); + union_.add_statement(&stmt2, ""); + Id_Query_Statement stmt3(0, Attr()("type", "relation")("ref", to_string(ref1)).kvs(), global_settings); + union_.add_statement(&stmt3, ""); + + Id_Query_Statement stmt4(0, Attr()("type", "node")("ref", to_string(ref2 + global_node_offset)).kvs(), + global_settings); + if (ref1 != ref2) + union_.add_statement(&stmt4, ""); + + Make_Statement stmt5(0, Attr()("type", "derivee").kvs(), global_settings); + Set_Prop_Statement stmt50(0, Attr()("k", "number").kvs(), global_settings); + stmt5.add_statement(&stmt50, ""); + Evaluator_Fixed stmt500(0, Attr()("v", derived_num).kvs(), global_settings); + stmt50.add_statement(&stmt500, ""); + + if (derived_num != "") + union_.add_statement(&stmt5, ""); + + union_.execute(rman); +} + + +void prepare_relation_test(Parsed_Query& global_settings, Resource_Manager& rman, + std::string from, uint64 ref1, uint64 ref2, uint64 ref3, uint64 ref4) +{ + Union_Statement union_(0, (from == "_" ? Attr() : Attr()("into", from)).kvs(), global_settings); + + Id_Query_Statement stmt1(0, Attr()("type", "relation")("ref", to_string(ref1)).kvs(), global_settings); + union_.add_statement(&stmt1, ""); + Id_Query_Statement stmt2(0, Attr()("type", "relation")("ref", to_string(ref2)).kvs(), global_settings); + union_.add_statement(&stmt2, ""); + Id_Query_Statement stmt3(0, Attr()("type", "relation")("ref", to_string(ref3)).kvs(), global_settings); + union_.add_statement(&stmt3, ""); + Id_Query_Statement stmt4(0, Attr()("type", "relation")("ref", to_string(ref4)).kvs(), global_settings); + union_.add_statement(&stmt4, ""); + + union_.execute(rman); +} + + +void just_copy_test(Parsed_Query& global_settings, Transaction& transaction, + std::string type, std::string from, uint64 ref1, uint64 ref2, std::string derived_num, uint64 global_node_offset) +{ + Resource_Manager rman(transaction, &global_settings); + prepare_value_test(global_settings, rman, from, ref1, ref2, derived_num, global_node_offset); + + Convert_Statement stmt(0, Attr()("from", from)("type", type).kvs(), global_settings); + + Set_Prop_Statement stmt1(0, Attr()("keytype", "generic").kvs(), global_settings); + stmt.add_statement(&stmt1, ""); + Evaluator_Generic stmt10(0, Attr().kvs(), global_settings); + stmt1.add_statement(&stmt10, ""); + + stmt.execute(rman); + Print_Statement(0, Attr().kvs(), global_settings).execute(rman); +} + + +void into_test(Parsed_Query& global_settings, Transaction& transaction, + std::string type, std::string into, uint64 global_node_offset) +{ + Resource_Manager rman(transaction, &global_settings); + prepare_value_test(global_settings, rman, "_", 7, 14, "1000", global_node_offset); + + Convert_Statement stmt(0, Attr()("type", type)("into", into).kvs(), global_settings); + + Set_Prop_Statement stmt1(0, Attr()("keytype", "generic").kvs(), global_settings); + stmt.add_statement(&stmt1, ""); + Evaluator_Generic stmt10(0, Attr().kvs(), global_settings); + stmt1.add_statement(&stmt10, ""); + + stmt.execute(rman); + Print_Statement(0, Attr()("from", into).kvs(), global_settings).execute(rman); +} + + +void tag_manipulation_test(Parsed_Query& global_settings, Transaction& transaction, + std::string type, std::string from, uint64 ref1, uint64 ref2, std::string derived_num, uint64 global_node_offset) +{ + Resource_Manager rman(transaction, &global_settings); + prepare_value_test(global_settings, rman, from, ref1, ref2, derived_num, global_node_offset); + + Convert_Statement stmt(0, Attr()("from", from)("type", type).kvs(), global_settings); + + Set_Prop_Statement stmt1(0, Attr()("keytype", "generic").kvs(), global_settings); + stmt.add_statement(&stmt1, ""); + Evaluator_Generic stmt10(0, Attr().kvs(), global_settings); + stmt1.add_statement(&stmt10, ""); + + Set_Prop_Statement stmt2(0, Attr()("k", "extra_key").kvs(), global_settings); + stmt.add_statement(&stmt2, ""); + Evaluator_Fixed stmt20(0, Attr()("v", "extra_value").kvs(), global_settings); + stmt2.add_statement(&stmt20, ""); + + Set_Prop_Statement stmt3(0, Attr()("k", "node_key").kvs(), global_settings); + stmt.add_statement(&stmt3, ""); + Set_Prop_Statement stmt4(0, Attr()("k", "number").kvs(), global_settings); + stmt.add_statement(&stmt4, ""); + + stmt.execute(rman); + Print_Statement(0, Attr().kvs(), global_settings).execute(rman); +} + + +void count_test(Parsed_Query& global_settings, Transaction& transaction, + std::string type, std::string from, uint64 ref, uint64 global_node_offset) +{ + Resource_Manager rman(transaction, &global_settings); + + { + std::map< std::string, std::string > attributes; + if (from != "_") + attributes["into"] = from; + Union_Statement union_(0, attributes, global_settings); + + attributes.clear(); + attributes["type"] = "node"; + attributes["ref"] = to_string(ref + global_node_offset); + Id_Query_Statement stmt1(0, attributes, global_settings); + union_.add_statement(&stmt1, ""); + + attributes.clear(); + attributes["type"] = "way"; + attributes["ref"] = to_string(ref); + Id_Query_Statement stmt2(0, attributes, global_settings); + union_.add_statement(&stmt2, ""); + + attributes.clear(); + attributes["type"] = "relation"; + attributes["ref"] = to_string(ref); + Id_Query_Statement stmt3(0, attributes, global_settings); + union_.add_statement(&stmt3, ""); + + union_.execute(rman); + } + + Convert_Statement stmt(0, Attr()("type", type).kvs(), global_settings); + + Set_Prop_Statement stmt1(0, Attr()("k", "nodes").kvs(), global_settings); + stmt.add_statement(&stmt1, ""); + Evaluator_Set_Count stmt10(0, (from == "_" ? Attr() : Attr()("from", from))("type", "nodes").kvs(), + global_settings); + stmt1.add_statement(&stmt10, ""); + + Set_Prop_Statement stmt2(0, Attr()("k", "ways").kvs(), global_settings); + stmt.add_statement(&stmt2, ""); + Evaluator_Set_Count stmt20(0, (from == "_" ? Attr() : Attr()("from", from))("type", "ways").kvs(), + global_settings); + stmt2.add_statement(&stmt20, ""); + + Set_Prop_Statement stmt3(0, Attr()("k", "relations").kvs(), global_settings); + stmt.add_statement(&stmt3, ""); + Evaluator_Set_Count stmt30(0, (from == "_" ? Attr() : Attr()("from", from))("type", "relations").kvs(), + global_settings); + stmt3.add_statement(&stmt30, ""); + + Set_Prop_Statement stmt4(0, Attr()("k", "tags").kvs(), global_settings); + stmt.add_statement(&stmt4, ""); + Evaluator_Properties_Count stmt40(0, (from == "_" ? Attr() : Attr()("from", from))("type", "tags").kvs(), + global_settings); + stmt4.add_statement(&stmt40, ""); + + Set_Prop_Statement stmt5(0, Attr()("k", "members").kvs(), global_settings); + stmt.add_statement(&stmt5, ""); + Evaluator_Properties_Count stmt50(0, (from == "_" ? Attr() : Attr()("from", from))("type", "members").kvs(), + global_settings); + stmt5.add_statement(&stmt50, ""); + + Set_Prop_Statement stmt6(0, Attr()("k", "distinct_members").kvs(), global_settings); + stmt.add_statement(&stmt6, ""); + Evaluator_Properties_Count stmt60(0, (from == "_" ? Attr() : Attr()("from", from)) + ("type", "distinct_members").kvs(), global_settings); + stmt6.add_statement(&stmt60, ""); + + Set_Prop_Statement stmt7(0, Attr()("k", "by_role").kvs(), global_settings); + stmt.add_statement(&stmt7, ""); + Evaluator_Properties_Count stmt70(0, (from == "_" ? Attr() : Attr()("from", from)) + ("type", "by_role")("role", "one").kvs(), global_settings); + stmt7.add_statement(&stmt70, ""); + + Set_Prop_Statement stmt8(0, Attr()("k", "distinct_by_role").kvs(), global_settings); + stmt.add_statement(&stmt8, ""); + Evaluator_Properties_Count stmt80(0, (from == "_" ? Attr() : Attr()("from", from)) + ("type", "distinct_by_role")("role", "one").kvs(), global_settings); + stmt8.add_statement(&stmt80, ""); + + Set_Prop_Statement stmt_10(0, Attr()("k", "members_with_type").kvs(), global_settings); + stmt.add_statement(&stmt_10, ""); + Evaluator_Properties_Count stmt_100(0, (from == "_" ? Attr() : Attr()("from", from)) + ("type", "members")("members_type", "nodes").kvs(), global_settings); + stmt_10.add_statement(&stmt_100, ""); + + Set_Prop_Statement stmt_11(0, Attr()("k", "distinct_members_with_type").kvs(), global_settings); + stmt.add_statement(&stmt_11, ""); + Evaluator_Properties_Count stmt_110(0, (from == "_" ? Attr() : Attr()("from", from)) + ("type", "distinct_members")("members_type", "nodes").kvs(), global_settings); + stmt_11.add_statement(&stmt_110, ""); + + Set_Prop_Statement stmt_12(0, Attr()("k", "by_role_with_type").kvs(), global_settings); + stmt.add_statement(&stmt_12, ""); + Evaluator_Properties_Count stmt_120(0, (from == "_" ? Attr() : Attr()("from", from)) + ("type", "by_role")("role", "one")("members_type", "nodes").kvs(), global_settings); + stmt_12.add_statement(&stmt_120, ""); + + Set_Prop_Statement stmt_13(0, Attr()("k", "distinct_by_role_with_type").kvs(), global_settings); + stmt.add_statement(&stmt_13, ""); + Evaluator_Properties_Count stmt_130(0, (from == "_" ? Attr() : Attr()("from", from)) + ("type", "distinct_by_role")("role", "one")("members_type", "nodes").kvs(), global_settings); + stmt_13.add_statement(&stmt_130, ""); + + stmt.execute(rman); + Print_Statement(0, Attr().kvs(), global_settings).execute(rman); +} + + +void is_tag_test(Parsed_Query& global_settings, Transaction& transaction, + std::string type, uint64 global_node_offset) +{ + Resource_Manager rman(transaction, &global_settings); + prepare_value_test(global_settings, rman, "_", 7, 14, "1000", global_node_offset); + + Convert_Statement stmt(0, Attr()("type", type).kvs(), global_settings); + + Set_Prop_Statement stmt1(0, Attr()("k", "node_key").kvs(), global_settings); + stmt.add_statement(&stmt1, ""); + Evaluator_Is_Tag stmt10(0, Attr()("k", "node_key").kvs(), global_settings); + stmt1.add_statement(&stmt10, ""); + Set_Prop_Statement stmt2(0, Attr()("k", "way_key").kvs(), global_settings); + stmt.add_statement(&stmt2, ""); + Evaluator_Is_Tag stmt20(0, Attr()("k", "way_key").kvs(), global_settings); + stmt2.add_statement(&stmt20, ""); + Set_Prop_Statement stmt3(0, Attr()("k", "relation_key").kvs(), global_settings); + stmt.add_statement(&stmt3, ""); + Evaluator_Is_Tag stmt30(0, Attr()("k", "relation_key").kvs(), global_settings); + stmt3.add_statement(&stmt30, ""); + Set_Prop_Statement stmt4(0, Attr()("k", "number").kvs(), global_settings); + stmt.add_statement(&stmt4, ""); + Evaluator_Is_Tag stmt40(0, Attr()("k", "number").kvs(), global_settings); + stmt4.add_statement(&stmt40, ""); + + stmt.execute(rman); + Print_Statement(0, Attr().kvs(), global_settings).execute(rman); +} + + +void lat_lon_test(Parsed_Query& global_settings, Transaction& transaction, + std::string type, uint64 global_node_offset) +{ + Resource_Manager rman(transaction, &global_settings); + prepare_value_test(global_settings, rman, "_", 7, 14, "1000", global_node_offset); + + Convert_Statement stmt1(0, Attr()("type", type).kvs(), global_settings); + + Set_Prop_Statement stmt11(0, Attr()("k", "lat").kvs(), global_settings); + stmt1.add_statement(&stmt11, ""); + Evaluator_Latitude stmt110(0, Attr().kvs(), global_settings); + stmt11.add_statement(&stmt110, ""); + Set_Prop_Statement stmt12(0, Attr()("k", "lon").kvs(), global_settings); + stmt1.add_statement(&stmt12, ""); + Evaluator_Longitude stmt120(0, Attr().kvs(), global_settings); + stmt12.add_statement(&stmt120, ""); + + stmt1.execute(rman); + Print_Statement(0, Attr().kvs(), global_settings).execute(rman); + + Make_Statement stmt2(0, Attr()("type", "derivee").kvs(), global_settings); + Set_Prop_Statement stmt20(0, Attr()("keytype", "geometry").kvs(), global_settings); + stmt2.add_statement(&stmt20, ""); + Evaluator_Point stmt200(0, Attr().kvs(), global_settings); + stmt20.add_statement(&stmt200, ""); + Evaluator_Fixed stmt2001(0, Attr()("v", "-15.0").kvs(), global_settings); + stmt200.add_statement(&stmt2001, ""); + Evaluator_Fixed stmt2002(0, Attr()("v", "5.55").kvs(), global_settings); + stmt200.add_statement(&stmt2002, ""); + stmt2.execute(rman); + + Convert_Statement stmt3(0, Attr()("type", type).kvs(), global_settings); + + Set_Prop_Statement stmt31(0, Attr()("k", "lat").kvs(), global_settings); + stmt3.add_statement(&stmt31, ""); + Evaluator_Latitude stmt310(0, Attr().kvs(), global_settings); + stmt31.add_statement(&stmt310, ""); + Set_Prop_Statement stmt32(0, Attr()("k", "lon").kvs(), global_settings); + stmt3.add_statement(&stmt32, ""); + Evaluator_Longitude stmt320(0, Attr().kvs(), global_settings); + stmt32.add_statement(&stmt320, ""); + + stmt3.execute(rman); + Print_Statement(0, Attr().kvs(), global_settings).execute(rman); +} + + +void per_member_test(Parsed_Query& global_settings, Transaction& transaction, + std::string type, uint64 global_node_offset) +{ + Resource_Manager rman(transaction, &global_settings); + prepare_value_test(global_settings, rman, "_", 10, 10, "1000", global_node_offset); + + Convert_Statement stmt1(0, Attr()("type", type).kvs(), global_settings); + + Set_Prop_Statement stmt11(0, Attr()("k", "ref").kvs(), global_settings); + stmt1.add_statement(&stmt11, ""); + Evaluator_Per_Member stmt110(0, Attr().kvs(), global_settings); + stmt11.add_statement(&stmt110, ""); + Evaluator_Ref stmt1100(0, Attr().kvs(), global_settings); + stmt110.add_statement(&stmt1100, ""); + + Set_Prop_Statement stmt12(0, Attr()("k", "refpos").kvs(), global_settings); + stmt1.add_statement(&stmt12, ""); + Evaluator_Per_Member stmt120(0, Attr().kvs(), global_settings); + stmt12.add_statement(&stmt120, ""); + Evaluator_Plus stmt1200(0, Attr().kvs(), global_settings); + stmt120.add_statement(&stmt1200, ""); + Evaluator_Plus stmt12001(0, Attr().kvs(), global_settings); + stmt1200.add_statement(&stmt12001, ""); + Evaluator_Pos stmt120011(0, Attr().kvs(), global_settings); + stmt12001.add_statement(&stmt120011, ""); + Evaluator_Fixed stmt120012(0, Attr()("v", ":").kvs(), global_settings); + stmt12001.add_statement(&stmt120012, ""); + Evaluator_Ref stmt12002(0, Attr().kvs(), global_settings); + stmt1200.add_statement(&stmt12002, ""); + + Set_Prop_Statement stmt13(0, Attr()("k", "full").kvs(), global_settings); + stmt1.add_statement(&stmt13, ""); + Evaluator_Per_Member stmt130(0, Attr().kvs(), global_settings); + stmt13.add_statement(&stmt130, ""); + Evaluator_Plus stmt1300(0, Attr().kvs(), global_settings); + stmt130.add_statement(&stmt1300, ""); + Evaluator_Plus stmt13001(0, Attr().kvs(), global_settings); + stmt1300.add_statement(&stmt13001, ""); + Evaluator_Plus stmt130011(0, Attr().kvs(), global_settings); + stmt13001.add_statement(&stmt130011, ""); + Evaluator_Plus stmt1300111(0, Attr().kvs(), global_settings); + stmt130011.add_statement(&stmt1300111, ""); + Evaluator_Membertype stmt13001111(0, Attr().kvs(), global_settings); + stmt1300111.add_statement(&stmt13001111, ""); + Evaluator_Fixed stmt13001112(0, Attr()("v", ",").kvs(), global_settings); + stmt1300111.add_statement(&stmt13001112, ""); + Evaluator_Ref stmt1300112(0, Attr().kvs(), global_settings); + stmt130011.add_statement(&stmt1300112, ""); + Evaluator_Fixed stmt130012(0, Attr()("v", ",").kvs(), global_settings); + stmt13001.add_statement(&stmt130012, ""); + Evaluator_Role stmt13002(0, Attr().kvs(), global_settings); + stmt1300.add_statement(&stmt13002, ""); + + Set_Prop_Statement stmt14(0, Attr()("k", "vertexrefpos").kvs(), global_settings); + stmt1.add_statement(&stmt14, ""); + Evaluator_Per_Vertex stmt140(0, Attr().kvs(), global_settings); + stmt14.add_statement(&stmt140, ""); + Evaluator_Plus stmt1400(0, Attr().kvs(), global_settings); + stmt140.add_statement(&stmt1400, ""); + Evaluator_Plus stmt14001(0, Attr().kvs(), global_settings); + stmt1400.add_statement(&stmt14001, ""); + Evaluator_Pos stmt140011(0, Attr().kvs(), global_settings); + stmt14001.add_statement(&stmt140011, ""); + Evaluator_Fixed stmt140012(0, Attr()("v", ":").kvs(), global_settings); + stmt14001.add_statement(&stmt140012, ""); + Evaluator_Ref stmt14002(0, Attr().kvs(), global_settings); + stmt1400.add_statement(&stmt14002, ""); + + stmt1.execute(rman); + Print_Statement(0, Attr().kvs(), global_settings).execute(rman); +} + + +void geom_test(Parsed_Query& global_settings, Transaction& transaction, + std::string type, uint64 global_node_offset) +{ + Resource_Manager rman(transaction, &global_settings); + prepare_value_test(global_settings, rman, "_", 8, 14, "1000", global_node_offset); + + Convert_Statement stmt(0, Attr()("type", type).kvs(), global_settings); + + Set_Prop_Statement stmt1(0, Attr()("keytype", "geometry").kvs(), global_settings); + stmt.add_statement(&stmt1, ""); + Evaluator_Geometry stmt10(0, Attr().kvs(), global_settings); + stmt1.add_statement(&stmt10, ""); + + stmt.execute(rman); + Print_Statement(0, Attr()("geometry", "full").kvs(), global_settings).execute(rman); +} + + +void trace_test_1(Parsed_Query& global_settings, Transaction& transaction, + std::string type, uint64 global_node_offset) +{ + Resource_Manager rman(transaction, &global_settings); + prepare_value_test(global_settings, rman, "_", 2, 3, "1000", global_node_offset); + + Convert_Statement stmt(0, Attr()("type", type).kvs(), global_settings); + + Set_Prop_Statement stmt1(0, Attr()("keytype", "geometry").kvs(), global_settings); + stmt.add_statement(&stmt1, ""); + Evaluator_Trace stmt10(0, Attr().kvs(), global_settings); + stmt1.add_statement(&stmt10, ""); + Evaluator_Geometry stmt100(0, Attr().kvs(), global_settings); + stmt10.add_statement(&stmt100, ""); + + stmt.execute(rman); + Print_Statement(0, Attr()("geometry", "full").kvs(), global_settings).execute(rman); +} + + +void trace_test_2(Parsed_Query& global_settings, Transaction& transaction, + std::string type, uint64 global_node_offset) +{ + Resource_Manager rman(transaction, &global_settings); + prepare_relation_test(global_settings, rman, "_", 2, 6, 9, 10); + + Convert_Statement stmt(0, Attr()("type", type).kvs(), global_settings); + + Set_Prop_Statement stmt1(0, Attr()("keytype", "geometry").kvs(), global_settings); + stmt.add_statement(&stmt1, ""); + Evaluator_Trace stmt10(0, Attr().kvs(), global_settings); + stmt1.add_statement(&stmt10, ""); + Evaluator_Geometry stmt100(0, Attr().kvs(), global_settings); + stmt10.add_statement(&stmt100, ""); + + stmt.execute(rman); + Print_Statement(0, Attr()("geometry", "full").kvs(), global_settings).execute(rman); +} + + +int main(int argc, char* args[]) +{ + if (argc < 5) + { + std::cout<<"Usage: "<\n" + "\n"; + + if ((test_to_execute == "") || (test_to_execute == "1")) + just_copy_test(global_settings, transaction, "just-copy", "_", 7, 14, "1000", global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "2")) + just_copy_test(global_settings, transaction, "just-copy", "_", 0, 0, "", global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "3")) + just_copy_test(global_settings, transaction, "just-copy", "some_set", 7, 14, "1000", global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "4")) + into_test(global_settings, transaction, "into", "_", global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "5")) + into_test(global_settings, transaction, "into", "some_set", global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "6")) + tag_manipulation_test(global_settings, transaction, "rewrite", "some_set", 7, 14, "1000", global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "7")) + count_test(global_settings, transaction, "count-from-default", "_", 1, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "8")) + is_tag_test(global_settings, transaction, "is-tag", global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "9")) + count_test(global_settings, transaction, "count-from-default", "_", 2, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "10")) + count_test(global_settings, transaction, "count-from-default", "_", 10, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "11")) + geom_test(global_settings, transaction, "geometry", global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "12")) + trace_test_1(global_settings, transaction, "trace", global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "13")) + trace_test_2(global_settings, transaction, "trace", global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "14")) + lat_lon_test(global_settings, transaction, "lat-lon", global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "15")) + per_member_test(global_settings, transaction, "per-member", global_node_offset); + + std::cout<<"\n"; + } + catch (File_Error e) + { + std::cerr<<"File error: "<. + */ + +#include +#include +#include "../../template_db/block_backend.h" +#include "../core/settings.h" +#include "../output_formats/output_xml.h" +#include "id_query.h" +#include "item.h" +#include "print.h" +#include "query.h" +#include "recurse.h" +#include "difference.h" + + +std::string to_string_(uint64 val) +{ + std::ostringstream buf; + buf<\n" + "\n"; + + if ((test_to_execute == "") || (test_to_execute == "1")) + { + // Test whether difference works well with an empty base std::set + try + { + { + Nonsynced_Transaction transaction(Access_Mode::readonly, false, args[2], ""); + Resource_Manager rman(transaction, &global_settings); + + const char* attributes[] = { 0 }; + Difference_Statement stmt(0, convert_c_pairs(attributes), global_settings); + + std::string buf = to_string_(size * size); + const char* attributes1[] = { "type", "node", "ref", buf.c_str(), 0 }; + Id_Query_Statement stmt1(0, convert_c_pairs(attributes1), global_settings); + stmt.add_statement(&stmt1, ""); + + buf = to_string_(2 + global_node_offset); + const char* attributes2[] = { "type", "node", "ref", buf.c_str(), 0 }; + Id_Query_Statement stmt2(0, convert_c_pairs(attributes2), global_settings); + stmt.add_statement(&stmt2, ""); + + stmt.execute(rman); + { + const char* attributes[] = { 0 }; + Print_Statement stmt(0, convert_c_pairs(attributes), global_settings); + stmt.execute(rman); + } + } + } + catch (File_Error e) + { + std::cerr<<"File error caught: " + <\n"; + return 0; +} diff --git a/src/overpass_api/statements/foreach.test.cc b/src/overpass_api/statements/foreach.test.cc new file mode 100644 index 000000000..96bf495c0 --- /dev/null +++ b/src/overpass_api/statements/foreach.test.cc @@ -0,0 +1,154 @@ +/** Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Roland Olbricht et al. + * + * This file is part of Overpass_API. + * + * Overpass_API is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Overpass_API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Overpass_API. If not, see . + */ + +#include +#include +#include "../../template_db/block_backend.h" +#include "../core/settings.h" +#include "../output_formats/output_xml.h" +#include "foreach.h" +#include "id_query.h" +#include "print.h" +#include "testing_tools.h" + + +Resource_Manager& perform_id_query(Resource_Manager& rman, std::string type, uint64 id) +{ + Parsed_Query global_settings; + global_settings.set_output_handler(Output_Handler_Parser::get_format_parser("xml"), 0, 0); + std::ostringstream buf(""); + buf<nodes.empty()) + target.nodes[default_->nodes.begin()->first].push_back(default_->nodes.begin()->second.front()); + perform_id_query(partial_rman, "node", 2 + global_node_offset); + if (default_ && !default_->nodes.empty()) + target.nodes[default_->nodes.begin()->first].push_back(default_->nodes.begin()->second.front()); + perform_id_query(partial_rman, "node", 3 + global_node_offset); + if (default_ && !default_->nodes.empty()) + target.nodes[default_->nodes.begin()->first].push_back(default_->nodes.begin()->second.front()); +/* perform_id_query(partial_rman, "way", 1); + if (!default_->ways.empty()) + target.ways[default_->ways.begin()->first].push_back(default_->ways.begin()->second.front());*/ + perform_id_query(partial_rman, "way", way_id_offset + 1); + if (default_ && !default_->ways.empty()) + target.ways[default_->ways.begin()->first].push_back(default_->ways.begin()->second.front()); + perform_id_query(partial_rman, "way", 2*way_id_offset + 1); + if (default_ && !default_->ways.empty()) + target.ways[default_->ways.begin()->first].push_back(default_->ways.begin()->second.front()); +/* perform_id_query(partial_rman, "relation", 10); + if (!default_->relations.empty()) + target.relations[default_->relations.begin()->first].push_back(default_->relations.begin()->second.front());*/ + perform_id_query(partial_rman, "relation", 21); + if (default_ && !default_->relations.empty()) + target.relations[default_->relations.begin()->first].push_back(default_->relations.begin()->second.front()); + perform_id_query(partial_rman, "relation", 32); + if (default_ && !default_->relations.empty()) + target.relations[default_->relations.begin()->first].push_back(default_->relations.begin()->second.front()); + + rman.swap_set(set_name, target); + return rman; +} + +int main(int argc, char* args[]) +{ + if (argc < 5) + { + std::cout<<"Usage: "<\n" + "\n"; + + try + { + if ((test_to_execute == "") || (test_to_execute == "1")) + { + Nonsynced_Transaction transaction(Access_Mode::readonly, false, args[3], ""); + Resource_Manager rman(transaction, &global_settings); + fill_loop_set(rman, "_", pattern_size, global_node_offset, transaction); + + Foreach_Statement stmt(0, Attr().kvs(), global_settings); + stmt_cont.add_stmt(new Print_Statement(0, Attr().kvs(), global_settings), &stmt); + stmt.execute(rman); + } + if ((test_to_execute == "") || (test_to_execute == "2")) + { + Nonsynced_Transaction transaction(Access_Mode::readonly, false, args[3], ""); + Resource_Manager rman(transaction, &global_settings); + fill_loop_set(rman, "_", pattern_size, global_node_offset, transaction); + + Foreach_Statement(0, Attr().kvs(), global_settings).execute(rman); + Print_Statement(0, Attr().kvs(), global_settings).execute(rman); + } + if ((test_to_execute == "") || (test_to_execute == "3")) + { + Nonsynced_Transaction transaction(Access_Mode::readonly, false, args[3], ""); + Resource_Manager rman(transaction, &global_settings); + fill_loop_set(rman, "A", pattern_size, global_node_offset, transaction); + + Foreach_Statement stmt(0, Attr()("from", "A")("into", "B").kvs(), global_settings); + stmt_cont.add_stmt(new Print_Statement(0, Attr()("from", "B").kvs(), global_settings), &stmt); + stmt.execute(rman); + } + if ((test_to_execute == "") || (test_to_execute == "4")) + { + Nonsynced_Transaction transaction(Access_Mode::readonly, false, args[3], ""); + Resource_Manager rman(transaction, &global_settings); + fill_loop_set(rman, "A", pattern_size, global_node_offset, transaction); + + Foreach_Statement(0, Attr()("from", "A")("into", "B").kvs(), global_settings).execute(rman); + Print_Statement(0, Attr()("from", "A").kvs(), global_settings).execute(rman); + } + } + catch (File_Error e) + { + std::cerr<<"File error caught: "<\n"; + return 0; +} diff --git a/src/overpass_api/statements/if.test.cc b/src/overpass_api/statements/if.test.cc new file mode 100644 index 000000000..703429670 --- /dev/null +++ b/src/overpass_api/statements/if.test.cc @@ -0,0 +1,211 @@ +/** Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Roland Olbricht et al. + * + * This file is part of Overpass_API. + * + * Overpass_API is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Overpass_API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Overpass_API. If not, see . + */ + +#include +#include + +#include "aggregators.h" +#include "binary_operators.h" +#include "id_query.h" +#include "if.h" +#include "print.h" +#include "tag_value.h" +#include "testing_tools.h" +#include "unary_operators.h" + + +template< typename T > +std::string to_string_(T val) +{ + std::ostringstream buf; + buf<& id_attributes, Statement& condition, + Resource_Manager& rman, Parsed_Query& global_settings, bool add_else) +{ + Statement_Container stmt_cont(global_settings); + + Id_Query_Statement(0, id_attributes, global_settings).execute(rman); + { + If_Statement stmt(0, Attr().kvs(), global_settings); + stmt.add_statement(&condition, ""); + stmt_cont.add_stmt(new Id_Query_Statement(0, Attr()("type", "way")("ref", "2").kvs(), global_settings), &stmt); + + if (add_else) + { + stmt_cont.add_stmt(new Else_Statement(0, Attr().kvs(), global_settings), &stmt); + stmt_cont.add_stmt(new Id_Query_Statement(0, Attr()("type", "way")("ref", "4").kvs(), global_settings), + &stmt); + } + stmt.execute(rman); + } + Print_Statement(0, Attr().kvs(), global_settings).execute(rman); +} + + +int main(int argc, char* args[]) +{ + if (argc < 4) + { + std::cout<<"Usage: "<\n" + "\n"; + + if ((test_to_execute == "") || (test_to_execute == "1")) + { + try + { + Nonsynced_Transaction transaction(Access_Mode::readonly, false, args[2], ""); + Resource_Manager rman(transaction, &global_settings); + Statement_Container stmt_cont(global_settings); + + Evaluator_Min_Value stmt0(0, Attr().kvs(), global_settings); + stmt_cont.add_stmt(new Evaluator_Id(0, Attr().kvs(), global_settings), &stmt0); + + execute_base_test_case(Attr()("type", "way")("ref", "1").kvs(), stmt0, rman, global_settings, false); + } + catch (File_Error e) + { + std::cerr<<"File error caught: " + <\n"; + return 0; +} diff --git a/src/overpass_api/statements/make.test.cc b/src/overpass_api/statements/make.test.cc new file mode 100644 index 000000000..2f9f91c9f --- /dev/null +++ b/src/overpass_api/statements/make.test.cc @@ -0,0 +1,1962 @@ +/** Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Roland Olbricht et al. + * + * This file is part of Overpass_API. + * + * Overpass_API is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Overpass_API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Overpass_API. If not, see . + */ + +#include "../data/utils.h" +#include "aggregators.h" +#include "binary_operators.h" +#include "explicit_geometry.h" +#include "geometry_endomorphisms.h" +#include "id_query.h" +#include "item.h" +#include "item_geometry.h" +#include "make.h" +#include "print.h" +#include "set_list_operators.h" +#include "set_prop.h" +#include "string_endomorphisms.h" +#include "tag_value.h" +#include "ternary_operator.h" +#include "testing_tools.h" +#include "unary_operators.h" +#include "union.h" + + +Statement* add_prop_stmt(const std::string& value, Statement* parent, Statement_Container& stmt_cont) +{ + return stmt_cont.create_stmt< Set_Prop_Statement >(Attr()("k", value).kvs(), parent); +} + + +Statement* add_fixed_stmt(const std::string& value, Statement* parent, Statement_Container& stmt_cont) +{ + return stmt_cont.create_stmt< Evaluator_Fixed >(Attr()("v", value).kvs(), parent); +} + + +void attribute_test(Parsed_Query& global_settings, Transaction& transaction, + std::string into, std::string type) +{ + Resource_Manager rman(transaction, &global_settings); + + Make_Statement stmt(0, Attr()("into", into)("type", type).kvs(), global_settings); + stmt.execute(rman); + + if (into == "_") + Print_Statement(0, Attr().kvs(), global_settings).execute(rman); + else + Print_Statement(0, Attr()("from", "target").kvs(), global_settings).execute(rman); +} + + +void plain_value_test(Parsed_Query& global_settings, Transaction& transaction, + std::string type, std::string key1, std::string value1, std::string key2 = "", std::string value2 = "") +{ + Resource_Manager rman(transaction, &global_settings); + Statement_Container stmt_cont(global_settings); + + Make_Statement stmt(0, Attr()("type", type).kvs(), global_settings); + + Statement* subs = add_prop_stmt(key1, &stmt, stmt_cont); + add_fixed_stmt(value1, subs, stmt_cont); + + if (key2 != "") + { + subs = add_prop_stmt(key2, &stmt, stmt_cont); + add_fixed_stmt(value2, subs, stmt_cont); + } + + stmt.execute(rman); + Print_Statement(0, Attr().kvs(), global_settings).execute(rman); +} + + +void count_test(Parsed_Query& global_settings, Transaction& transaction, + std::string type, std::string from, uint64 ref, uint64 global_node_offset) +{ + Resource_Manager rman(transaction, &global_settings); + Statement_Container stmt_cont(global_settings); + + { + Union_Statement union_(0, (from == "" ? Attr() : Attr()("into", from)).kvs(), global_settings); + + Id_Query_Statement stmt1(0, Attr()("type", "node")("ref", to_string(ref + global_node_offset)).kvs(), + global_settings); + union_.add_statement(&stmt1, ""); + + Id_Query_Statement stmt2(0, Attr()("type", "way")("ref", to_string(ref)).kvs(), global_settings); + union_.add_statement(&stmt2, ""); + + Id_Query_Statement stmt3(0, Attr()("type", "relation")("ref", to_string(ref)).kvs(), global_settings); + union_.add_statement(&stmt3, ""); + + Make_Statement stmt4(0, Attr()("type", "foo").kvs(), global_settings); + union_.add_statement(&stmt4, ""); + + union_.execute(rman); + } + + Make_Statement stmt(0, Attr()("type", type).kvs(), global_settings); + + Statement* subs = add_prop_stmt("nodes", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Set_Count(0, + (from == "" ? Attr() : Attr()("from", from))("type", "nodes").kvs(), + global_settings), subs); + + subs = add_prop_stmt("ways", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Set_Count(0, + (from == "" ? Attr() : Attr()("from", from))("type", "ways").kvs(), + global_settings), subs); + + subs = add_prop_stmt("relations", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Set_Count(0, + (from == "" ? Attr() : Attr()("from", from))("type", "relations").kvs(), + global_settings), subs); + + subs = add_prop_stmt("deriveds", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Set_Count(0, + (from == "" ? Attr() : Attr()("from", from))("type", "deriveds").kvs(), + global_settings), subs); + + subs = add_prop_stmt("nwr", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Set_Count(0, + (from == "" ? Attr() : Attr()("from", from))("type", "nwr").kvs(), + global_settings), subs); + + subs = add_prop_stmt("nw", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Set_Count(0, + (from == "" ? Attr() : Attr()("from", from))("type", "nw").kvs(), + global_settings), subs); + + subs = add_prop_stmt("wr", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Set_Count(0, + (from == "" ? Attr() : Attr()("from", from))("type", "wr").kvs(), + global_settings), subs); + + subs = add_prop_stmt("nr", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Set_Count(0, + (from == "" ? Attr() : Attr()("from", from))("type", "nr").kvs(), + global_settings), subs); + + subs = add_prop_stmt("tags", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Sum_Value(0, + (from == "" ? Attr() : Attr()("from", from)).kvs(), + global_settings), subs); + subs = stmt_cont.add_stmt(new Evaluator_Properties_Count(0, Attr()("type", "tags").kvs(), global_settings), + subs); + + subs = add_prop_stmt("members", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Sum_Value(0, + (from == "" ? Attr() : Attr()("from", from)).kvs(), + global_settings), subs); + subs = stmt_cont.add_stmt(new Evaluator_Properties_Count(0, Attr()("type", "members").kvs(), global_settings), + subs); + + stmt.execute(rman); + Print_Statement(0, Attr().kvs(), global_settings).execute(rman); +} + + +template< typename Evaluator_Pair > +void pair_test(Parsed_Query& global_settings, Transaction& transaction, + std::string type, std::string key, std::string value1, std::string value2) +{ + Resource_Manager rman(transaction, &global_settings); + Statement_Container stmt_cont(global_settings); + + Make_Statement stmt(0, Attr()("type", type).kvs(), global_settings); + + Statement* subs = add_prop_stmt(key, &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Pair(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt(value1, subs, stmt_cont); + add_fixed_stmt(value2, subs, stmt_cont); + + stmt.execute(rman); + Print_Statement(0, Attr().kvs(), global_settings).execute(rman); +} + + +void triple_test(Parsed_Query& global_settings, Transaction& transaction, + std::string type, std::string key, std::string condition, std::string value1, std::string value2) +{ + Resource_Manager rman(transaction, &global_settings); + Statement_Container stmt_cont(global_settings); + + Make_Statement stmt(0, Attr()("type", type).kvs(), global_settings); + + Statement* subs = add_prop_stmt(key, &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Ternary_Evaluator(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt(condition, subs, stmt_cont); + add_fixed_stmt(value1, subs, stmt_cont); + add_fixed_stmt(value2, subs, stmt_cont); + + stmt.execute(rman); + Print_Statement(0, Attr().kvs(), global_settings).execute(rman); +} + + +template< typename Evaluator_Prefix > +void prefix_test(Parsed_Query& global_settings, Transaction& transaction, + std::string type, std::string key, std::string value) +{ + Resource_Manager rman(transaction, &global_settings); + Statement_Container stmt_cont(global_settings); + + Make_Statement stmt(0, Attr()("type", type).kvs(), global_settings); + + Statement* subs = add_prop_stmt(key, &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Prefix(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt(value, subs, stmt_cont); + + stmt.execute(rman); + Print_Statement(0, Attr().kvs(), global_settings).execute(rman); +} + + +void prepare_value_test(Parsed_Query& global_settings, Resource_Manager& rman, + std::string from, uint64 ref1, uint64 ref2, uint64 global_node_offset) +{ + Statement_Container stmt_cont(global_settings); + Union_Statement union_(0, (from == "" ? Attr() : Attr()("into", from)).kvs(), global_settings); + + stmt_cont.add_stmt(new Id_Query_Statement(0, + Attr()("type", "node")("ref", to_string(ref1 + global_node_offset)).kvs(), global_settings), &union_); + stmt_cont.add_stmt(new Id_Query_Statement(0, + Attr()("type", "way")("ref", to_string(ref1)).kvs(), global_settings), &union_); + stmt_cont.add_stmt(new Id_Query_Statement(0, + Attr()("type", "relation")("ref", to_string(ref1)).kvs(), global_settings), &union_); + if (ref1 != ref2) + stmt_cont.add_stmt(new Id_Query_Statement(0, + Attr()("type", "node")("ref", to_string(ref2 + global_node_offset)).kvs(), global_settings), &union_); + + union_.execute(rman); +} + + +void union_value_test(Parsed_Query& global_settings, Transaction& transaction, + std::string type, std::string from, uint64 ref, uint64 global_node_offset) +{ + Resource_Manager rman(transaction, &global_settings); + prepare_value_test(global_settings, rman, from, ref, ref, global_node_offset); + Statement_Container stmt_cont(global_settings); + + Make_Statement stmt(0, Attr()("type", type).kvs(), global_settings); + + Statement* subs = add_prop_stmt("node_key", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Union_Value(0, + (from == "" ? Attr() : Attr()("from", from)).kvs(), global_settings), subs); + subs = stmt_cont.add_stmt(new Evaluator_Value(0, Attr().kvs(), global_settings), subs); + subs = stmt_cont.add_stmt(new Evaluator_Fixed(0, Attr()("v", "node_key").kvs(), global_settings), subs); + + subs = add_prop_stmt("way_key", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Union_Value(0, + (from == "" ? Attr() : Attr()("from", from)).kvs(), global_settings), subs); + subs = stmt_cont.add_stmt(new Evaluator_Value(0, Attr().kvs(), global_settings), subs); + subs = stmt_cont.add_stmt(new Evaluator_Fixed(0, Attr()("v", "way_key").kvs(), global_settings), subs); + + subs = add_prop_stmt("relation_key", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Union_Value(0, + (from == "" ? Attr() : Attr()("from", from)).kvs(), global_settings), subs); + subs = stmt_cont.add_stmt(new Evaluator_Value(0, Attr().kvs(), global_settings), subs); + subs = stmt_cont.add_stmt(new Evaluator_Fixed(0, Attr()("v", "relation_key").kvs(), global_settings), subs); + + subs = add_prop_stmt("unused_key", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Union_Value(0, + (from == "" ? Attr() : Attr()("from", from)).kvs(), global_settings), subs); + subs = stmt_cont.add_stmt(new Evaluator_Value(0, Attr().kvs(), global_settings), subs); + subs = stmt_cont.add_stmt(new Evaluator_Fixed(0, Attr()("v", "unused_key").kvs(), global_settings), subs); + + stmt.execute(rman); + Print_Statement(0, Attr().kvs(), global_settings).execute(rman); +} + + +void min_value_test(Parsed_Query& global_settings, Transaction& transaction, + std::string type, std::string from, uint64 ref1, uint64 ref2, uint64 global_node_offset) +{ + Resource_Manager rman(transaction, &global_settings); + prepare_value_test(global_settings, rman, from, ref1, ref2, global_node_offset); + Statement_Container stmt_cont(global_settings); + + Make_Statement stmt(0, Attr()("type", type).kvs(), global_settings); + + Statement* subs = add_prop_stmt("node_key_7", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Min_Value(0, + (from == "" ? Attr() : Attr()("from", from)).kvs(), global_settings), subs); + subs = stmt_cont.add_stmt(new Evaluator_Value(0, Attr().kvs(), global_settings), subs); + subs = stmt_cont.add_stmt(new Evaluator_Fixed(0, Attr()("v", "node_key_7").kvs(), global_settings), subs); + + subs = add_prop_stmt("way_key_7", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Min_Value(0, + (from == "" ? Attr() : Attr()("from", from)).kvs(), global_settings), subs); + subs = stmt_cont.add_stmt(new Evaluator_Value(0, Attr().kvs(), global_settings), subs); + subs = stmt_cont.add_stmt(new Evaluator_Fixed(0, Attr()("v", "way_key_7").kvs(), global_settings), subs); + + subs = add_prop_stmt("relation_key_7", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Min_Value(0, + (from == "" ? Attr() : Attr()("from", from)).kvs(), global_settings), subs); + subs = stmt_cont.add_stmt(new Evaluator_Value(0, Attr().kvs(), global_settings), subs); + subs = stmt_cont.add_stmt(new Evaluator_Fixed(0, Attr()("v", "relation_key_7").kvs(), global_settings), subs); + + subs = add_prop_stmt("unused_key_7", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Min_Value(0, + (from == "" ? Attr() : Attr()("from", from)).kvs(), global_settings), subs); + subs = stmt_cont.add_stmt(new Evaluator_Value(0, Attr().kvs(), global_settings), subs); + subs = stmt_cont.add_stmt(new Evaluator_Fixed(0, Attr()("v", "unused_key_7").kvs(), global_settings), subs); + + stmt.execute(rman); + Print_Statement(0, Attr().kvs(), global_settings).execute(rman); +} + + +void max_value_test(Parsed_Query& global_settings, Transaction& transaction, + std::string type, std::string from, uint64 ref1, uint64 ref2, uint64 global_node_offset) +{ + Resource_Manager rman(transaction, &global_settings); + prepare_value_test(global_settings, rman, from, ref1, ref2, global_node_offset); + Statement_Container stmt_cont(global_settings); + + Make_Statement stmt(0, Attr()("type", type).kvs(), global_settings); + + Statement* subs = add_prop_stmt("node_key_7", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Max_Value(0, + (from == "" ? Attr() : Attr()("from", from)).kvs(), global_settings), subs); + subs = stmt_cont.add_stmt(new Evaluator_Value(0, Attr().kvs(), global_settings), subs); + subs = stmt_cont.add_stmt(new Evaluator_Fixed(0, Attr()("v", "node_key_7").kvs(), global_settings), subs); + + subs = add_prop_stmt("way_key_7", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Max_Value(0, + (from == "" ? Attr() : Attr()("from", from)).kvs(), global_settings), subs); + subs = stmt_cont.add_stmt(new Evaluator_Value(0, Attr().kvs(), global_settings), subs); + subs = stmt_cont.add_stmt(new Evaluator_Fixed(0, Attr()("v", "way_key_7").kvs(), global_settings), subs); + + subs = add_prop_stmt("relation_key_7", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Max_Value(0, + (from == "" ? Attr() : Attr()("from", from)).kvs(), global_settings), subs); + subs = stmt_cont.add_stmt(new Evaluator_Value(0, Attr().kvs(), global_settings), subs); + subs = stmt_cont.add_stmt(new Evaluator_Fixed(0, Attr()("v", "relation_key_7").kvs(), global_settings), subs); + + subs = add_prop_stmt("unused_key_7", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Max_Value(0, + (from == "" ? Attr() : Attr()("from", from)).kvs(), global_settings), subs); + subs = stmt_cont.add_stmt(new Evaluator_Value(0, Attr().kvs(), global_settings), subs); + subs = stmt_cont.add_stmt(new Evaluator_Fixed(0, Attr()("v", "unused_key_7").kvs(), global_settings), subs); + + stmt.execute(rman); + Print_Statement(0, Attr().kvs(), global_settings).execute(rman); +} + + +void set_value_test(Parsed_Query& global_settings, Transaction& transaction, + std::string type, std::string from, uint64 ref1, uint64 ref2, uint64 global_node_offset) +{ + Resource_Manager rman(transaction, &global_settings); + prepare_value_test(global_settings, rman, from, ref1, ref2, global_node_offset); + Statement_Container stmt_cont(global_settings); + + Make_Statement stmt(0, Attr()("type", type).kvs(), global_settings); + + Statement* subs = add_prop_stmt("node_key_7", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Set_Value(0, + (from == "" ? Attr() : Attr()("from", from)).kvs(), global_settings), subs); + subs = stmt_cont.add_stmt(new Evaluator_Value(0, Attr().kvs(), global_settings), subs); + subs = stmt_cont.add_stmt(new Evaluator_Fixed(0, Attr()("v", "node_key_7").kvs(), global_settings), subs); + + subs = add_prop_stmt("way_key_7", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Set_Value(0, + (from == "" ? Attr() : Attr()("from", from)).kvs(), global_settings), subs); + subs = stmt_cont.add_stmt(new Evaluator_Value(0, Attr().kvs(), global_settings), subs); + subs = stmt_cont.add_stmt(new Evaluator_Fixed(0, Attr()("v", "way_key_7").kvs(), global_settings), subs); + + subs = add_prop_stmt("relation_key_7", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Set_Value(0, + (from == "" ? Attr() : Attr()("from", from)).kvs(), global_settings), subs); + subs = stmt_cont.add_stmt(new Evaluator_Value(0, Attr().kvs(), global_settings), subs); + subs = stmt_cont.add_stmt(new Evaluator_Fixed(0, Attr()("v", "relation_key_7").kvs(), global_settings), subs); + + subs = add_prop_stmt("unused_key_7", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Set_Value(0, + (from == "" ? Attr() : Attr()("from", from)).kvs(), global_settings), subs); + subs = stmt_cont.add_stmt(new Evaluator_Value(0, Attr().kvs(), global_settings), subs); + subs = stmt_cont.add_stmt(new Evaluator_Fixed(0, Attr()("v", "unused_key_7").kvs(), global_settings), subs); + + stmt.execute(rman); + Print_Statement(0, Attr().kvs(), global_settings).execute(rman); +} + + +void generic_key_test(Parsed_Query& global_settings, Transaction& transaction, + std::string type, std::string from, uint64 ref1, uint64 ref2, + bool set_value_const, bool exclude_a_key, + uint64 global_node_offset) +{ + Resource_Manager rman(transaction, &global_settings); + prepare_value_test(global_settings, rman, from, ref1, ref2, global_node_offset); + Statement_Container stmt_cont(global_settings); + + Make_Statement stmt(0, Attr()("type", type).kvs(), global_settings); + + Statement* subs = stmt_cont.create_stmt< Set_Prop_Statement >( + Attr()("keytype", "generic")("from", from).kvs(), &stmt); + + if (set_value_const) + add_fixed_stmt("...", subs, stmt_cont); + else + { + subs = stmt_cont.add_stmt(new Evaluator_Set_Value(0, + (from == "" ? Attr() : Attr()("from", from)).kvs(), global_settings), subs); + subs = stmt_cont.add_stmt(new Evaluator_Generic(0, Attr().kvs(), global_settings), subs); + } + + if (exclude_a_key) + subs = stmt_cont.create_stmt< Set_Prop_Statement >( + Attr()("keytype", "tag")("k", "way_key").kvs(), &stmt); + + stmt.execute(rman); + Print_Statement(0, Attr().kvs(), global_settings).execute(rman); +} + + +void value_id_type_test(Parsed_Query& global_settings, Transaction& transaction, + std::string type, std::string from, uint64 ref, uint64 global_node_offset) +{ + Resource_Manager rman(transaction, &global_settings); + prepare_value_test(global_settings, rman, from, ref, ref+1, global_node_offset); + + Statement_Container stmt_cont(global_settings); + + Make_Statement stmt(0, Attr()("type", type).kvs(), global_settings); + + Statement* subs = add_prop_stmt("id", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Set_Value(0, + from == "_" ? Attr().kvs() : Attr()("from", from).kvs(), + global_settings), subs); + subs = stmt_cont.add_stmt(new Evaluator_Id(0, Attr().kvs(), global_settings), subs); + + subs = add_prop_stmt("type", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Set_Value(0, + from == "_" ? Attr().kvs() : Attr()("from", from).kvs(), + global_settings), subs); + subs = stmt_cont.add_stmt(new Evaluator_Type(0, Attr().kvs(), global_settings), subs); + + subs = add_prop_stmt("is_closed", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Set_Value(0, + from == "_" ? Attr().kvs() : Attr()("from", from).kvs(), + global_settings), subs); + subs = stmt_cont.add_stmt(new Evaluator_Is_Closed(0, Attr().kvs(), global_settings), subs); + + stmt.execute(rman); + Print_Statement(0, Attr().kvs(), global_settings).execute(rman); +} + + +void number_test(Parsed_Query& global_settings, Transaction& transaction, + std::string type, uint64 global_node_offset) +{ + Resource_Manager rman(transaction, &global_settings); + Statement_Container stmt_cont(global_settings); + + Make_Statement stmt(0, Attr()("type", type).kvs(), global_settings); + + Statement* subs = add_prop_stmt("nan", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Number(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("-.", subs, stmt_cont); + + subs = add_prop_stmt("three", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Number(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("3.", subs, stmt_cont); + + subs = add_prop_stmt("one_trillion", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Number(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("1e12", subs, stmt_cont); + + subs = add_prop_stmt("minus_fourty-two", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Number(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("-42", subs, stmt_cont); + + subs = add_prop_stmt("is_nan", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Is_Num(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("-.", subs, stmt_cont); + + subs = add_prop_stmt("is_three", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Is_Num(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("3.", subs, stmt_cont); + + subs = add_prop_stmt("is_one_trillion", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Is_Num(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("1e12", subs, stmt_cont); + + subs = add_prop_stmt("is_minus_fourty-two", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Is_Num(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("-42", subs, stmt_cont); + + subs = add_prop_stmt("empty_isnt_num", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Is_Num(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("", subs, stmt_cont); + + stmt.execute(rman); + Print_Statement(0, Attr().kvs(), global_settings).execute(rman); +} + + +void date_test(Parsed_Query& global_settings, Transaction& transaction, + std::string type, uint64 global_node_offset) +{ + Resource_Manager rman(transaction, &global_settings); + Statement_Container stmt_cont(global_settings); + + Make_Statement stmt(0, Attr()("type", type).kvs(), global_settings); + + Statement* subs = add_prop_stmt("year_only", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Date(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("2006", subs, stmt_cont); + + subs = add_prop_stmt("year_month_day", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Date(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("2012-09-13", subs, stmt_cont); + + subs = add_prop_stmt("full_iso", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Date(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("2013-01-02T12:30:45Z", subs, stmt_cont); + + subs = add_prop_stmt("nonsense", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Date(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("christmas_day", subs, stmt_cont); + + subs = add_prop_stmt("is_year", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Is_Date(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("2006", subs, stmt_cont); + + subs = add_prop_stmt("is_year_month_day", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Is_Date(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("2012-09-13", subs, stmt_cont); + + subs = add_prop_stmt("is_full_iso", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Is_Date(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("2013-01-02T12:30:45Z", subs, stmt_cont); + + subs = add_prop_stmt("is_nonsense", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Is_Date(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("christmas_day", subs, stmt_cont); + + subs = add_prop_stmt("empty_isnt_date", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Is_Date(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("", subs, stmt_cont); + + stmt.execute(rman); + Print_Statement(0, Attr().kvs(), global_settings).execute(rman); +} + + +void suffix_test(Parsed_Query& global_settings, Transaction& transaction, + std::string type, uint64 global_node_offset) +{ + Resource_Manager rman(transaction, &global_settings); + Statement_Container stmt_cont(global_settings); + + Make_Statement stmt(0, Attr()("type", type).kvs(), global_settings); + + Statement* subs = add_prop_stmt("empty", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Suffix(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("", subs, stmt_cont); + + subs = add_prop_stmt("pure", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Suffix(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("1e100", subs, stmt_cont); + + subs = add_prop_stmt("unit", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Suffix(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("5.5m", subs, stmt_cont); + + subs = add_prop_stmt("whitespace", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Suffix(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("200 ", subs, stmt_cont); + + subs = add_prop_stmt("whitespace_and_unit", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Suffix(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("40 m/s", subs, stmt_cont); + + subs = add_prop_stmt("second_number", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Suffix(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("4 2", subs, stmt_cont); + + subs = add_prop_stmt("comma_sep_number", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Suffix(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("3,14", subs, stmt_cont); + + subs = add_prop_stmt("possible_exp", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Suffix(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("1e", subs, stmt_cont); + + subs = add_prop_stmt("misc", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Suffix(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("9 3/4", subs, stmt_cont); + + stmt.execute(rman); + Print_Statement(0, Attr().kvs(), global_settings).execute(rman); +} + + +void abs_test(Parsed_Query& global_settings, Transaction& transaction, + std::string type, uint64 global_node_offset) +{ + Resource_Manager rman(transaction, &global_settings); + Statement_Container stmt_cont(global_settings); + + Make_Statement stmt(0, Attr()("type", type).kvs(), global_settings); + + Statement* subs = add_prop_stmt("nan", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Abs(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("-.", subs, stmt_cont); + + subs = add_prop_stmt("pi", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Abs(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("3.14", subs, stmt_cont); + + subs = add_prop_stmt("minus_pi", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Abs(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("-3.14", subs, stmt_cont); + + subs = add_prop_stmt("one_trillion", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Abs(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("1e12", subs, stmt_cont); + + subs = add_prop_stmt("minus_one_trillion", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Abs(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("-1e12", subs, stmt_cont); + + subs = add_prop_stmt("fourty-two", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Abs(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("42", subs, stmt_cont); + + subs = add_prop_stmt("minus_fourty-two", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Abs(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("-42", subs, stmt_cont); + + stmt.execute(rman); + Print_Statement(0, Attr().kvs(), global_settings).execute(rman); +} + + +void lrs_test(Parsed_Query& global_settings, Transaction& transaction, + std::string type, uint64 global_node_offset) +{ + Resource_Manager rman(transaction, &global_settings); + Statement_Container stmt_cont(global_settings); + + Make_Statement stmt(0, Attr()("type", type).kvs(), global_settings); + + Statement* subs = add_prop_stmt("lrs_in_1_positive", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_In(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("a", subs, stmt_cont); + add_fixed_stmt("a", subs, stmt_cont); + + subs = add_prop_stmt("lrs_in_1_negative", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_In(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("z", subs, stmt_cont); + add_fixed_stmt("a", subs, stmt_cont); + + subs = add_prop_stmt("lrs_in_2_positive_1", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_In(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("a", subs, stmt_cont); + add_fixed_stmt("a;b", subs, stmt_cont); + + subs = add_prop_stmt("lrs_in_2_positive_2", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_In(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("b", subs, stmt_cont); + add_fixed_stmt("a;b", subs, stmt_cont); + + subs = add_prop_stmt("lrs_in_2_negative", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_In(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("z", subs, stmt_cont); + add_fixed_stmt("a;b", subs, stmt_cont); + + subs = add_prop_stmt("lrs_in_3_positive_1", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_In(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("a ", subs, stmt_cont); + add_fixed_stmt("a;b;c", subs, stmt_cont); + + subs = add_prop_stmt("lrs_in_3_positive_2", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_In(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("b", subs, stmt_cont); + add_fixed_stmt("a;b;c", subs, stmt_cont); + + subs = add_prop_stmt("lrs_in_3_positive_3", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_In(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt(" c", subs, stmt_cont); + add_fixed_stmt("a;b;c", subs, stmt_cont); + + subs = add_prop_stmt("lrs_in_3_negative", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_In(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("z", subs, stmt_cont); + add_fixed_stmt("a;b;c", subs, stmt_cont); + + subs = add_prop_stmt("lrs_in_space_1", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_In(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("", subs, stmt_cont); + add_fixed_stmt("a; ;c", subs, stmt_cont); + + subs = add_prop_stmt("lrs_in_space_2", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_In(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt(" ", subs, stmt_cont); + add_fixed_stmt("a;;c", subs, stmt_cont); + + subs = add_prop_stmt("lrs_in_space_3", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_In(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt(" ", subs, stmt_cont); + add_fixed_stmt("\t", subs, stmt_cont); + + subs = add_prop_stmt("lrs_in_space_4", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_In(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt(" ", subs, stmt_cont); + add_fixed_stmt("", subs, stmt_cont); + + subs = add_prop_stmt("lrs_isect_self_11", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Isect(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt(" foo", subs, stmt_cont); + add_fixed_stmt("foo ", subs, stmt_cont); + + subs = add_prop_stmt("lrs_isect_self_12", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Isect(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("\t", subs, stmt_cont); + add_fixed_stmt("\n", subs, stmt_cont); + + subs = add_prop_stmt("lrs_isect_self_21", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Isect(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("a;b", subs, stmt_cont); + add_fixed_stmt("b;a", subs, stmt_cont); + + subs = add_prop_stmt("lrs_isect_self_22", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Isect(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("a ; b", subs, stmt_cont); + add_fixed_stmt("b ; a", subs, stmt_cont); + + subs = add_prop_stmt("lrs_isect_self_23", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Isect(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt(" a;b ", subs, stmt_cont); + add_fixed_stmt(" b;a ", subs, stmt_cont); + + subs = add_prop_stmt("lrs_isect_self_24", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Isect(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("a;a", subs, stmt_cont); + add_fixed_stmt("a;a", subs, stmt_cont); + + subs = add_prop_stmt("lrs_isect_self_31", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Isect(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("a;b;c", subs, stmt_cont); + add_fixed_stmt("b;c;a", subs, stmt_cont); + + subs = add_prop_stmt("lrs_isect_self_32", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Isect(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt(" a; b;c ", subs, stmt_cont); + add_fixed_stmt(" c;a ;b ", subs, stmt_cont); + + subs = add_prop_stmt("lrs_isect_self_33", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Isect(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("a;b;b", subs, stmt_cont); + add_fixed_stmt("b;a;a", subs, stmt_cont); + + subs = add_prop_stmt("lrs_isect_zero_1", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Isect(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("a;b", subs, stmt_cont); + add_fixed_stmt("c;d", subs, stmt_cont); + + subs = add_prop_stmt("lrs_isect_zero_2", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Isect(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("a;b", subs, stmt_cont); + add_fixed_stmt("", subs, stmt_cont); + + subs = add_prop_stmt("lrs_isect_one_1", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Isect(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("a;b;c", subs, stmt_cont); + add_fixed_stmt("d;a;e", subs, stmt_cont); + + subs = add_prop_stmt("lrs_isect_one_2", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Isect(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("a;b;c", subs, stmt_cont); + add_fixed_stmt("d;b;e", subs, stmt_cont); + + subs = add_prop_stmt("lrs_isect_two_1", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Isect(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("a;b;c", subs, stmt_cont); + add_fixed_stmt("c;d;b", subs, stmt_cont); + + subs = add_prop_stmt("lrs_isect_two_2", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Isect(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("a;;b", subs, stmt_cont); + add_fixed_stmt("a; ", subs, stmt_cont); + + subs = add_prop_stmt("lrs_union_self_11", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Union(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt(" foo", subs, stmt_cont); + add_fixed_stmt("foo ", subs, stmt_cont); + + subs = add_prop_stmt("lrs_union_self_12", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Union(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("\t", subs, stmt_cont); + add_fixed_stmt("\n", subs, stmt_cont); + + subs = add_prop_stmt("lrs_union_self_21", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Union(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("a;b", subs, stmt_cont); + add_fixed_stmt("b;a", subs, stmt_cont); + + subs = add_prop_stmt("lrs_union_self_22", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Union(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("a ; b", subs, stmt_cont); + add_fixed_stmt("b ; a", subs, stmt_cont); + + subs = add_prop_stmt("lrs_union_self_23", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Union(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt(" a;b ", subs, stmt_cont); + add_fixed_stmt(" b;a ", subs, stmt_cont); + + subs = add_prop_stmt("lrs_union_self_24", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Union(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("a;a", subs, stmt_cont); + add_fixed_stmt("a;a", subs, stmt_cont); + + subs = add_prop_stmt("lrs_union_self_31", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Union(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("a;b;c", subs, stmt_cont); + add_fixed_stmt("b;c;a", subs, stmt_cont); + + subs = add_prop_stmt("lrs_union_self_32", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Union(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt(" a; b;c ", subs, stmt_cont); + add_fixed_stmt(" c;a ;b ", subs, stmt_cont); + + subs = add_prop_stmt("lrs_union_self_33", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Union(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("a;b;b", subs, stmt_cont); + add_fixed_stmt("b;a;a", subs, stmt_cont); + + subs = add_prop_stmt("lrs_union_disjoint_1", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Union(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("a;b", subs, stmt_cont); + add_fixed_stmt("c;d", subs, stmt_cont); + + subs = add_prop_stmt("lrs_union_zero_1", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Union(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("a;b", subs, stmt_cont); + add_fixed_stmt("", subs, stmt_cont); + + subs = add_prop_stmt("lrs_union_one_1", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Union(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("a;b;c", subs, stmt_cont); + add_fixed_stmt("d;a;e", subs, stmt_cont); + + subs = add_prop_stmt("lrs_union_one_2", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Union(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("a;b;c", subs, stmt_cont); + add_fixed_stmt("d;b;e", subs, stmt_cont); + + subs = add_prop_stmt("lrs_union_two_1", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Union(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("a;b;c", subs, stmt_cont); + add_fixed_stmt("c;d;b", subs, stmt_cont); + + subs = add_prop_stmt("lrs_union_two_2", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Union(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("a;b", subs, stmt_cont); + add_fixed_stmt("a; ", subs, stmt_cont); + + subs = add_prop_stmt("lrs_max_one_1", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Max(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt(" foo", subs, stmt_cont); + + subs = add_prop_stmt("lrs_max_one_2", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Max(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("foo ", subs, stmt_cont); + + subs = add_prop_stmt("lrs_max_one_3", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Max(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("1e3", subs, stmt_cont); + + subs = add_prop_stmt("lrs_max_one_4", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Max(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("100000000000000001", subs, stmt_cont); + + subs = add_prop_stmt("lrs_max_two_1", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Max(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("a;b", subs, stmt_cont); + + subs = add_prop_stmt("lrs_max_two_2", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Max(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("9;10", subs, stmt_cont); + + subs = add_prop_stmt("lrs_max_two_3", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Max(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("1e-2;1e-1", subs, stmt_cont); + + subs = add_prop_stmt("lrs_max_two_4", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Max(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("9 bis;10 bis", subs, stmt_cont); + + subs = add_prop_stmt("lrs_max_three_1", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Max(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("a;b;c", subs, stmt_cont); + + subs = add_prop_stmt("lrs_max_three_2", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Max(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt(".;9;10", subs, stmt_cont); + + subs = add_prop_stmt("lrs_min_one_1", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Min(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt(" foo", subs, stmt_cont); + + subs = add_prop_stmt("lrs_min_one_2", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Min(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("foo ", subs, stmt_cont); + + subs = add_prop_stmt("lrs_min_one_3", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Min(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("1e3", subs, stmt_cont); + + subs = add_prop_stmt("lrs_min_one_4", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Min(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("100000000000000001", subs, stmt_cont); + + subs = add_prop_stmt("lrs_min_two_1", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Min(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("a;b", subs, stmt_cont); + + subs = add_prop_stmt("lrs_min_two_2", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Min(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("9;10", subs, stmt_cont); + + subs = add_prop_stmt("lrs_min_two_3", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Min(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("1e-2;1e-1", subs, stmt_cont); + + subs = add_prop_stmt("lrs_min_two_4", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Min(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("9 bis;10 bis", subs, stmt_cont); + + subs = add_prop_stmt("lrs_min_three_1", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Min(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("a;b;c", subs, stmt_cont); + + subs = add_prop_stmt("lrs_min_three_2", &stmt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Lrs_Min(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("a;9;10", subs, stmt_cont); + + stmt.execute(rman); + Print_Statement(0, Attr().kvs(), global_settings).execute(rman); +} + + +void key_id_test(Parsed_Query& global_settings, Transaction& transaction, + std::string type, std::string from, uint64 ref, uint64 global_node_offset) +{ + Resource_Manager rman(transaction, &global_settings); + Statement_Container stmt_cont(global_settings); + if (ref > 0) + prepare_value_test(global_settings, rman, from, ref, ref+1, global_node_offset); + + Make_Statement stmt(0, Attr()("type", type).kvs(), global_settings); + + Statement* subs = stmt_cont.add_stmt( + new Set_Prop_Statement(0, Attr()("keytype", "id").kvs(), global_settings), &stmt); + + if (ref > 0) + { + subs = stmt_cont.add_stmt(new Evaluator_Max_Value(0, + (from == "" ? Attr() : Attr()("from", from)).kvs(), global_settings), subs); + stmt_cont.add_stmt(new Evaluator_Id(0, Attr().kvs(), global_settings), subs); + } + else + add_fixed_stmt("42", subs, stmt_cont); + + stmt.execute(rman); + + Print_Statement(0, Attr().kvs(), global_settings).execute(rman); +} + + +void make_point_test(Parsed_Query& global_settings, Transaction& transaction, + std::string type, uint64 ref, const std::string& lat, const std::string& lon, uint64 global_node_offset) +{ + Resource_Manager rman(transaction, &global_settings); + prepare_value_test(global_settings, rman, "_", ref, ref, global_node_offset); + Statement_Container stmt_cont(global_settings); + + Make_Statement stmt(0, Attr()("type", type).kvs(), global_settings); + + Statement* subs = stmt_cont.create_stmt< Set_Prop_Statement >(Attr()("keytype", "geometry").kvs(), &stmt); + subs = stmt_cont.add_stmt(new Evaluator_Point(0, Attr().kvs(), global_settings), subs); + if (lon.empty()) + { + add_fixed_stmt(lat, subs, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Times(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt(".0000001", subs, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Max_Value(0, Attr()("from", "_").kvs(), global_settings), subs); + stmt_cont.add_stmt(new Evaluator_Length(0, Attr().kvs(), global_settings), subs); + } + else + { + add_fixed_stmt(lat, subs, stmt_cont); + add_fixed_stmt(lon, subs, stmt_cont); + } + + stmt.execute(rman); + Print_Statement(0, Attr()("geometry", "full").kvs(), global_settings).execute(rman); +} + + +void add_point(const std::string& lat, const std::string& lon, + Statement* parent, Statement_Container& stmt_cont) +{ + Statement* pt = stmt_cont.create_stmt< Evaluator_Point >(Attr().kvs(), parent); + add_fixed_stmt(lat, pt, stmt_cont); + add_fixed_stmt(lon, pt, stmt_cont); +} + + +void make_linestring_test(Parsed_Query& global_settings, Transaction& transaction, + std::string type, uint64 ref, uint num_points, uint64 global_node_offset) +{ + Resource_Manager rman(transaction, &global_settings); + prepare_value_test(global_settings, rman, "_", ref, ref, global_node_offset); + Statement_Container stmt_cont(global_settings); + + Make_Statement stmt(0, Attr()("type", type).kvs(), global_settings); + + Statement* subs = stmt_cont.create_stmt< Set_Prop_Statement >(Attr()("keytype", "geometry").kvs(), &stmt); + subs = stmt_cont.add_stmt(new Evaluator_Linestring(0, Attr().kvs(), global_settings), subs); + + if (num_points > 0) + add_point("51.1", "7.1", subs, stmt_cont); + if (num_points > 1) + add_point("51.2", "7.2", subs, stmt_cont); + if (num_points > 2) + add_point("51.3", "7.3", subs, stmt_cont); + + if (num_points > 3) + { + Statement* pt = stmt_cont.add_stmt(new Evaluator_Point(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("51.4", pt, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Times(0, Attr().kvs(), global_settings), pt); + add_fixed_stmt(".0000001", subs, stmt_cont); + subs = stmt_cont.add_stmt(new Evaluator_Max_Value(0, Attr()("from", "_").kvs(), global_settings), subs); + stmt_cont.add_stmt(new Evaluator_Length(0, Attr().kvs(), global_settings), subs); + } + + stmt.execute(rman); + Print_Statement(0, Attr()("geometry", "full").kvs(), global_settings).execute(rman); +} + + +void make_polygon_test(Parsed_Query& global_settings, Transaction& transaction, + std::string type, uint64 ref, uint num_points, uint64 global_node_offset) +{ + Resource_Manager rman(transaction, &global_settings); + prepare_value_test(global_settings, rman, "_", ref, ref, global_node_offset); + Statement_Container stmt_cont(global_settings); + + Make_Statement stmt(0, Attr()("type", type).kvs(), global_settings); + + Statement* subs = stmt_cont.create_stmt< Set_Prop_Statement >(Attr()("keytype", "geometry").kvs(), &stmt); + Statement* poly = stmt_cont.add_stmt(new Evaluator_Polygon(0, Attr().kvs(), global_settings), subs); + subs = stmt_cont.add_stmt(new Evaluator_Linestring(0, Attr().kvs(), global_settings), poly); + + if (num_points > 0) + add_point("41.01", "0.01", subs, stmt_cont); + if (num_points > 1) + add_point("41.04", "0.02", subs, stmt_cont); + if (num_points > 2) + add_point("41.03", "0.03", subs, stmt_cont); + + if (num_points > 3) + { + add_point("41.0", "0.001", subs, stmt_cont); + + Statement* pt = stmt_cont.add_stmt(new Evaluator_Point(0, Attr().kvs(), global_settings), subs); + add_fixed_stmt("41.0", pt, stmt_cont); + Statement* times = stmt_cont.add_stmt(new Evaluator_Times(0, Attr().kvs(), global_settings), pt); + add_fixed_stmt(".0000001", times, stmt_cont); + Statement* max = stmt_cont.add_stmt(new Evaluator_Max_Value(0, Attr()("from", "_").kvs(), global_settings), times); + stmt_cont.add_stmt(new Evaluator_Length(0, Attr().kvs(), global_settings), max); + + add_point("41.0", "0.0", subs, stmt_cont); + } + if (num_points > 4) + add_point("41.01", "0.01", subs, stmt_cont); + + if (num_points > 5) + { + subs = stmt_cont.add_stmt(new Evaluator_Linestring(0, Attr().kvs(), global_settings), poly); + add_point("41.031", "0.02", subs, stmt_cont); + add_point("41.029", "0.019", subs, stmt_cont); + add_point("41.029", "0.021", subs, stmt_cont); + } + + stmt.execute(rman); + Print_Statement(0, Attr()("geometry", "full").kvs(), global_settings).execute(rman); +} + + +void make_polygon_date_line_test(Parsed_Query& global_settings, Transaction& transaction, + std::string type, uint64 global_node_offset) +{ + Resource_Manager rman(transaction, &global_settings); + Statement_Container stmt_cont(global_settings); + + Make_Statement stmt(0, Attr()("type", type).kvs(), global_settings); + + Statement* subs = stmt_cont.create_stmt< Set_Prop_Statement >(Attr()("keytype", "geometry").kvs(), &stmt); + Statement* poly = stmt_cont.add_stmt(new Evaluator_Polygon(0, Attr().kvs(), global_settings), subs); + + subs = stmt_cont.add_stmt(new Evaluator_Linestring(0, Attr().kvs(), global_settings), poly); + add_point("45", "179.99", subs, stmt_cont); + add_point("44.99", "-179.99", subs, stmt_cont); + add_point("44.98", "179.99", subs, stmt_cont); + + stmt.execute(rman); + Print_Statement(0, Attr()("geometry", "full").kvs(), global_settings).execute(rman); +} + + +void make_polygon_intersection_test_1(Parsed_Query& global_settings, + std::string type, Resource_Manager& rman, Statement_Container& stmt_cont, + const std::string& lat_1, const std::string& lon_1, + const std::string& lat_2, const std::string& lon_2, + const std::string& lat_3, const std::string& lon_3, + const std::string& lat_4, const std::string& lon_4, + const std::string& lat_5 = "", const std::string& lon_5 = "", + const std::string& lat_6 = "", const std::string& lon_6 = "") +{ + Make_Statement stmt(0, Attr()("type", type).kvs(), global_settings); + + Statement* subs = stmt_cont.create_stmt< Set_Prop_Statement >(Attr()("keytype", "geometry").kvs(), &stmt); + Statement* poly = stmt_cont.add_stmt(new Evaluator_Polygon(0, Attr().kvs(), global_settings), subs); + + subs = stmt_cont.add_stmt(new Evaluator_Linestring(0, Attr().kvs(), global_settings), poly); + add_point(lat_1, lon_1, subs, stmt_cont); + add_point(lat_2, lon_2, subs, stmt_cont); + add_point(lat_3, lon_3, subs, stmt_cont); + add_point(lat_4, lon_4, subs, stmt_cont); + if (!lat_5.empty()) + add_point(lat_5, lon_5, subs, stmt_cont); + if (!lat_6.empty()) + add_point(lat_6, lon_6, subs, stmt_cont); + + stmt.execute(rman); + Print_Statement(0, Attr()("geometry", "full").kvs(), global_settings).execute(rman); +} + + +void make_polygon_intersection_test_2(Parsed_Query& global_settings, + const std::string& lon_1, const std::string& lon_2, const std::string& lon_3, const std::string& lon_4, + std::string type, Resource_Manager& rman, Statement_Container& stmt_cont) +{ + Make_Statement stmt(0, Attr()("type", type).kvs(), global_settings); + + Statement* subs = stmt_cont.create_stmt< Set_Prop_Statement >(Attr()("keytype", "geometry").kvs(), &stmt); + Statement* poly = stmt_cont.add_stmt(new Evaluator_Polygon(0, Attr().kvs(), global_settings), subs); + + subs = stmt_cont.add_stmt(new Evaluator_Linestring(0, Attr().kvs(), global_settings), poly); + add_point("51.006", "7.0025", subs, stmt_cont); + add_point("51.005", lon_1, subs, stmt_cont); + add_point("51.005", lon_2, subs, stmt_cont); + + subs = stmt_cont.add_stmt(new Evaluator_Linestring(0, Attr().kvs(), global_settings), poly); + add_point("51.004", "7.0025", subs, stmt_cont); + add_point("51.005", lon_3, subs, stmt_cont); + add_point("51.005", lon_4, subs, stmt_cont); + + stmt.execute(rman); + Print_Statement(0, Attr()("geometry", "full").kvs(), global_settings).execute(rman); +} + + +void make_polygon_intersection_test_1(Parsed_Query& global_settings, Transaction& transaction, + std::string type, uint64 global_node_offset) +{ + Resource_Manager rman(transaction, &global_settings); + Statement_Container stmt_cont(global_settings); + + make_polygon_intersection_test_1(global_settings, + type, rman, stmt_cont, + "51.004", "7.004", + "51.006", "7.004", + "51.004", "7.006", + "51.006", "7.006"); + + make_polygon_intersection_test_1(global_settings, + type, rman, stmt_cont, + "51.104", "7.005", + "51.106", "7.005", + "51.105", "7.006", + "51.105", "7.004"); + + make_polygon_intersection_test_1(global_settings, + type, rman, stmt_cont, + "51.203", "7.004", + "51.207", "7.006", + "51.206", "7.007", + "51.204", "7.003"); + + make_polygon_intersection_test_1(global_settings, + type, rman, stmt_cont, + "51.004", "7.004", + "51.006", "7.004", + "51.005", "7.005", + "51.004", "7.006", + "51.006", "7.006"); + + make_polygon_intersection_test_1(global_settings, + type, rman, stmt_cont, + "51.104", "7.005", + "51.106", "7.005", + "51.105", "7.006", + "51.105", "7.005", + "51.105", "7.004"); + + make_polygon_intersection_test_1(global_settings, + type, rman, stmt_cont, + "51.203", "7.004", + "51.207", "7.006", + "51.206", "7.007", + "51.205", "7.005", + "51.204", "7.003"); + + make_polygon_intersection_test_1(global_settings, + type, rman, stmt_cont, + "51.004", "7.004", + "51.006", "7.004", + "51.005", "7.005", + "51.004", "7.006", + "51.006", "7.006", + "51.005", "7.005"); + + make_polygon_intersection_test_1(global_settings, + type, rman, stmt_cont, + "51.104", "7.005", + "51.105", "7.005", + "51.106", "7.005", + "51.105", "7.006", + "51.105", "7.005", + "51.105", "7.004"); + + make_polygon_intersection_test_1(global_settings, + type, rman, stmt_cont, + "51.203", "7.004", + "51.205", "7.005", + "51.207", "7.006", + "51.206", "7.007", + "51.205", "7.005", + "51.204", "7.003"); + + // Both intersections within the same index bucket + make_polygon_intersection_test_1(global_settings, + type, rman, stmt_cont, + "51.005", "7.003", + "51.006", "7.004", + "51.004", "7.005", + "51.006", "7.006", + "51.005", "7.007"); + + // Two intersections in different index buckets + make_polygon_intersection_test_1(global_settings, + type, rman, stmt_cont, + "51.005", "7.004", + "51.006", "7.005", + "51.004", "7.006", + "51.006", "7.007", + "51.005", "7.008"); +} + + +void make_polygon_intersection_test_2(Parsed_Query& global_settings, Transaction& transaction, + std::string type, uint64 global_node_offset) +{ + Resource_Manager rman(transaction, &global_settings); + Statement_Container stmt_cont(global_settings); + + make_polygon_intersection_test_2(global_settings, + "7.001", "7.002", "7.003", "7.004", type, rman, stmt_cont); + make_polygon_intersection_test_2(global_settings, + "7.001", "7.002", "7.004", "7.003", type, rman, stmt_cont); + make_polygon_intersection_test_2(global_settings, + "7.001", "7.003", "7.002", "7.004", type, rman, stmt_cont); + make_polygon_intersection_test_2(global_settings, + "7.001", "7.003", "7.004", "7.002", type, rman, stmt_cont); + make_polygon_intersection_test_2(global_settings, + "7.001", "7.004", "7.002", "7.003", type, rman, stmt_cont); + make_polygon_intersection_test_2(global_settings, + "7.001", "7.004", "7.003", "7.002", type, rman, stmt_cont); + make_polygon_intersection_test_2(global_settings, + "7.002", "7.001", "7.003", "7.004", type, rman, stmt_cont); + make_polygon_intersection_test_2(global_settings, + "7.002", "7.001", "7.004", "7.003", type, rman, stmt_cont); + make_polygon_intersection_test_2(global_settings, + "7.002", "7.003", "7.001", "7.004", type, rman, stmt_cont); + make_polygon_intersection_test_2(global_settings, + "7.002", "7.003", "7.004", "7.001", type, rman, stmt_cont); + make_polygon_intersection_test_2(global_settings, + "7.002", "7.004", "7.001", "7.003", type, rman, stmt_cont); + make_polygon_intersection_test_2(global_settings, + "7.002", "7.004", "7.003", "7.001", type, rman, stmt_cont); + make_polygon_intersection_test_2(global_settings, + "7.003", "7.001", "7.002", "7.004", type, rman, stmt_cont); + make_polygon_intersection_test_2(global_settings, + "7.003", "7.001", "7.004", "7.002", type, rman, stmt_cont); + make_polygon_intersection_test_2(global_settings, + "7.003", "7.002", "7.001", "7.004", type, rman, stmt_cont); + make_polygon_intersection_test_2(global_settings, + "7.003", "7.002", "7.004", "7.001", type, rman, stmt_cont); + make_polygon_intersection_test_2(global_settings, + "7.003", "7.004", "7.001", "7.002", type, rman, stmt_cont); + make_polygon_intersection_test_2(global_settings, + "7.003", "7.004", "7.002", "7.001", type, rman, stmt_cont); + make_polygon_intersection_test_2(global_settings, + "7.004", "7.001", "7.002", "7.003", type, rman, stmt_cont); + make_polygon_intersection_test_2(global_settings, + "7.004", "7.001", "7.003", "7.002", type, rman, stmt_cont); + make_polygon_intersection_test_2(global_settings, + "7.004", "7.002", "7.001", "7.003", type, rman, stmt_cont); + make_polygon_intersection_test_2(global_settings, + "7.004", "7.002", "7.003", "7.001", type, rman, stmt_cont); + make_polygon_intersection_test_2(global_settings, + "7.004", "7.003", "7.001", "7.002", type, rman, stmt_cont); + make_polygon_intersection_test_2(global_settings, + "7.004", "7.003", "7.002", "7.001", type, rman, stmt_cont); +} + + +void gcat_test(Parsed_Query& global_settings, Transaction& transaction, + std::string type, uint64 global_node_offset) +{ + Resource_Manager rman(transaction, &global_settings); + prepare_value_test(global_settings, rman, "_", 8, 14, global_node_offset); + + Statement_Container stmt_cont(global_settings); + Union_Statement union_(0, Attr().kvs(), global_settings); + stmt_cont.add_stmt(new Item_Statement(0, Attr().kvs(), global_settings), &union_); + Statement* geom_source = stmt_cont.add_stmt( + new Make_Statement(0, Attr()("type", "geom-source").kvs(), global_settings), &union_); + geom_source = stmt_cont.add_stmt( + new Set_Prop_Statement(0, Attr()("keytype", "geometry").kvs(), global_settings), geom_source); + Statement* lstr = stmt_cont.add_stmt( + new Evaluator_Linestring(0, Attr().kvs(), global_settings), geom_source); + add_point("51.004", "7.0025", lstr, stmt_cont); + add_point("51.005", "7.0025", lstr, stmt_cont); + add_point("51.005", "7.0015", lstr, stmt_cont); + + union_.execute(rman); + + Make_Statement stmt(0, Attr()("type", type).kvs(), global_settings); + + Set_Prop_Statement stmt1(0, Attr()("keytype", "geometry").kvs(), global_settings); + stmt.add_statement(&stmt1, ""); + Evaluator_Geom_Concat_Value stmt10(0, Attr().kvs(), global_settings); + stmt1.add_statement(&stmt10, ""); + Evaluator_Geometry stmt100(0, Attr().kvs(), global_settings); + stmt10.add_statement(&stmt100, ""); + + stmt.execute(rman); + + Print_Statement(0, Attr()("geometry", "full").kvs(), global_settings).execute(rman); +} + + +void center_test(Parsed_Query& global_settings, Transaction& transaction, + std::string type, double base_lat, double base_lon_1, double base_lon_2, uint64 global_node_offset) +{ + Resource_Manager rman(transaction, &global_settings); + Statement_Container stmt_cont(global_settings); + + Make_Statement stmt(0, Attr()("type", type).kvs(), global_settings); + + Statement* subs = stmt_cont.create_stmt< Set_Prop_Statement >(Attr()("keytype", "geometry").kvs(), &stmt); + Statement* center = stmt_cont.add_stmt(new Evaluator_Center(0, Attr().kvs(), global_settings), subs); + + subs = stmt_cont.add_stmt(new Evaluator_Linestring(0, Attr().kvs(), global_settings), center); + add_point(to_string(base_lat + 0.01), to_string(base_lon_1), subs, stmt_cont); + add_point(to_string(base_lat), to_string(base_lon_2), subs, stmt_cont); + add_point(to_string(base_lat - 0.01), to_string(base_lon_1), subs, stmt_cont); + + stmt.execute(rman); + Print_Statement(0, Attr()("geometry", "full").kvs(), global_settings).execute(rman); +} + + +void trace_test_1(Parsed_Query& global_settings, Transaction& transaction, + std::string type, bool multiple, bool same, uint64 global_node_offset) +{ + Resource_Manager rman(transaction, &global_settings); + + Statement_Container stmt_cont(global_settings); + Union_Statement union_(0, Attr().kvs(), global_settings); + + Statement* geom_source = stmt_cont.add_stmt( + new Make_Statement(0, Attr()("type", "geom-source").kvs(), global_settings), &union_); + geom_source = stmt_cont.add_stmt( + new Set_Prop_Statement(0, Attr()("keytype", "geometry").kvs(), global_settings), geom_source); + add_point("51.501", "7.0005", geom_source, stmt_cont); + + if (multiple) + { + geom_source = stmt_cont.add_stmt( + new Make_Statement(0, Attr()("type", "geom-source").kvs(), global_settings), &union_); + geom_source = stmt_cont.add_stmt( + new Set_Prop_Statement(0, Attr()("keytype", "geometry").kvs(), global_settings), geom_source); + add_point("51.501", same ? "7.0005" : "7.0035", geom_source, stmt_cont); + } + + union_.execute(rman); + + Make_Statement stmt(0, Attr()("type", type).kvs(), global_settings); + + Set_Prop_Statement stmt1(0, Attr()("keytype", "geometry").kvs(), global_settings); + stmt.add_statement(&stmt1, ""); + Evaluator_Trace stmt10(0, Attr().kvs(), global_settings); + stmt1.add_statement(&stmt10, ""); + Evaluator_Geom_Concat_Value stmt100(0, Attr().kvs(), global_settings); + stmt10.add_statement(&stmt100, ""); + Evaluator_Geometry stmt1000(0, Attr().kvs(), global_settings); + stmt100.add_statement(&stmt1000, ""); + + stmt.execute(rman); + + Print_Statement(0, Attr()("geometry", "full").kvs(), global_settings).execute(rman); +} + + +void trace_test_2(Parsed_Query& global_settings, Transaction& transaction, + std::string type, bool multiple, bool reversed, uint64 global_node_offset) +{ + Resource_Manager rman(transaction, &global_settings); + + Statement_Container stmt_cont(global_settings); + Union_Statement union_(0, Attr().kvs(), global_settings); + + Statement* geom_source = stmt_cont.add_stmt( + new Make_Statement(0, Attr()("type", "geom-source").kvs(), global_settings), &union_); + geom_source = stmt_cont.add_stmt( + new Set_Prop_Statement(0, Attr()("keytype", "geometry").kvs(), global_settings), geom_source); + Statement* lstr = stmt_cont.add_stmt( + new Evaluator_Linestring(0, Attr().kvs(), global_settings), geom_source); + add_point("52.004", "7.0025", lstr, stmt_cont); + add_point("52.005", "7.0025", lstr, stmt_cont); + + geom_source = stmt_cont.add_stmt( + new Make_Statement(0, Attr()("type", "geom-source").kvs(), global_settings), &union_); + geom_source = stmt_cont.add_stmt( + new Set_Prop_Statement(0, Attr()("keytype", "geometry").kvs(), global_settings), geom_source); + lstr = stmt_cont.add_stmt( + new Evaluator_Linestring(0, Attr().kvs(), global_settings), geom_source); + + if (multiple) + { + add_point("52.004", "7.0015", lstr, stmt_cont); + add_point("52.005", "7.0015", lstr, stmt_cont); + } + else if (!reversed) + { + add_point("52.004", "7.0025", lstr, stmt_cont); + add_point("52.005", "7.0025", lstr, stmt_cont); + } + else + { + add_point("52.005", "7.0025", lstr, stmt_cont); + add_point("52.004", "7.0025", lstr, stmt_cont); + } + + union_.execute(rman); + + Make_Statement stmt(0, Attr()("type", type).kvs(), global_settings); + + Set_Prop_Statement stmt1(0, Attr()("keytype", "geometry").kvs(), global_settings); + stmt.add_statement(&stmt1, ""); + Evaluator_Trace stmt10(0, Attr().kvs(), global_settings); + stmt1.add_statement(&stmt10, ""); + Evaluator_Geom_Concat_Value stmt100(0, Attr().kvs(), global_settings); + stmt10.add_statement(&stmt100, ""); + Evaluator_Geometry stmt1000(0, Attr().kvs(), global_settings); + stmt100.add_statement(&stmt1000, ""); + + stmt.execute(rman); + + Print_Statement(0, Attr()("geometry", "full").kvs(), global_settings).execute(rman); +} + + +void hull_test_1(Parsed_Query& global_settings, Transaction& transaction, + std::string type, uint test_level, uint64 global_node_offset) +{ + Resource_Manager rman(transaction, &global_settings); + + Statement_Container stmt_cont(global_settings); + Union_Statement union_(0, Attr().kvs(), global_settings); + + if (test_level > 0) + { + Statement* geom_source = stmt_cont.add_stmt( + new Make_Statement(0, Attr()("type", "geom-source").kvs(), global_settings), &union_); + geom_source = stmt_cont.add_stmt( + new Set_Prop_Statement(0, Attr()("keytype", "geometry").kvs(), global_settings), geom_source); + Statement* lstr = stmt_cont.add_stmt( + new Evaluator_Linestring(0, Attr().kvs(), global_settings), geom_source); + add_point("51.", "6.999", lstr, stmt_cont); + if (test_level > 1) + add_point("50.999", "7.", lstr, stmt_cont); + if (test_level > 2) + { + add_point("51.", "7.001", lstr, stmt_cont); + add_point("51.001", "7.", lstr, stmt_cont); + } + } + + if (test_level > 3) + { + Statement* geom_source = stmt_cont.add_stmt( + new Make_Statement(0, Attr()("type", "geom-source").kvs(), global_settings), &union_); + geom_source = stmt_cont.add_stmt( + new Set_Prop_Statement(0, Attr()("keytype", "geometry").kvs(), global_settings), geom_source); + add_point("50.9993", "6.9993", geom_source, stmt_cont); + } + + if (test_level > 4) + { + Statement* geom_source = stmt_cont.add_stmt( + new Make_Statement(0, Attr()("type", "geom-source").kvs(), global_settings), &union_); + geom_source = stmt_cont.add_stmt( + new Set_Prop_Statement(0, Attr()("keytype", "geometry").kvs(), global_settings), geom_source); + add_point("50.9994", "7.0005", geom_source, stmt_cont); + + geom_source = stmt_cont.add_stmt( + new Make_Statement(0, Attr()("type", "geom-source").kvs(), global_settings), &union_); + geom_source = stmt_cont.add_stmt( + new Set_Prop_Statement(0, Attr()("keytype", "geometry").kvs(), global_settings), geom_source); + add_point("50.9995", "7.0006", geom_source, stmt_cont); + } + + if (test_level > 5) + { + Statement* geom_source = stmt_cont.add_stmt( + new Make_Statement(0, Attr()("type", "geom-source").kvs(), global_settings), &union_); + geom_source = stmt_cont.add_stmt( + new Set_Prop_Statement(0, Attr()("keytype", "geometry").kvs(), global_settings), geom_source); + add_point("50.9991", "7.0009", geom_source, stmt_cont); + } + + if (test_level > 6) + { + Statement* geom_source = stmt_cont.add_stmt( + new Make_Statement(0, Attr()("type", "geom-source").kvs(), global_settings), &union_); + geom_source = stmt_cont.add_stmt( + new Set_Prop_Statement(0, Attr()("keytype", "geometry").kvs(), global_settings), geom_source); + add_point("51.", "6.9989", geom_source, stmt_cont); + } + + if (test_level > 7) + { + Statement* geom_source = stmt_cont.add_stmt( + new Make_Statement(0, Attr()("type", "geom-source").kvs(), global_settings), &union_); + geom_source = stmt_cont.add_stmt( + new Set_Prop_Statement(0, Attr()("keytype", "geometry").kvs(), global_settings), geom_source); + add_point("51.0005", "6.9989", geom_source, stmt_cont); + } + + if (test_level > 8) + { + Statement* geom_source = stmt_cont.add_stmt( + new Make_Statement(0, Attr()("type", "geom-source").kvs(), global_settings), &union_); + geom_source = stmt_cont.add_stmt( + new Set_Prop_Statement(0, Attr()("keytype", "geometry").kvs(), global_settings), geom_source); + add_point("51.003", "6.9988", geom_source, stmt_cont); + } + + union_.execute(rman); + + Make_Statement stmt(0, Attr()("type", type).kvs(), global_settings); + + Set_Prop_Statement stmt1(0, Attr()("keytype", "geometry").kvs(), global_settings); + stmt.add_statement(&stmt1, ""); + Evaluator_Hull stmt10(0, Attr().kvs(), global_settings); + stmt1.add_statement(&stmt10, ""); + Evaluator_Geom_Concat_Value stmt100(0, Attr().kvs(), global_settings); + stmt10.add_statement(&stmt100, ""); + Evaluator_Geometry stmt1000(0, Attr().kvs(), global_settings); + stmt100.add_statement(&stmt1000, ""); + + stmt.execute(rman); + + Print_Statement(0, Attr()("geometry", "full").kvs(), global_settings).execute(rman); +} + + +void hull_test_2(Parsed_Query& global_settings, Transaction& transaction, + std::string type, uint test_level, uint64 global_node_offset) +{ + Resource_Manager rman(transaction, &global_settings); + + Statement_Container stmt_cont(global_settings); + Union_Statement union_(0, Attr().kvs(), global_settings); + + Statement* geom_source = stmt_cont.add_stmt( + new Make_Statement(0, Attr()("type", "geom-source").kvs(), global_settings), &union_); + geom_source = stmt_cont.add_stmt( + new Set_Prop_Statement(0, Attr()("keytype", "geometry").kvs(), global_settings), geom_source); + Statement* lstr = stmt_cont.add_stmt( + new Evaluator_Linestring(0, Attr().kvs(), global_settings), geom_source); + add_point("51.002", "-179.999", lstr, stmt_cont); + add_point("51.", "179.998", lstr, stmt_cont); + add_point("50.998", "179.999", lstr, stmt_cont); + if (test_level > 0) + add_point("51.", "-179.998", lstr, stmt_cont); + + union_.execute(rman); + + Make_Statement stmt(0, Attr()("type", type).kvs(), global_settings); + + Set_Prop_Statement stmt1(0, Attr()("keytype", "geometry").kvs(), global_settings); + stmt.add_statement(&stmt1, ""); + Evaluator_Hull stmt10(0, Attr().kvs(), global_settings); + stmt1.add_statement(&stmt10, ""); + Evaluator_Geom_Concat_Value stmt100(0, Attr().kvs(), global_settings); + stmt10.add_statement(&stmt100, ""); + Evaluator_Geometry stmt1000(0, Attr().kvs(), global_settings); + stmt100.add_statement(&stmt1000, ""); + + stmt.execute(rman); + + Print_Statement(0, Attr()("geometry", "full").kvs(), global_settings).execute(rman); +} + + +void triple_geom_test(Parsed_Query& global_settings, Transaction& transaction, + std::string type, std::string key, std::string condition) +{ + Resource_Manager rman(transaction, &global_settings); + Statement_Container stmt_cont(global_settings); + + Make_Statement stmt(0, Attr()("type", type).kvs(), global_settings); + + Set_Prop_Statement stmt1(0, Attr()("keytype", "geometry").kvs(), global_settings); + stmt.add_statement(&stmt1, ""); + Statement* subs = stmt_cont.add_stmt(new Ternary_Evaluator(0, Attr().kvs(), global_settings), &stmt1); + add_fixed_stmt(condition, subs, stmt_cont); + add_point("51.5", "8.0", subs, stmt_cont); + add_point("52.5", "10.0", subs, stmt_cont); + + stmt.execute(rman); + Print_Statement(0, Attr()("geometry", "full").kvs(), global_settings).execute(rman); +} + + +int main(int argc, char* args[]) +{ + if (argc < 5) + { + std::cout<<"Usage: "<\n" + "\n"; + + if ((test_to_execute == "") || (test_to_execute == "1")) + attribute_test(global_settings, transaction, "_", "one"); + if ((test_to_execute == "") || (test_to_execute == "2")) + attribute_test(global_settings, transaction, "_", "two"); + if ((test_to_execute == "") || (test_to_execute == "3")) + attribute_test(global_settings, transaction, "target", "into_target"); + if ((test_to_execute == "") || (test_to_execute == "4")) + plain_value_test(global_settings, transaction, "with-tags", "single", "value"); + if ((test_to_execute == "") || (test_to_execute == "5")) + plain_value_test(global_settings, transaction, "with-tags", "not", "in", "alphabetic", "order"); + if ((test_to_execute == "") || (test_to_execute == "6")) + count_test(global_settings, transaction, "count-from-default", "_", 1, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "7")) + count_test(global_settings, transaction, "count-from-default", "_", 0, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "8")) + count_test(global_settings, transaction, "count-from-foo", "foo", 1, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "9")) + pair_test< Evaluator_And >(global_settings, transaction, "test-and", "and", "1", "0"); + if ((test_to_execute == "") || (test_to_execute == "10")) + pair_test< Evaluator_And >(global_settings, transaction, "test-and", "and", "0", "1"); + if ((test_to_execute == "") || (test_to_execute == "11")) + pair_test< Evaluator_And >(global_settings, transaction, "test-and", "and", "false", "false"); + if ((test_to_execute == "") || (test_to_execute == "12")) + pair_test< Evaluator_And >(global_settings, transaction, "test-and", "and", "true", ""); + if ((test_to_execute == "") || (test_to_execute == "13")) + pair_test< Evaluator_Or >(global_settings, transaction, "test-or", "or", "1", "0"); + if ((test_to_execute == "") || (test_to_execute == "14")) + pair_test< Evaluator_Or >(global_settings, transaction, "test-or", "or", "0", "1"); + if ((test_to_execute == "") || (test_to_execute == "15")) + pair_test< Evaluator_Or >(global_settings, transaction, "test-or", "or", "true", "true"); + if ((test_to_execute == "") || (test_to_execute == "16")) + pair_test< Evaluator_Or >(global_settings, transaction, "test-or", "or", "", ""); + if ((test_to_execute == "") || (test_to_execute == "17")) + prefix_test< Evaluator_Not >(global_settings, transaction, "test-not", "not", "0"); + if ((test_to_execute == "") || (test_to_execute == "18")) + prefix_test< Evaluator_Not >(global_settings, transaction, "test-not", "not", "1"); + if ((test_to_execute == "") || (test_to_execute == "19")) + prefix_test< Evaluator_Not >(global_settings, transaction, "test-not", "not", "false"); + if ((test_to_execute == "") || (test_to_execute == "20")) + prefix_test< Evaluator_Not >(global_settings, transaction, "test-not", "not", ""); + if ((test_to_execute == "") || (test_to_execute == "21")) + pair_test< Evaluator_Equal >(global_settings, transaction, "test-equal", "equal", "9.5", "9.50"); + if ((test_to_execute == "") || (test_to_execute == "22")) + pair_test< Evaluator_Equal >(global_settings, transaction, "test-equal", "equal", "99", "099"); + if ((test_to_execute == "") || (test_to_execute == "23")) + pair_test< Evaluator_Equal >(global_settings, transaction, "test-equal", "equal", "nine", "nine"); + if ((test_to_execute == "") || (test_to_execute == "24")) + pair_test< Evaluator_Equal >(global_settings, transaction, "test-equal", "equal", "nine", "nine "); + if ((test_to_execute == "") || (test_to_execute == "25")) + pair_test< Evaluator_Equal >(global_settings, transaction, "test-equal", "equal", "99", "99 "); + if ((test_to_execute == "") || (test_to_execute == "26")) + pair_test< Evaluator_Less >(global_settings, transaction, "test-less", "less", "9.5", "10"); + if ((test_to_execute == "") || (test_to_execute == "27")) + pair_test< Evaluator_Less >(global_settings, transaction, "test-less", "less", "9", "10.1"); + if ((test_to_execute == "") || (test_to_execute == "28")) + pair_test< Evaluator_Less >(global_settings, transaction, "test-less", "less", "9", "10"); + if ((test_to_execute == "") || (test_to_execute == "29")) + pair_test< Evaluator_Less >(global_settings, transaction, "test-less", "less", "10", "9"); + if ((test_to_execute == "") || (test_to_execute == "30")) + pair_test< Evaluator_Less >(global_settings, transaction, "test-less", "less", "a", "b"); + if ((test_to_execute == "") || (test_to_execute == "31")) + pair_test< Evaluator_Less >(global_settings, transaction, "test-less", "less", "b", "a"); + if ((test_to_execute == "") || (test_to_execute == "32")) + pair_test< Evaluator_Less >(global_settings, transaction, "test-less", "less", "1", "a"); + if ((test_to_execute == "") || (test_to_execute == "33")) + pair_test< Evaluator_Less >(global_settings, transaction, "test-less", "less", " ", "1"); + if ((test_to_execute == "") || (test_to_execute == "34")) + pair_test< Evaluator_Less_Equal >(global_settings, transaction, "test-less-equal", "less-equal", "a", "a.0"); + if ((test_to_execute == "") || (test_to_execute == "35")) + pair_test< Evaluator_Less_Equal >(global_settings, transaction, "test-less-equal", "less-equal", "a.0", "a"); + if ((test_to_execute == "") || (test_to_execute == "36")) + pair_test< Evaluator_Less_Equal >(global_settings, transaction, "test-less-equal", "less-equal", "a", "a"); + if ((test_to_execute == "") || (test_to_execute == "37")) + pair_test< Evaluator_Less_Equal >(global_settings, transaction, "test-less-equal", "less-equal", "9.0", "9"); + if ((test_to_execute == "") || (test_to_execute == "38")) + pair_test< Evaluator_Less_Equal >(global_settings, transaction, "test-less-equal", "less-equal", "9.1", "9"); + if ((test_to_execute == "") || (test_to_execute == "39")) + pair_test< Evaluator_Less_Equal >(global_settings, transaction, "test-less-equal", "less-equal", "9", "10"); + if ((test_to_execute == "") || (test_to_execute == "40")) + pair_test< Evaluator_Greater >(global_settings, transaction, "test-greater", "greater", "a", "a.0"); + if ((test_to_execute == "") || (test_to_execute == "41")) + pair_test< Evaluator_Greater >(global_settings, transaction, "test-greater", "greater", "a.0", "a"); + if ((test_to_execute == "") || (test_to_execute == "42")) + pair_test< Evaluator_Greater >(global_settings, transaction, "test-greater", "greater", "a", "a"); + if ((test_to_execute == "") || (test_to_execute == "43")) + pair_test< Evaluator_Greater >(global_settings, transaction, "test-greater", "greater", "9", "10"); + if ((test_to_execute == "") || (test_to_execute == "44")) + pair_test< Evaluator_Greater >(global_settings, transaction, "test-greater", "greater", "9.0", "9"); + if ((test_to_execute == "") || (test_to_execute == "45")) + pair_test< Evaluator_Greater >(global_settings, transaction, "test-greater", "greater", "10", "9"); + if ((test_to_execute == "") || (test_to_execute == "46")) + pair_test< Evaluator_Greater_Equal >(global_settings, transaction, "test-gr-equal", "greater-equal", "a", "a.0"); + if ((test_to_execute == "") || (test_to_execute == "47")) + pair_test< Evaluator_Greater_Equal >(global_settings, transaction, "test-gr-equal", "greater-equal", "a.0", "a"); + if ((test_to_execute == "") || (test_to_execute == "48")) + pair_test< Evaluator_Greater_Equal >(global_settings, transaction, "test-gr-equal", "greater-equal", "a", "a"); + if ((test_to_execute == "") || (test_to_execute == "49")) + pair_test< Evaluator_Greater_Equal >(global_settings, transaction, "test-gr-equal", "greater-equal", "9", "10"); + if ((test_to_execute == "") || (test_to_execute == "50")) + pair_test< Evaluator_Greater_Equal >(global_settings, transaction, "test-gr-equal", "greater-equal", "9.0", "9"); + if ((test_to_execute == "") || (test_to_execute == "51")) + pair_test< Evaluator_Greater_Equal >(global_settings, transaction, "test-gr-equal", "greater-equal", "10", "9"); + if ((test_to_execute == "") || (test_to_execute == "52")) + pair_test< Evaluator_Plus >(global_settings, transaction, "test-plus", "sum", "5.5", "3.5"); + if ((test_to_execute == "") || (test_to_execute == "53")) + pair_test< Evaluator_Plus >(global_settings, transaction, "test-plus", "sum", "1", "0 "); + if ((test_to_execute == "") || (test_to_execute == "54")) + pair_test< Evaluator_Plus >(global_settings, transaction, "test-plus", "sum", " 1", "10"); + if ((test_to_execute == "") || (test_to_execute == "55")) + pair_test< Evaluator_Plus >(global_settings, transaction, "test-plus", "sum", " 1", "2_"); + if ((test_to_execute == "") || (test_to_execute == "56")) + pair_test< Evaluator_Plus >(global_settings, transaction, "test-plus", "sum", "100000000000000000", "1"); + if ((test_to_execute == "") || (test_to_execute == "57")) + pair_test< Evaluator_Times >(global_settings, transaction, "test-times", "product", "2", "6.5"); + if ((test_to_execute == "") || (test_to_execute == "58")) + pair_test< Evaluator_Times >(global_settings, transaction, "test-times", "product", "_2", "7"); + if ((test_to_execute == "") || (test_to_execute == "59")) + pair_test< Evaluator_Minus >(global_settings, transaction, "test-minus", "difference", "2", "5"); + if ((test_to_execute == "") || (test_to_execute == "60")) + pair_test< Evaluator_Minus >(global_settings, transaction, "test-minus", "difference", "_2", "5"); + if ((test_to_execute == "") || (test_to_execute == "61")) + pair_test< Evaluator_Minus >(global_settings, transaction, "test-minus", "difference", "100000000000000001", "100000000000000000"); + if ((test_to_execute == "") || (test_to_execute == "62")) + prefix_test< Evaluator_Negate >(global_settings, transaction, "test-minus", "negation", "3.14"); + if ((test_to_execute == "") || (test_to_execute == "63")) + prefix_test< Evaluator_Negate >(global_settings, transaction, "test-minus", "negation", "-3."); + if ((test_to_execute == "") || (test_to_execute == "64")) + prefix_test< Evaluator_Negate >(global_settings, transaction, "test-minus", "negation", "100000000000000000"); + if ((test_to_execute == "") || (test_to_execute == "65")) + prefix_test< Evaluator_Negate >(global_settings, transaction, "test-minus", "negation", "one"); + if ((test_to_execute == "") || (test_to_execute == "66")) + pair_test< Evaluator_Divided >(global_settings, transaction, "test-divided", "quotient", "8", "9"); + if ((test_to_execute == "") || (test_to_execute == "67")) + pair_test< Evaluator_Divided >(global_settings, transaction, "test-divided", "quotient", "_8", "9"); + if ((test_to_execute == "") || (test_to_execute == "68")) + union_value_test(global_settings, transaction, "union-value", "_", 1, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "69")) + union_value_test(global_settings, transaction, "union-value", "foo", 1, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "70")) + min_value_test(global_settings, transaction, "min-value", "_", 7, 14, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "71")) + min_value_test(global_settings, transaction, "min-value", "_", 7, 14, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "72")) + max_value_test(global_settings, transaction, "max-value", "_", 7, 14, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "73")) + max_value_test(global_settings, transaction, "max-value", "_", 7, 14, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "74")) + set_value_test(global_settings, transaction, "value-set", "_", 7, 14, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "75")) + set_value_test(global_settings, transaction, "value-set", "_", 7, 14, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "76")) + value_id_type_test(global_settings, transaction, "id-and-type", "_", 1, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "77")) + key_id_test(global_settings, transaction, "key-id", "_", 0, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "78")) + key_id_test(global_settings, transaction, "key-id", "_", 1, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "79")) + number_test(global_settings, transaction, "test-number", global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "80")) + date_test(global_settings, transaction, "test-date", global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "81")) + suffix_test(global_settings, transaction, "test-suffix", global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "82")) + lrs_test(global_settings, transaction, "test-lrs", global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "83")) + triple_test(global_settings, transaction, "test-ternary", "ternary", "1", "A", "B"); + if ((test_to_execute == "") || (test_to_execute == "84")) + triple_test(global_settings, transaction, "test-ternary", "ternary", "false", "A", "B"); + if ((test_to_execute == "") || (test_to_execute == "85")) + triple_test(global_settings, transaction, "test-ternary", "ternary", "0", "A", "B"); + if ((test_to_execute == "") || (test_to_execute == "86")) + triple_test(global_settings, transaction, "test-ternary", "ternary", "", "A", "B"); + if ((test_to_execute == "") || (test_to_execute == "87")) + generic_key_test(global_settings, transaction, "generic-key", "_", 7, 14, false, false, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "88")) + generic_key_test(global_settings, transaction, "generic-key", "foo", 7, 14, false, false, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "89")) + generic_key_test(global_settings, transaction, "generic-key", "_", 7, 14, false, true, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "90")) + generic_key_test(global_settings, transaction, "generic-key", "_", 7, 14, true, false, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "91")) + make_point_test(global_settings, transaction, "make-point", 7, "51.25", "7.15", global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "92")) + make_point_test(global_settings, transaction, "make-point-invalid-north", 7, "91.25", "7.15", + global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "93")) + make_point_test(global_settings, transaction, "make-point-invalid-east", 7, "51.25", "187.15", + global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "94")) + make_point_test(global_settings, transaction, "make-point-dependencies", 34, "51.25", "", global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "95")) + make_linestring_test(global_settings, transaction, "make-linestring", 7, 0, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "96")) + make_linestring_test(global_settings, transaction, "make-linestring", 7, 1, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "97")) + make_linestring_test(global_settings, transaction, "make-linestring", 7, 2, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "98")) + make_linestring_test(global_settings, transaction, "make-linestring", 7, 3, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "99")) + make_linestring_test(global_settings, transaction, "make-linestring", 34, 4, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "100")) + make_polygon_test(global_settings, transaction, "make-polygon", 7, 0, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "101")) + make_polygon_test(global_settings, transaction, "make-polygon", 7, 1, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "102")) + make_polygon_test(global_settings, transaction, "make-polygon", 7, 2, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "103")) + make_polygon_test(global_settings, transaction, "make-polygon", 7, 3, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "104")) + make_polygon_test(global_settings, transaction, "make-polygon", 34, 4, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "105")) + make_polygon_test(global_settings, transaction, "make-polygon", 34, 5, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "106")) + make_polygon_test(global_settings, transaction, "make-polygon", 34, 6, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "107")) + make_polygon_date_line_test(global_settings, transaction, "make-polygon", global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "108")) + make_polygon_intersection_test_1(global_settings, transaction, "make-polygon", global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "109")) + make_polygon_intersection_test_2(global_settings, transaction, "make-polygon", global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "110")) + gcat_test(global_settings, transaction, "geometry", global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "111")) + center_test(global_settings, transaction, "center", 48, 11.01, 10.99, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "112")) + center_test(global_settings, transaction, "center", 42, 179.99, -179.99, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "113")) + trace_test_1(global_settings, transaction, "trace", false, false, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "114")) + trace_test_1(global_settings, transaction, "trace", true, false, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "115")) + trace_test_1(global_settings, transaction, "trace", true, true, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "116")) + trace_test_2(global_settings, transaction, "trace", false, false, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "117")) + trace_test_2(global_settings, transaction, "trace", true, false, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "118")) + trace_test_2(global_settings, transaction, "trace", false, true, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "119")) + hull_test_1(global_settings, transaction, "hull", 0, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "120")) + hull_test_1(global_settings, transaction, "hull", 1, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "121")) + hull_test_1(global_settings, transaction, "hull", 2, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "122")) + hull_test_1(global_settings, transaction, "hull", 3, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "123")) + hull_test_1(global_settings, transaction, "hull", 4, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "124")) + hull_test_1(global_settings, transaction, "hull", 5, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "125")) + hull_test_1(global_settings, transaction, "hull", 6, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "126")) + hull_test_1(global_settings, transaction, "hull", 7, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "127")) + hull_test_1(global_settings, transaction, "hull", 8, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "128")) + hull_test_1(global_settings, transaction, "hull", 9, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "129")) + hull_test_2(global_settings, transaction, "hull", 0, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "130")) + hull_test_2(global_settings, transaction, "hull", 1, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "131")) + triple_geom_test(global_settings, transaction, "test-ternary", "ternary-geom", "1"); + if ((test_to_execute == "") || (test_to_execute == "132")) + triple_geom_test(global_settings, transaction, "test-ternary", "ternary-geom", "0"); + if ((test_to_execute == "") || (test_to_execute == "133")) + abs_test(global_settings, transaction, "test-abs", global_node_offset); + + std::cout<<"\n"; + } + catch (File_Error e) + { + std::cerr<<"File error: "<. + */ + +#include +#include +#include "../../template_db/block_backend.h" +#include "../core/settings.h" +#include "../frontend/console_output.h" +#include "../output_formats/output_xml.h" +#include "area_query.h" +#include "bbox_query.h" +#include "coord_query.h" +#include "foreach.h" +#include "id_query.h" +#include "item.h" +#include "make_area.h" +#include "print.h" +#include "query.h" +#include "recurse.h" +#include "testing_tools.h" +#include "union.h" + +#include + + +void evaluate_grid(double south, double north, double west, double east, + double step, Resource_Manager& rman) +{ + Parsed_Query global_settings; + bool areas_printed = false; + std::vector< std::vector< uint > > area_counter; + for (double dlat = 0; dlat < north - south + step/2; dlat += step) + { + area_counter.push_back(std::vector< uint >()); + for (double dlon = 0; dlon < east - west + step/2; dlon += step) + { + { + std::ostringstream v_lat, v_lon; + v_lat< >::const_iterator + it = default_->areas.begin(); it != default_->areas.end(); ++it) + area_count += it->second.size(); + } + area_counter.back().push_back(area_count); + if (!areas_printed && default_ && !default_->areas.empty()) + { + areas_printed = true; + + const char* attributes[] = { 0 }; + Print_Statement stmt1(0, convert_c_pairs(attributes), global_settings); + stmt1.execute(rman); + } + } + } + + for (std::vector< std::vector< uint > >::const_reverse_iterator it = area_counter.rbegin(); + it != area_counter.rend(); ++it) + { + for (std::vector< uint >::const_iterator it2 = it->begin(); it2 != it->end(); ++it2) + std::cout<<' '<<*it2; + std::cout<<'\n'; + } +} + +int main(int argc, char* args[]) +{ + if (argc < 4) + { + std::cout<<"Usage: "<({ { "type", "way" } }, &stmt3); + cont.create_stmt< Has_Kv_Statement >({ { "k", "triangle" } }, stmt1); + } + { + Statement* stmt1 = cont.create_stmt< Query_Statement >({ { "type", "way" } }, &stmt3); + cont.create_stmt< Has_Kv_Statement >({ { "k", "shapes" } }, stmt1); + } + stmt3.execute(rman); + } + { + Foreach_Statement stmt1(0, { { "into", "way" } }, global_settings); + { + Statement* stmt2 = cont.create_stmt< Union_Statement >({}, &stmt1); + cont.create_stmt< Recurse_Statement >({ { "type", "way-node" }, { "from", "way" } }, stmt2); + cont.create_stmt< Item_Statement >({ { "set", "way" } }, stmt2); + } + cont.create_stmt< Make_Area_Statement >({ { "pivot", "way" } }, &stmt1); + stmt1.execute(rman); + } + + { + Query_Statement stmt1(0, { { "type", "relation" } }, global_settings); + cont.create_stmt< Has_Kv_Statement >({ { "k", "multpoly" } }, &stmt1); + stmt1.execute(rman); + } + { + Foreach_Statement stmt1(0, { { "into", "pivot" } }, global_settings); + { + Statement* stmt2 = cont.create_stmt< Union_Statement >({}, &stmt1); + cont.create_stmt< Recurse_Statement >({ { "type", "relation-way" }, { "from", "pivot" } }, stmt2); + cont.create_stmt< Recurse_Statement >({ { "type", "way-node" } }, stmt2); + } + cont.create_stmt< Make_Area_Statement >({ { "pivot", "pivot" } }, &stmt1); + stmt1.execute(rman); + } + } + else if (test_to_execute == "1") + { + for (uint i = 0; i < 8; ++i) + evaluate_grid( 0.0, 10.0, 0.0 + 6.0*i, 6.0 + 6.0*i, 1.0, rman); + for (uint i = 0; i < 8; ++i) + evaluate_grid(10.0, 11.0, 0.0 + 0.6*i, 0.6 + 0.6*i, 0.1, rman); + for (uint i = 0; i < 8; ++i) + evaluate_grid(11.0, 11.1, 0.0 + 0.06*i, 0.06 + 0.06*i, 0.01, rman); + for (uint i = 0; i < 8; ++i) + evaluate_grid(11.1, 11.11, 0.0 + 0.006*i, 0.006 + 0.006*i, 0.001, rman); + for (uint i = 0; i < 8; ++i) + evaluate_grid(11.11, 11.111, 0.0 + 0.0006*i, 0.0006 + 0.0006*i, 0.0001, rman); + for (uint i = 0; i < 8; ++i) + evaluate_grid(11.111, 11.1111, 0.0 + 0.00006*i, 0.00006 + 0.00006*i, 0.00001, rman); + for (uint i = 0; i < 8; ++i) + evaluate_grid(11.1111, 11.11111, 0.0 + 0.000006*i, 0.000006 + 0.000006*i, 0.000001, rman); + } + else if (test_to_execute == "2") + { + evaluate_grid(0.0, 5.0, 50.0, 55.0, 1.0, rman); + evaluate_grid(0.0, 3.0, 55.0, 60.0, 1.0, rman); + evaluate_grid(10.0, 10.5, 10.0, 10.5, 0.1, rman); + evaluate_grid(10.0, 10.3, 10.5, 11.0, 0.1, rman); + evaluate_grid(11.0, 11.05, 10.0, 10.05, 0.01, rman); + evaluate_grid(11.0, 11.03, 10.05, 10.1, 0.01, rman); + evaluate_grid(11.1, 11.105, 10.0, 10.005, 0.001, rman); + evaluate_grid(11.1, 11.103, 10.005, 10.01, 0.001, rman); + evaluate_grid(11.11, 11.1105, 10.0, 10.0005, 0.0001, rman); + evaluate_grid(11.11, 11.1103, 10.0005, 10.001, 0.0001, rman); + evaluate_grid(11.111, 11.11105, 10.0, 10.00005, 0.00001, rman); + evaluate_grid(11.111, 11.11103, 10.00005, 10.0001, 0.00001, rman); + evaluate_grid(11.1111, 11.111105, 10.0, 10.000005, 0.000001, rman); + evaluate_grid(11.1111, 11.111103, 10.000005, 10.00001, 0.000001, rman); + } + else if (test_to_execute == "3") + { + evaluate_grid(10.0, 10.3, 20.0, 20.5, 0.05, rman); + evaluate_grid(10.0, 10.4, 20.5, 20.9, 0.05, rman); + evaluate_grid(10.3, 10.3, 20.6, 20.6, 0.05, rman); + evaluate_grid(10.1, 10.1, 20.8, 20.8, 0.05, rman); + } + else if (test_to_execute == "4") + { + { + const char* attributes[] = { "ref", "2400000121", 0 }; + Area_Query_Statement* stmt1 = new Area_Query_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->execute(rman); + } + { + const char* attributes[] = { 0 }; + Print_Statement* stmt1 = new Print_Statement(0, convert_c_pairs(attributes), global_settings); + stmt1->execute(rman); + } + } + + return 0; +} diff --git a/src/overpass_api/statements/polygon_query.test.cc b/src/overpass_api/statements/polygon_query.test.cc new file mode 100644 index 000000000..e0d533962 --- /dev/null +++ b/src/overpass_api/statements/polygon_query.test.cc @@ -0,0 +1,177 @@ +/** Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Roland Olbricht et al. + * + * This file is part of Overpass_API. + * + * Overpass_API is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Overpass_API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Overpass_API. If not, see . + */ + +#include +#include +#include +#include "../../template_db/block_backend.h" +#include "../core/settings.h" +#include "../output_formats/output_xml.h" +#include "polygon_query.h" +#include "print.h" +#include "query.h" +#include "testing_tools.h" + + +void perform_polygon_print(std::string bounds, Transaction& transaction) +{ + try + { + // Select a polygon from the testset that contains one quarter + // of only one polygon. + Parsed_Query global_settings; + global_settings.set_output_handler(Output_Handler_Parser::get_format_parser("xml"), 0, 0); + Resource_Manager rman(transaction, &global_settings); + Polygon_Query_Statement(0, { { "bounds", bounds } }, global_settings).execute(rman); + Print_Statement(0, { { "mode", "body" } , { "order", "id" } }, global_settings).execute(rman); + } + catch (File_Error e) + { + std::cerr<<"File error caught: " + <({ { "bounds", bounds } }, &stmt1); + if (type == "node") + cont.create_stmt< Has_Kv_Statement >({ { "k", "node_key_5" } }, &stmt1); + stmt1.execute(rman); + } + Print_Statement(0, { { "mode", "body" }, { "order", "id" } }, global_settings).execute(rman); + } + catch (File_Error e) + { + std::cerr<<"File error caught: " + <\n" + "\n"; + + if ((test_to_execute == "") || (test_to_execute == "1")) + { + std::ostringstream bounds; + bounds<\n"; + return 0; +} diff --git a/src/overpass_api/statements/print.test.cc b/src/overpass_api/statements/print.test.cc new file mode 100644 index 000000000..d869dde7f --- /dev/null +++ b/src/overpass_api/statements/print.test.cc @@ -0,0 +1,298 @@ +/** Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Roland Olbricht et al. + * + * This file is part of Overpass_API. + * + * Overpass_API is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Overpass_API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Overpass_API. If not, see . + */ + +#include +#include +#include "../../template_db/block_backend.h" +#include "../core/settings.h" +#include "../output_formats/output_xml.h" +#include "id_query.h" +#include "print.h" + + +Resource_Manager& perform_id_query(Resource_Manager& rman, std::string type, uint64 id) +{ + std::ostringstream buf(""); + buf<\n" + "\n"; + + if ((test_to_execute == "") || (test_to_execute == "1")) + { + try + { + // Print each item alone: + for (uint32 i = 10000; i <= node_id_upper_limit; i += 10000) + { + // Print nodes: + Resource_Manager rman(transaction, &global_settings); + perform_id_query(rman, "node", i + global_node_offset); + { + const char* attributes[] = { 0 }; + Print_Statement stmt(2, convert_c_pairs(attributes), global_settings); + stmt.execute(rman); + } + } + for (uint32 i = 1000; i <= way_id_upper_limit; i += 1000) + { + // Print ways: + Resource_Manager rman(transaction, &global_settings); + perform_id_query(rman, "way", i); + { + const char* attributes[] = { 0 }; + Print_Statement stmt(2, convert_c_pairs(attributes), global_settings); + stmt.execute(rman); + } + } + for (uint32 i = 4; i <= relation_id_upper_limit; i += 4) + { + // Print relations: + Resource_Manager rman(transaction, &global_settings); + perform_id_query(rman, "relation", i); + { + const char* attributes[] = { 0 }; + Print_Statement stmt(2, convert_c_pairs(attributes), global_settings); + stmt.execute(rman); + } + } + } + catch (File_Error e) + { + std::cerr<<"File error caught: " + <nodes.empty()) + total.nodes[default_->nodes.begin()->first].push_back(default_->nodes.begin()->second.front()); + } + for (uint32 i = 1000; i <= way_id_upper_limit; i += 1000) + { + Resource_Manager rman(transaction, &global_settings); + perform_id_query(rman, "way", i); + const Set* default_ = rman.get_set("_"); + if (default_ && !default_->ways.empty()) + total.ways[default_->ways.begin()->first].push_back(default_->ways.begin()->second.front()); + } + for (uint32 i = 4; i <= relation_id_upper_limit; i += 4) + { + Resource_Manager rman(transaction, &global_settings); + perform_id_query(rman, "relation", i); + const Set* default_ = rman.get_set("_"); + if (default_ && !default_->relations.empty()) + total.relations[default_->relations.begin()->first].push_back(default_->relations.begin()->second.front()); + } + total_rman.swap_set("_", total); + { + const char* attributes[] = { "order", "id", 0 }; + Print_Statement stmt(2, convert_c_pairs(attributes), global_settings); + stmt.execute(total_rman); + } + } + catch (File_Error e) + { + std::cerr<<"File error caught: " + <nodes.empty()) + total.nodes[default_->nodes.begin()->first].push_back(default_->nodes.begin()->second.front()); + } + for (uint32 i = 1000; i <= way_id_upper_limit; i += 1000) + { + Resource_Manager rman(transaction, &global_settings); + perform_id_query(rman, "way", i); + const Set* default_ = rman.get_set("_"); + if (default_ && !default_->ways.empty()) + total.ways[default_->ways.begin()->first].push_back(default_->ways.begin()->second.front()); + } + for (uint32 i = 4; i <= relation_id_upper_limit; i += 4) + { + Resource_Manager rman(transaction, &global_settings); + perform_id_query(rman, "relation", i); + const Set* default_ = rman.get_set("_"); + if (default_ && !default_->relations.empty()) + total.relations[default_->relations.begin()->first].push_back(default_->relations.begin()->second.front()); + } + total_rman.swap_set("_", total); + { + const char* attributes[] = { "order", "quadtile", 0 }; + Print_Statement stmt(2, convert_c_pairs(attributes), global_settings); + stmt.execute(total_rman); + } + } + catch (File_Error e) + { + std::cerr<<"File error caught: " + <\n"; + return 0; +} diff --git a/src/overpass_api/statements/query.test.cc b/src/overpass_api/statements/query.test.cc new file mode 100644 index 000000000..95d51912c --- /dev/null +++ b/src/overpass_api/statements/query.test.cc @@ -0,0 +1,1916 @@ +/** Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Roland Olbricht et al. + * + * This file is part of Overpass_API. + * + * Overpass_API is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Overpass_API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Overpass_API. If not, see . + */ + +#include +#include +#include +#include "../../template_db/block_backend.h" +#include "../core/settings.h" +#include "../output_formats/output_xml.h" +#include "aggregators.h" +#include "around.h" +#include "bbox_query.h" +#include "binary_operators.h" +#include "filter.h" +#include "id_query.h" +#include "item.h" +#include "query.h" +#include "print.h" +#include "recurse.h" +#include "unary_operators.h" +#include "union.h" + + +template < class TStatement > +class SProxy +{ + public: + SProxy() : stmt_(0) {} + + ~SProxy() + { + if (stmt_) + delete stmt_; + } + + SProxy& operator()(const std::string& k, const std::string& v) + { + attributes[k] = v; + return *this; + } + + TStatement& stmt() + { + Parsed_Query global_settings; + global_settings.set_output_handler(Output_Handler_Parser::get_format_parser("xml"), 0, 0); + if (!stmt_) + stmt_ = new TStatement(0, attributes, global_settings); + + return *stmt_; + } + + private: + TStatement* stmt_; + std::map< std::string, std::string > attributes; +}; + +void perform_print(Resource_Manager& rman, std::string from = "_") +{ + SProxy< Print_Statement >()("order", "id")("from", from).stmt().execute(rman); +} + +void perform_query(std::string type, std::string key, std::string value, std::string db_dir) +{ + try + { + Nonsynced_Transaction transaction(Access_Mode::readonly, false, db_dir, ""); + Parsed_Query global_settings; + global_settings.set_output_handler(Output_Handler_Parser::get_format_parser("xml"), 0, 0); + Resource_Manager rman(transaction, &global_settings); + { + SProxy< Query_Statement > stmt1; + stmt1("type", type); + SProxy< Has_Kv_Statement > stmt2; + stmt1.stmt().add_statement(&stmt2("k", key)("v", value).stmt(), ""); + stmt1.stmt().execute(rman); + } + perform_print(rman); + { + SProxy< Query_Statement > stmt1; + stmt1("type", type)("into", "a"); + SProxy< Has_Kv_Statement > stmt2; + stmt1.stmt().add_statement(&stmt2("k", key)("v", value).stmt(), ""); + stmt1.stmt().execute(rman); + } + { + SProxy< Query_Statement > stmt1; + stmt1("type", type)("into", "b"); + SProxy< Item_Statement > stmt2; + stmt1.stmt().add_statement(&stmt2("set", "a").stmt(), ""); + stmt1.stmt().execute(rman); + } + Set empty; + const Set* lhs = rman.get_set("_"); + if (!lhs) + lhs = ∅ + const Set* rhs = rman.get_set("b"); + if (!rhs) + rhs = ∅ + if ((lhs->nodes != rhs->nodes) || (lhs->ways != rhs->ways) || (lhs->relations != rhs->relations)) + { + std::cout<<"Sets \"_\" and \"b\" differ:\n"; + perform_print(rman, "b"); + } + } + catch (File_Error e) + { + std::cerr<<"File error caught: " + < stmt1; + stmt1("type", type); + SProxy< Has_Kv_Statement > stmt2; + stmt1.stmt().add_statement(&stmt2("k", key1)("v", value1).stmt(), ""); + SProxy< Has_Kv_Statement > stmt3; + stmt1.stmt().add_statement(&stmt3("k", key2)("v", value2).stmt(), ""); + stmt1.stmt().execute(rman); + } + perform_print(rman); + { + SProxy< Query_Statement > stmt1; + stmt1("type", type)("into", "a"); + SProxy< Has_Kv_Statement > stmt2; + stmt1.stmt().add_statement(&stmt2("k", key1)("v", value1).stmt(), ""); + stmt1.stmt().execute(rman); + } + { + SProxy< Query_Statement > stmt1; + stmt1("type", type)("into", "b"); + SProxy< Item_Statement > stmt2; + stmt1.stmt().add_statement(&stmt2("set", "a").stmt(), ""); + SProxy< Has_Kv_Statement > stmt3; + stmt1.stmt().add_statement(&stmt3("k", key2)("v", value2).stmt(), ""); + stmt1.stmt().execute(rman); + } + Set empty; + const Set* lhs = rman.get_set("_"); + if (!lhs) + lhs = ∅ + const Set* rhs = rman.get_set("b"); + if (!rhs) + rhs = ∅ + if ((lhs->nodes != rhs->nodes) || (lhs->ways != rhs->ways) || (lhs->relations != rhs->relations)) + { + std::cout<<"Sets \"_\" and \"b\" differ:\n"; + perform_print(rman, "b"); + } + { + SProxy< Query_Statement > stmt1; + stmt1("type", type)("into", "c"); + SProxy< Has_Kv_Statement > stmt3; + stmt1.stmt().add_statement(&stmt3("k", key2)("v", value2).stmt(), ""); + stmt1.stmt().execute(rman); + } + { + SProxy< Query_Statement > stmt1; + stmt1("type", type)("into", "d"); + SProxy< Item_Statement > stmt2; + stmt1.stmt().add_statement(&stmt2("set", "a").stmt(), ""); + SProxy< Item_Statement > stmt3; + stmt1.stmt().add_statement(&stmt3("set", "c").stmt(), ""); + stmt1.stmt().execute(rman); + } + + lhs = rman.get_set("_"); + if (!lhs) + lhs = ∅ + rhs = rman.get_set("d"); + if (!rhs) + rhs = ∅ + if ((lhs->nodes != rhs->nodes) || (lhs->ways != rhs->ways) || (lhs->relations != rhs->relations)) + { + std::cout<<"Sets \"_\" and \"d\" differ:\n"; + perform_print(rman, "d"); + } + } + catch (File_Error e) + { + std::cerr<<"File error caught: " + < stmt1; + stmt1("type", type); + SProxy< Has_Kv_Statement > stmt2; + stmt1.stmt().add_statement(&stmt2("k", key1)("v", value1).stmt(), ""); + SProxy< Has_Kv_Statement > stmt3; + stmt1.stmt().add_statement(&stmt3("k", key2)("v", value2).stmt(), ""); + SProxy< Has_Kv_Statement > stmt4; + stmt1.stmt().add_statement(&stmt4("k", key3)("v", value3).stmt(), ""); + stmt1.stmt().execute(rman); + } + perform_print(rman); + { + SProxy< Query_Statement > stmt1; + stmt1("type", type)("into", "a"); + SProxy< Has_Kv_Statement > stmt2; + stmt1.stmt().add_statement(&stmt2("k", key1)("v", value1).stmt(), ""); + stmt1.stmt().execute(rman); + } + { + SProxy< Query_Statement > stmt1; + stmt1("type", type)("into", "b"); + SProxy< Has_Kv_Statement > stmt3; + stmt1.stmt().add_statement(&stmt3("k", key2)("v", value2).stmt(), ""); + stmt1.stmt().execute(rman); + } + { + SProxy< Query_Statement > stmt1; + stmt1("type", type)("into", "c"); + SProxy< Item_Statement > stmt2; + stmt1.stmt().add_statement(&stmt2("set", "a").stmt(), ""); + SProxy< Item_Statement > stmt3; + stmt1.stmt().add_statement(&stmt3("set", "b").stmt(), ""); + SProxy< Has_Kv_Statement > stmt4; + stmt1.stmt().add_statement(&stmt4("k", key3)("v", value3).stmt(), ""); + stmt1.stmt().execute(rman); + } + Set empty; + const Set* lhs = rman.get_set("_"); + if (!lhs) + lhs = ∅ + const Set* rhs = rman.get_set("c"); + if (!rhs) + rhs = ∅ + if ((lhs->nodes != rhs->nodes) || (lhs->ways != rhs->ways) || (lhs->relations != rhs->relations)) + { + std::cout<<"Sets \"_\" and \"c\" differ:\n"; + perform_print(rman, "c"); + } + } + catch (File_Error e) + { + std::cerr<<"File error caught: " + < stmt1; + stmt1("type", type); + SProxy< Has_Kv_Statement > stmt2; + if (key != "") + stmt1.stmt().add_statement(&stmt2("k", key)("v", value).stmt(), ""); + SProxy< Has_Kv_Statement > stmt3; + if (key2 != "") + stmt1.stmt().add_statement + (&stmt3("k", key2)("regv", regex2)("modv", straight2 ? "" : "not").stmt(), ""); + SProxy< Has_Kv_Statement > stmt4; + if (key3 != "") + stmt1.stmt().add_statement + (&stmt4("k", key3)("regv", regex3)("modv", straight3 ? "" : "not").stmt(), ""); + SProxy< Has_Kv_Statement > stmt5; + if (key4 != "") + stmt1.stmt().add_statement + (&stmt5("k", key4)("v", value4)("modv", straight4 ? "" : "not").stmt(), ""); + SProxy< Has_Kv_Statement > stmt6; + if (key5 != "") + stmt1.stmt().add_statement + (&stmt6("k", key5)("v", value5)("modv", straight5 ? "" : "not").stmt(), ""); + stmt1.stmt().execute(rman); + } + perform_print(rman); + } + catch (File_Error e) + { + std::cerr<<"File error caught: " + < stmt1; + stmt1("type", type); + SProxy< Has_Kv_Statement > stmt2; + if (key != "") + stmt1.stmt().add_statement(&stmt2("k", key)("v", value).stmt(), ""); + SProxy< Has_Kv_Statement > stmt3; + if (key2 != "") + stmt1.stmt().add_statement + (&stmt3("regk", key2)("regv", regval2)("modv", straight2 ? "" : "not").stmt(), ""); + SProxy< Has_Kv_Statement > stmt4; + if (key3 != "") + stmt1.stmt().add_statement + (&stmt4("regk", key3)("regv", regval3)("modv", straight3 ? "" : "not").stmt(), ""); + stmt1.stmt().execute(rman); + } + perform_print(rman); + } + catch (File_Error e) + { + std::cerr<<"File error caught: " + <()("type", id_type)("ref", buf.str()).stmt().execute(rman); + } + { + SProxy< Query_Statement > stmt1; + stmt1("type", type); + SProxy< Has_Kv_Statement > stmt2; + if (value1 != "") + stmt1.stmt().add_statement(&stmt2("k", key1)("v", value1).stmt(), ""); + else if (key1 != "") + stmt1.stmt().add_statement(&stmt2("k", key1).stmt(), ""); + SProxy< Around_Statement > stmt3; + stmt1.stmt().add_statement(&stmt3("radius", radius).stmt(), ""); + stmt1.stmt().execute(rman); + } + perform_print(rman); + if (key1 == "") + return; + { + std::ostringstream buf; + if (id_type == "node" && type == "node") + buf<<(2*pattern_size*pattern_size + 1 + global_node_offset); + else if (id_type == "node" && big_radius) + buf<<(pattern_size*pattern_size + 2*pattern_size + global_node_offset); + else if (id_type == "node") + buf<<(pattern_size*pattern_size + pattern_size - 1 + global_node_offset); + else + buf<<(pattern_size*pattern_size + pattern_size - 1); + SProxy< Id_Query_Statement >()("type", id_type)("ref", buf.str())("into", "a") + .stmt().execute(rman); + } + { + SProxy< Query_Statement > stmt1; + stmt1("type", type)("into", "b"); + SProxy< Has_Kv_Statement > stmt2; + if (value1 != "") + stmt1.stmt().add_statement(&stmt2("k", key1)("v", value1).stmt(), ""); + else + stmt1.stmt().add_statement(&stmt2("k", key1).stmt(), ""); + stmt1.stmt().execute(rman); + } + { + SProxy< Query_Statement > stmt1; + stmt1("type", type)("into", "c"); + SProxy< Item_Statement > stmt2; + stmt1.stmt().add_statement(&stmt2("set", "b").stmt(), ""); + SProxy< Around_Statement > stmt3; + stmt1.stmt().add_statement(&stmt3("radius", radius)("from", "a").stmt(), ""); + stmt1.stmt().execute(rman); + } + Set empty; + const Set* lhs = rman.get_set("_"); + if (!lhs) + lhs = ∅ + const Set* rhs = rman.get_set("c"); + if (!rhs) + rhs = ∅ + if ((lhs->nodes != rhs->nodes) || (lhs->ways != rhs->ways) || (lhs->relations != rhs->relations)) + { + std::cout<<"Sets \"_\" and \"c\" differ:\n"; + perform_print(rman, "c"); + } + } + catch (File_Error e) + { + std::cerr<<"File error caught: " + < stmt1; + stmt1("type", type); + SProxy< Has_Kv_Statement > stmt2; + if (value1 != "") + stmt1.stmt().add_statement(&stmt2("k", key1)("v", value1).stmt(), ""); + else if (key1 != "") + stmt1.stmt().add_statement(&stmt2("k", key1).stmt(), ""); + SProxy< Around_Statement > stmt3; + stmt1.stmt().add_statement(&stmt3("radius", radius)("lat", lat)("lon", lon).stmt(), ""); + stmt1.stmt().execute(rman); + } + perform_print(rman); + } + catch (File_Error e) + { + std::cerr<<"File error caught: " + < stmt1; + stmt1("type", type); + SProxy< Has_Kv_Statement > stmt2; + stmt1.stmt().add_statement(&stmt2("k", key1)("v", value1).stmt(), ""); + SProxy< Bbox_Query_Statement > stmt3; + stmt1.stmt().add_statement(&stmt3("n", north)("s", south)("e", east)("w", west).stmt(), ""); + stmt1.stmt().execute(rman); + } + perform_print(rman); + { + SProxy< Query_Statement > stmt1; + stmt1("type", type)("into", "a"); + SProxy< Has_Kv_Statement > stmt2; + stmt1.stmt().add_statement(&stmt2("k", key1)("v", value1).stmt(), ""); + stmt1.stmt().execute(rman); + } + { + SProxy< Query_Statement > stmt1; + stmt1("type", type)("into", "b"); + SProxy< Item_Statement > stmt2; + stmt1.stmt().add_statement(&stmt2("set", "a").stmt(), ""); + SProxy< Bbox_Query_Statement > stmt3; + stmt1.stmt().add_statement(&stmt3("n", north)("s", south)("e", east)("w", west).stmt(), ""); + stmt1.stmt().execute(rman); + } + Set empty; + const Set* lhs = rman.get_set("_"); + if (!lhs) + lhs = ∅ + const Set* rhs = rman.get_set("b"); + if (!rhs) + rhs = ∅ + if ((lhs->nodes != rhs->nodes) || (lhs->ways != rhs->ways) || (lhs->relations != rhs->relations)) + { + std::cout<<"Sets \"_\" and \"b\" differ:\n"; + perform_print(rman, "b"); + } + } + catch (File_Error e) + { + std::cerr<<"File error caught: " + < 0) + rman.set_limits(max_allowed_time, max_allowed_space); + + { + SProxy< Query_Statement > stmt1; + stmt1("type", type); + SProxy< Bbox_Query_Statement > stmt2; + stmt1.stmt().add_statement(&stmt2("n", north)("s", south)("e", east)("w", west).stmt(), ""); +// SProxy< Has_Kv_Statement > stmt3; +// stmt1.stmt().add_statement(&stmt3("k", key1)("v", value1).stmt(), ""); + SProxy< Filter_Statement > stmt3; + SProxy< Evaluator_Equal > stmt4; + SProxy< Evaluator_Value > stmt5; + SProxy< Evaluator_Fixed > stmt50; + SProxy< Evaluator_Fixed > stmt6; + stmt4.stmt().add_statement(&stmt6("v", value1).stmt(), ""); + stmt5.stmt().add_statement(&stmt50("v", key1).stmt(), ""); + stmt4.stmt().add_statement(&stmt5.stmt(), ""); + stmt3.stmt().add_statement(&stmt4.stmt(), ""); + stmt1.stmt().add_statement(&stmt3.stmt(), ""); + stmt1.stmt().execute(rman); + } + perform_print(rman); + } + catch (File_Error e) + { + std::cerr<<"File error caught: " + < stmt1; + stmt1("type", type); + SProxy< Has_Kv_Statement > stmt2; + stmt1.stmt().add_statement(&stmt2("k", key2).stmt(), ""); + SProxy< Filter_Statement > stmt3; + SProxy< Evaluator_Equal > stmt4; + SProxy< Evaluator_Value > stmt5; + SProxy< Evaluator_Fixed > stmt50; + SProxy< Evaluator_Fixed > stmt6; + stmt4.stmt().add_statement(&stmt6("v", value1).stmt(), ""); + stmt5.stmt().add_statement(&stmt50("v", key1).stmt(), ""); + stmt4.stmt().add_statement(&stmt5.stmt(), ""); + stmt3.stmt().add_statement(&stmt4.stmt(), ""); + stmt1.stmt().add_statement(&stmt3.stmt(), ""); + stmt1.stmt().execute(rman); + } + perform_print(rman); + } + catch (File_Error e) + { + std::cerr<<"File error caught: " + < stmt1; + stmt1("type", type); + stmt1("ref", to_string(start_id)); + stmt1.stmt().execute(rman); + } + { + SProxy< Query_Statement > stmt1; + stmt1("type", type); + SProxy< Has_Kv_Statement > stmt2; + stmt1.stmt().add_statement(&stmt2("k", key1).stmt(), ""); + SProxy< Filter_Statement > stmt3; + SProxy< Evaluator_Equal > stmt4; + SProxy< Evaluator_Value > stmt5; + SProxy< Evaluator_Fixed > stmt50; + SProxy< Evaluator_Union_Value > stmt6; + SProxy< Evaluator_Value > stmt7; + SProxy< Evaluator_Fixed > stmt70; + stmt7.stmt().add_statement(&stmt70("v", key2).stmt(), ""); + stmt6.stmt().add_statement(&stmt7.stmt(), ""); + stmt4.stmt().add_statement(&stmt6.stmt(), ""); + stmt5.stmt().add_statement(&stmt50("v", key1).stmt(), ""); + stmt4.stmt().add_statement(&stmt5.stmt(), ""); + stmt3.stmt().add_statement(&stmt4.stmt(), ""); + stmt1.stmt().add_statement(&stmt3.stmt(), ""); + stmt1.stmt().execute(rman); + } + perform_print(rman); + + std::string from_set = "foo"; + { + SProxy< Id_Query_Statement > stmt1; + stmt1("type", type); + stmt1("ref", to_string(start_id)); + stmt1("into", from_set); + stmt1.stmt().execute(rman); + } + { + SProxy< Query_Statement > stmt1; + stmt1("type", type); + stmt1("into", "b"); + SProxy< Has_Kv_Statement > stmt2; + stmt1.stmt().add_statement(&stmt2("k", key1).stmt(), ""); + SProxy< Filter_Statement > stmt3; + SProxy< Evaluator_Equal > stmt4; + SProxy< Evaluator_Value > stmt5; + SProxy< Evaluator_Fixed > stmt50; + SProxy< Evaluator_Union_Value > stmt6; + SProxy< Evaluator_Value > stmt7; + SProxy< Evaluator_Fixed > stmt70; + stmt7.stmt().add_statement(&stmt70("v", key2).stmt(), ""); + stmt6("from", from_set).stmt().add_statement(&stmt7.stmt(), ""); + stmt4.stmt().add_statement(&stmt6.stmt(), ""); + stmt5.stmt().add_statement(&stmt50("v", key1).stmt(), ""); + stmt4.stmt().add_statement(&stmt5.stmt(), ""); + stmt3.stmt().add_statement(&stmt4.stmt(), ""); + stmt1.stmt().add_statement(&stmt3.stmt(), ""); + stmt1.stmt().execute(rman); + } + + Set empty; + const Set* lhs = rman.get_set("_"); + if (!lhs) + lhs = ∅ + const Set* rhs = rman.get_set("b"); + if (!rhs) + rhs = ∅ + if ((lhs->nodes != rhs->nodes) || (lhs->ways != rhs->ways) || (lhs->relations != rhs->relations)) + { + std::cout<<"Sets \"_\" and \"b\" differ:\n"; + perform_print(rman, "b"); + } + } + catch (File_Error e) + { + std::cerr<<"File error caught: " + < stmt1; + stmt1("type", type); + + SProxy< Has_Kv_Statement > stmt2; + if (regex & 0x10) + stmt2("regk", key1); + else + stmt2("k", key1); + + if (value1 != "") + { + if (regex & 0x1) + stmt2("regv", value1); + else + stmt2("v", value1); + } + stmt1.stmt().add_statement(&stmt2.stmt(), ""); + + SProxy< Has_Kv_Statement > stmt4; + if (key2 != "") + { + if (regex & 0x20) + stmt4("regk", key2); + else + stmt4("k", key2); + + if (regex & 0x2) + stmt4("regv", value2); + else + stmt4("v", value2); + stmt1.stmt().add_statement(&stmt4("modv", straight2 ? "" : "not").stmt(), ""); + } + + SProxy< Has_Kv_Statement > stmt5; + if (key3 != "") + { + if (regex & 0x40) + stmt5("regk", key3); + else + stmt5("k", key3); + + if (regex & 0x4) + stmt5("regv", value3); + else + stmt5("v", value3); + stmt1.stmt().add_statement(&stmt5("modv", straight2 ? "" : "not").stmt(), ""); + } + + SProxy< Bbox_Query_Statement > stmt3; + stmt1.stmt().add_statement(&stmt3("n", to_string(north))("s", to_string(south)) + ("e", to_string(east))("w", to_string(west)).stmt(), ""); + stmt1.stmt().execute(rman); + } + perform_print(rman); + } + catch (File_Error e) + { + std::cerr<<"File error caught: " + < stmt1; + if (recurse_type == "way-node") + stmt1("type", "way")("ref", to_string((pattern_size-1)*pattern_size/2)).stmt().execute(rman); + else if (recurse_type == "relation-node") + stmt1("type", "relation")("ref", "11").stmt().execute(rman); + else if (recurse_type == "relation-way") + stmt1("type", "relation")("ref", "6").stmt().execute(rman); + else if (recurse_type == "relation-relation") + stmt1("type", "relation")("ref", "9").stmt().execute(rman); + else if (recurse_type == "relation-nwr" || recurse_type == "relation-nw" + || recurse_type == "relation-wr" || recurse_type == "relation-nr") + stmt1("type", "relation")("ref", "10").stmt().execute(rman); + else if (recurse_type == "node-way") + stmt1("type", "node")("lower", to_string(pattern_size*pattern_size - 4 + global_node_offset)) + ("upper", to_string(pattern_size*pattern_size - 1 + global_node_offset)).stmt().execute(rman); + else if (recurse_type == "node-relation") + stmt1("type", "node")("lower", to_string(pattern_size + global_node_offset)) + ("upper", to_string(pattern_size + 2 + global_node_offset)).stmt().execute(rman); + else if (recurse_type == "way-relation") + stmt1("type", "way")("ref", "1").stmt().execute(rman); + else if (recurse_type == "relation-backwards") + stmt1("type", "relation")("ref", "1").stmt().execute(rman); + else if (recurse_type == "down") + stmt1("type", "relation")("ref", "10").stmt().execute(rman); + else if (recurse_type == "down-rel") + stmt1("type", "relation")("ref", "9").stmt().execute(rman); + else if (recurse_type == "up" || recurse_type == "up-rel") + { + SProxy< Id_Query_Statement > stmt2; + SProxy< Union_Statement > stmt3; + stmt3.stmt().add_statement(&stmt1("type", "node")("ref", to_string(2 + + global_node_offset)).stmt(), ""); + stmt3.stmt().add_statement(&stmt2("type", "way")("ref", + to_string(pattern_size*pattern_size/2 - 1)).stmt(), ""); + stmt3.stmt().execute(rman); + } + } + if (double_recurse) + { + SProxy< Id_Query_Statement > stmt1; + if (recurse_type == "way-node") + stmt1("type", "way")("ref", to_string((pattern_size-1)*pattern_size/2 - 1))("into", "elem2") + .stmt().execute(rman); + else if (recurse_type == "relation-node") + stmt1("type", "relation")("ref", "1")("into", "elem2") + .stmt().execute(rman); + else if (recurse_type == "relation-way") + stmt1("type", "relation")("ref", "6")("into", "elem2") + .stmt().execute(rman); + else if (recurse_type == "relation-relation") + stmt1("type", "relation")("ref", "10")("into", "elem2").stmt().execute(rman); + else if (recurse_type == "node-way") + stmt1("type", "node")("into", "elem2") + ("lower", to_string(pattern_size*pattern_size - pattern_size - 6 + global_node_offset)) + ("upper", to_string(pattern_size*pattern_size - pattern_size - 3 + global_node_offset)).stmt().execute(rman); + else if (recurse_type == "node-relation") + stmt1("type", "node")("into", "elem2") + ("ref", to_string(pattern_size*pattern_size + global_node_offset)).stmt().execute(rman); + else if (recurse_type == "way-relation") + stmt1("type", "way")("ref", "2")("into", "elem2").stmt().execute(rman); + else if (recurse_type == "relation-backwards") + stmt1("type", "relation")("ref", "2")("into", "elem2").stmt().execute(rman); + } + { + SProxy< Query_Statement > stmt1; + stmt1("type", query_type); + + SProxy< Recurse_Statement > stmt2; + stmt1.stmt().add_statement(&stmt2("type", recurse_type).stmt(), ""); + + SProxy< Has_Kv_Statement > stmt3; + if (key1 != "") + stmt1.stmt().add_statement(&stmt3("k", key1)("v", value1).stmt(), ""); + + SProxy< Bbox_Query_Statement > stmt4; + if (south <= 90.0 && north <= 90.0) + { + stmt1.stmt().add_statement + (&stmt4("n", to_string(north))("s", to_string(south)) + ("w", to_string(west))("e", to_string(east)).stmt(), ""); + } + + SProxy< Recurse_Statement > stmt5; + if (double_recurse) + stmt1.stmt().add_statement(&stmt5("type", recurse_type)("from", "elem2").stmt(), ""); + + stmt1.stmt().execute(rman); + } + perform_print(rman); + } + catch (File_Error e) + { + std::cerr<<"File error caught: " + < stmt1; + stmt1("type", "node"); + + SProxy< Item_Statement > stmt2; + if (bypass_get_data) + stmt1.stmt().add_statement(&stmt2("from", "nn").stmt(), ""); + + SProxy< Recurse_Statement > stmt3; + stmt1.stmt().add_statement(&stmt3("type", recurse_type)("lower", "2")("upper", "2").stmt(), ""); + + SProxy< Bbox_Query_Statement > stmt4; + if (!bypass_get_data) + stmt1.stmt().add_statement(&stmt4("s", "50")("w", "6")("n", "52")("e", "9").stmt(), ""); + + stmt1.stmt().execute(rman); + } + perform_print(rman); + } + catch (File_Error e) + { + std::cerr<<"File error caught: " + < stmt1; + if (recurse_type == "relation-node") + stmt1("type", "relation")("ref", "1").stmt().execute(rman); + else if (recurse_type == "relation-way") + stmt1("type", "relation")("ref", "7").stmt().execute(rman); + else if (recurse_type == "relation-relation") + stmt1("type", "relation")("ref", "9").stmt().execute(rman); + else if (recurse_type == "relation-nwr" || recurse_type == "relation-nw" + || recurse_type == "relation-wr" || recurse_type == "relation-nr") + stmt1("type", "relation")("ref", "10").stmt().execute(rman); + else if (recurse_type == "node-relation") + stmt1("type", "node")("lower", to_string(global_node_offset + 1)) + ("upper", to_string(global_node_offset + 4)).stmt().execute(rman); + else if (recurse_type == "way-relation") + stmt1("type", "way")("ref", "1").stmt().execute(rman); + else if (recurse_type == "relation-backwards") + stmt1("type", "relation")("ref", "3").stmt().execute(rman); + } + { + SProxy< Query_Statement > stmt1; + stmt1("type", query_type); + + SProxy< Recurse_Statement > stmt2; + stmt1.stmt().add_statement(&stmt2("type", recurse_type)("role", role).stmt(), ""); + + SProxy< Has_Kv_Statement > stmt3; + if (key1 != "") + stmt1.stmt().add_statement(&stmt3("k", key1)("v", value1).stmt(), ""); + + stmt1.stmt().execute(rman); + } + perform_print(rman); + } + catch (File_Error e) + { + std::cerr<<"File error caught: " + < stmt1; + stmt1("type", query_type); + + SProxy< Id_Query_Statement > stmt2; + stmt1.stmt().add_statement(&stmt2 + ("type", query_type) + ("lower", to_string(1 + (query_type == "node" ? global_node_offset : 0))) + ("upper", to_string(10 + (query_type == "node" ? global_node_offset : 0))).stmt(), ""); + + SProxy< Has_Kv_Statement > stmt3; + if (key1 != "") + stmt1.stmt().add_statement(&stmt3("k", key1)("v", value1).stmt(), ""); + + SProxy< Bbox_Query_Statement > stmt4; + if (south <= 90.0 && north <= 90.0) + { + stmt1.stmt().add_statement + (&stmt4("n", to_string(north))("s", to_string(south)) + ("w", to_string(west))("e", to_string(east)).stmt(), ""); + } + + SProxy< Id_Query_Statement > stmt5; + if (double_id_query) + stmt1.stmt().add_statement(&stmt5 + ("type", query_type) + ("lower", to_string(9 + (query_type == "node" ? global_node_offset : 0))) + ("upper", to_string(12 + (query_type == "node" ? global_node_offset : 0))).stmt(), ""); + + stmt1.stmt().execute(rman); + } + perform_print(rman); + } + catch (File_Error e) + { + std::cerr<<"File error caught: " + < stmt1; + stmt1("type", query_type); + + SProxy< Id_Query_Statement > stmt2; + stmt1.stmt().add_statement(&stmt2 + ("type", query_type) + ("ref", to_string(10)) + ("ref_1", to_string(global_node_offset + 10)).stmt(), ""); + + stmt1.stmt().execute(rman); + } + perform_print(rman); + } + catch (File_Error e) + { + std::cerr<<"File error caught: " + <\n" + "\n"; + + // Test queries for nodes. + if ((test_to_execute == "") || (test_to_execute == "1")) + // Test a key and value which appears only locally + perform_query("node", "node_key_11", "node_value_2", args[3]); + if ((test_to_execute == "") || (test_to_execute == "2")) + // Test a key and value which appears almost everywhere + perform_query("node", "node_key_5", "node_value_5", args[3]); + if ((test_to_execute == "") || (test_to_execute == "3")) + // Test a key only which has multiple values + perform_query("node", "node_key_11", "", args[3]); + if ((test_to_execute == "") || (test_to_execute == "4")) + // Test a key only which has only one value + perform_query("node", "node_key_15", "", args[3]); + if ((test_to_execute == "") || (test_to_execute == "5")) + // Test a key only which doesn't appear at all + perform_query("node", "nowhere", "", args[3]); + if ((test_to_execute == "") || (test_to_execute == "6")) + // Test a key intersected with a small key and value pair + perform_query("node", "node_key_7", "", "node_key_11", "node_value_8", args[3]); + if ((test_to_execute == "") || (test_to_execute == "7")) + // Test a key intersected with a large key and value pair + perform_query("node", "node_key_7", "", "node_key_15", "node_value_15", args[3]); + if ((test_to_execute == "") || (test_to_execute == "8")) + // Test a bbox combined with a local key-value pair + perform_query_with_bbox("node", "node_key_11", "node_value_2", + "51.0", "51.2", "7.0", "8.0", args[3]); + if ((test_to_execute == "") || (test_to_execute == "9")) + // Test a bbox combined with a global key-value pair + perform_query_with_bbox("node", "node_key_5", "node_value_5", + "-10.0", "-1.0", "-15.0", "-3.0", args[3]); + if ((test_to_execute == "") || (test_to_execute == "10")) + // Test a bbox combined with a global key-value pair + perform_query_with_bbox("node", "node_key_7", "", + "-10.0", "-1.0", "-15.0", "-3.0", args[3]); + if ((test_to_execute == "") || (test_to_execute == "11")) + // Test three key-values intersected + perform_query("node", "node_key_5", "node_value_5", "node_key_7", "node_value_0", + "node_key_15", "node_value_15", args[3]); + + // Test queries for ways. + if ((test_to_execute == "") || (test_to_execute == "12")) + // Test a key and value which appears only locally + perform_query("way", "way_key_11", "way_value_2", args[3]); + if ((test_to_execute == "") || (test_to_execute == "13")) + // Test a key and value which appears almost everywhere + perform_query("way", "way_key_5", "way_value_5", args[3]); + if ((test_to_execute == "") || (test_to_execute == "14")) + // Test a key only which has multiple values + perform_query("way", "way_key_11", "", args[3]); + if ((test_to_execute == "") || (test_to_execute == "15")) + // Test a key only which has only one value + perform_query("way", "way_key_15", "", args[3]); + if ((test_to_execute == "") || (test_to_execute == "16")) + // Test a key only which doesn't appear at all + perform_query("way", "nowhere", "", args[3]); + if ((test_to_execute == "") || (test_to_execute == "17")) + // Test a key intersected with a small key and value pair + perform_query("way", "way_key_7", "", "way_key_11", "way_value_8", args[3]); + if ((test_to_execute == "") || (test_to_execute == "18")) + // Test a key intersected with a large key and value pair + perform_query("way", "way_key_7", "", "way_key_15", "way_value_15", args[3]); + if ((test_to_execute == "") || (test_to_execute == "19")) + // Test three key-values intersected + perform_query("way", "way_key_5", "way_value_5", "way_key_7", "way_value_0", + "way_key_15", "way_value_15", args[3]); + + // Test queries for relations. + if ((test_to_execute == "") || (test_to_execute == "20")) + // Test a key and value which appears only locally + perform_query("relation", "relation_key_11", "relation_value_2", args[3]); + if ((test_to_execute == "") || (test_to_execute == "21")) + // Test a key and value which appears almost everywhere + perform_query("relation", "relation_key_2/4", "relation_value_1", args[3]); + if ((test_to_execute == "") || (test_to_execute == "22")) + // Test a key only which has multiple values + perform_query("relation", "relation_key_2/4", "", args[3]); + if ((test_to_execute == "") || (test_to_execute == "23")) + // Test a key only which has only one value + perform_query("relation", "relation_key_5", "", args[3]); + if ((test_to_execute == "") || (test_to_execute == "24")) + // Test a key only which doesn't appear at all + perform_query("relation", "nowhere", "", args[3]); + if ((test_to_execute == "") || (test_to_execute == "25")) + // Test two key-values intersected. This tests also whether + // relations with index zero appear in the results. + perform_query("relation", "relation_key_2/4", "relation_value_0", + "relation_key_5", "relation_value_5", args[3]); + + if ((test_to_execute == "") || (test_to_execute == "26")) + // Test an around combined with a local key-value pair + perform_query_with_around("node", "node", "node_key_11", "", args[3], pattern_size, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "27")) + // Test an around combined with a global key-value pair + perform_query_with_around("node", "node", "node_key_7", "node_value_1", args[3], + pattern_size, global_node_offset); + + if ((test_to_execute == "") || (test_to_execute == "28")) + // Test a bbox combined with a global key-value pair, yielding diagonal ways. + perform_query_with_bbox("way", "way_key_5", "way_value_5", + "12.5", "35.0", "-15.0", "45.0", args[3]); + if ((test_to_execute == "") || (test_to_execute == "29")) + // Test a bbox combined with a global key-value pair, yielding horizontal and vertical ways. + perform_query_with_bbox("way", "way_key_5", "way_value_5", + "57.5", "80.0", "75.0", "105.0", args[3]); + + if ((test_to_execute == "") || (test_to_execute == "30")) + // Test a bbox combined with a global key-value pair, yielding diagonal ways. + perform_query_with_bbox("relation", "relation_key_2/4", "", + "12.5", "35.0", "-15.0", "45.0", args[3]); + if ((test_to_execute == "") || (test_to_execute == "31")) + // Test a bbox combined with a global key-value pair, yielding horizontal and vertical ways. + perform_query_with_bbox("relation", "relation_key_2/4", "", + "57.5", "80.0", "75.0", "105.0", args[3]); + + if ((test_to_execute == "") || (test_to_execute == "32")) + // Test regular expressions: A simple std::string + perform_regex_query("node", "", "", + "node_key_11", "^node_value_2$", true, + "", "", true, "", "", true, "", "", true, args[3]); + if ((test_to_execute == "") || (test_to_execute == "33")) + // Test regular expressions: An extended regular expression + perform_regex_query("node", "", "", + "node_key_11", "^node_.?alue_2$", true, + "", "", true, "", "", true, "", "", true, args[3]); + if ((test_to_execute == "") || (test_to_execute == "34")) + // Test regular expressions: Two regular expressions + perform_regex_query("relation", "", "", + "relation_key_2/4", "^relation_.*_0$", true, + "relation_key_5", "^relation_.*_5$", true, + "", "", true, "", "", true, args[3]); + if ((test_to_execute == "") || (test_to_execute == "35")) + // Test regular expressions: A regular expression and a key-value pair + perform_regex_query("relation", + "relation_key_2/4", "relation_value_0", + "relation_key_5", "^relation_.*_5$", true, + "", "", true, "", "", true, "", "", true, args[3]); + if ((test_to_execute == "") || (test_to_execute == "36")) + // Test regular expressions: A regular expression and a key only + perform_regex_query("way", "way_key_7", "", "way_key_11", "^way_.*_8$", true, + "", "", true, "", "", true, "", "", true, args[3]); + + if ((test_to_execute == "") || (test_to_execute == "37")) + // Test an around collecting ways from nodes + perform_query_with_around("node", "way", "", "", args[3], pattern_size, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "38")) + // Test an around collecting ways from nodes + perform_query_with_around("node", "way", "", "", args[3], pattern_size, global_node_offset, true); + + if ((test_to_execute == "") || (test_to_execute == "39")) + // Test an around collecting relations from nodes based on node membership + perform_query_with_around("node", "relation", "", "", args[3], pattern_size, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "40")) + // Test an around collecting relations from nodes based on way membership + perform_query_with_around("node", "relation", "", "", args[3], pattern_size, global_node_offset, true); + + if ((test_to_execute == "") || (test_to_execute == "41")) + // Test an around collecting relations from nodes based on node membership + perform_query_with_around("way", "node", "", "", args[3], pattern_size, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "42")) + // Test an around collecting relations from nodes based on way membership + perform_query_with_around("way", "way", "", "", args[3], pattern_size, global_node_offset); + + if ((test_to_execute == "") || (test_to_execute == "43")) + // Test an around collecting relations from nodes based on node membership + perform_query_with_around("relation", "node", "", "", args[3], pattern_size, global_node_offset); + if ((test_to_execute == "") || (test_to_execute == "44")) + // Test an around collecting relations from nodes based on way membership + perform_query_with_around("relation", "way", "", "", args[3], pattern_size, global_node_offset); + + if ((test_to_execute == "") || (test_to_execute == "45")) + // Test a simple has-k-not-v + perform_regex_query("relation", "", "", "", "", true, "", "", true, + "relation_key_7", "relation_value_2", false, + "", "", true, args[3]); + if ((test_to_execute == "") || (test_to_execute == "46")) + // Test a simple has-k-not-v guarded by another has-kv + perform_regex_query("node", "node_key", "node_few", + "", "", true, "", "", true, + "node_key_7", "node_value_0", false, + "", "", true, args[3]); + if ((test_to_execute == "") || (test_to_execute == "47")) + // Test two has-k-not-v + perform_regex_query("relation", "", "", "", "", true, "", "", true, + "relation_key_7", "relation_value_0", false, + "relation_key_7", "relation_value_2", false, args[3]); + if ((test_to_execute == "") || (test_to_execute == "48")) + // Test a simple has-k-not-reg-v + perform_regex_query("relation", "", "", + "relation_key_7", "^relation_value_2$", false, + "", "", true, "", "", true, "", "", true, args[3]); + if ((test_to_execute == "") || (test_to_execute == "49")) + // Test a simple has-k-not-reg-v guarded by another has-kv + perform_regex_query("node", "node_key", "node_few", + "node_key_7", "^node_value_0$", false, + "", "", true, "", "", true, "", "", true, args[3]); + if ((test_to_execute == "") || (test_to_execute == "50")) + // Test two has-k-not-reg-v + perform_regex_query("relation", "", "", + "relation_key_7", "^relation_value_0$", false, + "relation_key_7", "^relation_value_2$", false, + "", "", true, "", "", true, args[3]); + + // Test recurse of type way-node as subquery + if ((test_to_execute == "") || (test_to_execute == "51")) + perform_query_with_recurse("node", "way-node", "", "", 100.0, 100.0, 0.0, 0.0, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "52")) + perform_query_with_recurse("node", "way-node", "node_key_5", "node_value_5", + 100.0, 100.0, 0.0, 0.0, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "53")) + perform_query_with_recurse("node", "way-node", "", "", 51.5, 52.0, 7.5, 8.0, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "54")) + perform_query_with_recurse("node", "way-node", "node_key_5", "node_value_5", + 51.5, 52.0, 7.5, 8.0, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "55")) + perform_query_with_recurse("node", "way-node", "", "", 100.0, 100.0, 0.0, 0.0, true, + pattern_size, global_node_offset, args[3]); + + // Test recurse of type relation-node as subquery + if ((test_to_execute == "") || (test_to_execute == "56")) + perform_query_with_recurse("node", "relation-node", "", "", 100.0, 100.0, 0.0, 0.0, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "57")) + perform_query_with_recurse("node", "relation-node", "node_key_5", "node_value_5", + 100.0, 100.0, 0.0, 0.0, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "58")) + perform_query_with_recurse("node", "relation-node", "", "", 51.5, 52.0, 7.5, 8.0, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "59")) + perform_query_with_recurse("node", "relation-node", "node_key_5", "node_value_5", + 51.5, 52.0, 7.5, 8.0, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "60")) + perform_query_with_recurse("node", "relation-node", "", "", 100.0, 100.0, 0.0, 0.0, true, + pattern_size, global_node_offset, args[3]); + + // Test recurse of type relation-way as subquery + if ((test_to_execute == "") || (test_to_execute == "61")) + perform_query_with_recurse("way", "relation-way", "", "", 100.0, 100.0, 0.0, 0.0, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "62")) + perform_query_with_recurse("way", "relation-way", "way_key_2/4", "way_value_1", + 100.0, 100.0, 0.0, 0.0, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "63")) + perform_query_with_recurse("way", "relation-way", "", "", + 51.0, 51.0 + 2.0/pattern_size, 7.0, 7.5, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "64")) + perform_query_with_recurse("way", "relation-way", "way_key_2/4", "way_value_1", + 51.0, 51.0 + 2.0/pattern_size, 7.0, 7.5, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "65")) + perform_query_with_recurse("way", "relation-way", "", "", 100.0, 100.0, 0.0, 0.0, true, + pattern_size, global_node_offset, args[3]); + + // Test recurse of type relation-relation as subquery + if ((test_to_execute == "") || (test_to_execute == "66")) + perform_query_with_recurse("relation", "relation-relation", "", "", + 100.0, 100.0, 0.0, 0.0, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "67")) + perform_query_with_recurse("relation", "relation-relation", + "relation_key_2/4", "relation_value_0", + 100.0, 100.0, 0.0, 0.0, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "68")) + perform_query_with_recurse("relation", "relation-relation", "", "", + 51.75, 52.0, 7.0, 8.0, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "69")) + perform_query_with_recurse("relation", "relation-relation", + "relation_key_2/4", "relation_value_0", + 51.75, 52.0, 7.0, 8.0, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "70")) + perform_query_with_recurse("relation", "relation-relation", "", "", + 100.0, 100.0, 0.0, 0.0, true, + pattern_size, global_node_offset, args[3]); + + // Test recurse of type relation-relation as subquery + if ((test_to_execute == "") || (test_to_execute == "71")) + perform_query_with_recurse("way", "node-way", "", "", + 100.0, 100.0, 0.0, 0.0, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "72")) + perform_query_with_recurse("way", "node-way", "way_key_2/4", "way_value_0", + 100.0, 100.0, 0.0, 0.0, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "73")) + perform_query_with_recurse("way", "node-way", "", "", + 51.0, 51.5, 8.0 - 3.0/pattern_size, 8.0, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "74")) + perform_query_with_recurse("way", "node-way", "way_key_2/4", "way_value_0", + 51.0, 51.5, 8.0 - 3.0/pattern_size, 8.0, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "75")) + perform_query_with_recurse("way", "node-way", "", "", + 100.0, 100.0, 0.0, 0.0, true, + pattern_size, global_node_offset, args[3]); + + // Test recurse of type relation-relation as subquery + if ((test_to_execute == "") || (test_to_execute == "76")) + perform_query_with_recurse("relation", "node-relation", "", "", + 100.0, 100.0, 0.0, 0.0, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "77")) + perform_query_with_recurse("relation", "node-relation", "relation_key_2/4", "relation_value_0", + 100.0, 100.0, 0.0, 0.0, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "78")) + perform_query_with_recurse("relation", "node-relation", "", "", + 51.0, 51.0 + 1.0/pattern_size, 8.0 - 1.0/pattern_size, 8.0, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "79")) + perform_query_with_recurse("relation", "node-relation", "relation_key_2/4", "relation_value_0", + 52.0 - 1.0/pattern_size, 52.0, 8.0 - 1.0/pattern_size, 8.0, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "80")) + perform_query_with_recurse("relation", "node-relation", "", "", + 100.0, 100.0, 0.0, 0.0, true, + pattern_size, global_node_offset, args[3]); + + // Test recurse of type relation-relation as subquery + if ((test_to_execute == "") || (test_to_execute == "81")) + perform_query_with_recurse("relation", "way-relation", "", "", + 100.0, 100.0, 0.0, 0.0, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "82")) + perform_query_with_recurse("relation", "way-relation", "relation_key_5", "relation_value_5", + 100.0, 100.0, 0.0, 0.0, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "83")) + perform_query_with_recurse("relation", "way-relation", "", "", + 51.0, 51.0 + 2.0/pattern_size, 7.0, 7.0 + 1.0/pattern_size, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "84")) + perform_query_with_recurse("relation", "way-relation", "relation_key_5", "relation_value_5", + 51.0, 51.0 + 2.0/pattern_size, 7.0, 7.0 + 1.0/pattern_size, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "85")) + perform_query_with_recurse("relation", "way-relation", "", "", + 100.0, 100.0, 0.0, 0.0, true, + pattern_size, global_node_offset, args[3]); + + // Test recurse of type relation-relation as subquery + if ((test_to_execute == "") || (test_to_execute == "86")) + perform_query_with_recurse("relation", "relation-backwards", "", "", + 100.0, 100.0, 0.0, 0.0, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "87")) + perform_query_with_recurse("relation", "relation-backwards", + "relation_key_2/4", "relation_value_0", + 100.0, 100.0, 0.0, 0.0, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "88")) + perform_query_with_recurse("relation", "relation-backwards", "", "", + 51.0, 51.0 + 1.0/pattern_size, 7.0, 7.0 + 1.0/pattern_size, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "89")) + perform_query_with_recurse("relation", "relation-backwards", + "relation_key_2/4", "relation_value_0", + 51.0, 51.0 + 1.0/pattern_size, 7.0, 7.0 + 1.0/pattern_size, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "90")) + perform_query_with_recurse("relation", "relation-backwards", "", "", + 100.0, 100.0, 0.0, 0.0, true, + pattern_size, global_node_offset, args[3]); + + // Test id-query type node as subquery + if ((test_to_execute == "") || (test_to_execute == "91")) + perform_query_with_id_query("node", "", "", 100.0, 100.0, 0.0, 0.0, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "92")) + perform_query_with_id_query("node", "node_key_5", "node_value_5", + 100.0, 100.0, 0.0, 0.0, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "93")) + perform_query_with_id_query("node", "", "", + 51.0, 51.5, 7.0, 7.0 + 5.0/pattern_size, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "94")) + perform_query_with_id_query("node", "node_key_5", "node_value_5", + 51.0, 51.5, 7.0, 7.0 + 5.0/pattern_size, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "95")) + perform_query_with_id_query("node", "", "", 100.0, 100.0, 0.0, 0.0, true, + pattern_size, global_node_offset, args[3]); + + // Test id-query type way as subquery + if ((test_to_execute == "") || (test_to_execute == "96")) + perform_query_with_id_query("way", "", "", 100.0, 100.0, 0.0, 0.0, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "97")) + perform_query_with_id_query("way", "way_key_5", "way_value_5", + 100.0, 100.0, 0.0, 0.0, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "98")) + perform_query_with_id_query("way", "", "", + 51.0, 51.5, 7.0, 7.0 + 5.0/pattern_size, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "99")) + perform_query_with_id_query("way", "way_key_5", "way_value_5", + 51.0, 51.5, 7.0, 7.0 + 5.0/pattern_size, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "100")) + perform_query_with_id_query("way", "", "", 100.0, 100.0, 0.0, 0.0, true, + pattern_size, global_node_offset, args[3]); + + // Test id-query type relation as subquery + if ((test_to_execute == "") || (test_to_execute == "101")) + perform_query_with_id_query("relation", "", "", 100.0, 100.0, 0.0, 0.0, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "102")) + perform_query_with_id_query("relation", "relation_key_5", "relation_value_5", + 100.0, 100.0, 0.0, 0.0, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "103")) + perform_query_with_id_query("relation", "", "", + 51.0, 51.5, 7.0, 7.0 + 6.0/pattern_size, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "104")) + perform_query_with_id_query("relation", "relation_key_5", "relation_value_5", + 51.0, 51.5, 7.0, 7.0 + 6.0/pattern_size, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "105")) + perform_query_with_id_query("relation", "", "", 100.0, 100.0, 0.0, 0.0, true, + pattern_size, global_node_offset, args[3]); + + // Test recurse of type down as subquery + if ((test_to_execute == "") || (test_to_execute == "106")) + perform_query_with_recurse("node", "down", "", "", 100.0, 100.0, 0.0, 0.0, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "107")) + perform_query_with_recurse("way", "down", "", "", 100.0, 100.0, 0.0, 0.0, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "108")) + perform_query_with_recurse("relation", "down", "", "", 100.0, 100.0, 0.0, 0.0, false, + pattern_size, global_node_offset, args[3]); + + // Test recurse of type down-rel as subquery + if ((test_to_execute == "") || (test_to_execute == "109")) + perform_query_with_recurse("node", "down-rel", "", "", 100.0, 100.0, 0.0, 0.0, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "110")) + perform_query_with_recurse("way", "down-rel", "", "", 100.0, 100.0, 0.0, 0.0, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "111")) + perform_query_with_recurse("relation", "down-rel", "", "", 100.0, 100.0, 0.0, 0.0, false, + pattern_size, global_node_offset, args[3]); + + // Test recurse of type up as subquery + if ((test_to_execute == "") || (test_to_execute == "112")) + perform_query_with_recurse("node", "up", "", "", 100.0, 100.0, 0.0, 0.0, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "113")) + perform_query_with_recurse("way", "up", "", "", 100.0, 100.0, 0.0, 0.0, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "114")) + perform_query_with_recurse("relation", "up", "", "", 100.0, 100.0, 0.0, 0.0, false, + pattern_size, global_node_offset, args[3]); + + // Test recurse of type up-rel as subquery + if ((test_to_execute == "") || (test_to_execute == "115")) + perform_query_with_recurse("node", "up-rel", "", "", 100.0, 100.0, 0.0, 0.0, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "116")) + perform_query_with_recurse("way", "up-rel", "", "", 100.0, 100.0, 0.0, 0.0, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "117")) + perform_query_with_recurse("relation", "up-rel", "", "", 100.0, 100.0, 0.0, 0.0, false, + pattern_size, global_node_offset, args[3]); + + // Test combination of keys-only with several other elements + if ((test_to_execute == "") || (test_to_execute == "118")) + perform_multi_query_with_bbox("node", "node_key_5", "", "node_key_7", "", "", "", 0, true, + 30.0 + 9.9/pattern_size, 30.0 + 10.1/pattern_size, -120.0, -60.0, args[3]); + if ((test_to_execute == "") || (test_to_execute == "119")) + perform_multi_query_with_bbox("node", "node_key_7", "", "node_key_7", "", "", "", 0, true, + 30.0 + 9.9/pattern_size, 30.0 + 10.1/pattern_size, -120.0, -60.0, args[3]); + if ((test_to_execute == "") || (test_to_execute == "120")) + perform_multi_query_with_bbox("node", "node_key_7", "", "node_key_5", "", "", "", 0, true, + 30.0 + 9.9/pattern_size, 30.0 + 10.1/pattern_size, -120.0, -60.0, args[3]); + if ((test_to_execute == "") || (test_to_execute == "121")) + perform_multi_query_with_bbox("node", "node_key_7", "", "node_key_5", ".", "", "", 2, true, + 30.0 + 9.9/pattern_size, 30.0 + 10.1/pattern_size, -120.0, -60.0, args[3]); + if ((test_to_execute == "") || (test_to_execute == "122")) + perform_multi_query_with_bbox("node", "node_key_7", "", "node_key_7", "node_value_0", "", "", 0, false, + 30.0 + 9.9/pattern_size, 30.0 + 10.1/pattern_size, -120.0, -60.0, args[3]); + if ((test_to_execute == "") || (test_to_execute == "123")) + perform_multi_query_with_bbox("node", "node_key_7", "", "node_key_7", "node_value_0", "", "", 2, false, + 30.0 + 9.9/pattern_size, 30.0 + 10.1/pattern_size, -120.0, -60.0, args[3]); + if ((test_to_execute == "") || (test_to_execute == "124")) + perform_multi_query_with_bbox("node", "node_key_7", "", "node_key_11", "node_value", "", "", 2, false, + 30.0 + 9.9/pattern_size, 30.0 + 10.1/pattern_size, -120.0, -60.0, args[3]); + if ((test_to_execute == "") || (test_to_execute == "125")) + perform_multi_query_with_bbox("node", "node_key_7", "", "node_key_7", "value_0", "", "", 2, true, + 30.0 + 9.9/pattern_size, 30.0 + 10.1/pattern_size, -120.0, -60.0, args[3]); + if ((test_to_execute == "") || (test_to_execute == "126")) + perform_multi_query_with_bbox("node", "node_key_7", "node_....._0", "node_key_7", "value_", "", "", 3, true, + 30.0 + 9.9/pattern_size, 30.0 + 10.1/pattern_size, -120.0, -60.0, args[3]); + + if ((test_to_execute == "") || (test_to_execute == "127")) + // Test an around combined with a local key-value pair + perform_query_with_around("node", "node_key_11", "", args[3], pattern_size); + if ((test_to_execute == "") || (test_to_execute == "128")) + // Test an around combined with a global key-value pair + perform_query_with_around("node", "node_key_7", "node_value_1", args[3], + pattern_size); + + if ((test_to_execute == "") || (test_to_execute == "129")) + // Test an around collecting ways from nodes + perform_query_with_around("way", "", "", args[3], pattern_size); + if ((test_to_execute == "") || (test_to_execute == "130")) + // Test an around collecting ways from nodes + perform_query_with_around("way", "", "", args[3], pattern_size, true); + + if ((test_to_execute == "") || (test_to_execute == "131")) + // Test an around collecting relations from nodes based on node membership + perform_query_with_around("relation", "", "", args[3], pattern_size); + if ((test_to_execute == "") || (test_to_execute == "132")) + // Test an around collecting relations from nodes based on way membership + perform_query_with_around("relation", "", "", args[3], pattern_size, true); + + if ((test_to_execute == "") || (test_to_execute == "133")) + // Test an around collecting relations from nodes based on way membership + perform_query_with_role_recurse("relation-node", "one", "", "", + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "134")) + // Test an around collecting relations from nodes based on way membership + perform_query_with_role_recurse("relation-way", "two", "", "", + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "135")) + // Test an around collecting relations from nodes based on way membership + perform_query_with_role_recurse("relation-relation", "one", "", "", + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "136")) + // Test an around collecting relations from nodes based on way membership + perform_query_with_role_recurse("node-relation", "zero", "", "", + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "137")) + // Test an around collecting relations from nodes based on way membership + perform_query_with_role_recurse("way-relation", "two", "", "", + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "138")) + // Test an around collecting relations from nodes based on way membership + perform_query_with_role_recurse("relation-backwards", "one", "", "", + pattern_size, global_node_offset, args[3]); + + if ((test_to_execute == "") || (test_to_execute == "139")) + // Test a single regex on keys + perform_key_regex_query("node", "", "", + "^node_key_11$", "^node_value_..$", true, + "", "", true, args[3]); + if ((test_to_execute == "") || (test_to_execute == "140")) + // Test two regexes on keys + perform_key_regex_query("node", "", "", + "^node_key_11$", "^node_value_..$", true, + "^node_key_5", "^node", true, args[3]); + if ((test_to_execute == "") || (test_to_execute == "141")) + // Test a single regex on keys with a key-value + perform_key_regex_query("way", "way_key_2/4", "way_value_0", + "^way_key_11$", "^way_value_..$", true, + "", "", true, args[3]); + if ((test_to_execute == "") || (test_to_execute == "142")) + // Test two regexes on keys with a key-value + perform_key_regex_query("way", "way_key_2/4", "way_value_0", + "^way_key_11$", "^way_value_..$", true, + "^way_key_5", "^way", true, args[3]); + if ((test_to_execute == "") || (test_to_execute == "143")) + // Test a single regex on keys with a key only + perform_key_regex_query("way", "way_key_2/4", "", + "^way_key_11$", "^way_value_..$", true, + "", "", true, args[3]); + if ((test_to_execute == "") || (test_to_execute == "144")) + // Test two regexes on keys with a key only + perform_key_regex_query("way", "way_key_2/4", "", + "^way_key_11$", "^way_value_..$", true, + "^way_key_5", "^way", true, args[3]); + + if ((test_to_execute == "") || (test_to_execute == "145")) + // Test a single regex on keys with bounding box + perform_multi_query_with_bbox("node", "^node_key_11$", "^node_value_..$", + "", "", "", "", 0x33, true, 51, 51.5, 7, 8, args[3]); + if ((test_to_execute == "") || (test_to_execute == "146")) + // Test two regexes on keys with bounding box + perform_multi_query_with_bbox("node", "^node_key_11$", "^node_value_..$", + "^node_key_5", "^node", "", "", 0x33, true, 51, 51.5, 7, 8, args[3]); + if ((test_to_execute == "") || (test_to_execute == "147")) + // Test a single regex on keys with bounding box + perform_multi_query_with_bbox("way", "way_key_2/4", "way_value_0", + "^way_key_11$", "^way_value_..$", "", "", 0x22, true, 51, 51.5, 7, 8, args[3]); + if ((test_to_execute == "") || (test_to_execute == "148")) + // Test a single regex on keys with bounding box + perform_multi_query_with_bbox("way", "way_key_2/4", "way_value_0", + "^way_key_11$", "^way_value_..$", "^way_key_5", "^way", 0x66, true, 51, 51.5, 7, 8, args[3]); + if ((test_to_execute == "") || (test_to_execute == "149")) + // Test a single regex on keys with bounding box + perform_multi_query_with_bbox("way", "way_key_2/4", "", + "^way_key_11$", "^way_value_..$", "", "", 0x22, true, 51, 51.5, 7, 8, args[3]); + if ((test_to_execute == "") || (test_to_execute == "150")) + // Test a single regex on keys with bounding box + perform_multi_query_with_bbox("way", "way_key_2/4", "", + "^way_key_11$", "^way_value_..$", "^way_key_5", "^way", 0x66, true, 51, 51.5, 7, 8, args[3]); + + if ((test_to_execute == "") || (test_to_execute == "151")) + // Test a bbox combined with a key-value pair via a filter + perform_filter_with_bbox("node", "node_key_5", "node_value_5", + "12.5", "35.0", "-15.0", "45.0", args[3]); + if ((test_to_execute == "") || (test_to_execute == "152")) + // Test a bbox combined with a key-value pair via a filter + perform_filter_with_bbox("way", "way_key_5", "way_value_5", + "12.5", "35.0", "-15.0", "45.0", args[3]); + if ((test_to_execute == "") || (test_to_execute == "153")) + // Test a bbox combined with a key-value pair via a filter + perform_filter_with_bbox("relation", "relation_key_2/4", "relation_value_0", + "12.5", "35.0", "-15.0", "45.0", args[3]); + + if ((test_to_execute == "") || (test_to_execute == "154")) + // Test a key combined with a key-value pair via a filter + perform_filter_with_key("node", "node_key_5", "node_value_5", "node_key", args[3]); + if ((test_to_execute == "") || (test_to_execute == "155")) + // Test a key combined with a key-value pair via a filter + perform_filter_with_key("way", "way_key_5", "way_value_5", "way_key", args[3]); + if ((test_to_execute == "") || (test_to_execute == "156")) + // Test a key combined with a key-value pair via a filter + perform_filter_with_key("relation", "relation_key_5", "relation_value_5", + "relation_key_2/4", args[3]); + + if ((test_to_execute == "") || (test_to_execute == "157")) + // Test a key-value pair via a filter set by a previous element + perform_filter_from_previous_element("node", 14 + global_node_offset, "node_key_11", "node_key_7", "_", args[3]); + if ((test_to_execute == "") || (test_to_execute == "158")) + // Test a key-value pair via a filter set by a previous element + perform_filter_from_previous_element("way", 14, "way_key_11", "way_key_7", "_", args[3]); + if ((test_to_execute == "") || (test_to_execute == "159")) + // Test a key-value pair via a filter set by a previous element + perform_filter_from_previous_element("relation", 14, "relation_key_11", "relation_key_7", "_", args[3]); + + if ((test_to_execute == "") || (test_to_execute == "160")) + perform_query_with_recurse("nwr", "relation-nwr", "", "", + 100.0, 100.0, 0.0, 0.0, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "161")) + perform_query_with_role_recurse("relation-nwr", "two", "", "", + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "162")) + perform_query_with_role_recurse("relation-nwr", "three", "", "", + pattern_size, global_node_offset, args[3]); + + if ((test_to_execute == "") || (test_to_execute == "163")) + perform_query_with_recurse("nw", "relation-nw", "", "", + 100.0, 100.0, 0.0, 0.0, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "164")) + perform_query_with_role_recurse("relation-nw", "two", "", "", + pattern_size, global_node_offset, args[3]); + + if ((test_to_execute == "") || (test_to_execute == "165")) + perform_query_with_recurse("wr", "relation-wr", "", "", + 100.0, 100.0, 0.0, 0.0, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "166")) + perform_query_with_role_recurse("relation-wr", "three", "", "", + pattern_size, global_node_offset, args[3]); + + if ((test_to_execute == "") || (test_to_execute == "167")) + perform_query_with_recurse("nr", "relation-nr", "", "", + 100.0, 100.0, 0.0, 0.0, false, + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "168")) + perform_query_with_role_recurse("relation-nr", "one", "", "", + pattern_size, global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "169")) + perform_query_with_role_recurse("relation-nr", "zero", "", "", + pattern_size, global_node_offset, args[3]); + + if ((test_to_execute == "") || (test_to_execute == "170")) + // Test whether chunked processing works. + // For this purpose, test a bbox combined with a key-value pair via a filter + perform_filter_with_bbox("node", "node_key_15", "node_value_15", + "-90.0", "90.0", "-120.0", "105.0", args[3], 900, 33554432); + + // Test id-query types nwr, nw, wr, nr as subqueries + if ((test_to_execute == "") || (test_to_execute == "171")) + perform_query_with_two_ids_query("nwr", global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "172")) + perform_query_with_two_ids_query("nw", global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "173")) + perform_query_with_two_ids_query("wr", global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "174")) + perform_query_with_two_ids_query("nr", global_node_offset, args[3]); + if ((test_to_execute == "") || (test_to_execute == "175")) + perform_recurse_cnt_link("way-count", false, pattern_size, args[3]); + if ((test_to_execute == "") || (test_to_execute == "176")) + perform_recurse_cnt_link("way-count", true, pattern_size, args[3]); + if ((test_to_execute == "") || (test_to_execute == "177")) + perform_recurse_cnt_link("way-link", false, pattern_size, args[3]); + if ((test_to_execute == "") || (test_to_execute == "178")) + perform_recurse_cnt_link("way-link", true, pattern_size, args[3]); + + std::cout<<"\n"; + return 0; +} diff --git a/src/overpass_api/statements/recurse.test.cc b/src/overpass_api/statements/recurse.test.cc new file mode 100644 index 000000000..965f205ae --- /dev/null +++ b/src/overpass_api/statements/recurse.test.cc @@ -0,0 +1,660 @@ +/** Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Roland Olbricht et al. + * + * This file is part of Overpass_API. + * + * Overpass_API is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Overpass_API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Overpass_API. If not, see . + */ + +#include +#include +#include "../../template_db/block_backend.h" +#include "../core/settings.h" +#include "../output_formats/output_xml.h" +#include "id_query.h" +#include "print.h" +#include "recurse.h" + + +Resource_Manager& perform_id_query(Resource_Manager& rman, std::string type, uint64 id) +{ + Parsed_Query global_settings; + Id_Query_Statement(1, { {"type", type}, {"ref", std::to_string(id)} }, global_settings).execute(rman); + return rman; +} + +Resource_Manager& perform_multi_id_query(Resource_Manager& rman, std::string type, const std::vector< uint64 >& ids) +{ + std::map< std::string, std::string > attributes; + attributes["type"] = type; + if (!ids.empty()) + attributes["ref"] = std::to_string(ids[0]); + for (uint i = 1; i < ids.size(); ++i) + attributes["ref_" + std::to_string(i)] = std::to_string(ids[i]); + + Parsed_Query global_settings; + Id_Query_Statement(1, attributes, global_settings).execute(rman); + return rman; +} + +int main(int argc, char* args[]) +{ + if (argc < 5) + { + std::cout<<"Usage: "<\n" + "\n"; + + if ((test_to_execute == "") || (test_to_execute == "1")) + { + try + { + // Collect the nodes of some small ways + Nonsynced_Transaction transaction(Access_Mode::readonly, false, args[3], ""); + Resource_Manager total_rman(transaction, &global_settings); + Set total; + + for (uint32 i = 1; i <= pattern_size/2; ++i) + { + Resource_Manager rman(transaction, &global_settings); + perform_id_query(rman, "way", i); + const Set* default_ = rman.get_set("_"); + if (default_ && !default_->ways.empty()) + total.ways[default_->ways.begin()->first].push_back(default_->ways.begin()->second.front()); + } + total_rman.swap_set("_", total); + + Recurse_Statement(2, { { "type", "way-node" } }, global_settings).execute(total_rman); + Print_Statement(3, {}, global_settings).execute(total_rman); + } + catch (File_Error e) { std::cerr<<"File error caught: "<ways.empty()) + total.ways[default_->ways.begin()->first].push_back(default_->ways.begin()->second.front()); + } + total_rman.swap_set("_", total); + + Recurse_Statement(2, { { "type", "way-node" } }, global_settings).execute(total_rman); + Print_Statement(3, {}, global_settings).execute(total_rman); + } + catch (File_Error e) { std::cerr<<"File error caught: "< ids; + for (uint j = 1; j <= pattern_size/2; ++j) + ids.push_back(pattern_size*i + j + global_node_offset); + + Resource_Manager rman(transaction, &global_settings); + perform_multi_id_query(rman, "node", ids); + const Set* default_ = rman.get_set("_"); + if (default_) + { + for (std::map< Uint32_Index, std::vector< Node_Skeleton > >::const_iterator + it1 = default_->nodes.begin(); it1 != default_->nodes.end(); ++it1) + { + for (std::vector< Node_Skeleton >::const_iterator it2 = it1->second.begin(); + it2 != it1->second.end(); ++it2) + total.nodes[it1->first].push_back(*it2); + } + } + } + total_rman.swap_set("_", total); + + Recurse_Statement(2, { { "type", "node-way" } }, global_settings).execute(total_rman); + Print_Statement(3, {}, global_settings).execute(total_rman); + } + catch (File_Error e) { std::cerr<<"File error caught: "<relations.empty()) + total.relations[default_->relations.begin()->first].push_back(default_->relations.begin()->second.front()); + } + total_rman.swap_set("_", total); + + Recurse_Statement(2, { { "type", "relation-node" } }, global_settings).execute(total_rman); + Print_Statement(3, {}, global_settings).execute(total_rman); + } + catch (File_Error e) { std::cerr<<"File error caught: "<nodes.empty()) + total.nodes[default_->nodes.begin()->first].push_back(default_->nodes.begin()->second.front()); + } + total_rman.swap_set("_", total); + + Recurse_Statement(2, { { "type", "node-relation" }, { "role", "zero" } }, global_settings).execute(total_rman); + Print_Statement(3, {}, global_settings).execute(total_rman); + } + catch (File_Error e) { std::cerr<<"File error caught: "<relations.empty()) + total.relations[default_->relations.begin()->first].push_back(default_->relations.begin()->second.front()); + } + total_rman.swap_set("_", total); + + Recurse_Statement(2, { {"type", "relation-backwards"}, {"role", "one"} }, global_settings).execute(total_rman); + Print_Statement(3, {}, global_settings).execute(total_rman); + } + catch (File_Error e) { std::cerr<<"File error caught: "<\n"; + return 0; +} diff --git a/src/overpass_api/statements/testing_tools.cc b/src/overpass_api/statements/testing_tools.cc new file mode 100644 index 000000000..68bc43d5e --- /dev/null +++ b/src/overpass_api/statements/testing_tools.cc @@ -0,0 +1,27 @@ +/** Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Roland Olbricht et al. + * + * This file is part of Overpass_API. + * + * Overpass_API is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Overpass_API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Overpass_API. If not, see . + */ + +#include "testing_tools.h" + + +Statement* Statement_Container::add_stmt(Statement* stmt, Statement* parent) +{ + cont.push_back(stmt); + parent->add_statement(stmt, ""); + return stmt; +} diff --git a/src/overpass_api/statements/testing_tools.h b/src/overpass_api/statements/testing_tools.h new file mode 100644 index 000000000..c9fff8056 --- /dev/null +++ b/src/overpass_api/statements/testing_tools.h @@ -0,0 +1,70 @@ +/** Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Roland Olbricht et al. + * + * This file is part of Overpass_API. + * + * Overpass_API is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Overpass_API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Overpass_API. If not, see . + */ + +#ifndef DE__OSM3S___OVERPASS_API__STATEMENTS__TESTING_TOOLS_H +#define DE__OSM3S___OVERPASS_API__STATEMENTS__TESTING_TOOLS_H + + +#include "../core/parsed_query.h" +#include "statement.h" + +#include +#include +#include + + +struct Attr +{ + Attr& operator()(const std::string& k, const std::string& v) + { + kvs_[k] = v; + return *this; + } + + const std::map< std::string, std::string >& kvs() { return kvs_; } + +private: + std::map< std::string, std::string > kvs_; +}; + + +struct Statement_Container +{ + Statement_Container(Parsed_Query& global_settings) : global_settings_(&global_settings) {} + ~Statement_Container() + { + for (std::vector< Statement* >::iterator it = cont.begin(); it != cont.end(); ++it) + delete *it; + } + + Statement* add_stmt(Statement* stmt, Statement* parent); + Parsed_Query& global_settings() { return *global_settings_; } + + template< typename NewStatement > + Statement* create_stmt(const std::map< std::string, std::string >& attributes, Statement* parent) + { + return add_stmt(new NewStatement(0, attributes, *global_settings_), parent); + } + +private: + Parsed_Query* global_settings_; + std::vector< Statement* > cont; +}; + + +#endif diff --git a/src/overpass_api/statements/union.test.cc b/src/overpass_api/statements/union.test.cc new file mode 100644 index 000000000..e814294f1 --- /dev/null +++ b/src/overpass_api/statements/union.test.cc @@ -0,0 +1,304 @@ +/** Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Roland Olbricht et al. + * + * This file is part of Overpass_API. + * + * Overpass_API is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Overpass_API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Overpass_API. If not, see . + */ + +#include +#include +#include "../../template_db/block_backend.h" +#include "../core/settings.h" +#include "../output_formats/output_xml.h" +#include "id_query.h" +#include "item.h" +#include "print.h" +#include "query.h" +#include "recurse.h" +#include "union.h" + + +std::string to_string_(uint64 val) +{ + std::ostringstream buf; + buf<\n" + "\n"; + + if ((test_to_execute == "") || (test_to_execute == "1")) + { + // Test whether union works well with all relevant statements. + try + { + { + Nonsynced_Transaction transaction(Access_Mode::readonly, false, args[2], ""); + Resource_Manager rman(transaction, &global_settings); + + const char* attributes[] = { 0 }; + Union_Statement stmt(0, convert_c_pairs(attributes), global_settings); + + std::string buf = to_string_(2 + global_node_offset); + const char* attributes1[] = { "type", "node", "ref", buf.c_str(), 0 }; + Id_Query_Statement stmt1(0, convert_c_pairs(attributes1), global_settings); + stmt.add_statement(&stmt1, ""); + + const char* attributes2[] = { "type", "node-relation", 0 }; + Recurse_Statement stmt2(0, convert_c_pairs(attributes2), global_settings); + stmt.add_statement(&stmt2, ""); + + const char* attributes3[] = { "type", "way", 0 }; + Query_Statement stmt3(0, convert_c_pairs(attributes3), global_settings); + + const char* attributes_kv[] = { "k", "way_key_11", "v", "way_value_2", 0 }; + Has_Kv_Statement stmt4(0, convert_c_pairs(attributes_kv), global_settings); + stmt3.add_statement(&stmt4, ""); + + stmt.add_statement(&stmt3, ""); + + stmt.execute(rman); + { + const char* attributes[] = { 0 }; + Print_Statement stmt(0, convert_c_pairs(attributes), global_settings); + stmt.execute(rman); + } + } + } + catch (File_Error e) + { + std::cerr<<"File error caught: " + <\n"; + return 0; +} diff --git a/src/template_db/block_backend.test.cc b/src/template_db/block_backend.test.cc new file mode 100644 index 000000000..6a1638229 --- /dev/null +++ b/src/template_db/block_backend.test.cc @@ -0,0 +1,817 @@ +/** Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Roland Olbricht et al. + * + * This file is part of Overpass_API. + * + * Overpass_API is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Overpass_API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Overpass_API. If not, see . + */ + +#include +#include +#include + +#include + +#include "block_backend.h" +#include "block_backend_write.h" +#include "transaction.h" + + +/** + * Tests the library block_backend + */ + +//----------------------------------------------------------------------------- + +/* Sample class for TIndex */ +struct IntIndex +{ + typedef uint32 Id_Type; + + IntIndex(void* data) : value(*(uint32*)data) {} + IntIndex(int i) : value(i) {} + + static bool equal(void* lhs, void* rhs) { return *(uint32*)lhs == *(uint32*)rhs; } + bool less(void* rhs) const { return value < *(uint32*)rhs; } + bool leq(void* rhs) const { return value <= *(uint32*)rhs; } + bool equal(void* rhs) const { return value == *(uint32*)rhs; } + + uint32 size_of() const { return 4; } + static constexpr uint32 const_size() { return 4; } + static uint32 size_of(void* data) { return 4; } + + void to_data(void* data) const + { + *(uint32*)data = value; + } + + bool operator<(const IntIndex& index) const + { + return this->value < index.value; + } + + bool operator==(const IntIndex& index) const + { + return this->value == index.value; + } + + int val() const + { + return value; + } + + private: + uint32 value; +}; + + +struct IntObject +{ + typedef uint32 Id_Type; + + IntObject(void* data) : value(*(uint32*)data) + { + if (value >= 1000000000 && value/100000000%2 == 0) + { + uint size = (value - 1000000000)%1000000 + 4; + for (uint i = 1; 4*i < size - 3; ++i) + { + if (*(((uint32*)data)+i) != (0x55aa0000 | (i & 0xffff))) + { + value = -i; + break; + } + } + if (value > 0 && size%4 >= 3 && *(((uint8*)data)+size-3) != 0xa5) + value = -1000000003; + if (value > 0 && size%4 >= 2 && *(((uint8*)data)+size-2) != 0x5a) + value = -1000000002; + if (value > 0 && size%4 >= 1 && *(((uint8*)data)+size-1) != 0xa5) + value = -1000000001; + } + } + + IntObject(int i) : value(i) {} + + uint32 size_of() const + { + return value < 1000000000 || value/100000000%2 == 1 ? 4 : (value - 1000000000)%1000000 + 4; + } + + static uint32 size_of(void* data) + { + return *(uint32*)data < 1000000000 || *(uint32*)data/100000000%2 == 1 + ? 4 : (*(uint32*)data - 1000000000)%1000000 + 4; + } + + void to_data(void* data) const + { + if (value >= 1000000000 && value/100000000%2 == 0) + { + uint size = (value - 1000000000)%1000000 + 4; + *(((uint8*)data)+size-3) = 0xa5; + *(((uint8*)data)+size-2) = 0x5a; + *(((uint8*)data)+size-1) = 0xa5; + for (uint i = 1; 4*i < size - 3; ++i) + *(((uint32*)data)+i) = (0x55aa0000 | (i & 0xffff)); + } + *(uint32*)data = value; + } + + bool operator<(const IntObject& index) const + { + return this->value < index.value; + } + + int val() const + { + return value; + } + + private: + int32 value; +}; + + +typedef std::list< IntIndex >::const_iterator IntIterator; + +struct IntRangeIterator : std::list< std::pair< IntIndex, IntIndex > >::const_iterator +{ + IntRangeIterator + (const std::list< std::pair< IntIndex, IntIndex > >::const_iterator it) + : std::list< std::pair< IntIndex, IntIndex > >::const_iterator(it) {} + + const IntIndex& lower_bound() const + { + return (*this)->first; + } + + const IntIndex& upper_bound() const + { + return (*this)->second; + } +}; + +//----------------------------------------------------------------------------- + +/* We use our own test settings */ +std::string BASE_DIRECTORY("./"); +std::string DATA_SUFFIX(".bin"); +std::string INDEX_SUFFIX(".idx"); + + +struct Test_File : File_Properties +{ + const std::string& get_basedir() const + { + return BASE_DIRECTORY; + } + + const std::string& get_file_name_trunk() const + { + static std::string result("testfile"); + return result; + } + + const std::string& get_index_suffix() const + { + return INDEX_SUFFIX; + } + + const std::string& get_data_suffix() const + { + return DATA_SUFFIX; + } + + const std::string& get_id_suffix() const + { + static std::string result(""); + return result; + } + + const std::string& get_shadow_suffix() const + { + static std::string result(".shadow"); + return result; + } + + uint32 get_block_size() const + { + return 512; + } + + uint32 get_compression_factor() const + { + return 1; + } + + uint32 get_compression_method() const + { + return 0; + } + + uint32 get_map_compression_method() const + { + return File_Blocks_Index_Base::NO_COMPRESSION; + } + + uint32 get_map_block_size() const + { + return 16; + } + + uint32 get_map_compression_factor() const + { + return 1; + } + + std::vector< bool > get_data_footprint(const std::string& db_dir) const + { + return std::vector< bool >(); + } + + std::vector< bool > get_map_footprint(const std::string& db_dir) const + { + return std::vector< bool >(); + } + + uint32 id_max_size_of() const + { + throw std::string(); + return 0; + } + + File_Blocks_Index_Base* new_data_index( + Access_Mode access_mode, bool use_shadow, const std::string& db_dir, const std::string& file_name_extension) + const + { + if (access_mode == Access_Mode::writeable || access_mode == Access_Mode::truncate) + return new Writeable_File_Blocks_Index< IntIndex > + (*this, access_mode, use_shadow, db_dir, file_name_extension); + return new Readonly_File_Blocks_Index< IntIndex > + (*this, use_shadow, db_dir, file_name_extension); + } +}; + +//----------------------------------------------------------------------------- + +void fill_db + (const std::map< IntIndex, std::set< IntObject > >& to_delete, + const std::map< IntIndex, std::set< IntObject > >& to_insert, + unsigned int step) +{ +/* remove((get_file_name_trunk(0) + get_index_suffix(0)).c_str()); + remove((get_file_name_trunk(0) + get_data_suffix(0)).c_str());*/ + try + { + Nonsynced_Transaction transaction(Access_Mode::writeable, false, BASE_DIRECTORY, ""); + Test_File tf; + Block_Backend< IntIndex, IntObject > db_backend(transaction.data_index(&tf)); + db_backend.update(to_delete, to_insert); + } + catch (File_Error& e) + { + std::cout<<"File error catched in part "<& blocks, + Block_Backend< IntIndex, IntObject >::Flat_Iterator& it) +{ + if (it == blocks.flat_end()) + { + std::cout<<"[empty]\n"; + return; + } + IntIndex current_idx(it.index()); + std::cout<<"Index "<& blocks, + Block_Backend< IntIndex, IntObject >::Discrete_Iterator& it) +{ + if (it == blocks.discrete_end()) + { + std::cout<<"[empty]\n"; + return; + } + IntIndex current_idx(it.index()); + std::cout<<"Index "<& blocks, + Block_Backend< IntIndex, IntObject >::Range_Iterator& it) +{ + if (it == blocks.range_end()) + { + std::cout<<"[empty]\n"; + return; + } + IntIndex current_idx(it.index()); + std::cout<<"Index "< + db_backend(transaction.data_index(&tf)); + + std::cout<<"Read test\n"; + + std::cout<<"Reading all blocks ...\n"; + Block_Backend< IntIndex, IntObject >::Flat_Iterator fit(db_backend.flat_begin()); + read_loop(db_backend, fit); + std::cout<<"... all blocks read.\n"; + + std::vector< IntIndex > index_list; + for (unsigned int i(0); i < 100; i += 9) + index_list.push_back(&i); + std::cout<<"Reading blocks with indices {0, 9, ..., 99} ...\n"; + Block_Backend< IntIndex, IntObject >::Discrete_Iterator + it(db_backend.discrete_begin(index_list.begin(), index_list.end())); + read_loop(db_backend, it); + std::cout<<"... all blocks read.\n"; + + index_list.clear(); + for (unsigned int i(0); i < 10; ++i) + index_list.push_back(&i); + std::cout<<"Reading blocks with indices {0, 1, ..., 9} ...\n"; + it = db_backend.discrete_begin(index_list.begin(), index_list.end()); + read_loop(db_backend, it); + std::cout<<"... all blocks read.\n"; + + uint32 fool(0), foou(10); + Ranges< IntIndex > ranges((IntIndex(&fool)), (IntIndex(&foou))); + std::cout<<"Reading blocks with indices [0, 10[ ...\n"; + Block_Backend< IntIndex, IntObject >::Range_Iterator + rit(db_backend.range_begin(ranges)); + read_loop(db_backend, rit); + std::cout<<"... all blocks read.\n"; + + index_list.clear(); + for (unsigned int i(90); i < 100; ++i) + index_list.push_back(&i); + std::cout<<"Reading blocks with indices {90, 91, ..., 99} ...\n"; + it = db_backend.discrete_begin(index_list.begin(), index_list.end()); + read_loop(db_backend, it); + std::cout<<"... all blocks read.\n"; + + fool = 90; + foou = 100; + ranges = Ranges< IntIndex >(IntIndex(&fool), IntIndex(&foou)); + std::cout<<"Reading blocks with indices [90, 100[ ...\n"; + rit = db_backend.range_begin(ranges); + read_loop(db_backend, rit); + std::cout<<"... all blocks read.\n"; + + index_list.clear(); + uint32 foo(50); + index_list.push_back(&foo); + std::cout<<"Reading blocks with index 50 ...\n"; + it = db_backend.discrete_begin(index_list.begin(), index_list.end()); + read_loop(db_backend, it); + std::cout<<"... all blocks read.\n"; + + fool = 50; + foou = 51; + ranges = Ranges< IntIndex >(IntIndex(&fool), IntIndex(&foou)); + std::cout<<"Reading blocks with indices [50, 51[ ...\n"; + rit = db_backend.range_begin(ranges); + read_loop(db_backend, rit); + std::cout<<"... all blocks read.\n"; + + ranges = Ranges< IntIndex >(); + fool = 0; + foou = 10; + ranges.push_back(IntIndex(&fool), IntIndex(&foou)); + fool = 50; + foou = 51; + ranges.push_back(IntIndex(&fool), IntIndex(&foou)); + fool = 90; + foou = 100; + ranges.push_back(IntIndex(&fool), IntIndex(&foou)); + std::cout<<"Reading blocks with indices [0,10[\\cup [50, 51[\\cup [90, 100[ ...\n"; + rit = db_backend.range_begin(ranges); + read_loop(db_backend, rit); + std::cout<<"... all blocks read.\n"; + + index_list.clear(); + std::cout<<"Reading blocks with indices \\emptyset ...\n"; + it = db_backend.discrete_begin(index_list.begin(), index_list.end()); + read_loop(db_backend, it); + std::cout<<"... all blocks read.\n"; + + std::cout<<"This block of read tests is complete.\n"; + } + catch (File_Error& e) + { + std::cout<<"File error catched in part "< 1) + test_to_execute = args[1]; + + if ((test_to_execute == "") || (test_to_execute == "1")) + std::cout<<"** Test the behaviour for non-exsiting files\n"; + remove((BASE_DIRECTORY + Test_File().get_file_name_trunk() + + Test_File().get_index_suffix()).c_str()); + remove((BASE_DIRECTORY + Test_File().get_file_name_trunk() + + Test_File().get_data_suffix()).c_str()); + try + { + Nonsynced_Transaction transaction(Access_Mode::readonly, false, BASE_DIRECTORY, ""); + Test_File tf; + Block_Backend< IntIndex, IntIndex > db_backend + (transaction.data_index(&tf)); + } + catch (File_Error e) + { + std::cout<<"File error catched in part 1: " + < > to_delete; + std::map< IntIndex, std::set< IntObject > > to_insert; + std::set< IntObject > objects; + + if ((test_to_execute == "") || (test_to_execute == "2")) + std::cout<<"** Test the behaviour for an empty db\n"; + fill_db(to_delete, to_insert, 2); + if ((test_to_execute == "") || (test_to_execute == "2")) + read_test(2); + + if ((test_to_execute == "") || (test_to_execute == "3")) + std::cout<<"** Test the behaviour for a db with one entry\n"; + to_delete.clear(); + to_insert.clear(); + objects.clear(); + objects.insert(IntObject(642)); + to_insert[42] = objects; + + fill_db(to_delete, to_insert, 4); + if ((test_to_execute == "") || (test_to_execute == "3")) + read_test(3); + + if ((test_to_execute == "") || (test_to_execute == "4")) + std::cout<<"** Test the behaviour for a db with multiple short indizes\n"; + to_delete.clear(); + to_insert.clear(); + for (unsigned int i(0); i < 100; i += 9) + { + std::set< IntObject > objects; + objects.insert(IntObject((i%10 + 10)*100 + i)); + to_insert[i] = objects; + } + + fill_db(to_delete, to_insert, 6); + if ((test_to_execute == "") || (test_to_execute == "4")) + read_test(4); + + if ((test_to_execute == "") || (test_to_execute == "5")) + std::cout<<"** Delete an item\n"; + to_delete.clear(); + to_insert.clear(); + objects.clear(); + objects.insert(IntObject(642)); + to_delete[42] = objects; + + fill_db(to_delete, to_insert, 8); + if ((test_to_execute == "") || (test_to_execute == "5")) + read_test(5); + + if ((test_to_execute == "") || (test_to_execute == "6")) + std::cout<<"** Add some empty indices (should not appear)\n"; + to_delete.clear(); + to_insert.clear(); + for (unsigned int i(0); i < 99; i += 9) + { + std::set< IntObject > objects; + to_insert[i+1] = objects; + } + + fill_db(to_delete, to_insert, 10); + if ((test_to_execute == "") || (test_to_execute == "6")) + read_test(6); + + if ((test_to_execute == "") || (test_to_execute == "7")) + std::cout<<"** Add much more items\n"; + to_delete.clear(); + to_insert.clear(); + for (unsigned int i(0); i < 100; ++i) + { + std::set< IntObject > objects; + objects.insert(IntObject(900 + i)); + objects.insert(IntObject(2000 + i)); + to_insert[i] = objects; + } + + fill_db(to_delete, to_insert, 12); + if ((test_to_execute == "") || (test_to_execute == "7")) + read_test(7); + + if ((test_to_execute == "") || (test_to_execute == "8")) + std::cout<<"** Blow up a single index\n"; + to_delete.clear(); + to_insert.clear(); + objects.clear(); + for (unsigned int i(0); i < 200; ++i) + objects.insert(IntObject(i*200 + 150)); + to_insert[50] = objects; + + fill_db(to_delete, to_insert, 14); + if ((test_to_execute == "") || (test_to_execute == "8")) + read_test(8); + + if ((test_to_execute == "") || (test_to_execute == "9")) + std::cout<<"** Blow up an index and delete some data\n"; + to_delete.clear(); + to_insert.clear(); + objects.clear(); + for (unsigned int i(0); i < 200; ++i) + objects.insert(IntObject(i*100 + 148)); + to_insert[48] = objects; + objects.clear(); + objects.insert(IntObject(949)); + objects.insert(IntObject(2049)); + to_delete[49] = objects; + + fill_db(to_delete, to_insert, 16); + if ((test_to_execute == "") || (test_to_execute == "9")) + read_test(9); + + if ((test_to_execute == "") || (test_to_execute == "10")) + std::cout<<"** Blow up further the same index\n"; + to_delete.clear(); + to_insert.clear(); + objects.clear(); + for (unsigned int i(0); i < 201; ++i) + objects.insert(IntObject(i*200 + 50)); + to_insert[50] = objects; + + fill_db(to_delete, to_insert, 18); + if ((test_to_execute == "") || (test_to_execute == "10")) + read_test(10); + + if ((test_to_execute == "") || (test_to_execute == "11")) + std::cout<<"** Blow up two indices\n"; + to_delete.clear(); + to_insert.clear(); + objects.clear(); + for (unsigned int i(0); i < 200; ++i) + objects.insert(IntObject(i*100 + 147)); + to_insert[47] = objects; + objects.clear(); + for (unsigned int i(0); i < 200; ++i) + objects.insert(IntObject(i*100 + 199)); + to_insert[99] = objects; + + fill_db(to_delete, to_insert, 20); + if ((test_to_execute == "") || (test_to_execute == "11")) + read_test(11); + + if ((test_to_execute == "") || (test_to_execute == "12")) + std::cout<<"** Delete an entire block\n"; + to_delete.clear(); + to_insert.clear(); + for (unsigned int i(55); i < 95; ++i) + { + std::set< IntObject > objects; + objects.insert(IntObject(900 + i)); + objects.insert(IntObject(2000 + i)); + if (i%9 == 0) + objects.insert(IntObject((i%10 + 10)*100 + i)); + to_delete[i] = objects; + } + + fill_db(to_delete, to_insert, 22); + if ((test_to_execute == "") || (test_to_execute == "12")) + read_test(12); + + if ((test_to_execute == "") || (test_to_execute == "13")) + std::cout<<"** Delete many items\n"; + to_delete.clear(); + to_insert.clear(); + for (unsigned int i(0); i < 100; ++i) + { + std::set< IntObject > objects; + objects.insert(IntObject(900 + i)); + objects.insert(IntObject(2000 + i)); + to_delete[i] = objects; + } + + fill_db(to_delete, to_insert, 24); + if ((test_to_execute == "") || (test_to_execute == "13")) + read_test(13); + + if ((test_to_execute == "") || (test_to_execute == "14")) + std::cout<<"** Delete an item from a non-existing index between two segments\n"; + + to_delete.clear(); + to_insert.clear(); + to_delete[49].insert(IntObject(1049)); + fill_db(to_delete, to_insert, 26); + + if ((test_to_execute == "") || (test_to_execute == "14")) + read_test(14); + + if ((test_to_execute == "") || (test_to_execute == "15")) + std::cout<<"** Insert an item after the segment at the end\n"; + + to_delete.clear(); + to_insert.clear(); + to_insert[100].insert(IntObject(1000)); + fill_db(to_delete, to_insert, 28); + + if ((test_to_execute == "") || (test_to_execute == "15")) + read_test(15); + + if ((test_to_execute == "") || (test_to_execute == "16")) + std::cout<<"** Delete an object from a group block and block up an index immediately behind\n"; + + to_delete.clear(); + to_delete[0].insert(IntObject(1000)); + to_delete[9].insert(IntObject(1909)); + to_insert.clear(); + for (unsigned int j = 5004; j <= 20004; j += 100) + to_insert[4].insert(IntObject(j)); + fill_db(to_delete, to_insert, 30); + + if ((test_to_execute == "") || (test_to_execute == "16")) + read_test(16); + + if ((test_to_execute == "") || (test_to_execute == "17")) + std::cout<<"** Delete more items\n"; + to_delete.clear(); + to_insert.clear(); + for (unsigned int i = 0; i < 100; ++i) + { + std::set< IntObject > objects; + for (unsigned int j = 1000; j < 2000; ++j) + objects.insert(IntObject(j)); + to_delete[i] = objects; + } + { + std::set< IntObject > objects; + for (unsigned int j = 5004; j <= 20004; j += 100) + objects.insert(IntObject(j)); + to_delete[4] = objects; + } + { + std::set< IntObject > objects; + for (unsigned int j = 47; j <= 20047; j += 100) + objects.insert(IntObject(j)); + to_delete[47] = objects; + } + { + std::set< IntObject > objects; + for (unsigned int j = 48; j <= 20048; j += 100) + objects.insert(IntObject(j)); + to_delete[48] = objects; + } + { + std::set< IntObject > objects; + for (unsigned int j = 50; j <= 40050; j += 100) + objects.insert(IntObject(j)); + to_delete[50] = objects; + } + { + std::set< IntObject > objects; + for (unsigned int j = 99; j <= 20099; j += 100) + objects.insert(IntObject(j)); + to_delete[99] = objects; + } + to_delete[100].insert(IntObject(1000)); + + fill_db(to_delete, to_insert, 32); + if ((test_to_execute == "") || (test_to_execute == "17")) + read_test(17); + + if ((test_to_execute == "") || (test_to_execute == "18")) + std::cout<<"** Insert some oversized objects\n"; + to_delete.clear(); + to_insert.clear(); + to_insert[2].insert(IntObject(1000001221)); + to_insert[3].insert(IntObject(1230)); + to_insert[3].insert(IntObject(1000001231)); + to_insert[4].insert(IntObject(1000001241)); + to_insert[4].insert(IntObject(1100001242)); + to_insert[5].insert(IntObject(1000001251)); + to_insert[5].insert(IntObject(1000001252)); + to_insert[6].insert(IntObject(1000001261)); + to_insert[6].insert(IntObject(1000001262)); + to_insert[7].insert(IntObject(1000001271)); + to_insert[7].insert(IntObject(1100001272)); + to_insert[7].insert(IntObject(1200001273)); + to_insert[8].insert(IntObject(1000001281)); + + fill_db(to_delete, to_insert, 34); + if ((test_to_execute == "") || (test_to_execute == "18")) + read_test(18); + + if ((test_to_execute == "") || (test_to_execute == "19")) + std::cout<<"** Keep the oversized objects\n"; + to_delete.clear(); + to_insert.clear(); + to_delete[3].insert(IntObject(1230)); + to_insert[3].insert(IntObject(1100001232)); + to_insert[4].insert(IntObject(1240)); + to_delete[4].insert(IntObject(1100001242)); + to_insert[5].insert(IntObject(1000001253)); + to_insert[7].insert(IntObject(11272)); + + fill_db(to_delete, to_insert, 36); + if ((test_to_execute == "") || (test_to_execute == "19")) + read_test(19); + + if ((test_to_execute == "") || (test_to_execute == "20")) + std::cout<<"** Delete multiple oversized objects\n"; + to_delete.clear(); + to_insert.clear(); + to_delete[2].insert(IntObject(1000001221)); + to_delete[3].insert(IntObject(1000001231)); + to_delete[4].insert(IntObject(1000001241)); + to_delete[5].insert(IntObject(1000001251)); + to_delete[6].insert(IntObject(1000001261)); + to_delete[6].insert(IntObject(1000001262)); + to_delete[7].insert(IntObject(1200001273)); + to_delete[8].insert(IntObject(1000001281)); + to_insert[8].insert(IntObject(1282)); + + fill_db(to_delete, to_insert, 38); + if ((test_to_execute == "") || (test_to_execute == "20")) + read_test(20); + + remove((BASE_DIRECTORY + Test_File().get_file_name_trunk() + + Test_File().get_data_suffix() + + Test_File().get_index_suffix()).c_str()); + remove((BASE_DIRECTORY + Test_File().get_file_name_trunk() + + Test_File().get_data_suffix() + + Test_File().get_shadow_suffix()).c_str()); + remove((BASE_DIRECTORY + Test_File().get_file_name_trunk() + + Test_File().get_data_suffix()).c_str()); + + return 0; +} diff --git a/src/template_db/dispatcher.test.cc b/src/template_db/dispatcher.test.cc new file mode 100644 index 000000000..520eb57ca --- /dev/null +++ b/src/template_db/dispatcher.test.cc @@ -0,0 +1,1540 @@ +/** Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Roland Olbricht et al. + * + * This file is part of Overpass_API. + * + * Overpass_API is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Overpass_API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Overpass_API. If not, see . + */ + +#include "block_backend.h" +#include "block_backend_write.h" +#include "dispatcher.h" +#include "dispatcher_client.h" +#include "file_blocks.h" +#include "random_file.h" +#include "transaction.h" + +#include +#include +#include + + +//----------------------------------------------------------------------------- + +/* Sample class for TIndex */ +struct IntIndex +{ + typedef uint32 Id_Type; + + IntIndex(uint32 i) : value(i) {} + IntIndex(void* data) : value(*(uint32*)data) {} + + static bool equal(void* lhs, void* rhs) { return *(uint32*)lhs == *(uint32*)rhs; } + bool less(void* rhs) const { return value < *(uint32*)rhs; } + bool leq(void* rhs) const { return value <= *(uint32*)rhs; } + bool equal(void* rhs) const { return value == *(uint32*)rhs; } + + uint32 size_of() const { return 4; } + static constexpr uint32 const_size() { return 4; } + static uint32 size_of(void* data) { return 4; } + static uint32 max_size_of() { return 4; } + + void to_data(void* data) const + { + *(uint32*)data = value; + } + + bool operator<(const IntIndex& index) const + { + return this->value < index.value; + } + + bool operator==(const IntIndex& index) const + { + return this->value == index.value; + } + + uint32 val() const + { + return value; + } + + private: + uint32 value; +}; + +struct IntObject +{ + typedef uint32 Id_Type; + + IntObject(void* data) : value(*(uint32*)data) {} + IntObject(int i) : value(i) {} + + uint32 size_of() const + { + return 4; + } + + static uint32 size_of(void* data) + { + return 4; + } + + void to_data(void* data) const + { + *(uint32*)data = value; + } + + bool operator<(const IntObject& index) const + { + return this->value < index.value; + } + + int val() const + { + return value; + } + + private: + uint32 value; +}; + +//----------------------------------------------------------------------------- + +/* We use our own test settings */ +std::string BASE_DIRECTORY("./"); +std::string ID_SUFFIX(".map"); + + +struct Test_File : File_Properties +{ + Test_File(std::string basename_) : basename(basename_), basedir(BASE_DIRECTORY) {} + + const std::string& get_basedir() const + { + return basedir; + } + + void set_basedir(const std::string& basedir_) + { + basedir = basedir_; + } + + const std::string& get_file_name_trunk() const + { + return basename; + } + + const std::string& get_index_suffix() const + { + static std::string result(".idx"); + return result; + } + + const std::string& get_data_suffix() const + { + static std::string result(".bin"); + return result; + } + + const std::string& get_id_suffix() const + { + return ID_SUFFIX; + } + + const std::string& get_shadow_suffix() const + { + static std::string result(".shadow"); + return result; + } + + uint32 get_block_size() const + { + return 512; + } + + uint32 get_compression_factor() const + { + return 1; + } + + uint32 get_compression_method() const + { + return 0; + } + + uint32 get_map_compression_method() const + { + return 0; + } + + uint32 get_map_block_size() const + { + return 16*IntIndex::max_size_of(); + } + + uint32 get_map_compression_factor() const + { + return 1; + } + + std::vector< bool > get_data_footprint(const std::string& db_dir) const + { + return get_data_index_footprint< IntIndex >(*this, db_dir); + } + + std::vector< bool > get_map_footprint(const std::string& db_dir) const + { + return get_map_index_footprint(*this, db_dir); + } + + uint32 id_max_size_of() const + { + return IntIndex::max_size_of(); + } + + File_Blocks_Index_Base* new_data_index( + Access_Mode access_mode, bool use_shadow, const std::string& db_dir, const std::string& file_name_extension) + const + { + if (access_mode == Access_Mode::writeable || access_mode == Access_Mode::truncate) + return new Writeable_File_Blocks_Index< IntIndex > + (*this, access_mode, use_shadow, db_dir, file_name_extension); + return new Readonly_File_Blocks_Index< IntIndex > + (*this, use_shadow, db_dir, file_name_extension); + } + + std::string basename, basedir; +}; + +//----------------------------------------------------------------------------- + +void create_dummy_files + (const File_Properties& test_file_1, + const File_Properties& test_file_2, + const File_Properties& test_file_3, + const File_Properties& test_file_4, + bool shadow) +{ + if (!shadow) + { + { + std::ofstream test_bin_out((BASE_DIRECTORY + test_file_1.get_file_name_trunk() + + test_file_1.get_data_suffix()).c_str()); + test_bin_out<<"This is test file bin 1\n"; + std::ofstream test_idx_out((BASE_DIRECTORY + test_file_1.get_file_name_trunk() + + test_file_1.get_data_suffix() + test_file_1.get_index_suffix()).c_str()); + test_idx_out<<"ZZZZ\x7\x1 \n"; + } + { + std::ofstream test_bin_out((BASE_DIRECTORY + test_file_2.get_file_name_trunk() + + test_file_2.get_id_suffix()).c_str()); + test_bin_out<<"This is test file map 2\n"; + std::ofstream test_idx_out((BASE_DIRECTORY + test_file_2.get_file_name_trunk() + + test_file_2.get_id_suffix() + test_file_2.get_index_suffix()).c_str()); + test_idx_out<<"This is test file map idx 2\n"; + } + { + std::ofstream test_bin_out((BASE_DIRECTORY + test_file_3.get_file_name_trunk() + + test_file_3.get_data_suffix()).c_str()); + test_bin_out<<"This is test file bin 3\n"; + std::ofstream test_idx_out((BASE_DIRECTORY + test_file_3.get_file_name_trunk() + + test_file_3.get_data_suffix() + test_file_3.get_index_suffix()).c_str()); + test_idx_out<<"ZZZZ\x7\x1 \n"; + } + { + std::ofstream test_bin_out((BASE_DIRECTORY + test_file_3.get_file_name_trunk() + + test_file_3.get_id_suffix()).c_str()); + test_bin_out<<"This is test file map 3\n"; + std::ofstream test_idx_out((BASE_DIRECTORY + test_file_3.get_file_name_trunk() + + test_file_3.get_id_suffix()+ test_file_3.get_index_suffix()).c_str()); + test_idx_out<<"This is test file map idx 3\n"; + } + { + std::ofstream test_bin_out((BASE_DIRECTORY + test_file_4.get_file_name_trunk() + + test_file_4.get_data_suffix()).c_str()); + test_bin_out<<"This is test file bin 4\n"; + std::ofstream test_idx_out((BASE_DIRECTORY + test_file_4.get_file_name_trunk() + + test_file_4.get_data_suffix() + test_file_4.get_index_suffix()).c_str()); + test_idx_out<<"ZZZZ\x7\x1 \n"; + } + { + std::ofstream test_bin_out((BASE_DIRECTORY + test_file_4.get_file_name_trunk() + + test_file_4.get_id_suffix()).c_str()); + test_bin_out<<"This is test file map 4\n"; + std::ofstream test_idx_out((BASE_DIRECTORY + test_file_4.get_file_name_trunk() + + test_file_4.get_id_suffix()+ test_file_4.get_index_suffix()).c_str()); + test_idx_out<<"This is test file map idx 4\n"; + } + } + else + { + { + std::ofstream test_bin_out((BASE_DIRECTORY + test_file_1.get_file_name_trunk() + + test_file_1.get_data_suffix()).c_str()); + test_bin_out<<"This is test file bin 1\n"; + std::ofstream test_idx_out((BASE_DIRECTORY + test_file_1.get_file_name_trunk() + + test_file_1.get_data_suffix() + test_file_1.get_index_suffix() + + test_file_1.get_shadow_suffix()).c_str()); + test_idx_out<<"ZZZZ\x7\x1 \n"; + } + { + std::ofstream test_bin_out((BASE_DIRECTORY + test_file_2.get_file_name_trunk() + + test_file_2.get_id_suffix()).c_str()); + test_bin_out<<"This is test file map 2\n"; + std::ofstream test_idx_out((BASE_DIRECTORY + test_file_2.get_file_name_trunk() + + test_file_2.get_id_suffix() + test_file_2.get_index_suffix() + + test_file_2.get_shadow_suffix()).c_str()); + test_idx_out<<"This is test file map idx shadow 2\n"; + } + { + std::ofstream test_bin_out((BASE_DIRECTORY + test_file_3.get_file_name_trunk() + + test_file_3.get_data_suffix()).c_str()); + test_bin_out<<"This is test file bin 3\n"; + std::ofstream test_idx_out((BASE_DIRECTORY + test_file_3.get_file_name_trunk() + + test_file_3.get_data_suffix() + test_file_3.get_index_suffix() + + test_file_3.get_shadow_suffix()).c_str()); + test_idx_out<<"ZZZZ\x7\x1 \n"; + } + { + std::ofstream test_bin_out((BASE_DIRECTORY + test_file_3.get_file_name_trunk() + + test_file_3.get_id_suffix()).c_str()); + test_bin_out<<"This is test file map 3\n"; + std::ofstream test_idx_out((BASE_DIRECTORY + test_file_3.get_file_name_trunk() + + test_file_3.get_id_suffix() + test_file_3.get_index_suffix() + + test_file_3.get_shadow_suffix()).c_str()); + test_idx_out<<"This is test file map idx shadow 3\n"; + } + { + std::ofstream test_bin_out((BASE_DIRECTORY + test_file_4.get_file_name_trunk() + + test_file_4.get_data_suffix()).c_str()); + test_bin_out<<"This is test file bin 4\n"; + std::ofstream test_idx_out((BASE_DIRECTORY + test_file_4.get_file_name_trunk() + + test_file_4.get_data_suffix() + test_file_4.get_index_suffix() + + test_file_4.get_shadow_suffix()).c_str()); + test_idx_out<<"ZZZZ\x7\x1 \n"; + } + { + std::ofstream test_bin_out((BASE_DIRECTORY + test_file_4.get_file_name_trunk() + + test_file_4.get_id_suffix()).c_str()); + test_bin_out<<"This is test file map 4\n"; + std::ofstream test_idx_out((BASE_DIRECTORY + test_file_4.get_file_name_trunk() + + test_file_4.get_id_suffix()+ test_file_4.get_index_suffix() + + test_file_4.get_shadow_suffix()).c_str()); + test_idx_out<<"This is test file map idx shadow 4\n"; + } + } +} + +void map_read_test(bool use_shadow = false) +{ + try + { + std::cout<<"Read test\n"; + std::vector< bool > footprint = + get_map_index_footprint(Test_File("Test_File"), BASE_DIRECTORY, use_shadow); + std::cout<<"Index footprint: "; + for (std::vector< bool >::const_iterator it(footprint.begin()); + it != footprint.end(); ++it) + std::cout<<*it; + std::cout<<'\n'; + + Nonsynced_Transaction transaction(Access_Mode::readonly, use_shadow, BASE_DIRECTORY, ""); + Test_File tf("Test_File"); + Random_File< IntIndex, IntIndex > id_file(transaction.random_index(&tf)); + + std::cout<& blocks, + Block_Backend< IntIndex, IntObject >::Flat_Iterator& it) +{ + if (it == blocks.flat_end()) + { + std::cout<<"[empty]\n"; + return; + } + IntIndex current_idx(it.index()); + std::cout<<"Index "< + db_backend(transaction.data_index(&tf)); + + std::cout<<"Read test\n"; + std::vector< bool > footprint = get_data_index_footprint< IntIndex > + (tf, tf.get_basedir()); + std::cout<<"Index footprint: "; + for (std::vector< bool >::const_iterator it(footprint.begin()); it != footprint.end(); ++it) + std::cout<<*it; + std::cout<<'\n'; + + Block_Backend< IntIndex, IntObject >::Flat_Iterator fit(db_backend.flat_begin()); + read_loop(db_backend, fit); + std::cout<<"This block of read tests is complete.\n"; + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < > to_delete; + std::map< IntIndex, std::set< IntObject > > to_insert; + to_insert[IntIndex(idx)].insert(IntObject(val)); + try + { + Nonsynced_Transaction transaction(Access_Mode::writeable, true, db_dir, ""); + Block_Backend< IntIndex, IntObject > db_backend + (transaction.data_index(&tf)); + db_backend.update(to_delete, to_insert); + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < 1) + test_to_execute = args[1]; + + if ((test_to_execute == "") || (test_to_execute == "1")) + { + try + { + Test_File test_file_1("Test_File_1"); + Test_File test_file_2("Test_File_2"); + Test_File test_file_3("Test_File_3"); + Test_File test_file_4("Test_File_4"); + + create_dummy_files(test_file_1, test_file_2, test_file_3, test_file_4, false); + + std::vector< File_Properties* > file_properties; + file_properties.push_back(&test_file_1); + file_properties.push_back(&test_file_2); + file_properties.push_back(&test_file_3); + Dispatcher dispatcher("osm3s_share_test", "osm3s_index_share_test", + BASE_DIRECTORY + "test-shadow", BASE_DIRECTORY, "", + 5, 500, 180, 1024*1024*1024, 1024*1024, file_properties); + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < file_properties; + file_properties.push_back(&test_file_1); + file_properties.push_back(&test_file_2); + file_properties.push_back(&test_file_3); + Dispatcher dispatcher("osm3s_share_test", "osm3s_index_share_test", + BASE_DIRECTORY + "test-shadow", BASE_DIRECTORY, "", + 5, 500, 180, 1024*1024*1024, 1024*1024, file_properties); + } + + if ((test_to_execute == "") || (test_to_execute == "3")) + { + Test_File test_file("Test_File"); + + std::vector< File_Properties* > file_properties; + file_properties.push_back(&test_file); + Dispatcher dispatcher("osm3s_share_test", "osm3s_index_share_test", + BASE_DIRECTORY + "test-shadow", BASE_DIRECTORY, "", + 5, 500, 180, 1024*1024*1024, 1024*1024, file_properties); + } + + if ((test_to_execute == "") || (test_to_execute == "4")) + { + Test_File test_file("Test_File"); + + std::vector< File_Properties* > file_properties; + file_properties.push_back(&test_file); + Dispatcher dispatcher("osm3s_share_test", "osm3s_index_share_test", + BASE_DIRECTORY + "test-shadow", BASE_DIRECTORY, "", + 5, 500, 180, 1024*1024*1024, 1024*1024, file_properties); + dispatcher.write_start(480); + { + Nonsynced_Transaction transaction(Access_Mode::writeable, true, BASE_DIRECTORY, ""); + Test_File tf("Test_File"); + Random_File< IntIndex, IntIndex > blocks(transaction.random_index(&tf)); + blocks.put(0u, 1); + } + map_read_test(true); + remove("Test_File.map"); + remove("Test_File.map.idx.shadow"); + } + + if ((test_to_execute == "") || (test_to_execute == "5")) + { + Test_File test_file("Test_File"); + + std::vector< File_Properties* > file_properties; + file_properties.push_back(&test_file); + Dispatcher dispatcher("osm3s_share_test", "osm3s_index_share_test", + BASE_DIRECTORY + "test-shadow", BASE_DIRECTORY, "", + 5, 500, 180, 1024*1024*1024, 1024*1024, file_properties); + dispatcher.write_start(495); + dispatcher.write_start(480); + try + { + pid_t locked_pid = 0; + std::ifstream lock((BASE_DIRECTORY + "test-shadow" + ".lock").c_str()); + lock>>locked_pid; + std::cout<<"The lock file points to pid "< blocks(transaction.random_index(&tf)); + blocks.put(0u, 1); + } + map_read_test(true); + remove("Test_File.map"); + remove("Test_File.map.idx.shadow"); + } + + if ((test_to_execute == "") || (test_to_execute == "6")) + { + Test_File test_file("Test_File"); + + std::vector< File_Properties* > file_properties; + file_properties.push_back(&test_file); + Dispatcher dispatcher("osm3s_share_test", "osm3s_index_share_test", + BASE_DIRECTORY + "test-shadow", BASE_DIRECTORY, "", + 5, 500, 180, 1024*1024*1024, 1024*1024, file_properties); + dispatcher.write_start(480); + { + Nonsynced_Transaction transaction(Access_Mode::writeable, true, BASE_DIRECTORY, ""); + Test_File tf("Test_File"); + Random_File< IntIndex, IntIndex > blocks(transaction.random_index(&tf)); + blocks.put(0u, 1); + } + dispatcher.write_commit(0); + map_read_test(); + remove("Test_File.map"); + remove("Test_File.map.idx"); + } + + if ((test_to_execute == "") || (test_to_execute == "7")) + { + Test_File test_file("Test_File"); + + std::vector< File_Properties* > file_properties; + file_properties.push_back(&test_file); + Dispatcher dispatcher("osm3s_share_test", "osm3s_index_share_test", + BASE_DIRECTORY + "test-shadow", BASE_DIRECTORY, "", + 5, 500, 180, 1024*1024*1024, 1024*1024, file_properties); + dispatcher.write_start(480); + { + Nonsynced_Transaction transaction(Access_Mode::writeable, true, BASE_DIRECTORY, ""); + Test_File tf("Test_File"); + Random_File< IntIndex, IntIndex > blocks(transaction.random_index(&tf)); + blocks.put(0u, 1); + } + dispatcher.write_commit(0); + dispatcher.write_start(481); + { + Nonsynced_Transaction transaction(Access_Mode::writeable, true, BASE_DIRECTORY, ""); + Test_File tf("Test_File"); + Random_File< IntIndex, IntIndex > blocks(transaction.random_index(&tf)); + blocks.put(0u, 2); + } + dispatcher.write_commit(0); + map_read_test(); + remove("Test_File.map"); + remove("Test_File.map.idx"); + } + + if ((test_to_execute == "") || (test_to_execute == "8")) + { + Test_File test_file("Test_File"); + + std::vector< File_Properties* > file_properties; + file_properties.push_back(&test_file); + Dispatcher dispatcher("osm3s_share_test", "osm3s_index_share_test", + BASE_DIRECTORY + "test-shadow", BASE_DIRECTORY, "", + 5, 500, 180, 1024*1024*1024, 1024*1024, file_properties); + dispatcher.write_start(480); + { + Nonsynced_Transaction transaction(Access_Mode::writeable, true, BASE_DIRECTORY, ""); + Test_File tf("Test_File"); + Random_File< IntIndex, IntIndex > blocks(transaction.random_index(&tf)); + blocks.put(0u, 1); + } + dispatcher.write_commit(0); + dispatcher.write_start(481); + { + Nonsynced_Transaction transaction(Access_Mode::writeable, true, BASE_DIRECTORY, ""); + Test_File tf("Test_File"); + Random_File< IntIndex, IntIndex > blocks(transaction.random_index(&tf)); + blocks.put(0u, 2); + } + dispatcher.write_commit(0); + dispatcher.write_start(482); + { + Nonsynced_Transaction transaction(Access_Mode::writeable, true, BASE_DIRECTORY, ""); + Test_File tf("Test_File"); + Random_File< IntIndex, IntIndex > blocks(transaction.random_index(&tf)); + blocks.put(0u, 3); + } + dispatcher.write_commit(0); + map_read_test(); + remove("Test_File.map"); + remove("Test_File.map.idx"); + } + + if ((test_to_execute == "") || (test_to_execute == "9")) + { + Test_File test_file("Test_File"); + + std::vector< File_Properties* > file_properties; + file_properties.push_back(&test_file); + Dispatcher dispatcher("osm3s_share_test", "osm3s_index_share_test", + BASE_DIRECTORY + "test-shadow", BASE_DIRECTORY, "", + 5, 500, 180, 1024*1024*1024, 1024*1024, file_properties); + dispatcher.write_start(480); + put_elem(0, 1, test_file); + dispatcher.write_commit(0); + data_read_test(test_file); + remove("Test_File.bin"); + remove("Test_File.bin.idx"); + } + + if ((test_to_execute == "") || (test_to_execute == "10")) + { + Test_File test_file("Test_File"); + + std::vector< File_Properties* > file_properties; + file_properties.push_back(&test_file); + Dispatcher dispatcher("osm3s_share_test", "osm3s_index_share_test", + BASE_DIRECTORY + "test-shadow", BASE_DIRECTORY, "", + 5, 500, 180, 1024*1024*1024, 1024*1024, file_properties); + dispatcher.write_start(480); + put_elem(0, 1, test_file); + dispatcher.write_commit(0); + dispatcher.write_start(481); + put_elem(0, 2, test_file); + dispatcher.write_commit(0); + data_read_test(test_file); + remove("Test_File.bin"); + remove("Test_File.bin.idx"); + } + + if ((test_to_execute == "") || (test_to_execute == "11")) + { + Test_File test_file("Test_File"); + + std::vector< File_Properties* > file_properties; + file_properties.push_back(&test_file); + Dispatcher dispatcher("osm3s_share_test", "osm3s_index_share_test", + BASE_DIRECTORY + "test-shadow", BASE_DIRECTORY, "", + 5, 500, 180, 1024*1024*1024, 1024*1024, file_properties); + dispatcher.write_start(480); + put_elem(0, 1, test_file); + dispatcher.write_commit(0); + dispatcher.write_start(481); + put_elem(0, 2, test_file); + dispatcher.write_commit(0); + dispatcher.write_start(482); + put_elem(0, 3, test_file); + dispatcher.write_commit(0); + data_read_test(test_file); + remove("Test_File.bin"); + remove("Test_File.bin.idx"); + } + + if ((test_to_execute == "") || (test_to_execute == "12")) + { + Test_File test_file("Test_File"); + + std::vector< File_Properties* > file_properties; + file_properties.push_back(&test_file); + Dispatcher dispatcher("osm3s_share_test", "osm3s_index_share_test", + BASE_DIRECTORY + "test-shadow", BASE_DIRECTORY, "", + 5, 500, 180, 1024*1024*1024, 1024*1024, file_properties); + dispatcher.write_start(480); + { + Nonsynced_Transaction transaction(Access_Mode::writeable, true, BASE_DIRECTORY, ""); + Test_File tf("Test_File"); + Random_File< IntIndex, IntIndex > blocks(transaction.random_index(&tf)); + blocks.put(0u, 1); + } + dispatcher.request_read_and_idx(640, 180, 512*1024*1024, 640); + dispatcher.output_status(); + dispatcher.write_commit(0); + std::cout<<"Write lock is " + <<(file_exists("test-shadow.lock") ? "still set.\n" : "released.\n"); + dispatcher.read_idx_finished(640); + dispatcher.write_commit(0); + std::cout<<"Write lock is " + <<(file_exists("test-shadow.lock") ? "still set.\n" : "released.\n"); + map_read_test(); + remove("Test_File.map"); + remove("Test_File.map.idx"); + } + + if ((test_to_execute == "") || (test_to_execute == "13")) + { + Test_File test_file("Test_File"); + + std::vector< File_Properties* > file_properties; + file_properties.push_back(&test_file); + Dispatcher dispatcher("osm3s_share_test", "osm3s_index_share_test", + BASE_DIRECTORY + "test-shadow", BASE_DIRECTORY, "", + 5, 500, 180, 1024*1024*1024, 1024*1024, file_properties); + dispatcher.write_start(480); + dispatcher.request_read_and_idx(640, 180, 512*1024*1024, 640); + dispatcher.read_idx_finished(640); + dispatcher.output_status(); + { + Nonsynced_Transaction transaction(Access_Mode::writeable, true, BASE_DIRECTORY, ""); + Test_File tf("Test_File"); + Random_File< IntIndex, IntIndex > blocks(transaction.random_index(&tf)); + blocks.put(0u, 1); + } + dispatcher.read_finished(640); + dispatcher.write_commit(0); + dispatcher.write_start(481); + dispatcher.request_read_and_idx(641, 180, 512*1024*1024, 641); + dispatcher.read_idx_finished(641); + { + Nonsynced_Transaction transaction(Access_Mode::writeable, true, BASE_DIRECTORY, ""); + Test_File tf("Test_File"); + Random_File< IntIndex, IntIndex > blocks(transaction.random_index(&tf)); + blocks.put(0u, 2); + } + dispatcher.read_finished(641); + dispatcher.write_commit(0); + dispatcher.write_start(482); + dispatcher.request_read_and_idx(642, 180, 512*1024*1024, 642); + dispatcher.read_idx_finished(642); + { + Nonsynced_Transaction transaction(Access_Mode::writeable, true, BASE_DIRECTORY, ""); + Test_File tf("Test_File"); + Random_File< IntIndex, IntIndex > blocks(transaction.random_index(&tf)); + blocks.put(0u, 3); + } + dispatcher.read_finished(642); + dispatcher.write_commit(0); + map_read_test(); + remove("Test_File.map"); + remove("Test_File.map.idx"); + } + + if ((test_to_execute == "") || (test_to_execute == "14")) + { + Test_File test_file("Test_File"); + + std::vector< File_Properties* > file_properties; + file_properties.push_back(&test_file); + Dispatcher dispatcher("osm3s_share_test", "osm3s_index_share_test", + BASE_DIRECTORY + "test-shadow", BASE_DIRECTORY, "", + 5, 500, 180, 1024*1024*1024, 1024*1024, file_properties); + dispatcher.write_start(480); + dispatcher.request_read_and_idx(640, 180, 512*1024*1024, 640); + dispatcher.read_idx_finished(640); + put_elem(0, 1, test_file); + dispatcher.read_finished(640); + dispatcher.output_status(); + dispatcher.write_commit(0); + dispatcher.write_start(481); + dispatcher.request_read_and_idx(641, 180, 512*1024*1024, 641); + dispatcher.read_idx_finished(641); + put_elem(0, 2, test_file); + dispatcher.read_finished(641); + dispatcher.write_commit(0); + dispatcher.write_start(482); + dispatcher.request_read_and_idx(642, 180, 512*1024*1024, 642); + dispatcher.read_idx_finished(642); + put_elem(0, 3, test_file); + dispatcher.read_finished(642); + dispatcher.write_commit(0); + data_read_test(test_file); + remove("Test_File.bin"); + remove("Test_File.bin.idx"); + } + + if ((test_to_execute == "") || (test_to_execute == "15")) + { + Test_File test_file("Test_File"); + + std::vector< File_Properties* > file_properties; + file_properties.push_back(&test_file); + Dispatcher dispatcher("osm3s_share_test", "osm3s_index_share_test", + BASE_DIRECTORY + "test-shadow", BASE_DIRECTORY, "", + 5, 500, 180, 1024*1024*1024, 1024*1024, file_properties); + dispatcher.write_start(480); + { + Nonsynced_Transaction transaction(Access_Mode::writeable, true, BASE_DIRECTORY, ""); + Test_File tf("Test_File"); + Random_File< IntIndex, IntIndex > blocks(transaction.random_index(&tf)); + blocks.put(0u, 1); + } + dispatcher.write_commit(0); + dispatcher.request_read_and_idx(640, 180, 512*1024*1024, 640); + dispatcher.read_idx_finished(640); + dispatcher.write_start(481); + { + Nonsynced_Transaction transaction(Access_Mode::writeable, true, BASE_DIRECTORY, ""); + Test_File tf("Test_File"); + Random_File< IntIndex, IntIndex > blocks(transaction.random_index(&tf)); + blocks.put(0u, 2); + } + dispatcher.write_commit(0); + dispatcher.write_start(482); + dispatcher.read_finished(640); + { + Nonsynced_Transaction transaction(Access_Mode::writeable, true, BASE_DIRECTORY, ""); + Test_File tf("Test_File"); + Random_File< IntIndex, IntIndex > blocks(transaction.random_index(&tf)); + blocks.put(0u, 3); + } + dispatcher.write_commit(0); + map_read_test(); + remove("Test_File.map"); + remove("Test_File.map.idx"); + } + + if ((test_to_execute == "") || (test_to_execute == "16")) + { + Test_File test_file("Test_File"); + + std::vector< File_Properties* > file_properties; + file_properties.push_back(&test_file); + Dispatcher dispatcher("osm3s_share_test", "osm3s_index_share_test", + BASE_DIRECTORY + "test-shadow", BASE_DIRECTORY, "", + 5, 500, 180, 1024*1024*1024, 1024*1024, file_properties); + dispatcher.write_start(480); + put_elem(0, 1, test_file); + dispatcher.write_commit(0); + dispatcher.request_read_and_idx(640, 180, 512*1024*1024, 640); + dispatcher.read_idx_finished(640); + dispatcher.write_start(481); + put_elem(0, 2, test_file); + dispatcher.write_commit(0); + dispatcher.write_start(482); + dispatcher.read_finished(640); + put_elem(0, 3, test_file); + dispatcher.write_commit(0); + data_read_test(test_file); + remove("Test_File.bin"); + remove("Test_File.bin.idx"); + } + + if ((test_to_execute == "") || (test_to_execute == "17")) + { + Test_File test_file("Test_File"); + + std::vector< File_Properties* > file_properties; + file_properties.push_back(&test_file); + Dispatcher dispatcher("osm3s_share_test", "osm3s_index_share_test", + BASE_DIRECTORY + "test-shadow", BASE_DIRECTORY, "", + 5, 500, 180, 1024*1024*1024, 1024*1024, file_properties); + dispatcher.write_start(480); + { + Nonsynced_Transaction transaction(Access_Mode::writeable, true, BASE_DIRECTORY, ""); + Test_File tf("Test_File"); + Random_File< IntIndex, IntIndex > blocks(transaction.random_index(&tf)); + blocks.put(0u, 1); + } + dispatcher.write_commit(0); + dispatcher.request_read_and_idx(640, 180, 512*1024*1024, 640); + dispatcher.read_idx_finished(640); + dispatcher.write_start(481); + { + Nonsynced_Transaction transaction(Access_Mode::writeable, true, BASE_DIRECTORY, ""); + Test_File tf("Test_File"); + Random_File< IntIndex, IntIndex > blocks(transaction.random_index(&tf)); + blocks.put(0u, 2); + } + dispatcher.write_commit(0); + dispatcher.write_start(482); + { + Nonsynced_Transaction transaction(Access_Mode::writeable, true, BASE_DIRECTORY, ""); + Test_File tf("Test_File"); + Random_File< IntIndex, IntIndex > blocks(transaction.random_index(&tf)); + blocks.put(0u, 3); + } + dispatcher.write_commit(0); + dispatcher.write_start(483); + dispatcher.read_finished(640); + { + Nonsynced_Transaction transaction(Access_Mode::writeable, true, BASE_DIRECTORY, ""); + Test_File tf("Test_File"); + Random_File< IntIndex, IntIndex > blocks(transaction.random_index(&tf)); + blocks.put(0u, 4); + } + dispatcher.write_commit(0); + map_read_test(); + remove("Test_File.map"); + remove("Test_File.map.idx"); + } + + if ((test_to_execute == "") || (test_to_execute == "18")) + { + Test_File test_file("Test_File"); + + std::vector< File_Properties* > file_properties; + file_properties.push_back(&test_file); + Dispatcher dispatcher("osm3s_share_test", "osm3s_index_share_test", + BASE_DIRECTORY + "test-shadow", BASE_DIRECTORY, "", + 5, 500, 180, 1024*1024*1024, 1024*1024, file_properties); + dispatcher.write_start(480); + put_elem(0, 1, test_file); + dispatcher.write_commit(0); + dispatcher.request_read_and_idx(640, 180, 512*1024*1024, 640); + dispatcher.read_idx_finished(640); + dispatcher.write_start(481); + put_elem(0, 2, test_file); + dispatcher.write_commit(0); + dispatcher.write_start(482); + put_elem(0, 3, test_file); + dispatcher.write_commit(0); + dispatcher.write_start(483); + dispatcher.read_finished(640); + put_elem(0, 4, test_file); + dispatcher.write_commit(0); + data_read_test(test_file); + remove("Test_File.bin"); + remove("Test_File.bin.idx"); + } + + if ((test_to_execute == "") || (test_to_execute == "19")) + { + Test_File test_file("Test_File"); + + std::vector< File_Properties* > file_properties; + file_properties.push_back(&test_file); + try + { + Dispatcher dispatcher("/", "osm3s_index_share_test", + BASE_DIRECTORY + "test-shadow", BASE_DIRECTORY, "", + 5, 500, 180, 1024*1024*1024, 1024*1024, file_properties); + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < file_properties; + file_properties.push_back(&test_file); + try + { + Dispatcher_Client dispatcher_client("osm3s_share_test"); + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < file_properties; + file_properties.push_back(&test_file); + try + { + Dispatcher dispatcher("osm3s_share_test", "osm3s_index_share_test", + BASE_DIRECTORY + "test-shadow", BASE_DIRECTORY, "", + 5, 500, 180, 1024*1024*1024, 1024*1024, file_properties); + dispatcher.write_start(480); + put_elem(0, 1, test_file); + dispatcher.write_commit(0); + + std::cerr<<"[server] Starting ...\n"; + uint32 execution_time = 3; + std::istringstream sin(test_to_execute.substr(7)); + sin>>execution_time; + dispatcher.standby_loop(execution_time*1000); + std::cerr<<"[server] done.\n"; + return 0; + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < file_properties; + // Try to start a sceond dispatcher instance. This shall fail with + // a File_Error. + try + { + Dispatcher dispatcher("osm3s_share_test", "osm3s_index_share_test", + BASE_DIRECTORY + "test-shadow", BASE_DIRECTORY, "", + 5, 500, 180, 1024*1024*1024, 1024*1024, file_properties); + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < file_properties; + file_properties.push_back(&test_file); + try + { + Dispatcher_Client dispatcher_client("osm3s_share_test"); + test_file.set_basedir(dispatcher_client.get_db_dir()); + + std::string shadow_name = dispatcher_client.get_shadow_name() + ".lock"; + if (file_exists(shadow_name)) + { + std::cout<<"Failed before write_start(): " + <>read_pid; + if (read_pid != getpid()) + { + std::cout<<"Pid in lock doesn't match.\n"; + return 0; + } + + put_elem(0, 21, test_file, dispatcher_client.get_db_dir()); + dispatcher_client.write_commit(); + if (file_exists(dispatcher_client.get_shadow_name() + ".lock")) + { + std::cout<<"Failed after write_commit().\n"; + return 0; + } + + std::cout<<"Writing successfully done.\n"; + Nonsynced_Transaction transaction + (Access_Mode::readonly, false, dispatcher_client.get_db_dir(), ""); + data_read_test(test_file, transaction); + remove((dispatcher_client.get_db_dir() + "Test_File.bin").c_str()); + remove((dispatcher_client.get_db_dir() + "Test_File.bin.idx").c_str()); + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < file_properties; + file_properties.push_back(&test_file); + try + { + Dispatcher_Client dispatcher_client("osm3s_share_test"); + test_file.set_basedir(dispatcher_client.get_db_dir()); + + std::string shadow_name = dispatcher_client.get_shadow_name() + ".lock"; + if (file_exists(shadow_name)) + { + std::cout<<"Failed before write_start(): " + <>read_pid; + if (read_pid != getpid()) + { + std::cout<<"Pid in lock doesn't match.\n"; + return 0; + } + + put_elem(0, 21, test_file, dispatcher_client.get_db_dir()); + dispatcher_client.write_rollback(); + if (file_exists(dispatcher_client.get_shadow_name() + ".lock")) + { + std::cout<<"Failed after write_rollback().\n"; + return 0; + } + + std::cout<<"Writing successfully done.\n"; + Nonsynced_Transaction transaction + (Access_Mode::readonly, false, dispatcher_client.get_db_dir(), ""); + data_read_test(test_file, transaction); + remove((dispatcher_client.get_db_dir() + "Test_File.bin").c_str()); + remove((dispatcher_client.get_db_dir() + "Test_File.bin.idx").c_str()); + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < file_properties; + file_properties.push_back(&test_file); + try + { + Dispatcher_Client dispatcher_client("osm3s_share_test"); + test_file.set_basedir(dispatcher_client.get_db_dir()); + + std::string shadow_name = dispatcher_client.get_shadow_name() + ".lock"; + if (file_exists(shadow_name)) + { + std::cout<<"Failed before write_start(): " + <>read_pid; + + if (read_pid != getpid()) + { + std::cout<<"Pid in lock doesn't match.\n"; + return 0; + } + } + + put_elem(0, 21, test_file, dispatcher_client.get_db_dir()); + dispatcher_client.write_commit(); + if (file_exists(dispatcher_client.get_shadow_name() + ".lock")) + { + std::cout<<"Failed after write_commit().\n"; + return 0; + } + + std::cout<<"First writing successfully done.\n"; + + dispatcher_client.write_start(); + if (!file_exists(dispatcher_client.get_shadow_name() + ".lock")) + { + std::cout<<"Failed after write_start().\n"; + return 0; + } + + { + pid_t read_pid; + + std::ifstream in((dispatcher_client.get_shadow_name() + ".lock").c_str()); + in>>read_pid; + + if (read_pid != getpid()) + { + std::cout<<"Pid in lock doesn't match.\n"; + return 0; + } + } + + put_elem(0, 23, test_file, dispatcher_client.get_db_dir()); + dispatcher_client.write_commit(); + if (file_exists(dispatcher_client.get_shadow_name() + ".lock")) + { + std::cout<<"Failed after write_commit().\n"; + return 0; + } + + std::cout<<"Second writing successfully done.\n"; + + Nonsynced_Transaction transaction + (Access_Mode::readonly, false, dispatcher_client.get_db_dir(), ""); + data_read_test(test_file, transaction); + remove((dispatcher_client.get_db_dir() + "Test_File.bin").c_str()); + remove((dispatcher_client.get_db_dir() + "Test_File.bin.idx").c_str()); + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < file_properties; + file_properties.push_back(&test_file); + try + { + { + //sleep for a second + struct timeval timeout_; + timeout_.tv_sec = 0; + timeout_.tv_usec = 1000*1000; + select(FD_SETSIZE, NULL, NULL, NULL, &timeout_); + } + + Dispatcher_Client dispatcher_client("osm3s_share_test"); + test_file.set_basedir(dispatcher_client.get_db_dir()); + + sync_log("Try request_read().\n"); + dispatcher_client.request_read_and_idx(24*60, 1024*1024, 0, 0); + sync_log("request_read() returned.\n"); + + { + //sleep for two seconds + struct timeval timeout_; + timeout_.tv_sec = 0; + timeout_.tv_usec = 2*1000*1000; + select(FD_SETSIZE, NULL, NULL, NULL, &timeout_); + } + + sync_log("Announce read_idx_finished().\n"); + dispatcher_client.read_idx_finished(); + sync_log("read_idx_finished\n"); + dispatcher_client.read_finished(); + //std::cerr<<"read_finished() done.\n"; //Timing with 24w can't be controlled. + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < file_properties; + file_properties.push_back(&test_file); + try + { + Dispatcher_Client dispatcher_client("osm3s_share_test"); + test_file.set_basedir(dispatcher_client.get_db_dir()); + + dispatcher_client.write_start(); + put_elem(0, 24, test_file, dispatcher_client.get_db_dir()); + sync_log("write_start() done and written an element.\n"); + + { + //sleep for two seconds + struct timeval timeout_; + timeout_.tv_sec = 0; + timeout_.tv_usec = 2*1000*1000; + select(FD_SETSIZE, NULL, NULL, NULL, &timeout_); + } + + sync_log("Try write_commit().\n"); + dispatcher_client.write_commit(); + sync_log("write_commit() done.\n"); + + Nonsynced_Transaction transaction + (Access_Mode::readonly, false, dispatcher_client.get_db_dir(), ""); + data_read_test(test_file, transaction); + remove((dispatcher_client.get_db_dir() + "Test_File.bin").c_str()); + remove((dispatcher_client.get_db_dir() + "Test_File.bin.idx").c_str()); + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < file_properties; + file_properties.push_back(&test_file); + try + { + { + //sleep for a second + struct timeval timeout_; + timeout_.tv_sec = 0; + timeout_.tv_usec = 1000*1000; + select(FD_SETSIZE, NULL, NULL, NULL, &timeout_); + } + + Dispatcher_Client dispatcher_client("osm3s_share_test"); + test_file.set_basedir(dispatcher_client.get_db_dir()); + + sync_log("Try request_read().\n"); + dispatcher_client.request_read_and_idx(24*60, 1024*1024, 0, 0); + sync_log("request_read() done.\n"); + + Nonsynced_Transaction transaction + (Access_Mode::readonly, false, dispatcher_client.get_db_dir(), ""); + transaction.data_index(&test_file); + + dispatcher_client.read_idx_finished(); + sync_log("read_idx_finished() done.\n"); + + { + //sleep for two seconds + struct timeval timeout_; + timeout_.tv_sec = 0; + timeout_.tv_usec = 2*1000*1000; + select(FD_SETSIZE, NULL, NULL, NULL, &timeout_); + } + + data_read_test(test_file, transaction); + + sync_log("Announce read_finished().\n"); + dispatcher_client.read_finished(); + sync_log("read_finished() done.\n"); + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < file_properties; + file_properties.push_back(&test_file); + try + { + Dispatcher_Client dispatcher_client("osm3s_share_test"); + test_file.set_basedir(dispatcher_client.get_db_dir()); + + dispatcher_client.write_start(); + put_elem(0, 25, test_file, dispatcher_client.get_db_dir()); + sync_log("write_start() done and written an element.\n"); + + { + //sleep for two seconds + struct timeval timeout_; + timeout_.tv_sec = 0; + timeout_.tv_usec = 2*1000*1000; + select(FD_SETSIZE, NULL, NULL, NULL, &timeout_); + } + + sync_log("Try write_commit().\n"); + dispatcher_client.write_commit(); + sync_log("write_commit() done.\n"); + + dispatcher_client.write_start(); + put_elem(0, 26, test_file, dispatcher_client.get_db_dir()); + sync_log("write_start() done and written an element.\n"); + + { + //sleep for two seconds + struct timeval timeout_; + timeout_.tv_sec = 0; + timeout_.tv_usec = 2*1000*1000; + select(FD_SETSIZE, NULL, NULL, NULL, &timeout_); + } + + sync_log("Try write_commit().\n"); + dispatcher_client.write_commit(); + sync_log("write_commit() done.\n"); + + Nonsynced_Transaction transaction + (Access_Mode::readonly, false, dispatcher_client.get_db_dir(), ""); + data_read_test(test_file, transaction); + remove((dispatcher_client.get_db_dir() + "Test_File.bin").c_str()); + remove((dispatcher_client.get_db_dir() + "Test_File.bin.idx").c_str()); + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < file_properties; + file_properties.push_back(&test_file); + try + { + { + //sleep for a second + struct timeval timeout_; + timeout_.tv_sec = 0; + timeout_.tv_usec = 1000*1000; + select(FD_SETSIZE, NULL, NULL, NULL, &timeout_); + } + + Dispatcher_Client dispatcher_client("osm3s_share_test"); + test_file.set_basedir(dispatcher_client.get_db_dir()); + + sync_log("Try request_read().\n"); + dispatcher_client.request_read_and_idx(24*60, 1024*1024, 0, 0); + sync_log("request_read() done.\n"); + + Nonsynced_Transaction transaction + (Access_Mode::readonly, false, dispatcher_client.get_db_dir(), ""); + transaction.data_index(&test_file); + + dispatcher_client.read_idx_finished(); + sync_log("read_idx_finished() done.\n"); + + { + //sleep for two seconds + struct timeval timeout_; + timeout_.tv_sec = 0; + timeout_.tv_usec = 2*1000*1000; + select(FD_SETSIZE, NULL, NULL, NULL, &timeout_); + } + + data_read_test(test_file, transaction); + + sync_log("Announce read_finished().\n"); + dispatcher_client.read_finished(); + sync_log("read_finished() done.\n"); + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < file_properties; + file_properties.push_back(&test_file); + try + { + Dispatcher_Client dispatcher_client("osm3s_share_test"); + test_file.set_basedir(dispatcher_client.get_db_dir()); + + { + //sleep for a seconds + struct timeval timeout_; + timeout_.tv_sec = 0; + timeout_.tv_usec = 1000*1000; + select(FD_SETSIZE, NULL, NULL, NULL, &timeout_); + } + + sync_log("Request output status.\n"); + dispatcher_client.output_status(); + sync_log("Request output status finished.\n"); + + { + //sleep for a seconds + struct timeval timeout_; + timeout_.tv_sec = 0; + timeout_.tv_usec = 2*1000*1000; + select(FD_SETSIZE, NULL, NULL, NULL, &timeout_); + } + + remove((dispatcher_client.get_db_dir() + "Test_File.bin").c_str()); + remove((dispatcher_client.get_db_dir() + "Test_File.bin.idx").c_str()); + } + catch (File_Error e) + { + std::cout<<"File error catched: " + <. + */ + +#include +#include + +#include + +#include "file_blocks.h" +#include "transaction.h" + + +/** + * Tests the library file_blocks + */ + +//----------------------------------------------------------------------------- + +/* Sample class for TIndex */ +struct IntIndex +{ + IntIndex(uint32 i) : value(i) {} + IntIndex(void* data) : value(*(uint32*)data) {} + + static bool equal(void* lhs, void* rhs) { return *(uint32*)lhs == *(uint32*)rhs; } + bool less(void* rhs) const { return value < *(uint32*)rhs; } + bool leq(void* rhs) const { return value <= *(uint32*)rhs; } + bool equal(void* rhs) const { return value == *(uint32*)rhs; } + + uint32 size_of() const { return (value < 24 ? 12 : value-12); } + static constexpr uint32 const_size() { return 0; } + static uint32 size_of(void* data) { return ((*(uint32*)data) < 24 ? 12 : (*(uint32*)data)-12); } + + void to_data(void* data) const + { + uint32 size = size_of(); + *(uint32*)(((uint8*)data) + size - 4) = 0x5a5a5a5a; + *(uint32*)data = value; + uint32 i = 1; + while (i < size/4) + { + *(uint32*)(((uint8*)data) + 4*i) = 4*i/3; + ++i; + } + } + + bool operator<(const IntIndex& index) const { return this->value < index.value; } + bool operator==(const IntIndex& index) const { return this->value == index.value; } + + uint32 val() const { return value; } + + private: + uint32 value; +}; + + +typedef std::list< IntIndex >::const_iterator IntIterator; + + +struct IntRangeIterator : std::list< std::pair< IntIndex, IntIndex > >::const_iterator +{ + IntRangeIterator() {} + + IntRangeIterator + (const std::list< std::pair< IntIndex, IntIndex > >::const_iterator it) + : std::list< std::pair< IntIndex, IntIndex > >::const_iterator(it) {} + + const IntIndex& lower_bound() const + { + return (*this)->first; + } + + const IntIndex& upper_bound() const + { + return (*this)->second; + } +}; + +//----------------------------------------------------------------------------- + +/* We use our own test settings */ +std::string BASE_DIRECTORY("./"); +std::string DATA_SUFFIX(".bin"); +std::string INDEX_SUFFIX(".idx"); + + +struct Test_File : File_Properties +{ + const std::string& get_basedir() const + { + return BASE_DIRECTORY; + } + + const std::string& get_file_name_trunk() const + { + static std::string result("testfile"); + return result; + } + + const std::string& get_index_suffix() const + { + return INDEX_SUFFIX; + } + + const std::string& get_data_suffix() const + { + return DATA_SUFFIX; + } + + const std::string& get_id_suffix() const + { + static std::string result(""); + return result; + } + + const std::string& get_shadow_suffix() const + { + static std::string result(".shadow"); + return result; + } + + uint32 get_block_size() const + { + return 512; + } + + uint32 get_compression_factor() const + { + return 1; + } + + uint32 get_map_compression_factor() const + { + return 1; + } + + uint32 get_compression_method() const + { + return File_Blocks_Index_Base::NO_COMPRESSION; + } + + uint32 get_map_compression_method() const + { + return File_Blocks_Index_Base::NO_COMPRESSION; + } + + uint32 get_map_block_size() const + { + return 16; + } + + std::vector< bool > get_data_footprint(const std::string& db_dir) const + { + return std::vector< bool >(); + } + + std::vector< bool > get_map_footprint(const std::string& db_dir) const + { + return std::vector< bool >(); + } + + uint32 id_max_size_of() const + { + throw std::string(); + return 0; + } + + File_Blocks_Index_Base* new_data_index( + Access_Mode access_mode, bool use_shadow, const std::string& db_dir, const std::string& file_name_extension) + const + { + if (access_mode == Access_Mode::writeable || access_mode == Access_Mode::truncate) + return new Writeable_File_Blocks_Index< IntIndex > + (*this, access_mode, use_shadow, db_dir, file_name_extension); + return new Readonly_File_Blocks_Index< IntIndex > + (*this, use_shadow, db_dir, file_name_extension); + } +}; + + +struct Variable_Block_Test_File : File_Properties +{ + const std::string& get_basedir() const + { + return BASE_DIRECTORY; + } + + const std::string& get_file_name_trunk() const + { + static std::string result("variable"); + return result; + } + + const std::string& get_index_suffix() const + { + return INDEX_SUFFIX; + } + + const std::string& get_data_suffix() const + { + return DATA_SUFFIX; + } + + const std::string& get_id_suffix() const + { + static std::string result(""); + return result; + } + + const std::string& get_shadow_suffix() const + { + static std::string result(".shadow"); + return result; + } + + uint32 get_block_size() const + { + return 64; + } + + uint32 get_compression_factor() const + { + return 8; + } + + uint32 get_map_compression_factor() const + { + return 1; + } + + uint32 get_compression_method() const + { + return File_Blocks_Index_Base::NO_COMPRESSION; + } + + uint32 get_map_compression_method() const + { + return File_Blocks_Index_Base::NO_COMPRESSION; + } + + uint32 get_map_block_size() const + { + return 16; + } + + std::vector< bool > get_data_footprint(const std::string& db_dir) const + { + return std::vector< bool >(); + } + + std::vector< bool > get_map_footprint(const std::string& db_dir) const + { + return std::vector< bool >(); + } + + uint32 id_max_size_of() const + { + throw std::string(); + return 0; + } + + File_Blocks_Index_Base* new_data_index( + Access_Mode access_mode, bool use_shadow, const std::string& db_dir, const std::string& file_name_extension) + const + { + if (access_mode == Access_Mode::writeable || access_mode == Access_Mode::truncate) + return new Writeable_File_Blocks_Index< IntIndex > + (*this, access_mode, use_shadow, db_dir, file_name_extension); + return new Readonly_File_Blocks_Index< IntIndex > + (*this, use_shadow, db_dir, file_name_extension); + } +}; + + +struct Compressed_Test_File : File_Properties +{ + const std::string& get_basedir() const + { + return BASE_DIRECTORY; + } + + const std::string& get_file_name_trunk() const + { + static std::string result("compressed"); + return result; + } + + const std::string& get_index_suffix() const + { + return INDEX_SUFFIX; + } + + const std::string& get_data_suffix() const + { + return DATA_SUFFIX; + } + + const std::string& get_id_suffix() const + { + static std::string result(""); + return result; + } + + const std::string& get_shadow_suffix() const + { + static std::string result(".shadow"); + return result; + } + + uint32 get_block_size() const + { + return 8*1024; + } + + uint32 get_compression_factor() const + { + return 8; + } + + uint32 get_map_compression_factor() const + { + return 8; + } + + uint32 get_compression_method() const + { +#ifdef HAVE_LZ4 + return File_Blocks_Index_Base::LZ4_COMPRESSION; +#else + return File_Blocks_Index_Base::ZLIB_COMPRESSION; +#endif + } + + uint32 get_map_compression_method() const + { + return File_Blocks_Index_Base::NO_COMPRESSION; + } + + uint32 get_map_block_size() const + { + return 4*1024; + } + + std::vector< bool > get_data_footprint(const std::string& db_dir) const + { + return std::vector< bool >(); + } + + std::vector< bool > get_map_footprint(const std::string& db_dir) const + { + return std::vector< bool >(); + } + + uint32 id_max_size_of() const + { + throw std::string(); + return 0; + } + + File_Blocks_Index_Base* new_data_index( + Access_Mode access_mode, bool use_shadow, const std::string& db_dir, const std::string& file_name_extension) + const + { + if (access_mode == Access_Mode::writeable || access_mode == Access_Mode::truncate) + return new Writeable_File_Blocks_Index< IntIndex > + (*this, access_mode, use_shadow, db_dir, file_name_extension); + return new Readonly_File_Blocks_Index< IntIndex > + (*this, use_shadow, db_dir, file_name_extension); + } +}; + +//----------------------------------------------------------------------------- + +void read_loop( + File_Blocks< IntIndex, IntIterator >& blocks, + File_Blocks< IntIndex, IntIterator >::Flat_Iterator& it, + uint32 block_size) +{ + while (!it.is_end()) + { + uint8* data = (uint8*)(blocks.read_block(it)); + uint32 max_keysize = *(uint32*)(data+sizeof(uint32)); + std::cout<<"Real size "<<(*(uint32*)data)<<" bytes, " + <<"first block size "< (*(uint32*)data)-sizeof(uint32)) + { + uint32 large_block_size = ((max_keysize+3)/block_size+1)*block_size; + std::cout<<"\nChecking "<& blocks, + File_Blocks< IntIndex, IntIterator >::Discrete_Iterator& it, + uint32 block_size) +{ + while (!it.is_end()) + { + uint8* data((uint8*)(blocks.read_block(it))); + std::cout<<"Real size "<<(*(uint32*)data)<<" bytes, " + <<"first block size "<<*(uint32*)(data+sizeof(uint32))<<" bytes, " + <<"first index "<<*(uint32*)(data+2*sizeof(uint32)); + if (*(uint32*)(data+sizeof(uint32)) < (*(uint32*)data)-sizeof(uint32)) + { + uint8* pos(data+sizeof(uint32)); + pos += *(uint32*)pos; + std::cout<<", second block size "<<(*(uint32*)pos)<<" bytes, " + <<"second index "<<*(uint32*)(pos+sizeof(uint32)); + } + else if (*(uint32*)(data+sizeof(uint32)) > (*(uint32*)data)-sizeof(uint32)) + { + uint32 large_block_size = (((*(uint32*)(data+4))+3)/block_size+1)*block_size; + std::cout<<"\nSkipping "<& blocks, + File_Blocks_Range_Iterator< IntIndex, IntRangeIterator >& it, + uint32 block_size) +{ + while (!it.is_end()) + { + uint8* data((uint8*)(blocks.read_block(it))); + std::cout<<"Real size "<<(*(uint32*)data)<<" bytes, " + <<"first block size "<<*(uint32*)(data+sizeof(uint32))<<" bytes, " + <<"first index "<<*(uint32*)(data+2*sizeof(uint32)); + if (*(uint32*)(data+sizeof(uint32)) < (*(uint32*)data)-sizeof(uint32)) + { + uint8* pos(data+sizeof(uint32)); + pos += *(uint32*)pos; + std::cout<<", second block size "<<(*(uint32*)pos)<<" bytes, " + <<"second index "<<*(uint32*)(pos+sizeof(uint32)); + } + else if (*(uint32*)(data+sizeof(uint32)) > (*(uint32*)data)-sizeof(uint32)) + { + uint32 large_block_size = (((*(uint32*)(data+4))+3)/block_size+1)*block_size; + std::cout<<"\nSkipping "< blocks + (transaction.data_index(&tf)); + uint32 block_size = tf.get_block_size(); + + std::vector< bool > footprint = get_data_index_footprint< IntIndex > + (Test_File(), BASE_DIRECTORY); + std::cout<<"Index footprint: "; + for (std::vector< bool >::const_iterator it(footprint.begin()); it != footprint.end(); + ++it) + std::cout<<*it; + std::cout<<'\n'; + + std::cout<<"Reading all blocks ...\n"; + File_Blocks< IntIndex, IntIterator >::Flat_Iterator + fit(blocks.flat_begin()); + read_loop(blocks, fit, block_size); + std::cout<<"... all blocks read.\n"; + + std::list< IntIndex > index_list; + for (unsigned int i(0); i < 100; i += 9) + index_list.push_back(&i); + std::cout<<"Reading blocks with indices {0, 9, ..., 99} ...\n"; + File_Blocks< IntIndex, IntIterator >::Discrete_Iterator + it(blocks.discrete_begin(index_list.begin(), index_list.end())); + read_loop(blocks, it, block_size); + std::cout<<"... all blocks read.\n"; + + index_list.clear(); + for (unsigned int i(0); i < 10; ++i) + index_list.push_back(&i); + std::cout<<"Reading blocks with indices {0, 1, ..., 9} ...\n"; + it = blocks.discrete_begin(index_list.begin(), index_list.end()); + read_loop(blocks, it, block_size); + std::cout<<"... all blocks read.\n"; + + std::list< std::pair< IntIndex, IntIndex > > range_list; + uint32 fool(0), foou(10); + range_list.push_back(std::make_pair(IntIndex(&fool), IntIndex(&foou))); + std::cout<<"Reading blocks with indices [0, 10[ ...\n"; + File_Blocks_Range_Iterator< IntIndex, IntRangeIterator > + rit(blocks.range_begin + (IntRangeIterator(range_list.begin()), IntRangeIterator(range_list.end()))); + read_loop(blocks, rit, block_size); + std::cout<<"... all blocks read.\n"; + + index_list.clear(); + for (unsigned int i(90); i < 100; ++i) + index_list.push_back(&i); + std::cout<<"Reading blocks with indices {90, 91, ..., 99} ...\n"; + it = blocks.discrete_begin(index_list.begin(), index_list.end()); + read_loop(blocks, it, block_size); + std::cout<<"... all blocks read.\n"; + + range_list.clear(); + fool = 90; + foou = 100; + range_list.push_back(std::make_pair(IntIndex(&fool), IntIndex(&foou))); + std::cout<<"Reading blocks with indices [90, 100[ ...\n"; + rit = blocks.range_begin + (IntRangeIterator(range_list.begin()), IntRangeIterator(range_list.end())); + read_loop(blocks, rit, block_size); + std::cout<<"... all blocks read.\n"; + + index_list.clear(); + uint32 foo(50); + index_list.push_back(&foo); + std::cout<<"Reading blocks with index 50 ...\n"; + it = blocks.discrete_begin(index_list.begin(), index_list.end()); + read_loop(blocks, it, block_size); + std::cout<<"... all blocks read.\n"; + + range_list.clear(); + fool = 50; + foou = 51; + range_list.push_back(std::make_pair(IntIndex(&fool), IntIndex(&foou))); + std::cout<<"Reading blocks with indices [50, 51[ ...\n"; + rit = blocks.range_begin + (IntRangeIterator(range_list.begin()), IntRangeIterator(range_list.end())); + read_loop(blocks, rit, block_size); + std::cout<<"... all blocks read.\n"; + + range_list.clear(); + fool = 0; + foou = 10; + range_list.push_back(std::make_pair(IntIndex(&fool), IntIndex(&foou))); + fool = 50; + foou = 51; + range_list.push_back(std::make_pair(IntIndex(&fool), IntIndex(&foou))); + fool = 90; + foou = 100; + range_list.push_back(std::make_pair(IntIndex(&fool), IntIndex(&foou))); + std::cout<<"Reading blocks with indices [0,10[\\cup [50, 51[\\cup [90, 100[ ...\n"; + rit = blocks.range_begin + (IntRangeIterator(range_list.begin()), IntRangeIterator(range_list.end())); + read_loop(blocks, rit, block_size); + std::cout<<"... all blocks read.\n"; + + index_list.clear(); + std::cout<<"Reading blocks with indices \\emptyset ...\n"; + it = blocks.discrete_begin(index_list.begin(), index_list.end()); + read_loop(blocks, it, block_size); + std::cout<<"... all blocks read.\n"; + + std::cout<<"This block of read tests is complete.\n"; + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < blocks + (transaction.data_index(&tf)); + uint32 block_size = tf.get_block_size(); + + std::vector< bool > footprint = get_data_index_footprint< IntIndex > + (Variable_Block_Test_File(), BASE_DIRECTORY); + std::cout<<"Index footprint: "; + for (std::vector< bool >::const_iterator it(footprint.begin()); it != footprint.end(); + ++it) + std::cout<<*it; + std::cout<<'\n'; + + std::cout<<"Reading all blocks ...\n"; + File_Blocks< IntIndex, IntIterator >::Flat_Iterator + fit(blocks.flat_begin()); + read_loop(blocks, fit, block_size); + std::cout<<"... all blocks read.\n"; + + std::cout<<"This block of read tests is complete.\n"; + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < blocks + (transaction.data_index(&tf)); + uint32 block_size = tf.get_block_size(); + + std::vector< bool > footprint = get_data_index_footprint< IntIndex > + (Variable_Block_Test_File(), BASE_DIRECTORY); + std::cout<<"Index footprint: "; + for (std::vector< bool >::const_iterator it(footprint.begin()); it != footprint.end(); + ++it) + std::cout<<*it; + std::cout<<'\n'; + + std::cout<<"Reading all blocks ...\n"; + File_Blocks< IntIndex, IntIterator >::Flat_Iterator + fit(blocks.flat_begin()); + read_loop(blocks, fit, block_size); + std::cout<<"... all blocks read.\n"; + + std::cout<<"This block of read tests is complete.\n"; + } + catch (File_Error e) + { + std::cout<<"File error catched: " + <& indices) +{ + if (indices.empty()) + { + *(uint32*)block = 0; + return; + } + + uint32 pos(sizeof(uint32)); + for (std::list< IntIndex >::const_iterator it(indices.begin()); + it != indices.end(); ++it) + { + *(uint32*)(((uint8*)block)+pos) = (*it).val() + 12; + (*it).to_data(((uint8*)block)+pos+sizeof(uint32)); + pos += (*it).val() + 12; + } + + *(uint32*)block = pos; +} + + +void prepare_large_block(void* block, IntIndex index, uint32 block_size, uint32 total_size, uint offset) +{ + for (uint i = 0; i < block_size/4; ++i) + *(((uint32*)block)+i) = 3*(i + offset) + 91000; + + if (offset == 0) + { + *(uint32*)block = block_size; + *(((uint32*)block)+1) = total_size; + index.to_data(((uint32*)block)+2); + } +} + + +int main(int argc, char* args[]) +{ + std::string test_to_execute; + if (argc > 1) + test_to_execute = args[1]; + + int data_fd = open64 + ((BASE_DIRECTORY + + Test_File().get_file_name_trunk() + Test_File().get_data_suffix()).c_str(), + O_WRONLY|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); + close(data_fd); + int index_fd = open64 + ((BASE_DIRECTORY + + Test_File().get_file_name_trunk() + Test_File().get_data_suffix() + + Test_File().get_index_suffix()).c_str(), + O_WRONLY|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); + close(index_fd); + + if ((test_to_execute == "") || (test_to_execute == "info")) + { + Compressed_Test_File tf; + + if (tf.get_compression_method() == File_Blocks_Index_Base::NO_COMPRESSION) + std::cout<<"Using no compression for bin files.\n"; + else if (tf.get_compression_method() == File_Blocks_Index_Base::ZLIB_COMPRESSION) + std::cout<<"Using zlib compression for bin files.\n"; + else if (tf.get_compression_method() == File_Blocks_Index_Base::LZ4_COMPRESSION) + std::cout<<"Using lz4 compression for bin files.\n"; + + if (tf.get_map_compression_method() == File_Blocks_Index_Base::NO_COMPRESSION) + std::cout<<"Using no compression for map files.\n"; + else if (tf.get_map_compression_method() == File_Blocks_Index_Base::ZLIB_COMPRESSION) + std::cout<<"Using zlib compression for map files.\n"; + else if (tf.get_map_compression_method() == File_Blocks_Index_Base::LZ4_COMPRESSION) + std::cout<<"Using lz4 compression for map files.\n"; + } + + if ((test_to_execute == "") || (test_to_execute == "1")) + { + std::cout<<"** Test the behaviour for an empty file\n"; + read_test(); + } + + if ((test_to_execute == "") || (test_to_execute == "2")) + std::cout<<"** Test the behaviour for a file with one entry - part 1\n"; + try + { + Nonsynced_Transaction transaction(Access_Mode::writeable, false, BASE_DIRECTORY, ""); + Test_File tf; + File_Blocks< IntIndex, IntIterator > blocks + (transaction.data_index(&tf)); + std::list< IntIndex > indices; + + indices.clear(); + indices.push_back(IntIndex(49)); + indices.push_back(IntIndex(50)); + uint64* buf = (uint64*)aligned_alloc(8, Test_File().get_block_size()); + prepare_block(buf, indices); + blocks.insert_block(blocks.write_end(), buf); + free(buf); + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < blocks + (transaction.data_index(&tf)); + std::list< IntIndex > indices; + + indices.clear(); + indices.push_back(IntIndex(51)); + uint64* buf = (uint64*)aligned_alloc(8, Test_File().get_block_size()); + prepare_block(buf, indices); + blocks.replace_block( + blocks.write_begin(indices.begin(), indices.end()), buf); + free(buf); + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < blocks + (transaction.data_index(&tf)); + std::list< IntIndex > indices; + + indices.clear(); + indices.push_back(IntIndex(9)); + uint64* buf = (uint64*)aligned_alloc(8, Test_File().get_block_size()); + prepare_block(buf, indices); + blocks.insert_block( + blocks.write_begin(indices.begin(), indices.end()), buf); + + indices.clear(); + indices.push_back(IntIndex(89)); + prepare_block(buf, indices); + blocks.insert_block(blocks.write_end(), buf); + free(buf); + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < blocks + (transaction.data_index(&tf)); + std::list< IntIndex > indices; + + indices.clear(); + indices.push_back(IntIndex(10)); + indices.push_back(IntIndex(51)); + indices.push_back(IntIndex(63)); + indices.push_back(IntIndex(64)); + indices.push_back(IntIndex(65)); + indices.push_back(IntIndex(89)); + + File_Blocks< IntIndex, IntIterator >::Write_Iterator + it = blocks.write_begin(indices.begin(), indices.end()); + + ++it; + indices.clear(); + indices.push_back(IntIndex(10)); + uint64* buf = (uint64*)aligned_alloc(8, Test_File().get_block_size()); + prepare_block(buf, indices); + it = blocks.insert_block(it, buf); + ++it; + + indices.clear(); + indices.push_back(IntIndex(63)); + prepare_block(buf, indices); + it = blocks.insert_block(it, buf); + + indices.clear(); + indices.push_back(IntIndex(64)); + prepare_block(buf, indices); + it = blocks.insert_block(it, buf); + + indices.clear(); + indices.push_back(IntIndex(65)); + prepare_block(buf, indices); + blocks.insert_block(it, buf); + free(buf); + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < blocks + (transaction.data_index(&tf)); + std::list< IntIndex > indices, work; + + indices.clear(); + indices.push_back(IntIndex(7)); + indices.push_back(IntIndex(51)); + indices.push_back(IntIndex(52)); + indices.push_back(IntIndex(89)); + indices.push_back(IntIndex(90)); + + File_Blocks< IntIndex, IntIterator >::Write_Iterator + it(blocks.write_begin(indices.begin(), indices.end())); + + work.clear(); + work.push_back(IntIndex(7)); + uint64* buf = (uint64*)aligned_alloc(8, Test_File().get_block_size()); + prepare_block(buf, work); + it = blocks.replace_block(it, buf); + ++it; + + work.clear(); + work.push_back(IntIndex(51)); + work.push_back(IntIndex(52)); + prepare_block(buf, work); + it = blocks.replace_block(it, buf); + ++it; + + work.clear(); + work.push_back(IntIndex(89)); + work.push_back(IntIndex(90)); + prepare_block(buf, work); + it = blocks.replace_block(it, buf); + free(buf); + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < blocks + (transaction.data_index(&tf)); + std::list< IntIndex > indices; + + indices.clear(); + indices.push_back(IntIndex(51)); + indices.push_back(IntIndex(64)); + indices.push_back(IntIndex(65)); + + File_Blocks< IntIndex, IntIterator >::Write_Iterator + it(blocks.write_begin(indices.begin(), indices.end())); + + it = blocks.erase_block(it); + it = blocks.erase_block(it); + it = blocks.erase_block(it); + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < blocks + (transaction.data_index(&tf)); + std::list< IntIndex > indices; + + indices.clear(); + indices.push_back(IntIndex(7)); + indices.push_back(IntIndex(90)); + + File_Blocks< IntIndex, IntIterator >::Write_Iterator + it(blocks.write_begin(indices.begin(), indices.end())); + + it = blocks.erase_block(it); + it = blocks.erase_block(it); + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < blocks + (transaction.data_index(&tf)); + std::list< IntIndex > indices, work; + + indices.clear(); + for (unsigned int i(20); i < 30; ++i) + indices.push_back(IntIndex(i)); + indices.push_back(IntIndex(63)); + + File_Blocks< IntIndex, IntIterator >::Write_Iterator + it(blocks.write_begin(indices.begin(), indices.end())); + + ++it; + for (unsigned int i(20); i < 30; ++i) + { + work.clear(); + work.push_back(IntIndex(i)); + uint64* buf = (uint64*)aligned_alloc(8, Test_File().get_block_size()); + prepare_block(buf, work); + it = blocks.insert_block(it, buf); + free(buf); + } + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < blocks + (transaction.data_index(&tf)); + std::list< IntIndex > indices; + + indices.clear(); + for (unsigned int i(0); i < 100; ++i) + indices.push_back(IntIndex(i)); + + File_Blocks< IntIndex, IntIterator >::Write_Iterator + it(blocks.write_begin(indices.begin(), indices.end())); + + while (!it.is_end()) + { + it = blocks.erase_block(it); + } + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < blocks + (transaction.data_index(&tf)); + std::list< IntIndex > indices; + + indices.clear(); + indices.push_back(IntIndex(40)); + uint64* buf = (uint64*)aligned_alloc(8, Test_File().get_block_size()); + prepare_block(buf, indices); + blocks.insert_block(blocks.write_end(), buf); + blocks.insert_block(blocks.write_end(), buf); + blocks.insert_block(blocks.write_end(), buf); + blocks.insert_block(blocks.write_end(), buf); + + indices.clear(); + indices.push_back(IntIndex(60)); + prepare_block(buf, indices); + blocks.insert_block(blocks.write_end(), buf); + blocks.insert_block(blocks.write_end(), buf); + blocks.insert_block(blocks.write_end(), buf); + blocks.insert_block(blocks.write_end(), buf); + free(buf); + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < blocks + (transaction.data_index(&tf)); + std::list< IntIndex > indices, work; + + indices.clear(); + indices.push_back(IntIndex(8)); + indices.push_back(IntIndex(40)); + indices.push_back(IntIndex(50)); + indices.push_back(IntIndex(60)); + indices.push_back(IntIndex(90)); + indices.push_back(IntIndex(99)); + + File_Blocks< IntIndex, IntIterator >::Write_Iterator + it(blocks.write_begin(indices.begin(), indices.end())); + + work.clear(); + work.push_back(IntIndex(8)); + uint64* buf = (uint64*)aligned_alloc(8, Test_File().get_block_size()); + prepare_block(buf, work); + it = blocks.insert_block(it, buf); + it = blocks.insert_block(it, buf); + ++it; + + it = blocks.erase_block(it); + it = blocks.erase_block(it); + it = blocks.erase_block(it); + it = blocks.erase_block(it); + + work.clear(); + work.push_back(IntIndex(50)); + prepare_block(buf, work); + it = blocks.insert_block(it, buf); + it = blocks.insert_block(it, buf); + ++it; + + it = blocks.erase_block(it); + it = blocks.erase_block(it); + it = blocks.erase_block(it); + it = blocks.erase_block(it); + + work.clear(); + work.push_back(IntIndex(90)); + prepare_block(buf, work); + it = blocks.insert_block(it, buf); + it = blocks.insert_block(it, buf); + + work.clear(); + work.push_back(IntIndex(99)); + prepare_block(buf, work); + it = blocks.insert_block(it, buf); + it = blocks.insert_block(it, buf); + free(buf); + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < blocks + (transaction.data_index(&tf)); + while (!blocks.flat_begin().is_end()) + { + std::list< IntIndex > indices; + indices.push_back(blocks.flat_begin().block().index()); + File_Blocks_Write_Iterator< IntIndex, std::list< IntIndex >::const_iterator > it = + blocks.write_begin(indices.begin(), indices.end()); + while (!it.is_end()) + it = blocks.erase_block(it); + } + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < blocks + (transaction.data_index(&tf)); + uint32 block_size = tf.get_block_size(); + + std::list< IntIndex > indices; + indices.push_back(IntIndex(6)); + File_Blocks_Write_Iterator< IntIndex, std::list< IntIndex >::const_iterator > it = + blocks.write_begin(indices.begin(), indices.end()); + + uint64* buf = (uint64*)aligned_alloc(8, block_size); + prepare_large_block(buf, *indices.begin(), block_size, 2*block_size + block_size/2, 0); + it = blocks.insert_block(it, buf, block_size, *indices.begin()); + prepare_large_block(buf, *indices.begin(), block_size, 0, block_size/4); + it = blocks.insert_block(it, buf, block_size, *indices.begin()); + prepare_large_block(buf, *indices.begin(), block_size, 0, 2*block_size/4); + blocks.insert_block(it, buf, block_size/2+4, *indices.begin()); + free(buf); + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < blocks + (transaction.data_index(&tf)); + uint32 block_size = tf.get_block_size(); + + std::list< IntIndex > indices; + indices.push_back(IntIndex(6)); + File_Blocks_Write_Iterator< IntIndex, std::list< IntIndex >::const_iterator > it = + blocks.write_begin(indices.begin(), indices.end()); + + ++it; + ++it; + ++it; + uint64* buf = (uint64*)aligned_alloc(8, block_size); + prepare_block(buf, indices); + blocks.insert_block(it, buf); + free(buf); + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < blocks + (transaction.data_index(&tf)); + uint32 block_size = tf.get_block_size(); + + std::list< IntIndex > indices; + indices.push_back(IntIndex(5)); + File_Blocks_Write_Iterator< IntIndex, std::list< IntIndex >::const_iterator > it = + blocks.write_begin(indices.begin(), indices.end()); + + uint64* buf = (uint64*)aligned_alloc(8, block_size); + prepare_large_block(buf, *indices.begin(), block_size, block_size-4, 0); + it = blocks.insert_block(it, buf, block_size, *indices.begin()); + prepare_large_block(buf, *indices.begin(), block_size, block_size-3, 0); + it = blocks.insert_block(it, buf, block_size, *indices.begin()); + prepare_large_block(buf, *indices.begin(), block_size, 0, block_size/4); + blocks.insert_block(it, buf, 1, *indices.begin()); + free(buf); + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < blocks + (transaction.data_index(&tf)); + uint32 block_size = tf.get_block_size(); + + std::list< IntIndex > indices; + indices.push_back(IntIndex(6)); + File_Blocks_Write_Iterator< IntIndex, std::list< IntIndex >::const_iterator > it = + blocks.write_begin(indices.begin(), indices.end()); + + uint64* buf = (uint64*)aligned_alloc(8, block_size); + prepare_large_block(buf, *indices.begin(), block_size, 2*block_size + block_size/2 + 20, 0); + it = blocks.replace_block(it, buf, block_size, *indices.begin()); + ++it; + ++it; + prepare_large_block(buf, *indices.begin(), block_size, 0, 2*block_size/4); + it = blocks.replace_block(it, buf, block_size/2 + 24, *indices.begin()); + + indices.clear(); + indices.push_back(IntIndex(7)); + it = blocks.write_begin(indices.begin(), indices.end()); + + prepare_large_block(buf, *indices.begin(), block_size, 3*block_size-3, 0); + it = blocks.insert_block(it, buf, block_size, *indices.begin()); + prepare_large_block(buf, *indices.begin(), block_size, 0, block_size/4); + it = blocks.insert_block(it, buf, block_size, *indices.begin()); + prepare_large_block(buf, *indices.begin(), block_size, 0, 2*block_size/4); + it = blocks.insert_block(it, buf, block_size, *indices.begin()); + prepare_large_block(buf, *indices.begin(), block_size, 0, 3*block_size/4); + it = blocks.insert_block(it, buf, 1, *indices.begin()); + prepare_large_block(buf, *indices.begin(), block_size, 3*block_size-4, 0); + it = blocks.insert_block(it, buf, block_size, *indices.begin()); + prepare_large_block(buf, *indices.begin(), block_size, 0, block_size/4); + it = blocks.insert_block(it, buf, block_size, *indices.begin()); + prepare_large_block(buf, *indices.begin(), block_size, 0, 2*block_size/4); + blocks.insert_block(it, buf, block_size, *indices.begin()); + free(buf); + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < blocks + (transaction.data_index(&tf)); + std::list< IntIndex > indices; + + indices.clear(); + indices.push_back(IntIndex(20)); + indices.push_back(IntIndex(21)); + indices.push_back(IntIndex(22)); + uint64* buf = (uint64*)aligned_alloc(8, Variable_Block_Test_File().get_block_size() + * Variable_Block_Test_File().get_compression_factor()); + prepare_block(buf, indices); + blocks.insert_block(blocks.write_end(), buf); + free(buf); + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < blocks + (transaction.data_index(&tf)); + std::list< IntIndex > indices; + + uint64* buf = (uint64*)aligned_alloc(8, Variable_Block_Test_File().get_block_size() * Variable_Block_Test_File().get_compression_factor()); + + indices.clear(); + indices.push_back(IntIndex(30)); + indices.push_back(IntIndex(31)); + indices.push_back(IntIndex(32)); + prepare_block(buf, indices); + blocks.insert_block(blocks.write_end(), buf); + + indices.clear(); + indices.push_back(IntIndex(33)); + indices.push_back(IntIndex(34)); + indices.push_back(IntIndex(35)); + prepare_block(buf, indices); + blocks.insert_block(blocks.write_end(), buf); + + indices.clear(); + indices.push_back(IntIndex(36)); + indices.push_back(IntIndex(37)); + prepare_block(buf, indices); + blocks.insert_block(blocks.write_end(), buf); + + indices.clear(); + indices.push_back(IntIndex(38)); + indices.push_back(IntIndex(39)); + prepare_block(buf, indices); + blocks.insert_block(blocks.write_end(), buf); + + indices.clear(); + indices.push_back(IntIndex(40)); + prepare_block(buf, indices); + blocks.insert_block(blocks.write_end(), buf); + + indices.clear(); + indices.push_back(IntIndex(41)); + prepare_block(buf, indices); + blocks.insert_block(blocks.write_end(), buf); + + indices.clear(); + indices.push_back(IntIndex(50)); + indices.push_back(IntIndex(51)); + indices.push_back(IntIndex(52)); + indices.push_back(IntIndex(53)); + indices.push_back(IntIndex(54)); + indices.push_back(IntIndex(55)); + indices.push_back(IntIndex(56)); + prepare_block(buf, indices); + blocks.insert_block(blocks.write_end(), buf); + + indices.clear(); + indices.push_back(IntIndex(57)); + prepare_block(buf, indices); + blocks.insert_block(blocks.write_end(), buf); + + indices.clear(); + indices.push_back(IntIndex(60)); + indices.push_back(IntIndex(61)); + prepare_block(buf, indices); + blocks.insert_block(blocks.write_end(), buf); + + indices.clear(); + indices.push_back(IntIndex(62)); + indices.push_back(IntIndex(63)); + prepare_block(buf, indices); + blocks.insert_block(blocks.write_end(), buf); + + free(buf); + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < blocks + (transaction.data_index(&tf)); + + std::list< IntIndex > indices; + for (int i = 0; i < 100; ++i) + indices.push_back(IntIndex(i)); + + File_Blocks< IntIndex, IntIterator >::Write_Iterator + it = blocks.write_begin(indices.begin(), indices.end()); + + ++it; + it = blocks.erase_block(it); + ++it; + it = blocks.erase_block(it); + ++it; + it = blocks.erase_block(it); + ++it; + it = blocks.erase_block(it); + ++it; + it = blocks.erase_block(it); + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < blocks + (transaction.data_index(&tf)); + + std::list< IntIndex > indices; + for (int i = 0; i < 100; ++i) + indices.push_back(IntIndex(i)); + + File_Blocks< IntIndex, IntIterator >::Write_Iterator + it = blocks.write_begin(indices.begin(), indices.end()); + + uint64* buf = (uint64*)aligned_alloc(8, Variable_Block_Test_File().get_block_size() * Variable_Block_Test_File().get_compression_factor()); + + while (!it.is_end() && it.block().index < 25) + ++it; + indices.clear(); + indices.push_back(IntIndex(25)); + prepare_block(buf, indices); + blocks.insert_block(it, buf); + + free(buf); + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < blocks + (transaction.data_index(&tf)); + + std::list< IntIndex > indices; + for (int i = 0; i < 100; ++i) + indices.push_back(IntIndex(i)); + + File_Blocks< IntIndex, IntIterator >::Write_Iterator + it = blocks.write_begin(indices.begin(), indices.end()); + + uint64* buf = (uint64*)aligned_alloc(8, Variable_Block_Test_File().get_block_size() * Variable_Block_Test_File().get_compression_factor()); + + while (!it.is_end() && it.block().index < 26) + ++it; + indices.clear(); + indices.push_back(IntIndex(26)); + prepare_block(buf, indices); + blocks.insert_block(it, buf); + + free(buf); + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < blocks + (transaction.data_index(&tf)); + + std::list< IntIndex > indices; + for (int i = 0; i < 100; ++i) + indices.push_back(IntIndex(i)); + + File_Blocks< IntIndex, IntIterator >::Write_Iterator + it = blocks.write_begin(indices.begin(), indices.end()); + + uint64* buf = (uint64*)aligned_alloc(8, Variable_Block_Test_File().get_block_size() * Variable_Block_Test_File().get_compression_factor()); + + while (!it.is_end() && it.block().index < 60) + ++it; + indices.clear(); + indices.push_back(IntIndex(60)); + indices.push_back(IntIndex(61)); + prepare_block(buf, indices); + blocks.insert_block(it, buf); + + free(buf); + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < blocks + (transaction.data_index(&tf)); + + std::list< IntIndex > indices; + for (int i = 0; i < 100; ++i) + indices.push_back(IntIndex(i)); + + File_Blocks< IntIndex, IntIterator >::Write_Iterator + it = blocks.write_begin(indices.begin(), indices.end()); + + uint64* buf = (uint64*)aligned_alloc(8, Variable_Block_Test_File().get_block_size() * Variable_Block_Test_File().get_compression_factor()); + + while (!it.is_end() && it.block().index < 65) + ++it; + indices.clear(); + indices.push_back(IntIndex(65)); + indices.push_back(IntIndex(66)); + indices.push_back(IntIndex(67)); + prepare_block(buf, indices); + blocks.insert_block(it, buf); + + free(buf); + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < blocks + (transaction.data_index(&tf)); + + std::list< IntIndex > indices; + for (int i = 0; i < 100; ++i) + indices.push_back(IntIndex(i)); + + File_Blocks< IntIndex, IntIterator >::Write_Iterator + it = blocks.write_begin(indices.begin(), indices.end()); + + uint64* buf = (uint64*)aligned_alloc(8, Variable_Block_Test_File().get_block_size() * Variable_Block_Test_File().get_compression_factor()); + + while (!it.is_end() && it.block().index < 68) + ++it; + indices.clear(); + indices.push_back(IntIndex(68)); + indices.push_back(IntIndex(69)); + prepare_block(buf, indices); + blocks.insert_block(it, buf); + + free(buf); + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < blocks + (transaction.data_index(&tf)); + + std::list< IntIndex > indices; + for (int i = 0; i < 100; ++i) + indices.push_back(IntIndex(i)); + + File_Blocks< IntIndex, IntIterator >::Write_Iterator + it = blocks.write_begin(indices.begin(), indices.end()); + + uint64* buf = (uint64*)aligned_alloc(8, Variable_Block_Test_File().get_block_size() * Variable_Block_Test_File().get_compression_factor()); + + while (!it.is_end() && it.block().index < 70) + ++it; + indices.clear(); + indices.push_back(IntIndex(70)); + indices.push_back(IntIndex(71)); + indices.push_back(IntIndex(72)); + prepare_block(buf, indices); + blocks.insert_block(it, buf); + + free(buf); + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < blocks + (transaction.data_index(&tf)); + + std::list< IntIndex > indices; + for (int i = 0; i < 100; ++i) + indices.push_back(IntIndex(i)); + + File_Blocks< IntIndex, IntIterator >::Write_Iterator + it = blocks.write_begin(indices.begin(), indices.end()); + + uint64* buf = (uint64*)aligned_alloc(8, Variable_Block_Test_File().get_block_size() * Variable_Block_Test_File().get_compression_factor()); + + while (!it.is_end() && it.block().index < 20) + ++it; + indices.clear(); + indices.push_back(IntIndex(20)); + indices.push_back(IntIndex(22)); + prepare_block(buf, indices); + it = blocks.replace_block(it, buf); + + free(buf); + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < blocks + (transaction.data_index(&tf)); + std::list< IntIndex > indices; + + uint64* buf = (uint64*)aligned_alloc(8, Compressed_Test_File().get_block_size() * Compressed_Test_File().get_compression_factor()); + + indices.clear(); + for (int i = 20; i < 21; ++i) + indices.push_back(IntIndex(i)); + prepare_block(buf, indices); + blocks.insert_block(blocks.write_end(), buf); + + indices.clear(); + for (int i = 100; i < 280; ++i) + indices.push_back(IntIndex(i)); + prepare_block(buf, indices); + blocks.insert_block(blocks.write_end(), buf); + + indices.clear(); + for (int i = 1000; i < 1060; ++i) + indices.push_back(IntIndex(i)); + prepare_block(buf, indices); + blocks.insert_block(blocks.write_end(), buf); + + free(buf); + } + catch (File_Error e) + { + std::cout<<"File error catched: " + <. + */ + +#include +#include + +#include + +#include "random_file.h" +#include "transaction.h" + + +/** + * Tests the library random_file + */ + +//----------------------------------------------------------------------------- + +/* Sample class for TIndex */ +struct IntIndex +{ + IntIndex(uint32 i) : value(i) {} + IntIndex(void* data) : value(*(uint32*)data) {} + + static uint32 max_size_of() + { + return 4; + } + + void to_data(void* data) const + { + *(uint32*)data = value; + } + + bool operator<(const IntIndex& index) const + { + return this->value < index.value; + } + + bool operator==(const IntIndex& index) const + { + return this->value == index.value; + } + + uint32 val() const + { + return value; + } + + private: + uint32 value; +}; + +//----------------------------------------------------------------------------- + +/* We use our own test settings */ +std::string BASE_DIRECTORY("./"); +std::string ID_SUFFIX(".map"); + + +struct Test_File : File_Properties +{ + const std::string& get_basedir() const + { + return BASE_DIRECTORY; + } + + const std::string& get_file_name_trunk() const + { + static std::string result("testfile"); + return result; + } + + const std::string& get_index_suffix() const + { + static std::string result(".idx"); + return result; + } + + const std::string& get_data_suffix() const + { + static std::string result(""); + return result; + } + + const std::string& get_id_suffix() const + { + return ID_SUFFIX; + } + + const std::string& get_shadow_suffix() const + { + static std::string result(".shadow"); + return result; + } + + uint32 get_block_size() const + { + return 512; + } + + uint32 get_compression_factor() const + { + return 1; + } + + uint32 get_compression_method() const + { + return 0; + } + + uint32 get_map_compression_method() const + { + return 0; + } + + uint32 get_map_block_size() const + { + return 16*IntIndex::max_size_of(); + } + + uint32 get_map_compression_factor() const + { + return 1; + } + + std::vector< bool > get_data_footprint(const std::string& db_dir) const + { + return std::vector< bool >(); + } + + std::vector< bool > get_map_footprint(const std::string& db_dir) const + { + return std::vector< bool >(); + } + + uint32 id_max_size_of() const + { + return IntIndex::max_size_of(); + } + + File_Blocks_Index_Base* new_data_index( + Access_Mode access_mode, bool use_shadow, const std::string& db_dir, const std::string& file_name_extension) + const + { + throw std::string(); + return 0; + } +}; + +//----------------------------------------------------------------------------- + +void read_test() +{ + try + { + std::cout<<"Read test\n"; + std::vector< bool > footprint = get_map_index_footprint + (Test_File(), BASE_DIRECTORY, false); + std::cout<<"Index footprint: "; + for (std::vector< bool >::const_iterator it(footprint.begin()); it != footprint.end(); + ++it) + std::cout<<*it; + std::cout<<'\n'; + + Nonsynced_Transaction transaction(Access_Mode::readonly, false, BASE_DIRECTORY, ""); + Test_File tf; + Random_File< IntIndex, IntIndex > id_file(transaction.random_index(&tf)); + + std::cout< 1) + test_to_execute = args[1]; + + if ((test_to_execute == "") || (test_to_execute == "1")) + std::cout<<"** Test the behaviour for an empty file\n"; + int data_fd = open64 + ((BASE_DIRECTORY + Test_File().get_file_name_trunk() + Test_File().get_id_suffix()).c_str(), + O_WRONLY|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); + close(data_fd); + int index_fd = open64 + ((BASE_DIRECTORY + Test_File().get_file_name_trunk() + Test_File().get_id_suffix() + + Test_File().get_index_suffix()).c_str(), + O_WRONLY|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); + close(index_fd); + if ((test_to_execute == "") || (test_to_execute == "1")) + read_test(); + + if ((test_to_execute == "") || (test_to_execute == "2")) + std::cout<<"** Test the behaviour for a file with two entries - part 1\n"; + try + { + Nonsynced_Transaction transaction(Access_Mode::writeable, false, BASE_DIRECTORY, ""); + Test_File tf; + { + Random_File< IntIndex, IntIndex > blocks(transaction.random_index(&tf)); + + blocks.put(2u, 12); + blocks.put(5u, 15); + } + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < blocks(transaction.random_index(&tf)); + + blocks.put(6u, 16); + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < blocks(transaction.random_index(&tf)); + + blocks.put(2u, 32); + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < blocks(transaction.random_index(&tf)); + + blocks.put(16u, 1); + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < blocks(transaction.random_index(&tf)); + + blocks.put(0u, 2); + blocks.put(32u, 3); + blocks.put(48u, 4); + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < blocks(transaction.random_index(&tf)); + + blocks.put(80u, 5); + } + catch (File_Error e) + { + std::cout<<"File error catched: " + < blocks(transaction.random_index(&tf)); + + blocks.put(64u, 6); + } + catch (File_Error e) + { + std::cout<<"File error catched: " + <stdout.log 2>stderr.log }; fi + # When and where a query stood when it hit a limit depends on the machine + sed -i -E 's/^After [0-9]+h[0-9]+m[0-9]+s: /After: /; s/ Stack: .*$//' stderr.log evaluate_test "${EXEC}_$I" if [[ -n $FAILED ]]; then { @@ -112,6 +114,8 @@ perform_test_stdout_null() { "$BASEDIR/bin/$1" $ARGS >/dev/null 2>stderr.log }; fi + # When and where a query stood when it hit a limit depends on the machine + sed -i -E 's/^After [0-9]+h[0-9]+m[0-9]+s: /After: /; s/ Stack: .*$//' stderr.log evaluate_test "${EXEC}_$I" if [[ -n $FAILED ]]; then { @@ -161,9 +165,14 @@ perform_test osm3s_query 18 cat input/update_database/transactions.log $BASEDIR/bin/dispatcher --terminate +# Tests 19, 28, 31, 34, 66 and 67 are skipped: their queries take less than ten +# seconds, so whether they hit their one second timeout depends on the speed of +# the machine. +TIMEOUT_TESTS=" 19 28 31 34 66 67 " II=19 while [[ $II -lt 58 ]]; do { + [[ $TIMEOUT_TESTS == *" $II "* ]] || perform_test osm3s_query $II "--db-dir=../../input/update_database/" II=$(($II + 1)) }; done @@ -176,8 +185,6 @@ perform_test_stdout_null osm3s_query 62 "--db-dir=../../input/update_database/" perform_test_stdout_null osm3s_query 63 "--db-dir=../../input/update_database/" perform_test_stdout_null osm3s_query 64 "--db-dir=../../input/update_database/" perform_test osm3s_query 65 "--db-dir=../../input/update_database/" -perform_test_stdout_null osm3s_query 66 "--db-dir=../../input/update_database/" -perform_test_stdout_null osm3s_query 67 "--db-dir=../../input/update_database/" perform_test_stdout_null osm3s_query 68 "--db-dir=../../input/update_database/" perform_test osm3s_query 69 "--db-dir=../../input/update_database/" diff --git a/src/test-bin/run_testsuite_regressions.sh b/src/test-bin/run_testsuite_regressions.sh new file mode 100755 index 000000000..c228d67ea --- /dev/null +++ b/src/test-bin/run_testsuite_regressions.sh @@ -0,0 +1,158 @@ +#!/usr/bin/env bash + +# Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Roland Olbricht et al. +# +# This file is part of Overpass_API. +# +# Overpass_API is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# Overpass_API is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with Overpass_API. If not, see . + +# Runs every test in input/regression_*/. A test is a directory with +# +# stdin.log the query; for a CGI test, the request body, if any +# init.osm optional: data to import into a database of its own +# import.args optional: arguments for update_database (default: --meta) +# env optional: makes it a test of cgi-bin/interpreter, run with +# these environment variables (one NAME=value per line) +# +# and its expected output in expected/regression_*/stdout.log and stderr.log. +# Without env, the query runs with osm3s_query. Version numbers in the output +# are replaced by "Overpass API". + +BASEDIR="$(cd "$(dirname "$0")" && pwd)/.." +# A test of a hang must fail rather than block the suite or fill the disk: +# each test runs for at most TIMEOUT seconds and writes at most MAX_FILE_KB +# per file. +TIMEOUT=60 +MAX_FILE_KB=10240 + +evaluate_test() +{ + local DIRNAME="$1" FILE RES + + FAILED= + for FILE in "../../expected/$DIRNAME"/*; do + { + FILE="$(basename "$FILE")" + if [[ ! -f $FILE ]]; then + { + echo "In Test $DIRNAME: Expected file \"$FILE\" doesn't exist." + FAILED=YES + }; fi + }; done + for FILE in *; do + { + [[ -e $FILE ]] || continue + if [[ ! -f "../../expected/$DIRNAME/$FILE" ]]; then + { + echo "In Test $DIRNAME: Unexpected file \"$FILE\" exists." + FAILED=YES + }; else + { + RES="$(diff -q "../../expected/$DIRNAME/$FILE" "$FILE")" + if [[ -n $RES ]]; then + { + echo "$RES" + FAILED=YES + }; fi + }; fi + }; done +}; + +perform_regression_test() +{ + local NAME="$1" + local INPUT="../../input/$NAME" + local STDIN DB_DIR RC LINE + local DB_ARGS=() IMPORT_ARGS=() ENV_VARS=() + + mkdir -p "run/$NAME" + pushd "run/$NAME/" >/dev/null || return + rm -fR ./* + + STDIN="$INPUT/stdin.log" + if [[ ! -f $STDIN ]]; then + STDIN=/dev/null + fi + + # The database lives in a short temporary path: the dispatcher's socket is + # created in it, and socket paths are limited to about 100 characters. + DB_DIR= + if [[ -f "$INPUT/init.osm" ]]; then + { + DB_DIR="$(mktemp -d)" + IMPORT_ARGS=(--meta) + if [[ -f "$INPUT/import.args" ]]; then + read -r -a IMPORT_ARGS <"$INPUT/import.args" + fi + "$BASEDIR/bin/update_database" --db-dir="$DB_DIR/" "${IMPORT_ARGS[@]}" --version=mock-up-init \ + <"$INPUT/init.osm" >/dev/null 2>&1 + DB_ARGS=(--db-dir="$DB_DIR/") + }; fi + + if [[ -f "$INPUT/env" ]]; then + { + if [[ -n $DB_DIR ]]; then + { + local DISPATCHER_META="--meta" + if [[ " ${IMPORT_ARGS[*]} " == *" --keep-attic "* ]]; then + DISPATCHER_META="--attic" + fi + "$BASEDIR/bin/dispatcher" --osm-base "$DISPATCHER_META" "${DB_ARGS[@]}" & + sleep 1 + }; fi + while IFS= read -r LINE || [[ -n $LINE ]]; do + [[ -n $LINE ]] && ENV_VARS+=("$LINE") + done <"$INPUT/env" + ( ulimit -f "$MAX_FILE_KB" + env -i PATH="$PATH" "${ENV_VARS[@]}" timeout "$TIMEOUT" "$BASEDIR/cgi-bin/interpreter" \ + <"$STDIN" >stdout.log 2>stderr.log ) + RC=$? + if [[ -n $DB_DIR ]]; then + "$BASEDIR/bin/dispatcher" --osm-base --terminate + fi + }; else + { + ( ulimit -f "$MAX_FILE_KB" + timeout "$TIMEOUT" "$BASEDIR/bin/osm3s_query" "${DB_ARGS[@]}" \ + <"$STDIN" >stdout.log 2>stderr.log ) + RC=$? + }; fi + if [[ $RC -eq 124 ]]; then + echo "Timed out after $TIMEOUT seconds." >>stderr.log + elif [[ $RC -eq 153 ]]; then + printf '\nStopped after writing %s KB to one file.\n' "$MAX_FILE_KB" >>stderr.log + fi + sed -i 's/Overpass API [^ ]* [a-f0-9]*\([" ]\)/Overpass API\1/g' stdout.log + + evaluate_test "$NAME" + if [[ -n $FAILED ]]; then + { + echo "$(date +%T) Test $NAME FAILED." + }; else + { + echo "$(date +%T) Test $NAME succeeded." + rm -fR ./* + }; fi + if [[ -n $DB_DIR ]]; then + rm -fR "$DB_DIR" + fi + popd >/dev/null || return +}; + +date +%T +for DIR in input/regression_*/; do +{ + [[ -d $DIR ]] || continue + perform_regression_test "$(basename "$DIR")" +}; done