From c7649e39e5b917c329646ef20d7247e237e6ab9f Mon Sep 17 00:00:00 2001 From: Erica Fischer Date: Mon, 25 Nov 2024 15:54:41 -0800 Subject: [PATCH] Add missing fixture, and don't crash if it is missing --- clip.cpp | 5 ++ tests/pbf/region.json | 135 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 140 insertions(+) create mode 100644 tests/pbf/region.json diff --git a/clip.cpp b/clip.cpp index c162a788..dda4032f 100644 --- a/clip.cpp +++ b/clip.cpp @@ -1174,8 +1174,13 @@ bool pnpoly_mp(drawvec const &geom, long long x, long long y) { clipbbox parse_clip_poly(std::string arg) { json_pull *jp = json_begin_string(arg.c_str()); json_object *j = json_read_tree(jp); + if (j == NULL) { + fprintf(stderr, "Expected JSON object, not %s\n", arg.c_str()); + exit(EXIT_ARGS); + } if (j->type != JSON_HASH) { fprintf(stderr, "Expected JSON geometry object, not %s\n", arg.c_str()); + exit(EXIT_ARGS); } std::pair parsed_geometry = parse_geometry(j, jp, j, 0, 0, 0, 1LL << 32, false); diff --git a/tests/pbf/region.json b/tests/pbf/region.json new file mode 100644 index 00000000..19b21c96 --- /dev/null +++ b/tests/pbf/region.json @@ -0,0 +1,135 @@ + { + "coordinates": [ + [ + [ + [ + 13.577060272719763, + 53.17369971291083 + ], + [ + 10.704205888641951, + 52.74867374387799 + ], + [ + 8.234559137417222, + 50.4321686022941 + ], + [ + 4.20248280888643, + 49.91569934015271 + ], + [ + 3.3960675431802656, + 47.351710786357756 + ], + [ + 4.958497120486356, + 45.82785468647634 + ], + [ + 7.680148642243836, + 45.54618382040567 + ], + [ + 10.704205888641951, + 47.82759699398349 + ], + [ + 13.728263135039242, + 48.332677316517476 + ], + [ + 16.903523243756865, + 47.24917200504791 + ], + [ + 19.272368086768267, + 48.26561972235635 + ], + [ + 19.52437285730184, + 50.97481113632679 + ], + [ + 16.701919427330296, + 52.53459175523133 + ], + [ + 13.577060272719763, + 53.17369971291083 + ] + ], + [ + [ + 14.78668317127898, + 51.66775442536286 + ], + [ + 12.46823928237373, + 51.6051918576735 + ], + [ + 11.208215429708275, + 50.78400718973347 + ], + [ + 11.359418292027812, + 49.980563422399655 + ], + [ + 12.417838328266726, + 49.39363856874314 + ], + [ + 14.181871721999357, + 49.32798696801095 + ], + [ + 16.046707023944435, + 50.62440671313237 + ], + [ + 14.78668317127898, + 51.66775442536286 + ] + ] + ], + [ + [ + [ + 21.055284848897287, + 46.16048194834923 + ], + [ + 18.988845730525668, + 45.81027671022295 + ], + [ + 18.53523714356635, + 45.13878150945956 + ], + [ + 18.585638097672586, + 43.989754759795915 + ], + [ + 19.896062904445103, + 43.18663878167516 + ], + [ + 22.31530870156351, + 44.134624205316555 + ], + [ + 22.31530870156351, + 45.280813880909534 + ], + [ + 21.055284848897287, + 46.16048194834923 + ] + ] + ] + ], + "type": "MultiPolygon" + }