Data timestamp version in response
This commit is contained in:
parent
381d492a8f
commit
41d9aeb5b5
@ -2,6 +2,7 @@
|
|||||||
- Changes from 5.21.0
|
- Changes from 5.21.0
|
||||||
- Features:
|
- Features:
|
||||||
- ADDED: new waypoints parameter to the `route` plugin, enabling silent waypoints [#5345](https://github.com/Project-OSRM/osrm-backend/pull/5345)
|
- ADDED: new waypoints parameter to the `route` plugin, enabling silent waypoints [#5345](https://github.com/Project-OSRM/osrm-backend/pull/5345)
|
||||||
|
- ADDED: data timestamp information in the response. [#5115](https://github.com/Project-OSRM/osrm-backend/issues/5115)
|
||||||
|
|
||||||
# 5.21.0
|
# 5.21.0
|
||||||
- Changes from 5.20.0
|
- Changes from 5.20.0
|
||||||
|
|||||||
@ -70,6 +70,8 @@ curl 'http://router.project-osrm.org/route/v1/driving/polyline(ofp_Ik_vpAilAyu@t
|
|||||||
|
|
||||||
### Responses
|
### Responses
|
||||||
|
|
||||||
|
#### Code
|
||||||
|
|
||||||
Every response object has a `code` property containing one of the strings below or a service dependent code:
|
Every response object has a `code` property containing one of the strings below or a service dependent code:
|
||||||
|
|
||||||
| Type | Description |
|
| Type | Description |
|
||||||
@ -87,12 +89,17 @@ Every response object has a `code` property containing one of the strings below
|
|||||||
- `message` is a **optional** human-readable error message. All other status types are service dependent.
|
- `message` is a **optional** human-readable error message. All other status types are service dependent.
|
||||||
- In case of an error the HTTP status code will be `400`. Otherwise the HTTP status code will be `200` and `code` will be `Ok`.
|
- In case of an error the HTTP status code will be `400`. Otherwise the HTTP status code will be `200` and `code` will be `Ok`.
|
||||||
|
|
||||||
|
#### 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.
|
||||||
|
|
||||||
#### Example response
|
#### Example response
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"code": "Ok",
|
"code": "Ok",
|
||||||
"message": "Everything worked"
|
"message": "Everything worked",
|
||||||
|
"data_version": "2017-11-17T21:43:02Z"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@ -68,6 +68,7 @@ class RouteAPI : public BaseAPI
|
|||||||
response.values["waypoints"] = BaseAPI::MakeWaypoints(all_start_end_points);
|
response.values["waypoints"] = BaseAPI::MakeWaypoints(all_start_end_points);
|
||||||
response.values["routes"] = std::move(jsRoutes);
|
response.values["routes"] = std::move(jsRoutes);
|
||||||
response.values["code"] = "Ok";
|
response.values["code"] = "Ok";
|
||||||
|
response.values["data_version"] = facade.GetTimestamp();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@ -137,6 +137,7 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
|||||||
extractor::Datasources *m_datasources;
|
extractor::Datasources *m_datasources;
|
||||||
|
|
||||||
std::uint32_t m_check_sum;
|
std::uint32_t m_check_sum;
|
||||||
|
DataTimestamp m_data_timestamp;
|
||||||
util::vector_view<util::Coordinate> m_coordinate_list;
|
util::vector_view<util::Coordinate> m_coordinate_list;
|
||||||
extractor::PackedOSMIDsView m_osmnodeid_list;
|
extractor::PackedOSMIDsView m_osmnodeid_list;
|
||||||
util::vector_view<std::uint32_t> m_lane_description_offsets;
|
util::vector_view<std::uint32_t> m_lane_description_offsets;
|
||||||
@ -183,6 +184,8 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
|||||||
|
|
||||||
m_check_sum = *index.GetBlockPtr<std::uint32_t>("/common/connectivity_checksum");
|
m_check_sum = *index.GetBlockPtr<std::uint32_t>("/common/connectivity_checksum");
|
||||||
|
|
||||||
|
m_data_timestamp = *index.GetBlockPtr<DataTimestamp>("/common/timestamp");
|
||||||
|
|
||||||
std::tie(m_coordinate_list, m_osmnodeid_list) =
|
std::tie(m_coordinate_list, m_osmnodeid_list) =
|
||||||
make_nbn_data_view(index, "/common/nbn_data");
|
make_nbn_data_view(index, "/common/nbn_data");
|
||||||
|
|
||||||
@ -432,6 +435,18 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
|||||||
|
|
||||||
std::uint32_t GetCheckSum() const override final { return m_check_sum; }
|
std::uint32_t GetCheckSum() const override final { return m_check_sum; }
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
GeometryID GetGeometryIndex(const NodeID id) const override final
|
GeometryID GetGeometryIndex(const NodeID id) const override final
|
||||||
{
|
{
|
||||||
return edge_based_node_data.GetGeometryID(id);
|
return edge_based_node_data.GetGeometryID(id);
|
||||||
|
|||||||
@ -74,6 +74,8 @@ class BaseDataFacade
|
|||||||
|
|
||||||
virtual std::uint32_t GetCheckSum() const = 0;
|
virtual std::uint32_t GetCheckSum() const = 0;
|
||||||
|
|
||||||
|
virtual std::string GetTimestamp() const = 0;
|
||||||
|
|
||||||
// node and edge information access
|
// node and edge information access
|
||||||
virtual util::Coordinate GetCoordinateOfNode(const NodeID id) const = 0;
|
virtual util::Coordinate GetCoordinateOfNode(const NodeID id) const = 0;
|
||||||
|
|
||||||
|
|||||||
@ -55,6 +55,7 @@ struct ExtractorConfig final : storage::IOConfig
|
|||||||
".osrm.geometry",
|
".osrm.geometry",
|
||||||
".osrm.nbg_nodes",
|
".osrm.nbg_nodes",
|
||||||
".osrm.ebg_nodes",
|
".osrm.ebg_nodes",
|
||||||
|
".osrm.timestamp",
|
||||||
".osrm.edges",
|
".osrm.edges",
|
||||||
".osrm.ebg",
|
".osrm.ebg",
|
||||||
".osrm.ramIndex",
|
".osrm.ramIndex",
|
||||||
|
|||||||
@ -308,6 +308,26 @@ inline void writeTurnLaneData(const boost::filesystem::path &path,
|
|||||||
storage::serialization::write(writer, "/common/turn_lanes/data", turn_lane_data);
|
storage::serialization::write(writer, "/common/turn_lanes/data", turn_lane_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// reads .osrm.timestamp
|
||||||
|
template <typename TimestampDataT>
|
||||||
|
inline void readTimestamp(const boost::filesystem::path &path, TimestampDataT ×tamp)
|
||||||
|
{
|
||||||
|
const auto fingerprint = storage::tar::FileReader::VerifyFingerprint;
|
||||||
|
storage::tar::FileReader reader{path, fingerprint};
|
||||||
|
|
||||||
|
storage::serialization::read(reader, "/common/timestamp", timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
// writes .osrm.timestamp
|
||||||
|
template <typename TimestampDataT>
|
||||||
|
inline void writeTimestamp(const boost::filesystem::path &path, const TimestampDataT ×tamp)
|
||||||
|
{
|
||||||
|
const auto fingerprint = storage::tar::FileWriter::GenerateFingerprint;
|
||||||
|
storage::tar::FileWriter writer{path, fingerprint};
|
||||||
|
|
||||||
|
storage::serialization::write(writer, "/common/timestamp", timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
// reads .osrm.maneuver_overrides
|
// reads .osrm.maneuver_overrides
|
||||||
template <typename StorageManeuverOverrideT, typename NodeSequencesT>
|
template <typename StorageManeuverOverrideT, typename NodeSequencesT>
|
||||||
inline void readManeuverOverrides(const boost::filesystem::path &path,
|
inline void readManeuverOverrides(const boost::filesystem::path &path,
|
||||||
|
|||||||
@ -201,6 +201,18 @@ inline void read(tar::FileReader &reader, const std::string &name, std::string &
|
|||||||
reader.ReadInto(name, const_cast<char *>(data.data()), count);
|
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>
|
template <typename T>
|
||||||
inline void read(tar::FileReader &reader, const std::string &name, std::vector<T> &data)
|
inline void read(tar::FileReader &reader, const std::string &name, std::vector<T> &data)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -58,6 +58,7 @@ struct StorageConfig final : IOConfig
|
|||||||
".osrm.turn_duration_penalties",
|
".osrm.turn_duration_penalties",
|
||||||
".osrm.datasource_names",
|
".osrm.datasource_names",
|
||||||
".osrm.names",
|
".osrm.names",
|
||||||
|
".osrm.timestamp",
|
||||||
".osrm.properties",
|
".osrm.properties",
|
||||||
".osrm.icd",
|
".osrm.icd",
|
||||||
".osrm.maneuver_overrides"},
|
".osrm.maneuver_overrides"},
|
||||||
|
|||||||
@ -272,6 +272,11 @@ inline auto make_partition_view(const SharedDataIndex &index, const std::string
|
|||||||
level_data_ptr, std::move(partition), std::move(cell_to_children)};
|
level_data_ptr, std::move(partition), std::move(cell_to_children)};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline auto make_timestamp_view(const SharedDataIndex &index, const std::string &name)
|
||||||
|
{
|
||||||
|
return index.template GetBlockPtr<DataTimestamp>(name);
|
||||||
|
}
|
||||||
|
|
||||||
inline auto make_cell_storage_view(const SharedDataIndex &index, const std::string &name)
|
inline auto make_cell_storage_view(const SharedDataIndex &index, const std::string &name)
|
||||||
{
|
{
|
||||||
auto source_boundary = make_vector_view<NodeID>(index, name + "/source_boundary");
|
auto source_boundary = make_vector_view<NodeID>(index, name + "/source_boundary");
|
||||||
|
|||||||
@ -79,6 +79,7 @@ using EdgeDistance = float;
|
|||||||
using SegmentWeight = std::uint32_t;
|
using SegmentWeight = std::uint32_t;
|
||||||
using SegmentDuration = std::uint32_t;
|
using SegmentDuration = std::uint32_t;
|
||||||
using TurnPenalty = std::int16_t; // turn penalty in 100ms units
|
using TurnPenalty = std::int16_t; // turn penalty in 100ms units
|
||||||
|
using DataTimestamp = std::uint64_t;
|
||||||
|
|
||||||
static const std::size_t INVALID_INDEX = std::numeric_limits<std::size_t>::max();
|
static const std::size_t INVALID_INDEX = std::numeric_limits<std::size_t>::max();
|
||||||
|
|
||||||
|
|||||||
@ -51,6 +51,7 @@
|
|||||||
#include <osmium/handler/node_locations_for_ways.hpp>
|
#include <osmium/handler/node_locations_for_ways.hpp>
|
||||||
#include <osmium/index/map/flex_mem.hpp>
|
#include <osmium/index/map/flex_mem.hpp>
|
||||||
#include <osmium/io/any_input.hpp>
|
#include <osmium/io/any_input.hpp>
|
||||||
|
#include <osmium/osm/timestamp.hpp>
|
||||||
#include <osmium/thread/pool.hpp>
|
#include <osmium/thread/pool.hpp>
|
||||||
#include <osmium/visitor.hpp>
|
#include <osmium/visitor.hpp>
|
||||||
|
|
||||||
@ -425,11 +426,17 @@ Extractor::ParseOSMData(ScriptingEnvironment &scripting_environment,
|
|||||||
|
|
||||||
// write .timestamp data file
|
// write .timestamp data file
|
||||||
std::string timestamp = header.get("osmosis_replication_timestamp");
|
std::string timestamp = header.get("osmosis_replication_timestamp");
|
||||||
|
osmium::Timestamp ts;
|
||||||
if (timestamp.empty())
|
if (timestamp.empty())
|
||||||
{
|
{
|
||||||
timestamp = "n/a";
|
timestamp = "n/a";
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ts = osmium::Timestamp(timestamp);
|
||||||
|
}
|
||||||
util::Log() << "timestamp: " << timestamp;
|
util::Log() << "timestamp: " << timestamp;
|
||||||
|
files::writeTimestamp(config.GetPath(".osrm.timestamp").string(), DataTimestamp(ts));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extraction containers and restriction parser
|
// Extraction containers and restriction parser
|
||||||
|
|||||||
@ -302,6 +302,7 @@ std::vector<std::pair<bool, boost::filesystem::path>> Storage::GetStaticFiles()
|
|||||||
{REQUIRED, config.GetPath(".osrm.ebg_nodes")},
|
{REQUIRED, config.GetPath(".osrm.ebg_nodes")},
|
||||||
{REQUIRED, config.GetPath(".osrm.tls")},
|
{REQUIRED, config.GetPath(".osrm.tls")},
|
||||||
{REQUIRED, config.GetPath(".osrm.tld")},
|
{REQUIRED, config.GetPath(".osrm.tld")},
|
||||||
|
{REQUIRED, config.GetPath(".osrm.timestamp")},
|
||||||
{REQUIRED, config.GetPath(".osrm.maneuver_overrides")},
|
{REQUIRED, config.GetPath(".osrm.maneuver_overrides")},
|
||||||
{REQUIRED, config.GetPath(".osrm.edges")},
|
{REQUIRED, config.GetPath(".osrm.edges")},
|
||||||
{REQUIRED, config.GetPath(".osrm.names")},
|
{REQUIRED, config.GetPath(".osrm.names")},
|
||||||
@ -401,6 +402,12 @@ void Storage::PopulateStaticData(const SharedDataIndex &index)
|
|||||||
extractor::files::readNames(config.GetPath(".osrm.names"), name_table);
|
extractor::files::readNames(config.GetPath(".osrm.names"), name_table);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Timestamp mark
|
||||||
|
{
|
||||||
|
auto timestamp = make_timestamp_view(index, "/common/timestamp");
|
||||||
|
extractor::files::readTimestamp(config.GetPath(".osrm.timestamp"), *timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
// Turn lane data
|
// Turn lane data
|
||||||
{
|
{
|
||||||
auto turn_lane_data = make_lane_data_view(index, "/common/turn_lanes");
|
auto turn_lane_data = make_lane_data_view(index, "/common/turn_lanes");
|
||||||
|
|||||||
@ -341,6 +341,7 @@ class ContiguousInternalMemoryDataFacade<routing_algorithms::offline::Algorithm>
|
|||||||
StringView GetDestinationsForID(const NameID /*id*/) const override { return StringView{}; }
|
StringView GetDestinationsForID(const NameID /*id*/) const override { return StringView{}; }
|
||||||
StringView GetExitsForID(const NameID /*id*/) const override { return StringView{}; }
|
StringView GetExitsForID(const NameID /*id*/) const override { return StringView{}; }
|
||||||
bool GetContinueStraightDefault() const override { return false; }
|
bool GetContinueStraightDefault() const override { return false; }
|
||||||
|
std::string GetTimestamp() const override { return "n/a"; }
|
||||||
double GetMapMatchingMaxSpeed() const override { return 0; }
|
double GetMapMatchingMaxSpeed() const override { return 0; }
|
||||||
const char *GetWeightName() const override { return ""; }
|
const char *GetWeightName() const override { return ""; }
|
||||||
unsigned GetWeightPrecision() const override { return 0; }
|
unsigned GetWeightPrecision() const override { return 0; }
|
||||||
|
|||||||
@ -47,6 +47,7 @@ BOOST_AUTO_TEST_CASE(test_route_same_coordinates_fixture)
|
|||||||
|
|
||||||
json::Object reference{
|
json::Object reference{
|
||||||
{{"code", "Ok"},
|
{{"code", "Ok"},
|
||||||
|
{"data_version", "2016-03-05T00:26:02Z"},
|
||||||
{"waypoints",
|
{"waypoints",
|
||||||
json::Array{{json::Object{{{"name", "Boulevard du Larvotto"},
|
json::Array{{json::Object{{{"name", "Boulevard du Larvotto"},
|
||||||
{"location", location},
|
{"location", location},
|
||||||
|
|||||||
@ -10,7 +10,6 @@
|
|||||||
#include "extractor/turn_lane_types.hpp"
|
#include "extractor/turn_lane_types.hpp"
|
||||||
#include "guidance/turn_bearing.hpp"
|
#include "guidance/turn_bearing.hpp"
|
||||||
#include "guidance/turn_instruction.hpp"
|
#include "guidance/turn_instruction.hpp"
|
||||||
#include "guidance/turn_instruction.hpp"
|
|
||||||
|
|
||||||
#include "engine/algorithm.hpp"
|
#include "engine/algorithm.hpp"
|
||||||
#include "engine/datafacade/algorithm_datafacade.hpp"
|
#include "engine/datafacade/algorithm_datafacade.hpp"
|
||||||
@ -54,6 +53,7 @@ class MockBaseDataFacade : public engine::datafacade::BaseDataFacade
|
|||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
std::string GetTimestamp() const override { return "n/a"; }
|
||||||
NodeForwardRange GetUncompressedForwardGeometry(const EdgeID /* id */) const override
|
NodeForwardRange GetUncompressedForwardGeometry(const EdgeID /* id */) const override
|
||||||
{
|
{
|
||||||
static NodeID data[] = {0, 1, 2, 3};
|
static NodeID data[] = {0, 1, 2, 3};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user