review fixes
This commit is contained in:
parent
41d9aeb5b5
commit
65acbae808
@ -91,7 +91,7 @@ Every response object has a `code` property containing one of the strings below
|
||||
|
||||
#### Data version
|
||||
|
||||
Every response object has a `data_version` propetry containing timestamp from the original OpenStreetMap file. May be `n/a` if original OSM file has not `osmosis_replication_timestamp` section.
|
||||
Every response object has a `data_version` propetry containing timestamp from the original OpenStreetMap file. This field is optional. It can be ommited if data_version parametr was not set on osrm-extract stage or OSM file has not `osmosis_replication_timestamp` section.
|
||||
|
||||
#### Example response
|
||||
|
||||
|
||||
@ -68,7 +68,11 @@ class RouteAPI : public BaseAPI
|
||||
response.values["waypoints"] = BaseAPI::MakeWaypoints(all_start_end_points);
|
||||
response.values["routes"] = std::move(jsRoutes);
|
||||
response.values["code"] = "Ok";
|
||||
response.values["data_version"] = facade.GetTimestamp();
|
||||
auto data_timestamp = facade.GetTimestamp();
|
||||
if (!data_timestamp.empty())
|
||||
{
|
||||
response.values["data_version"] = facade.GetTimestamp();
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
@ -137,7 +137,7 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
||||
extractor::Datasources *m_datasources;
|
||||
|
||||
std::uint32_t m_check_sum;
|
||||
DataTimestamp m_data_timestamp;
|
||||
StringView m_data_timestamp;
|
||||
util::vector_view<util::Coordinate> m_coordinate_list;
|
||||
extractor::PackedOSMIDsView m_osmnodeid_list;
|
||||
util::vector_view<std::uint32_t> m_lane_description_offsets;
|
||||
@ -184,7 +184,7 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
||||
|
||||
m_check_sum = *index.GetBlockPtr<std::uint32_t>("/common/connectivity_checksum");
|
||||
|
||||
m_data_timestamp = *index.GetBlockPtr<DataTimestamp>("/common/timestamp");
|
||||
m_data_timestamp = make_timestamp_view(index, "/common/timestamp");
|
||||
|
||||
std::tie(m_coordinate_list, m_osmnodeid_list) =
|
||||
make_nbn_data_view(index, "/common/nbn_data");
|
||||
@ -437,14 +437,7 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
||||
|
||||
std::string GetTimestamp() const override final
|
||||
{
|
||||
if (!m_data_timestamp)
|
||||
{
|
||||
return "n/a";
|
||||
}
|
||||
time_t ts(m_data_timestamp);
|
||||
char buf[21]; // sizeof "2019-01-01T01:01:01Z\n"];
|
||||
strftime(buf, 21, "%FT%TZ", gmtime(&ts));
|
||||
return std::string(buf, 20);
|
||||
return std::string(m_data_timestamp.begin(), m_data_timestamp.end());
|
||||
}
|
||||
|
||||
GeometryID GetGeometryIndex(const NodeID id) const override final
|
||||
|
||||
@ -83,6 +83,7 @@ struct ExtractorConfig final : storage::IOConfig
|
||||
boost::filesystem::path input_path;
|
||||
boost::filesystem::path profile_path;
|
||||
std::vector<boost::filesystem::path> location_dependent_data_paths;
|
||||
std::string data_version;
|
||||
|
||||
unsigned requested_num_threads;
|
||||
unsigned small_component_size;
|
||||
|
||||
@ -201,18 +201,6 @@ inline void read(tar::FileReader &reader, const std::string &name, std::string &
|
||||
reader.ReadInto(name, const_cast<char *>(data.data()), count);
|
||||
}
|
||||
|
||||
inline void write(tar::FileWriter &writer, const std::string &name, const std::uint64_t &data)
|
||||
{
|
||||
writer.WriteElementCount64(name, data);
|
||||
writer.WriteFrom(name, &data, 1);
|
||||
}
|
||||
|
||||
inline void read(tar::FileReader &reader, const std::string &name, std::uint64_t &data)
|
||||
{
|
||||
data = reader.ReadElementCount64(name);
|
||||
reader.ReadInto(name, &data, 1);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void read(tar::FileReader &reader, const std::string &name, std::vector<T> &data)
|
||||
{
|
||||
|
||||
@ -274,7 +274,7 @@ inline auto make_partition_view(const SharedDataIndex &index, const std::string
|
||||
|
||||
inline auto make_timestamp_view(const SharedDataIndex &index, const std::string &name)
|
||||
{
|
||||
return index.template GetBlockPtr<DataTimestamp>(name);
|
||||
return util::StringView(index.GetBlockPtr<char>(name), index.GetBlockEntries(name));
|
||||
}
|
||||
|
||||
inline auto make_cell_storage_view(const SharedDataIndex &index, const std::string &name)
|
||||
|
||||
@ -79,7 +79,7 @@ using EdgeDistance = float;
|
||||
using SegmentWeight = std::uint32_t;
|
||||
using SegmentDuration = std::uint32_t;
|
||||
using TurnPenalty = std::int16_t; // turn penalty in 100ms units
|
||||
using DataTimestamp = std::uint64_t;
|
||||
using DataTimestamp = std::string;
|
||||
|
||||
static const std::size_t INVALID_INDEX = std::numeric_limits<std::size_t>::max();
|
||||
|
||||
|
||||
@ -426,17 +426,19 @@ Extractor::ParseOSMData(ScriptingEnvironment &scripting_environment,
|
||||
|
||||
// write .timestamp data file
|
||||
std::string timestamp = header.get("osmosis_replication_timestamp");
|
||||
osmium::Timestamp ts;
|
||||
if (config.data_version == "osmosis")
|
||||
{
|
||||
files::writeTimestamp(config.GetPath(".osrm.timestamp").string(), timestamp);
|
||||
}
|
||||
else
|
||||
{
|
||||
files::writeTimestamp(config.GetPath(".osrm.timestamp").string(), config.data_version);
|
||||
}
|
||||
if (timestamp.empty())
|
||||
{
|
||||
timestamp = "n/a";
|
||||
}
|
||||
else
|
||||
{
|
||||
ts = osmium::Timestamp(timestamp);
|
||||
}
|
||||
util::Log() << "timestamp: " << timestamp;
|
||||
files::writeTimestamp(config.GetPath(".osrm.timestamp").string(), DataTimestamp(ts));
|
||||
}
|
||||
|
||||
// Extraction containers and restriction parser
|
||||
|
||||
@ -404,8 +404,12 @@ void Storage::PopulateStaticData(const SharedDataIndex &index)
|
||||
|
||||
// Timestamp mark
|
||||
{
|
||||
auto timestamp = make_timestamp_view(index, "/common/timestamp");
|
||||
extractor::files::readTimestamp(config.GetPath(".osrm.timestamp"), *timestamp);
|
||||
auto timestamp_ref = make_timestamp_view(index, "/common/timestamp");
|
||||
std::string ts;
|
||||
extractor::files::readTimestamp(config.GetPath(".osrm.timestamp"), ts);
|
||||
if (!ts.empty()) {
|
||||
memcpy(const_cast<char *>(timestamp_ref.data()), ts.data(), ts.size());
|
||||
}
|
||||
}
|
||||
|
||||
// Turn lane data
|
||||
|
||||
@ -43,6 +43,10 @@ return_code parseArguments(int argc,
|
||||
boost::program_options::value<boost::filesystem::path>(&extractor_config.profile_path)
|
||||
->default_value("profiles/car.lua"),
|
||||
"Path to LUA routing profile")(
|
||||
"data_version,d",
|
||||
boost::program_options::value<std::string>(&extractor_config.data_version)
|
||||
->default_value(""),
|
||||
"Data version. Leave blank to avoid. osmosis - to get timestamp from file")(
|
||||
"threads,t",
|
||||
boost::program_options::value<unsigned int>(&extractor_config.requested_num_threads)
|
||||
->default_value(tbb::task_scheduler_init::default_num_threads()),
|
||||
|
||||
@ -341,7 +341,7 @@ class ContiguousInternalMemoryDataFacade<routing_algorithms::offline::Algorithm>
|
||||
StringView GetDestinationsForID(const NameID /*id*/) const override { return StringView{}; }
|
||||
StringView GetExitsForID(const NameID /*id*/) const override { return StringView{}; }
|
||||
bool GetContinueStraightDefault() const override { return false; }
|
||||
std::string GetTimestamp() const override { return "n/a"; }
|
||||
std::string GetTimestamp() const override { return ""; }
|
||||
double GetMapMatchingMaxSpeed() const override { return 0; }
|
||||
const char *GetWeightName() const override { return ""; }
|
||||
unsigned GetWeightPrecision() const override { return 0; }
|
||||
|
||||
@ -47,7 +47,6 @@ BOOST_AUTO_TEST_CASE(test_route_same_coordinates_fixture)
|
||||
|
||||
json::Object reference{
|
||||
{{"code", "Ok"},
|
||||
{"data_version", "2016-03-05T00:26:02Z"},
|
||||
{"waypoints",
|
||||
json::Array{{json::Object{{{"name", "Boulevard du Larvotto"},
|
||||
{"location", location},
|
||||
|
||||
@ -53,7 +53,7 @@ class MockBaseDataFacade : public engine::datafacade::BaseDataFacade
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
std::string GetTimestamp() const override { return "n/a"; }
|
||||
std::string GetTimestamp() const override { return ""; }
|
||||
NodeForwardRange GetUncompressedForwardGeometry(const EdgeID /* id */) const override
|
||||
{
|
||||
static NodeID data[] = {0, 1, 2, 3};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user