get intersection analysis unit, timezoner and updater unit tests to pass
get timzone unit tests to pass get validation tests to pass get updater and timezone unit test files to build with multiline string formatting update validateFeature to validate polygon outterings and tzid add tzid to all test fixtures of geojson features add txid to test fixture added tzid to hongkon test data but it already has timezone property
This commit is contained in:
parent
0940f23d9d
commit
0fa2c14500
@ -48,6 +48,15 @@ inline void validateFeature(const rapidjson::Value &feature)
|
|||||||
{
|
{
|
||||||
throw osrm::util::exception("Feature has non-object properties member.");
|
throw osrm::util::exception("Feature has non-object properties member.");
|
||||||
}
|
}
|
||||||
|
else if (!feature.GetObject()["properties"].HasMember("tzid"))
|
||||||
|
{
|
||||||
|
throw osrm::util::exception("Feature is missing tzid member.");
|
||||||
|
}
|
||||||
|
else if (!feature["properties"]["tzid"].IsString())
|
||||||
|
{
|
||||||
|
throw osrm::util::exception("Feature has non-string tzid member.");
|
||||||
|
}
|
||||||
|
|
||||||
if (!feature.HasMember("geometry"))
|
if (!feature.HasMember("geometry"))
|
||||||
{
|
{
|
||||||
throw osrm::util::exception("Feature is missing geometry member.");
|
throw osrm::util::exception("Feature is missing geometry member.");
|
||||||
@ -76,6 +85,11 @@ inline void validateFeature(const rapidjson::Value &feature)
|
|||||||
const auto coord_array = feature["geometry"].GetObject()["coordinates"].GetArray();
|
const auto coord_array = feature["geometry"].GetObject()["coordinates"].GetArray();
|
||||||
if (coord_array.Empty())
|
if (coord_array.Empty())
|
||||||
throw osrm::util::exception("Feature geometry coordinates member is empty.");
|
throw osrm::util::exception("Feature geometry coordinates member is empty.");
|
||||||
|
|
||||||
|
if (feature["geometry"].GetObject()["type"] == "polygon" && coord_array[0].IsArray() &&
|
||||||
|
coord_array[0][0].IsNumber())
|
||||||
|
throw osrm::util::exception(
|
||||||
|
"Feature geometry coordinates of type Polygon is missing outterring.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -3,6 +3,7 @@
|
|||||||
"features": [ {
|
"features": [ {
|
||||||
"type": "Feature",
|
"type": "Feature",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"tzid": "Europe/Berlin",
|
||||||
"driving_side": "left",
|
"driving_side": "left",
|
||||||
"answer": 42,
|
"answer": 42,
|
||||||
"boolean": true,
|
"boolean": true,
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
// #include "extractor/intersection/intersection_analysis.hpp"
|
#include "extractor/intersection/intersection_analysis.hpp"
|
||||||
|
|
||||||
#include "extractor/graph_compressor.hpp"
|
#include "extractor/graph_compressor.hpp"
|
||||||
|
|
||||||
@ -47,6 +47,7 @@ BOOST_AUTO_TEST_CASE(simple_intersection_connectivity)
|
|||||||
to,
|
to,
|
||||||
1,
|
1,
|
||||||
1,
|
1,
|
||||||
|
1,
|
||||||
GeometryID{0, false},
|
GeometryID{0, false},
|
||||||
!allowed,
|
!allowed,
|
||||||
NodeBasedEdgeClassification(),
|
NodeBasedEdgeClassification(),
|
||||||
@ -169,12 +170,12 @@ BOOST_AUTO_TEST_CASE(roundabout_intersection_connectivity)
|
|||||||
// 0
|
// 0
|
||||||
// ↙ ↑ ↘
|
// ↙ ↑ ↘
|
||||||
// 4 5 6
|
// 4 5 6
|
||||||
const auto unit_edge = [](const NodeID from, const NodeID to, bool allowed, bool roundabout)
|
const auto unit_edge = [](const NodeID from, const NodeID to, bool allowed, bool roundabout) {
|
||||||
{
|
|
||||||
return InputEdge{from,
|
return InputEdge{from,
|
||||||
to,
|
to,
|
||||||
1,
|
1,
|
||||||
1,
|
1,
|
||||||
|
1,
|
||||||
GeometryID{0, false},
|
GeometryID{0, false},
|
||||||
!allowed,
|
!allowed,
|
||||||
NodeBasedEdgeClassification{
|
NodeBasedEdgeClassification{
|
||||||
@ -278,7 +279,7 @@ BOOST_AUTO_TEST_CASE(skip_degree_two_nodes)
|
|||||||
//
|
//
|
||||||
const auto unit_edge = [](const NodeID from, const NodeID to, bool allowed) {
|
const auto unit_edge = [](const NodeID from, const NodeID to, bool allowed) {
|
||||||
return InputEdge{
|
return InputEdge{
|
||||||
from, to, 1, 1, GeometryID{0, false}, !allowed, NodeBasedEdgeClassification{}, 0};
|
from, to, 1, 1, 1, GeometryID{0, false}, !allowed, NodeBasedEdgeClassification{}, 0};
|
||||||
};
|
};
|
||||||
std::vector<InputEdge> edges = {unit_edge(0, 1, true), // 0
|
std::vector<InputEdge> edges = {unit_edge(0, 1, true), // 0
|
||||||
unit_edge(1, 0, true),
|
unit_edge(1, 0, true),
|
||||||
|
|||||||
@ -30,26 +30,28 @@ struct LocationDataFixture
|
|||||||
BOOST_AUTO_TEST_CASE(polygon_tests)
|
BOOST_AUTO_TEST_CASE(polygon_tests)
|
||||||
{
|
{
|
||||||
LocationDataFixture fixture(R"json({
|
LocationDataFixture fixture(R"json({
|
||||||
"type": "FeatureCollection",
|
"type": "FeatureCollection",
|
||||||
"features": [
|
"features": [
|
||||||
{
|
{
|
||||||
"type": "Feature",
|
"type": "Feature",
|
||||||
"properties": {
|
"properties": {
|
||||||
"answer": 42
|
"tzid" : "Europe/Berlin",
|
||||||
},
|
"answer": 42
|
||||||
"geometry": { "type": "Polygon", "coordinates": [
|
},
|
||||||
[ [3, 0], [1, 1], [0, 3], [-1, 1], [-3, 0], [-1, -1], [0, -3], [1, -1], [3, 0] ],
|
"geometry": { "type": "Polygon", "coordinates": [
|
||||||
[ [1, 0], [0, 1], [-1, 0], [0, -1], [1, 0] ]
|
[ [3, 0], [1, 1], [0, 3], [-1, 1], [-3, 0], [-1, -1], [0, -3], [1, -1], [3, 0] ],
|
||||||
] }
|
[ [1, 0], [0, 1], [-1, 0], [0, -1], [1, 0] ]
|
||||||
},
|
] }
|
||||||
{
|
},
|
||||||
"type": "Feature",
|
{
|
||||||
"properties": {
|
"type": "Feature",
|
||||||
"answer": true
|
"properties": {
|
||||||
},
|
"tzid" : "Europe/Berlin",
|
||||||
"geometry": { "type": "Polygon", "coordinates": [ [ [0, 10], [3, 5], [1, 5], [10, 0], [-1, 5], [-3, 5], [0, 10] ] ] }
|
"answer": true
|
||||||
}
|
},
|
||||||
]})json");
|
"geometry": { "type": "Polygon", "coordinates": [ [ [0, 10], [3, 5], [1, 5], [10, 0], [-1, 5], [-3, 5], [0, 10] ] ] }
|
||||||
|
}
|
||||||
|
]})json");
|
||||||
|
|
||||||
LocationDependentData data({fixture.temporary_file});
|
LocationDependentData data({fixture.temporary_file});
|
||||||
|
|
||||||
@ -77,7 +79,8 @@ BOOST_AUTO_TEST_CASE(multy_polygon_tests)
|
|||||||
{
|
{
|
||||||
"type": "Feature",
|
"type": "Feature",
|
||||||
"properties": {
|
"properties": {
|
||||||
"answer": 42
|
"answer": 42,
|
||||||
|
"tzid" : "Europe/Berlin"
|
||||||
},
|
},
|
||||||
"geometry": { "type": "MultiPolygon", "coordinates": [
|
"geometry": { "type": "MultiPolygon", "coordinates": [
|
||||||
[ [ [1, 0], [0, 1], [-1, 0], [0, -1], [1, 0] ] ],
|
[ [ [1, 0], [0, 1], [-1, 0], [0, -1], [1, 0] ] ],
|
||||||
@ -103,17 +106,17 @@ BOOST_AUTO_TEST_CASE(polygon_merging_tests)
|
|||||||
"features": [
|
"features": [
|
||||||
{
|
{
|
||||||
"type": "Feature",
|
"type": "Feature",
|
||||||
"properties": { "answer": "a" },
|
"properties": { "tzid" : "Europe/Berlin", "answer": "a" },
|
||||||
"geometry": { "type": "Polygon", "coordinates": [ [ [3, 3], [-3, 3], [-3, -3], [3, -3], [3, 3] ] ] }
|
"geometry": { "type": "Polygon", "coordinates": [ [ [3, 3], [-3, 3], [-3, -3], [3, -3], [3, 3] ] ] }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "Feature",
|
"type": "Feature",
|
||||||
"properties": { "answer": "b" },
|
"properties": { "tzid" : "Europe/Berlin", "answer": "b" },
|
||||||
"geometry": { "type": "Polygon", "coordinates": [ [ [7, 3], [1, 3], [1, -3], [7, -3], [7, 3] ] ] }
|
"geometry": { "type": "Polygon", "coordinates": [ [ [7, 3], [1, 3], [1, -3], [7, -3], [7, 3] ] ] }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "Feature",
|
"type": "Feature",
|
||||||
"properties": { "answer": "c" },
|
"properties": { "tzid" : "Europe/Berlin", "answer": "c" },
|
||||||
"geometry": { "type": "Polygon", "coordinates": [ [ [8, 3], [2, 3], [2, -3], [8, -3], [8, 3] ] ] }
|
"geometry": { "type": "Polygon", "coordinates": [ [ [8, 3], [2, 3], [2, -3], [8, -3], [8, 3] ] ] }
|
||||||
}
|
}
|
||||||
]})json");
|
]})json");
|
||||||
@ -149,7 +152,7 @@ BOOST_AUTO_TEST_CASE(staircase_polygon)
|
|||||||
"features": [
|
"features": [
|
||||||
{
|
{
|
||||||
"type": "Feature",
|
"type": "Feature",
|
||||||
"properties": { "answer": "a" },
|
"properties": { "tzid" : "Europe/Berlin", "answer": "a" },
|
||||||
"geometry": { "type": "Polygon", "coordinates": [ [ [0, 0], [3, 0], [3, 3], [2, 3], [2, 2], [1, 2], [1, 1], [0, 1], [0, 0] ] ] }
|
"geometry": { "type": "Polygon", "coordinates": [ [ [0, 0], [3, 0], [3, 3], [2, 3], [2, 2], [1, 2], [1, 1], [0, 1], [0, 0] ] ] }
|
||||||
}
|
}
|
||||||
]})json");
|
]})json");
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
{
|
{
|
||||||
"type": "Feature",
|
"type": "Feature",
|
||||||
"properties": {
|
"properties": {
|
||||||
"TZID": "Europe\\/Berlin"
|
"tzid": "Europe\\/Berlin"
|
||||||
},
|
},
|
||||||
"geometry": {
|
"geometry": {
|
||||||
"type": "Polygon",
|
"type": "Polygon",
|
||||||
|
|||||||
@ -12,50 +12,37 @@ using namespace osrm::updater;
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(timezoner_test)
|
BOOST_AUTO_TEST_CASE(timezoner_test)
|
||||||
{
|
{
|
||||||
const char json[] =
|
auto json = R"({ "type" : "FeatureCollection", "features": [{ "type" :
|
||||||
"{ \"type\" : \"FeatureCollection\", \"features\": ["
|
"Feature", "properties" : { "tzid" : "Europe/Berlin"},
|
||||||
"{ \"type\" : \"Feature\","
|
"geometry" : { "type" : "polygon", "coordinates":
|
||||||
"\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometry\" : { \"type\":
|
[[[8.28369,48.88277], [8.57757, 48.88277], [8.57757, 49.07206], [8.28369,49.07206], [8.28369, 48.88277]]] }} ]} )";
|
||||||
\"polygon\", "
|
|
||||||
"\"coordinates\": [[[8.28369,48.88277], [8.57757, "
|
|
||||||
"48.88277], [8.57757, 49.07206], [8.28369, "
|
|
||||||
"49.07206], [8.28369, 48.88277]]] }} ]}";
|
|
||||||
std::time_t now = time(0);
|
std::time_t now = time(0);
|
||||||
BOOST_CHECK_NO_THROW(Timezoner tz(json, now));
|
BOOST_CHECK_NO_THROW(Timezoner tz(json, now));
|
||||||
|
|
||||||
boost::filesystem::path test_path(TEST_DATA_DIR "/test.geojson");
|
boost::filesystem::path test_path(TEST_DATA_DIR "/test.geojson");
|
||||||
BOOST_CHECK_NO_THROW(Timezoner tz(test_path, now));
|
BOOST_CHECK_NO_THROW(Timezoner tz(test_path, now));
|
||||||
|
|
||||||
missing opening bracket
|
// missing opening bracket
|
||||||
const char bad[] =
|
auto bad = R"({ "type" : "FeatureCollection", "features": [{ "type" :
|
||||||
"\"type\" : \"FeatureCollection\", \"features\": ["
|
"Feature","properties" : { "TZID" : "Europe/Berlin"}, "geometry"
|
||||||
"{ \"type\" : \"Feature\","
|
: { "type":"polygon", "coordinates": [[[8.28369,48.88277], [8.57757,
|
||||||
"\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometry\" : { \"type\":
|
48.88277], [8.57757, 49.07206], [8.28369, 49.07206], [8.28369, 48.88277]]]
|
||||||
\"polygon\", "
|
}} ]})";
|
||||||
"\"coordinates\": [[[8.28369,48.88277], [8.57757, "
|
|
||||||
"48.88277], [8.57757, 49.07206], [8.28369, "
|
|
||||||
"49.07206], [8.28369, 48.88277]]] }} ]}";
|
|
||||||
BOOST_CHECK_THROW(Timezoner tz(bad, now), util::exception);
|
BOOST_CHECK_THROW(Timezoner tz(bad, now), util::exception);
|
||||||
|
|
||||||
missing/malformed FeatureCollection type field
|
// missing / malformed FeatureCollection type field
|
||||||
const char missing_type[] =
|
auto missing_type = R"({ "FeatureCollection", "features": [{ "type" :
|
||||||
"{ \"FeatureCollection\", \"features\": ["
|
"Feature","properties" : { "TZID" : "Europe/Berlin"},
|
||||||
"{ \"type\" : \"Feature\","
|
"geometry" : { "type":"polygon", "coordinates":
|
||||||
"\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometry\" : { \"type\":
|
[[[8.28369,48.88277], [8.57757, 48.88277], [8.57757, 49.07206],
|
||||||
\"polygon\", "
|
[8.28369, 49.07206], [8.28369, 48.88277]]] }} ]})";
|
||||||
"\"coordinates\": [[[8.28369,48.88277], [8.57757, "
|
|
||||||
"48.88277], [8.57757, 49.07206], [8.28369, "
|
|
||||||
"49.07206], [8.28369, 48.88277]]] }} ]}";
|
|
||||||
BOOST_CHECK_THROW(Timezoner tz(missing_type, now), util::exception);
|
BOOST_CHECK_THROW(Timezoner tz(missing_type, now), util::exception);
|
||||||
|
|
||||||
const char missing_featc[] =
|
auto missing_featc = R"({ "type" : "Collection", "features": [{ "type" :
|
||||||
"{ \"type\" : \"Collection\", \"features\": ["
|
"Feature","properties" : { "TZID" : "Europe/Berlin"},
|
||||||
"{ \"type\" : \"Feature\","
|
"geometry" : { "type":"polygon", "coordinates":
|
||||||
"\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometry\" : { \"type\":
|
[[[8.28369,48.88277], [8.57757, 48.88277], [8.57757, 49.07206],
|
||||||
\"polygon\", "
|
[8.28369, 49.07206], [8.28369, 48.88277]]] }} ]})";
|
||||||
"\"coordinates\": [[[8.28369,48.88277], [8.57757, "
|
|
||||||
"48.88277], [8.57757, 49.07206], [8.28369, "
|
|
||||||
"49.07206], [8.28369, 48.88277]]] }} ]}";
|
|
||||||
BOOST_CHECK_THROW(Timezoner tz(missing_featc, now), util::exception);
|
BOOST_CHECK_THROW(Timezoner tz(missing_featc, now), util::exception);
|
||||||
}
|
}
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|||||||
@ -29,116 +29,110 @@ BOOST_AUTO_TEST_CASE(timezone_coordinate_validation_test)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(timezone_validation_test)
|
BOOST_AUTO_TEST_CASE(timezone_validation_test)
|
||||||
{
|
{
|
||||||
char json[] =
|
auto json =
|
||||||
"{ \"type\" : \"Feature\","
|
R"({ "type" : "Feature",
|
||||||
"\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometry\" : { \"type\": \"polygon\", "
|
"properties" : { "tzid" : "Europe/Berlin"}, "geometry" : { "type": "polygon",
|
||||||
"\"coordinates\": [[[8.28369,48.88277], [8.57757, "
|
"coordinates": [[[8.28369,48.88277], [8.57757,
|
||||||
"48.88277], [8.57757, 49.07206], [8.28369, "
|
48.88277], [8.57757, 49.07206], [8.28369,
|
||||||
"49.07206], [8.28369, 48.88277]]] }}";
|
49.07206], [8.28369, 48.88277]]] }})";
|
||||||
rapidjson::Document doc;
|
rapidjson::Document doc;
|
||||||
doc.Parse(json);
|
doc.Parse(json);
|
||||||
BOOST_CHECK_NO_THROW(util::validateFeature(doc));
|
BOOST_CHECK_NO_THROW(util::validateFeature(doc));
|
||||||
|
|
||||||
char missing_type[] = "{\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometry\" : { "
|
auto missing_type = R"({"properties" : { "tzid" : "Europe/Berlin"}, "geometry" : {
|
||||||
"\"type\": \"polygon\", "
|
"type": "polygon",
|
||||||
"\"coordinates\": [[[8.28369,48.88277], [8.57757, "
|
"coordinates": [[[8.28369,48.88277], [8.57757,
|
||||||
"48.88277], [8.57757, 49.07206], [8.28369, "
|
48.88277], [8.57757, 49.07206], [8.28369,
|
||||||
"49.07206], [8.28369, 48.88277]]] }}";
|
49.07206], [8.28369, 48.88277]]] }})";
|
||||||
doc.Parse(missing_type);
|
doc.Parse(missing_type);
|
||||||
BOOST_CHECK_THROW(util::validateFeature(doc), util::exception);
|
BOOST_CHECK_THROW(util::validateFeature(doc), util::exception);
|
||||||
|
|
||||||
char missing_props[] =
|
auto missing_props =
|
||||||
"{ \"type\" : \"Feature\","
|
R"({ "type" : "Feature",
|
||||||
"\"props\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometry\" : { \"type\": \"polygon\", "
|
"props" : { "tzid" : "Europe/Berlin"}, "geometry" : { "type": "polygon",
|
||||||
"\"coordinates\": [[[8.28369,48.88277], [8.57757, "
|
"coordinates": [[[8.28369,48.88277], [8.57757,
|
||||||
"48.88277], [8.57757, 49.07206], [8.28369, "
|
48.88277], [8.57757, 49.07206], [8.28369,
|
||||||
"49.07206], [8.28369, 48.88277]]] }}";
|
49.07206], [8.28369, 48.88277]]] }})";
|
||||||
doc.Parse(missing_props);
|
doc.Parse(missing_props);
|
||||||
BOOST_CHECK_THROW(util::validateFeature(doc), util::exception);
|
BOOST_CHECK_THROW(util::validateFeature(doc), util::exception);
|
||||||
|
|
||||||
char nonobj_props[] =
|
auto nonobj_props =
|
||||||
"{ \"type\" : \"Feature\","
|
R"({ "type" : "Feature",
|
||||||
"\"properties\" : [ \"TZID\", \"Europe/Berlin\"], \"geometry\" : { \"type\": \"polygon\", "
|
"properties" : [ "tzid", "Europe/Berlin"], "geometry" : { "type": "polygon",
|
||||||
"\"coordinates\": [[[8.28369,48.88277], [8.57757, "
|
"coordinates": [[[8.28369,48.88277], [8.57757,
|
||||||
"48.88277], [8.57757, 49.07206], [8.28369, "
|
48.88277], [8.57757, 49.07206], [8.28369,
|
||||||
"49.07206], [8.28369, 48.88277]]] }}";
|
49.07206], [8.28369, 48.88277]]] }})";
|
||||||
doc.Parse(nonobj_props);
|
doc.Parse(nonobj_props);
|
||||||
BOOST_CHECK_THROW(util::validateFeature(doc), util::exception);
|
BOOST_CHECK_THROW(util::validateFeature(doc), util::exception);
|
||||||
|
|
||||||
char missing_tzid[] = "{ \"type\" : \"Feature\","
|
auto missing_tzid = R"({ "type" : "Feature",
|
||||||
"\"properties\" : { }, \"geometry\" : { \"type\": \"polygon\", "
|
"properties" : { }, "geometry" : { "type": "polygon",
|
||||||
"\"coordinates\": [[[8.28369,48.88277], [8.57757, "
|
"coordinates": [[[8.28369,48.88277], [8.57757,
|
||||||
"48.88277], [8.57757, 49.07206], [8.28369, "
|
48.88277], [8.57757, 49.07206], [8.28369,
|
||||||
"49.07206], [8.28369, 48.88277]]] }}";
|
49.07206], [8.28369, 48.88277]]] }})";
|
||||||
doc.Parse(missing_tzid);
|
doc.Parse(missing_tzid);
|
||||||
// BOOST_CHECK_THROW(util::validateFeature(doc), util::exception);
|
BOOST_CHECK_THROW(util::validateFeature(doc), util::exception);
|
||||||
|
|
||||||
// char tzid_err[] = "{ \"type\" : \"Feature\","
|
auto tzid_err = R"({ "type" : "Feature",
|
||||||
// "\"properties\" : { \"TZID\" : []}, \"geometry\" : { \"type\": \"polygon\",
|
"properties" : { "tzid" : []}, "geometry" : { "type": "polygon",
|
||||||
// "
|
"coordinates": [[[8.28369,48.88277], [8.57757,
|
||||||
// "\"coordinates\": [[[8.28369,48.88277], [8.57757, "
|
48.88277], [8.57757, 49.07206], [8.28369,
|
||||||
// "48.88277], [8.57757, 49.07206], [8.28369, "
|
49.07206], [8.28369, 48.88277]]] }})";
|
||||||
// "49.07206], [8.28369, 48.88277]]] }}";
|
doc.Parse(tzid_err);
|
||||||
// doc.Parse(tzid_err);
|
BOOST_CHECK_THROW(util::validateFeature(doc), util::exception);
|
||||||
// BOOST_CHECK_THROW(util::validateFeature(doc), util::exception);
|
|
||||||
|
|
||||||
// char missing_geom[] = "{ \"type\" : \"Feature\","
|
auto missing_geom = R"({ "type" : "Feature",
|
||||||
// "\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometries\" : { "
|
"properties" : { "tzid" : "Europe/Berlin"}, "geometries" : {
|
||||||
// "\"type\": \"polygon\", "
|
"type": "polygon",
|
||||||
// "\"coordinates\": [[[8.28369,48.88277], [8.57757, "
|
"coordinates": [[[8.28369,48.88277], [8.57757,
|
||||||
// "48.88277], [8.57757, 49.07206], [8.28369, "
|
48.88277], [8.57757, 49.07206], [8.28369,
|
||||||
// "49.07206], [8.28369, 48.88277]]] }}";
|
49.07206], [8.28369, 48.88277]]] }})";
|
||||||
// doc.Parse(missing_geom);
|
doc.Parse(missing_geom);
|
||||||
// BOOST_CHECK_THROW(util::validateFeature(doc), util::exception);
|
BOOST_CHECK_THROW(util::validateFeature(doc), util::exception);
|
||||||
|
|
||||||
// char nonobj_geom[] =
|
auto nonobj_geom =
|
||||||
// "{ \"type\" : \"Feature\","
|
R"({ "type" : "Feature",
|
||||||
// "\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometry\" : [ \"type\",
|
"properties" : { "tzid" : "Europe/Berlin"}, "geometry" : [ "type",
|
||||||
// \"polygon\", "
|
"polygon",
|
||||||
// "\"coordinates\", [[[8.28369,48.88277], [8.57757, "
|
"coordinates", [[[8.28369,48.88277], [8.57757,
|
||||||
// "48.88277], [8.57757, 49.07206], [8.28369, "
|
48.88277], [8.57757, 49.07206], [8.28369,
|
||||||
// "49.07206], [8.28369, 48.88277]]] ]}";
|
49.07206], [8.28369, 48.88277]]] ]})";
|
||||||
// doc.Parse(nonobj_geom);
|
doc.Parse(nonobj_geom);
|
||||||
// BOOST_CHECK_THROW(util::validateFeature(doc), util::exception);
|
BOOST_CHECK_THROW(util::validateFeature(doc), util::exception);
|
||||||
|
|
||||||
// char missing_geom_type[] = "{ \"type\" : \"Feature\","
|
auto missing_geom_type = R"({ "type" : "Feature",
|
||||||
// "\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometry\" :
|
"properties" : { "tzid" : "Europe/Berlin"}, "geometry" : {
|
||||||
// { "
|
"no_type": "polygon",
|
||||||
// "\"no_type\": \"polygon\", "
|
"coordinates": [[[8.28369,48.88277], [8.57757,
|
||||||
// "\"coordinates\": [[[8.28369,48.88277], [8.57757, "
|
48.88277], [8.57757, 49.07206], [8.28369,
|
||||||
// "48.88277], [8.57757, 49.07206], [8.28369, "
|
49.07206], [8.28369, 48.88277]]] }})";
|
||||||
// "49.07206], [8.28369, 48.88277]]] }}";
|
doc.Parse(missing_geom_type);
|
||||||
// doc.Parse(missing_geom_type);
|
BOOST_CHECK_THROW(util::validateFeature(doc), util::exception);
|
||||||
// BOOST_CHECK_THROW(util::validateFeature(doc), util::exception);
|
|
||||||
|
|
||||||
// char nonstring_geom_type[] = "{ \"type\" : \"Feature\","
|
auto nonstring_geom_type = R"({ "type" : "Feature",
|
||||||
// "\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometry\"
|
"properties" : { "tzid" : "Europe/Berlin"}, "geometry" :
|
||||||
// : "
|
{ "type": ["polygon"], "
|
||||||
// "{ \"type\": [\"polygon\"], "
|
"coordinates": [[[8.28369,48.88277], [8.57757,
|
||||||
// "\"coordinates\": [[[8.28369,48.88277], [8.57757, "
|
48.88277], [8.57757, 49.07206], [8.28369,
|
||||||
// "48.88277], [8.57757, 49.07206], [8.28369, "
|
49.07206], [8.28369, 48.88277]]] }})";
|
||||||
// "49.07206], [8.28369, 48.88277]]] }}";
|
doc.Parse(nonstring_geom_type);
|
||||||
// doc.Parse(nonstring_geom_type);
|
BOOST_CHECK_THROW(util::validateFeature(doc), util::exception);
|
||||||
// BOOST_CHECK_THROW(util::validateFeature(doc), util::exception);
|
|
||||||
|
|
||||||
// char missing_coords[] =
|
auto missing_coords = R"({ "type" : "Feature",
|
||||||
// "{ \"type\" : \"Feature\","
|
"properties" : { "tzid" : "Europe/Berlin"}, "geometry" : { "type":
|
||||||
// "\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometry\" : { \"type\":
|
"polygon",
|
||||||
// \"polygon\", "
|
"coords": [[[8.28369,48.88277], [8.57757,
|
||||||
// "\"coords\": [[[8.28369,48.88277], [8.57757, "
|
48.88277], [8.57757, 49.07206], [8.28369,
|
||||||
// "48.88277], [8.57757, 49.07206], [8.28369, "
|
49.07206], [8.28369, 48.88277]]] }})";
|
||||||
// "49.07206], [8.28369, 48.88277]]] }}";
|
doc.Parse(missing_coords);
|
||||||
// doc.Parse(missing_coords);
|
BOOST_CHECK_THROW(util::validateFeature(doc), util::exception);
|
||||||
// BOOST_CHECK_THROW(util::validateFeature(doc), util::exception);
|
|
||||||
|
|
||||||
// char missing_outerring[] =
|
auto missing_outerring = R"({ "type" : "Feature",
|
||||||
// "{ \"type\" : \"Feature\","
|
"properties" : { "tzid" : "Europe/Berlin"}, "geometry" : { "type": "polygon",
|
||||||
// "\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometry\" : { \"type\":
|
"coordinates": [[8.28369,48.88277], [8.57757,
|
||||||
// \"polygon\", "
|
48.88277], [8.57757, 49.07206], [8.28369,
|
||||||
// "\"coordinates\": [[8.28369,48.88277], [8.57757, "
|
49.07206], [8.28369, 48.88277]] }})";
|
||||||
// "48.88277], [8.57757, 49.07206], [8.28369, "
|
doc.Parse(missing_outerring);
|
||||||
// "49.07206], [8.28369, 48.88277]] }}";
|
BOOST_CHECK_THROW(util::validateFeature(doc), util::exception);
|
||||||
// doc.Parse(missing_outerring);
|
|
||||||
// BOOST_CHECK_THROW(util::validateFeature(doc), util::exception);
|
|
||||||
}
|
}
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user