Merge branch 'master' into 5.20
This commit is contained in:
commit
ab22cc7516
@ -2,6 +2,7 @@
|
|||||||
- Changes from 5.20.0
|
- Changes from 5.20.0
|
||||||
- Features:
|
- Features:
|
||||||
- ADDED: all waypoints in responses now contain a distance property between the original coordinate and the snapped location. [#5255](https://github.com/Project-OSRM/osrm-backend/pull/5255)
|
- ADDED: all waypoints in responses now contain a distance property between the original coordinate and the snapped location. [#5255](https://github.com/Project-OSRM/osrm-backend/pull/5255)
|
||||||
|
|
||||||
# 5.20.0
|
# 5.20.0
|
||||||
- Changes from 5.19.0:
|
- Changes from 5.19.0:
|
||||||
- Table:
|
- Table:
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
FROM alpine:3.6 as buildstage
|
FROM debian:buster-slim as builder
|
||||||
|
|
||||||
ARG DOCKER_TAG
|
ARG DOCKER_TAG
|
||||||
RUN mkdir -p /src && mkdir -p /opt
|
RUN mkdir -p /src && mkdir -p /opt
|
||||||
COPY . /src
|
COPY . /src
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
|
|
||||||
RUN NPROC=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) && \
|
RUN NPROC=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) && \
|
||||||
echo "@testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories && \
|
apt-get update && \
|
||||||
apk update && \
|
apt-get -y --no-install-recommends install cmake make git gcc g++ libbz2-dev libstxxl-dev libstxxl1v5 libxml2-dev \
|
||||||
apk upgrade && \
|
libzip-dev libboost-all-dev lua5.2 liblua5.2-dev libtbb-dev -o APT::Install-Suggests=0 -o APT::Install-Recommends=0 && \
|
||||||
apk add git cmake wget make libc-dev gcc g++ bzip2-dev boost-dev zlib-dev expat-dev lua5.2-dev libtbb@testing libtbb-dev@testing && \
|
|
||||||
NPROC=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) && \
|
NPROC=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) && \
|
||||||
echo "Building OSRM ${DOCKER_TAG}" && \
|
echo "Building OSRM ${DOCKER_TAG}" && \
|
||||||
git show --format="%H" | head -n1 > /opt/OSRM_GITSHA && \
|
git show --format="%H" | head -n1 > /opt/OSRM_GITSHA && \
|
||||||
@ -33,13 +31,16 @@ RUN NPROC=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) && \
|
|||||||
|
|
||||||
# Multistage build to reduce image size - https://docs.docker.com/engine/userguide/eng-image/multistage-build/#use-multi-stage-builds
|
# Multistage build to reduce image size - https://docs.docker.com/engine/userguide/eng-image/multistage-build/#use-multi-stage-builds
|
||||||
# Only the content below ends up in the image, this helps remove /src from the image (which is large)
|
# Only the content below ends up in the image, this helps remove /src from the image (which is large)
|
||||||
FROM alpine:3.6 as runstage
|
FROM debian:buster-slim as runstage
|
||||||
RUN mkdir -p /src && mkdir -p /opt
|
RUN mkdir -p /src && mkdir -p /opt
|
||||||
RUN echo "@testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories && \
|
RUN apt-get update && \
|
||||||
apk update && \
|
apt-get install -y --no-install-recommends libboost-program-options1.62.0 libboost-regex1.62.0 \
|
||||||
apk add boost-filesystem boost-program_options boost-regex boost-iostreams boost-thread libgomp lua5.2 expat libtbb@testing
|
libboost-date-time1.62.0 libboost-chrono1.62.0 libboost-filesystem1.62.0 \
|
||||||
COPY --from=buildstage /usr/local /usr/local
|
libboost-iostreams1.62.0 libboost-thread1.62.0 expat liblua5.2-0 libtbb2 &&\
|
||||||
COPY --from=buildstage /opt /opt
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
COPY --from=builder /usr/local /usr/local
|
||||||
|
COPY --from=builder /opt /opt
|
||||||
|
RUN chmod 0644 -R /opt
|
||||||
WORKDIR /opt
|
WORKDIR /opt
|
||||||
|
|
||||||
EXPOSE 5000
|
EXPOSE 5000
|
||||||
|
@ -119,7 +119,6 @@ In addition to the [general options](#general-options) the following options are
|
|||||||
|
|
||||||
- `code` if the request was successful `Ok` otherwise see the service dependent and general status codes.
|
- `code` if the request was successful `Ok` otherwise see the service dependent and general status codes.
|
||||||
- `waypoints` array of `Waypoint` objects sorted by distance to the input coordinate. Each object has at least the following additional properties:
|
- `waypoints` array of `Waypoint` objects sorted by distance to the input coordinate. Each object has at least the following additional properties:
|
||||||
- `distance`: Distance in meters to the supplied input coordinate.
|
|
||||||
- `nodes`: Array of OpenStreetMap node ids.
|
- `nodes`: Array of OpenStreetMap node ids.
|
||||||
|
|
||||||
#### Example Requests
|
#### Example Requests
|
||||||
@ -906,6 +905,7 @@ Object used to describe waypoint on a route.
|
|||||||
|
|
||||||
- `name` Name of the street the coordinate snapped to
|
- `name` Name of the street the coordinate snapped to
|
||||||
- `location` Array that contains the `[longitude, latitude]` pair of the snapped coordinate
|
- `location` Array that contains the `[longitude, latitude]` pair of the snapped coordinate
|
||||||
|
- `distance` The distance, in metres, from the input coordinate to the snapped coordinate
|
||||||
- `hint` Unique internal identifier of the segment (ephemeral, not constant over data updates)
|
- `hint` Unique internal identifier of the segment (ephemeral, not constant over data updates)
|
||||||
This can be used on subsequent request to significantly speed up the query and to connect multiple services.
|
This can be used on subsequent request to significantly speed up the query and to connect multiple services.
|
||||||
E.g. you can use the `hint` value obtained by the `nearest` query as `hint` values for `route` inputs.
|
E.g. you can use the `hint` value obtained by the `nearest` query as `hint` values for `route` inputs.
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include "engine/api/json_factory.hpp"
|
#include "engine/api/json_factory.hpp"
|
||||||
#include "engine/hint.hpp"
|
#include "engine/hint.hpp"
|
||||||
|
#include "util/coordinate_calculation.hpp"
|
||||||
|
|
||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
#include <boost/range/algorithm/transform.hpp>
|
#include <boost/range/algorithm/transform.hpp>
|
||||||
@ -53,6 +54,8 @@ class BaseAPI
|
|||||||
// TODO: check forward/reverse
|
// TODO: check forward/reverse
|
||||||
return json::makeWaypoint(
|
return json::makeWaypoint(
|
||||||
phantom.location,
|
phantom.location,
|
||||||
|
util::coordinate_calculation::fccApproximateDistance(phantom.location,
|
||||||
|
phantom.input_location),
|
||||||
facade.GetNameForID(facade.GetNameIndex(phantom.forward_segment_id.id)).to_string(),
|
facade.GetNameForID(facade.GetNameIndex(phantom.forward_segment_id.id)).to_string(),
|
||||||
Hint{phantom, facade.GetCheckSum()});
|
Hint{phantom, facade.GetCheckSum()});
|
||||||
}
|
}
|
||||||
@ -61,6 +64,8 @@ class BaseAPI
|
|||||||
// TODO: check forward/reverse
|
// TODO: check forward/reverse
|
||||||
return json::makeWaypoint(
|
return json::makeWaypoint(
|
||||||
phantom.location,
|
phantom.location,
|
||||||
|
util::coordinate_calculation::fccApproximateDistance(phantom.location,
|
||||||
|
phantom.input_location),
|
||||||
facade.GetNameForID(facade.GetNameIndex(phantom.forward_segment_id.id))
|
facade.GetNameForID(facade.GetNameIndex(phantom.forward_segment_id.id))
|
||||||
.to_string());
|
.to_string());
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ namespace json
|
|||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
|
|
||||||
util::json::Array coordinateToLonLat(const util::Coordinate coordinate);
|
util::json::Array coordinateToLonLat(const util::Coordinate &coordinate);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensures that a bearing value is a whole number, and clamped to the range 0-359
|
* Ensures that a bearing value is a whole number, and clamped to the range 0-359
|
||||||
@ -86,11 +86,14 @@ util::json::Object makeRoute(const guidance::Route &route,
|
|||||||
const char *weight_name);
|
const char *weight_name);
|
||||||
|
|
||||||
// Creates a Waypoint without Hint, see the Hint overload below
|
// Creates a Waypoint without Hint, see the Hint overload below
|
||||||
util::json::Object makeWaypoint(const util::Coordinate location, std::string name);
|
util::json::Object
|
||||||
|
makeWaypoint(const util::Coordinate &location, const double &distance, std::string name);
|
||||||
|
|
||||||
// Creates a Waypoint with Hint, see the overload above when Hint is not needed
|
// Creates a Waypoint with Hint, see the overload above when Hint is not needed
|
||||||
util::json::Object
|
util::json::Object makeWaypoint(const util::Coordinate &location,
|
||||||
makeWaypoint(const util::Coordinate location, std::string name, const Hint &hint);
|
const double &distance,
|
||||||
|
std::string name,
|
||||||
|
const Hint &hint);
|
||||||
|
|
||||||
util::json::Object makeRouteLeg(guidance::RouteLeg leg, util::json::Array steps);
|
util::json::Object makeRouteLeg(guidance::RouteLeg leg, util::json::Array steps);
|
||||||
|
|
||||||
|
@ -41,7 +41,6 @@ class NearestAPI final : public BaseAPI
|
|||||||
[this](const PhantomNodeWithDistance &phantom_with_distance) {
|
[this](const PhantomNodeWithDistance &phantom_with_distance) {
|
||||||
auto &phantom_node = phantom_with_distance.phantom_node;
|
auto &phantom_node = phantom_with_distance.phantom_node;
|
||||||
auto waypoint = MakeWaypoint(phantom_node);
|
auto waypoint = MakeWaypoint(phantom_node);
|
||||||
waypoint.values["distance"] = phantom_with_distance.distance;
|
|
||||||
|
|
||||||
util::json::Array nodes;
|
util::json::Array nodes;
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ std::string waypointTypeToString(const guidance::WaypointType waypoint_type)
|
|||||||
return waypoint_type_names[static_cast<std::size_t>(waypoint_type)];
|
return waypoint_type_names[static_cast<std::size_t>(waypoint_type)];
|
||||||
}
|
}
|
||||||
|
|
||||||
util::json::Array coordinateToLonLat(const util::Coordinate coordinate)
|
util::json::Array coordinateToLonLat(const util::Coordinate &coordinate)
|
||||||
{
|
{
|
||||||
util::json::Array array;
|
util::json::Array array;
|
||||||
array.values.push_back(static_cast<double>(util::toFloating(coordinate.lon)));
|
array.values.push_back(static_cast<double>(util::toFloating(coordinate.lon)));
|
||||||
@ -240,17 +240,22 @@ util::json::Object makeRoute(const guidance::Route &route,
|
|||||||
return json_route;
|
return json_route;
|
||||||
}
|
}
|
||||||
|
|
||||||
util::json::Object makeWaypoint(const util::Coordinate location, std::string name)
|
util::json::Object
|
||||||
|
makeWaypoint(const util::Coordinate &location, const double &distance, std::string name)
|
||||||
{
|
{
|
||||||
util::json::Object waypoint;
|
util::json::Object waypoint;
|
||||||
waypoint.values["location"] = detail::coordinateToLonLat(location);
|
waypoint.values["location"] = detail::coordinateToLonLat(location);
|
||||||
waypoint.values["name"] = std::move(name);
|
waypoint.values["name"] = std::move(name);
|
||||||
|
waypoint.values["distance"] = distance;
|
||||||
return waypoint;
|
return waypoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
util::json::Object makeWaypoint(const util::Coordinate location, std::string name, const Hint &hint)
|
util::json::Object makeWaypoint(const util::Coordinate &location,
|
||||||
|
const double &distance,
|
||||||
|
std::string name,
|
||||||
|
const Hint &hint)
|
||||||
{
|
{
|
||||||
auto waypoint = makeWaypoint(location, name);
|
auto waypoint = makeWaypoint(location, distance, name);
|
||||||
waypoint.values["hint"] = hint.ToBase64();
|
waypoint.values["hint"] = hint.ToBase64();
|
||||||
return waypoint;
|
return waypoint;
|
||||||
}
|
}
|
||||||
|
@ -153,7 +153,7 @@ double perpendicularDistance(const Coordinate segment_source,
|
|||||||
web_mercator::fromWGS84(query_location));
|
web_mercator::fromWGS84(query_location));
|
||||||
nearest_location = web_mercator::toWGS84(projected_nearest);
|
nearest_location = web_mercator::toWGS84(projected_nearest);
|
||||||
|
|
||||||
const double approximate_distance = greatCircleDistance(query_location, nearest_location);
|
const double approximate_distance = fccApproximateDistance(query_location, nearest_location);
|
||||||
BOOST_ASSERT(0.0 <= approximate_distance);
|
BOOST_ASSERT(0.0 <= approximate_distance);
|
||||||
return approximate_distance;
|
return approximate_distance;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#include <boost/test/test_case_template.hpp>
|
#include <boost/test/test_case_template.hpp>
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
#include "coordinates.hpp"
|
#include "coordinates.hpp"
|
||||||
#include "equal_json.hpp"
|
#include "equal_json.hpp"
|
||||||
#include "fixture.hpp"
|
#include "fixture.hpp"
|
||||||
@ -32,18 +34,28 @@ BOOST_AUTO_TEST_CASE(test_route_same_coordinates_fixture)
|
|||||||
|
|
||||||
// unset snapping dependent hint
|
// unset snapping dependent hint
|
||||||
for (auto &itr : result.values["waypoints"].get<json::Array>().values)
|
for (auto &itr : result.values["waypoints"].get<json::Array>().values)
|
||||||
|
{
|
||||||
|
// Hint values aren't stable, so blank it out
|
||||||
itr.get<json::Object>().values["hint"] = "";
|
itr.get<json::Object>().values["hint"] = "";
|
||||||
|
|
||||||
|
// Round value to 6 decimal places for double comparison later
|
||||||
|
itr.get<json::Object>().values["distance"] =
|
||||||
|
round(itr.get<json::Object>().values["distance"].get<json::Number>().value * 1000000);
|
||||||
|
}
|
||||||
|
|
||||||
const auto location = json::Array{{{7.437070}, {43.749248}}};
|
const auto location = json::Array{{{7.437070}, {43.749248}}};
|
||||||
|
|
||||||
json::Object reference{
|
json::Object reference{
|
||||||
{{"code", "Ok"},
|
{{"code", "Ok"},
|
||||||
{"waypoints",
|
{"waypoints",
|
||||||
json::Array{
|
json::Array{{json::Object{{{"name", "Boulevard du Larvotto"},
|
||||||
{json::Object{
|
{"location", location},
|
||||||
{{"name", "Boulevard du Larvotto"}, {"location", location}, {"hint", ""}}},
|
{"distance", round(0.137249 * 1000000)},
|
||||||
json::Object{
|
{"hint", ""}}},
|
||||||
{{"name", "Boulevard du Larvotto"}, {"location", location}, {"hint", ""}}}}}},
|
json::Object{{{"name", "Boulevard du Larvotto"},
|
||||||
|
{"location", location},
|
||||||
|
{"distance", round(0.137249 * 1000000)},
|
||||||
|
{"hint", ""}}}}}},
|
||||||
{"routes",
|
{"routes",
|
||||||
json::Array{{json::Object{
|
json::Array{{json::Object{
|
||||||
{{"distance", 0.},
|
{{"distance", 0.},
|
||||||
|
Loading…
Reference in New Issue
Block a user