Introduce osm_nodes annotations for 64-bit OSM Node Ids
This commit is contained in:
parent
bfb74c2dad
commit
466ed10ef8
@ -10,6 +10,8 @@ table Annotation {
|
|||||||
duration: [uint];
|
duration: [uint];
|
||||||
datasources: [uint];
|
datasources: [uint];
|
||||||
nodes: [uint];
|
nodes: [uint];
|
||||||
|
osm_nodes: [ulong];
|
||||||
|
|
||||||
weight: [uint];
|
weight: [uint];
|
||||||
speed: [float];
|
speed: [float];
|
||||||
metadata: Metadata;
|
metadata: Metadata;
|
||||||
|
|||||||
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include "engine/api/json_factory.hpp"
|
#include "engine/api/json_factory.hpp"
|
||||||
#include "engine/phantom_node.hpp"
|
#include "engine/phantom_node.hpp"
|
||||||
|
#include "util/json_container.hpp"
|
||||||
|
|
||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
|
|
||||||
@ -110,6 +111,11 @@ class NearestAPI final : public BaseAPI
|
|||||||
nodes.values.push_back(node_values.second);
|
nodes.values.push_back(node_values.second);
|
||||||
waypoint.values["nodes"] = std::move(nodes);
|
waypoint.values["nodes"] = std::move(nodes);
|
||||||
|
|
||||||
|
util::json::Array osm_nodes;
|
||||||
|
osm_nodes.values.emplace_back(std::to_string(node_values.first));
|
||||||
|
osm_nodes.values.emplace_back(std::to_string(node_values.second));
|
||||||
|
waypoint.values["osm_nodes"] = std::move(osm_nodes);
|
||||||
|
|
||||||
return waypoint;
|
return waypoint;
|
||||||
});
|
});
|
||||||
response.values["waypoints"] = std::move(waypoints);
|
response.values["waypoints"] = std::move(waypoints);
|
||||||
|
|||||||
@ -28,6 +28,7 @@
|
|||||||
#include "util/json_util.hpp"
|
#include "util/json_util.hpp"
|
||||||
|
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace osrm
|
namespace osrm
|
||||||
@ -822,14 +823,43 @@ class RouteAPI : public BaseAPI
|
|||||||
return anno.datasource;
|
return anno.datasource;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (requested_annotations & RouteParameters::AnnotationsType::Nodes)
|
if (requested_annotations & RouteParameters::AnnotationsType::Nodes ||
|
||||||
|
requested_annotations & RouteParameters::AnnotationsType::OSMNodes)
|
||||||
|
{
|
||||||
|
util::json::Array nodes;
|
||||||
|
util::json::Array osm_nodes;
|
||||||
|
|
||||||
|
nodes.values.reserve(leg_geometry.node_ids.size());
|
||||||
|
for (const auto node_id : leg_geometry.node_ids)
|
||||||
|
{
|
||||||
|
const auto osm_node_id =
|
||||||
|
static_cast<std::uint64_t>(facade.GetOSMNodeIDOfNode(node_id));
|
||||||
|
if (requested_annotations & RouteParameters::AnnotationsType::Nodes)
|
||||||
|
{
|
||||||
|
nodes.values.emplace_back(osm_node_id);
|
||||||
|
}
|
||||||
|
if (requested_annotations & RouteParameters::AnnotationsType::OSMNodes)
|
||||||
|
{
|
||||||
|
osm_nodes.values.emplace_back(osm_node_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (requested_annotations & RouteParameters::AnnotationsType::Nodes)
|
||||||
|
{
|
||||||
|
annotation.values["nodes"] = nodes;
|
||||||
|
}
|
||||||
|
if (requested_annotations & RouteParameters::AnnotationsType::OSMNodes)
|
||||||
|
{
|
||||||
|
annotation.values["osmnodes"] = osm_nodes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (requested_annotations & RouteParameters::AnnotationsType::OSMNodes)
|
||||||
{
|
{
|
||||||
util::json::Array nodes;
|
util::json::Array nodes;
|
||||||
nodes.values.reserve(leg_geometry.node_ids.size());
|
nodes.values.reserve(leg_geometry.node_ids.size());
|
||||||
for (const auto node_id : leg_geometry.node_ids)
|
for (const auto node_id : leg_geometry.node_ids)
|
||||||
{
|
{
|
||||||
nodes.values.push_back(
|
nodes.values.push_back(std::to_string(
|
||||||
static_cast<std::uint64_t>(facade.GetOSMNodeIDOfNode(node_id)));
|
static_cast<std::uint64_t>(facade.GetOSMNodeIDOfNode(node_id))));
|
||||||
}
|
}
|
||||||
annotation.values["nodes"] = std::move(nodes);
|
annotation.values["nodes"] = std::move(nodes);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -70,13 +70,14 @@ struct RouteParameters : public BaseParameters
|
|||||||
enum class AnnotationsType
|
enum class AnnotationsType
|
||||||
{
|
{
|
||||||
None = 0,
|
None = 0,
|
||||||
Duration = 0x01,
|
Duration = 1 << 1,
|
||||||
Nodes = 0x02,
|
Nodes = 1 << 2,
|
||||||
Distance = 0x04,
|
Distance = 1 << 3,
|
||||||
Weight = 0x08,
|
Weight = 1 << 4,
|
||||||
Datasources = 0x10,
|
Datasources = 1 << 5,
|
||||||
Speed = 0x20,
|
Speed = 1 << 6,
|
||||||
All = Duration | Nodes | Distance | Weight | Datasources | Speed
|
OSMNodes = 1 << 7,
|
||||||
|
All = Duration | Nodes | Distance | Weight | Datasources | Speed | OSMNodes
|
||||||
};
|
};
|
||||||
|
|
||||||
RouteParameters() = default;
|
RouteParameters() = default;
|
||||||
|
|||||||
@ -778,6 +778,11 @@ inline bool parseCommonParameters(const v8::Local<v8::Object> &obj, ParamType &p
|
|||||||
params->annotations_type =
|
params->annotations_type =
|
||||||
params->annotations_type | osrm::RouteParameters::AnnotationsType::Nodes;
|
params->annotations_type | osrm::RouteParameters::AnnotationsType::Nodes;
|
||||||
}
|
}
|
||||||
|
else if (annotations_str == "osm_nodes")
|
||||||
|
{
|
||||||
|
params->annotations_type =
|
||||||
|
params->annotations_type | osrm::RouteParameters::AnnotationsType::OSMNodes;
|
||||||
|
}
|
||||||
else if (annotations_str == "distance")
|
else if (annotations_str == "distance")
|
||||||
{
|
{
|
||||||
params->annotations_type =
|
params->annotations_type =
|
||||||
|
|||||||
@ -73,8 +73,8 @@ struct RouteParametersGrammar : public BaseParametersGrammar<Iterator, Signature
|
|||||||
"full", engine::api::RouteParameters::OverviewType::Full)(
|
"full", engine::api::RouteParameters::OverviewType::Full)(
|
||||||
"false", engine::api::RouteParameters::OverviewType::False);
|
"false", engine::api::RouteParameters::OverviewType::False);
|
||||||
|
|
||||||
annotations_type.add("duration", AnnotationsType::Duration)("nodes",
|
annotations_type.add("duration", AnnotationsType::Duration)(
|
||||||
AnnotationsType::Nodes)(
|
"nodes", AnnotationsType::Nodes)("osm_nodes", AnnotationsType::OSMNodes)(
|
||||||
"distance", AnnotationsType::Distance)("weight", AnnotationsType::Weight)(
|
"distance", AnnotationsType::Distance)("weight", AnnotationsType::Weight)(
|
||||||
"datasources", AnnotationsType::Datasources)("speed", AnnotationsType::Speed);
|
"datasources", AnnotationsType::Datasources)("speed", AnnotationsType::Speed);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user