remove shapefile dependency from build

This commit is contained in:
karenzshea
2017-05-29 12:57:33 +02:00
parent 6f41e3faf1
commit f268163ea0
5 changed files with 19 additions and 58 deletions
+5 -12
View File
@@ -68,18 +68,11 @@ return_code parseArguments(int argc, char *argv[], contractor::ContractorConfig
->default_value(0),
"Optional for conditional turn restriction parsing, provide a UTC time stamp from "
"which "
"to evaluate the validity of conditional turn restrictions");
if (updater::SupportsShapefiles())
{
config_options.add_options()("time-zone-file",
boost::program_options::value<std::string>(
&contractor_config.updater_config.tz_file_path)
->default_value(""),
"Required for conditional turn restriction parsing, provide a "
"shp or dbf file containing "
"time zone boundaries");
}
"to evaluate the validity of conditional turn restrictions")(
"time-zone-file",
boost::program_options::value<std::string>(&contractor_config.updater_config.tz_file_path),
"Required for conditional turn restriction parsing, provide a geojson file containing "
"time zone boundaries");
// hidden options, will be allowed on command line, but will not be shown to the user
boost::program_options::options_description hidden_options("Hidden options");
+7 -12
View File
@@ -59,18 +59,13 @@ parseArguments(int argc, char *argv[], customizer::CustomizationConfig &customiz
->default_value(0),
"Optional for conditional turn restriction parsing, provide a UTC time stamp from "
"which "
"to evaluate the validity of conditional turn restrictions");
if (updater::SupportsShapefiles())
{
config_options.add_options()("time-zone-file",
boost::program_options::value<std::string>(
&customization_config.updater_config.tz_file_path)
->default_value(""),
"Required for conditional turn restriction parsing, provide a "
"shp or dbf file containing "
"time zone boundaries");
}
"to evaluate the validity of conditional turn restrictions")(
"time-zone-file",
boost::program_options::value<std::string>(
&customization_config.updater_config.tz_file_path)
->default_value(""),
"Required for conditional turn restriction parsing, provide a geojson file containing "
"time zone boundaries");
// hidden options, will be allowed on command line, but will not be
// shown to the user
+3 -11
View File
@@ -19,15 +19,6 @@ namespace osrm
namespace updater
{
bool SupportsShapefiles()
{
#ifdef ENABLE_SHAPEFILE
return true;
#else
return false;
#endif
}
Timezoner::Timezoner(std::string tz_filename, std::time_t utc_time_now)
{
util::Log() << "Time zone validation based on UTC time : " << utc_time_now;
@@ -89,11 +80,12 @@ void Timezoner::ValidateFeature(const rapidjson::Value &feature, const std::stri
void Timezoner::LoadLocalTimesRTree(const std::string &tz_shapes_filename, std::time_t utc_time)
{
if (tz_shapes_filename.empty())
return;
throw osrm::util::exception("Missing time zone geojson file");
std::ifstream file(tz_shapes_filename.data());
if (!file.is_open())
throw osrm::util::exception("failed to open " + tz_shapes_filename);
util::Log() << "Parsing " + tz_shapes_filename;
rapidjson::IStreamWrapper isw(file);
rapidjson::Document geojson;
geojson.ParseStream(isw);
@@ -137,7 +129,7 @@ void Timezoner::LoadLocalTimesRTree(const std::string &tz_shapes_filename, std::
if (feat_type == "polygon")
{
polygon_t polygon;
// per geojson spec, the first array of polygon coords is the exterior ring
// per geojson spec, the first array of polygon coords is the exterior ring, we only want to access that
auto coords_outer_array = features_array[i]
.GetObject()["geometry"]
.GetObject()["coordinates"]