Compare commits

...

9 Commits

Author SHA1 Message Date
6ab6564d42
fix arch on normal build
Some checks failed
Build and Publish Docker Image / publish (debian) (release) Failing after 21s
Build and Publish Docker Image / publish (alpine) (release) Failing after 3h14m36s
2025-02-15 14:29:51 -05:00
513966056b
remove 2 32bit unsupported arch
Some checks failed
Build and Publish Docker Image / publish (alpine) (release) Failing after 1h38m5s
Build and Publish Docker Image / publish (debian) (release) Failing after 22s
2025-02-15 12:28:08 -05:00
2c91c0c259
update image name
Some checks failed
Build and Publish Docker Image / publish (alpine) (release) Failing after 1m49s
Build and Publish Docker Image / publish (debian) (release) Failing after 21s
2025-02-15 12:21:44 -05:00
Matt Robinson
c59ad69d6a
Correct Docker FromAsCasing warning (#7064) 2025-02-10 19:22:09 +01:00
Alexander Farber
61464fc2bd
Fix no member named 'construct' in 'optional<type-parameter-0-0 &>' error in sol.hpp with Clang 19 (#7098) 2025-01-25 07:09:37 +00:00
Alexander Farber
6f235cca15
Use libtbb-dev/libtbb12 packages in Dockerfile-debian, sort packages alphabetically in both Dockerfiles (#7095)
* - Use libtbb-dev in builder stage and libtbb12 package in the runstage instead of building oneTBB v2021.12.0 from source code
- Remove wget package from builder stage, because it is not used
- Uppercase "FROM ... as" -> "FROM ... AS" to silence a "docker build" warning
- Sort packages alphabetically and put them on separate lines for easier comparison

* - Fix the warning "FromAsCasing: 'as' and 'FROM' keywords' casing do not match"
- Sort packages alphabetically and put them on separate lines for easier comparison

* Revert  -Wno-stringop-overflow

* Update the link to multi staged builds in the comment

* Update alpine:3.20.0 -> alpine:3.20.5
2025-01-12 16:28:56 +00:00
Siarhei Fedartsou
3614af7f64
Use std::string_view for key type in json::Object (#7062) 2024-11-03 18:23:23 +01:00
Siarhei Fedartsou
48e8382785
Remove unused bearing::get function (#7040)
* Remove unused bearing::get function

* Remove unused bearing::get function

* Remove unused bearing::get function

* Remove unused bearing::get function
2024-10-20 19:46:49 +02:00
Frédéric Rodrigo
becfd8a56d
Add optional support of cargo bike exclusion and width to bicyle profile (#7044) 2024-10-01 15:19:44 +03:00
16 changed files with 215 additions and 96 deletions

View File

@ -0,0 +1,65 @@
name: Build and Publish Docker Image
on:
release:
types: [published, prereleased]
env:
IMAGE_NAME: openharbor/osrm-backend
jobs:
publish:
strategy:
matrix:
docker-base-image: ["debian", "alpine"]
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.IMAGE_NAME }}
- name: Docker meta - debug
id: metadebug
uses: docker/metadata-action@v4
with:
images: ${{ env.IMAGE_NAME }}
flavor: |
latest=true
suffix=-debug,onlatest=true
- name: Log in to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}
- name: Build and push debug image
uses: docker/build-push-action@v4
with:
push: true
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/riscv64
file: ./docker/Dockerfile-${{ matrix.docker-base-image }}
tags: ${{ steps.metadebug.outputs.tags }}
build-args: |
DOCKER_TAG=${{ join(steps.metadebug.outputs.tags) }}-${{ matrix.docker-base-image }}
- name: Build and push normal image
uses: docker/build-push-action@v4
with:
push: true
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/riscv64
file: ./docker/Dockerfile-${{ matrix.docker-base-image }}
tags: ${{ steps.meta.outputs.tags }}
build-args: |
DOCKER_TAG=${{ join(steps.meta.outputs.tags) }}-${{ matrix.docker-base-image }}

View File

@ -446,14 +446,14 @@ jobs:
if: steps.cache-boost.outputs.cache-hit != 'true' && runner.os == 'Linux' && matrix.ENABLE_CONAN != 'ON'
run: |
BOOST_VERSION="1.85.0"
BOOST_VERSION_UNDERSCORE="${BOOST_VERSION//./_}"
wget -q https://boostorg.jfrog.io/artifactory/main/release/${BOOST_VERSION}/source/boost_${BOOST_VERSION_UNDERSCORE}.tar.gz
tar xzf boost_${BOOST_VERSION_UNDERSCORE}.tar.gz
cd boost_${BOOST_VERSION_UNDERSCORE}
BOOST_VERSION_FLAVOR="${BOOST_VERSION}-b2-nodocs"
wget -q https://github.com/boostorg/boost/releases/download/boost-${BOOST_VERSION}/boost-${BOOST_VERSION_FLAVOR}.tar.gz
tar xzf boost-${BOOST_VERSION_FLAVOR}.tar.gz
cd boost-${BOOST_VERSION}
sudo ./bootstrap.sh
sudo ./b2 install
cd ..
sudo rm -rf boost_${BOOST_VERSION_UNDERSCORE}*
sudo rm -rf boost-${BOOST_VERSION}*
- name: Install dev dependencies
run: |
@ -502,6 +502,13 @@ jobs:
conan config init
yq eval '.compiler.clang.version += ["18"]' -i "$HOME/.conan/settings.yml"
- name: Add Apple-clang 16 to list of Conan compilers # workaround for the issue that Conan 1.x doesn't know about Apple-clang 16
if: ${{ matrix.ENABLE_CONAN == 'ON' && matrix.runs-on == 'macos-14' }}
run: |
sudo wget https://github.com/mikefarah/yq/releases/download/v4.9.6/yq_darwin_arm64 -O /usr/local/bin/yq && sudo chmod +x /usr/local/bin/yq
conan config init
yq eval '.compiler.apple-clang.version += ["16.0"]' -i "$HOME/.conan/settings.yml"
- name: Prepare build
run: |
mkdir ${OSRM_BUILD_DIR}

View File

@ -25,6 +25,7 @@
- NodeJS:
- CHANGED: Use node-api instead of NAN. [#6452](https://github.com/Project-OSRM/osrm-backend/pull/6452)
- Misc:
- CHANGED: Use std::string_view for key type in json::Object. [#7062](https://github.com/Project-OSRM/osrm-backend/pull/7062)
- CHANGED: Use thread_local instead of boost::thread_specific_ptr. [#6991](https://github.com/Project-OSRM/osrm-backend/pull/6991)
- CHANGED: Bump flatbuffers to v24.3.25 version. [#6988](https://github.com/Project-OSRM/osrm-backend/pull/6988)
- CHANGED: Add .reserve(...) to assembleGeometry function. [#6983](https://github.com/Project-OSRM/osrm-backend/pull/6983)
@ -79,6 +80,7 @@
- ADDED: Extract prerelease/build information from package semver [#6839](https://github.com/Project-OSRM/osrm-backend/pull/6839)
- Profiles:
- FIXED: Bicycle and foot profiles now don't route on proposed ways [#6615](https://github.com/Project-OSRM/osrm-backend/pull/6615)
- ADDED: Add optional support of cargo bike exclusion and width to bicyle profile [#7044](https://github.com/Project-OSRM/osrm-backend/pull/7044)
- Routing:
- FIXED: Fix adding traffic signal penalties during compression [#6419](https://github.com/Project-OSRM/osrm-backend/pull/6419)
- FIXED: Correctly handle compressed traffic signals. [#6724](https://github.com/Project-OSRM/osrm-backend/pull/6724)

View File

@ -56,6 +56,9 @@ endif()
if (POLICY CMP0074)
cmake_policy(SET CMP0074 NEW)
endif()
if (POLICY CMP0167)
cmake_policy(SET CMP0167 NEW)
endif()
project(OSRM C CXX)

View File

@ -1,20 +1,34 @@
FROM alpine:3.20.0 as alpine-mimalloc
FROM alpine:3.21.2 AS alpine-mimalloc
RUN apk add --no-cache mimalloc
RUN apk update && \
apk upgrade && \
apk add --no-cache \
boost-iostreams \
boost-program_options \
boost-thread \
mimalloc
ENV LD_PRELOAD=/usr/lib/libmimalloc.so.2
ENV MIMALLOC_LARGE_OS_PAGES=1
FROM alpine-mimalloc as builder
FROM alpine-mimalloc AS builder
ARG DOCKER_TAG
ARG BUILD_CONCURRENCY
RUN mkdir -p /src && mkdir -p /opt
RUN apk add --no-cache \
cmake make git clang libbz2 libxml2 \
boost-dev boost-program_options boost-filesystem boost-iostreams boost-thread \
lua5.4-dev onetbb-dev expat-dev
RUN mkdir -p /src /opt && \
apk add --no-cache \
boost-dev \
boost-filesystem \
clang \
cmake \
expat-dev \
git \
libbz2 \
libxml2 \
lua5.4-dev \
make \
onetbb-dev
COPY . /src
WORKDIR /src
@ -39,16 +53,18 @@ RUN NPROC=${BUILD_CONCURRENCY:-$(nproc)} && \
rm -rf /src
# 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/build/building/multi-stage/#use-multi-stage-builds
# Only the content below ends up in the image, this helps remove /src from the image (which is large)
FROM alpine-mimalloc as runstage
FROM alpine-mimalloc AS runstage
COPY --from=builder /usr/local /usr/local
COPY --from=builder /opt /opt
RUN apk add --no-cache \
boost-program_options boost-date_time boost-iostreams boost-thread \
expat lua5.4 onetbb && \
boost-date_time \
expat \
lua5.4 \
onetbb && \
ldconfig /usr/local/lib
RUN /usr/local/bin/osrm-extract --help && \
@ -60,3 +76,4 @@ RUN /usr/local/bin/osrm-extract --help && \
WORKDIR /opt
EXPOSE 5000

View File

@ -1,21 +1,24 @@
FROM debian:bookworm-slim as builder
FROM debian:bookworm-slim AS builder
ARG DOCKER_TAG
ARG BUILD_CONCURRENCY
RUN mkdir -p /src && mkdir -p /opt
RUN apt-get update && \
apt-get -y --no-install-recommends install ca-certificates cmake make git gcc g++ libbz2-dev libxml2-dev wget \
libzip-dev libboost1.81-all-dev lua5.4 liblua5.4-dev pkg-config -o APT::Install-Suggests=0 -o APT::Install-Recommends=0
RUN NPROC=${BUILD_CONCURRENCY:-$(nproc)} && \
ldconfig /usr/local/lib && \
git clone --branch v2021.12.0 --single-branch https://github.com/oneapi-src/oneTBB.git && \
cd oneTBB && \
mkdir build && \
cd build && \
cmake -DTBB_TEST=OFF -DCMAKE_BUILD_TYPE=Release .. && \
cmake --build . && \
cmake --install .
RUN mkdir -p /src /opt && \
apt-get update && \
apt-get -y --no-install-recommends --no-install-suggests install \
ca-certificates \
cmake \
g++ \
gcc \
git \
libboost1.81-all-dev \
libbz2-dev \
liblua5.4-dev \
libtbb-dev \
libxml2-dev \
libzip-dev \
lua5.4 \
make \
pkg-config
COPY . /src
WORKDIR /src
@ -41,19 +44,24 @@ RUN NPROC=${BUILD_CONCURRENCY:-$(nproc)} && \
rm -rf /src
# 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/build/building/multi-stage/#use-multi-stage-builds
# Only the content below ends up in the image, this helps remove /src from the image (which is large)
FROM debian:bookworm-slim as runstage
FROM debian:bookworm-slim AS runstage
COPY --from=builder /usr/local /usr/local
COPY --from=builder /opt /opt
RUN apt-get update && \
apt-get install -y --no-install-recommends \
libboost-program-options1.81.0 libboost-date-time1.81.0 libboost-iostreams1.81.0 libboost-thread1.81.0 \
expat liblua5.4-0 && \
apt-get install -y --no-install-recommends --no-install-suggests \
expat \
libboost-date-time1.81.0 \
libboost-iostreams1.81.0 \
libboost-program-options1.81.0 \
libboost-thread1.81.0 \
liblua5.4-0 \
libtbb12 && \
rm -rf /var/lib/apt/lists/* && \
# add /usr/local/lib to ldconfig to allow loading libraries from there
# Add /usr/local/lib to ldconfig to allow loading libraries from there
ldconfig /usr/local/lib
RUN /usr/local/bin/osrm-extract --help && \
@ -65,3 +73,4 @@ RUN /usr/local/bin/osrm-extract --help && \
WORKDIR /opt
EXPOSE 5000

View File

@ -30,7 +30,7 @@ struct V8Renderer
{
Napi::Value child;
std::visit(V8Renderer(env, child), keyValue.second);
obj.Set(keyValue.first, child);
obj.Set(keyValue.first.data(), child);
}
out = obj;
}

View File

@ -11,46 +11,6 @@ namespace osrm::util
namespace bearing
{
inline std::string get(const double heading)
{
BOOST_ASSERT(heading >= 0);
BOOST_ASSERT(heading <= 360);
if (heading <= 22.5)
{
return "N";
}
if (heading <= 67.5)
{
return "NE";
}
if (heading <= 112.5)
{
return "E";
}
if (heading <= 157.5)
{
return "SE";
}
if (heading <= 202.5)
{
return "S";
}
if (heading <= 247.5)
{
return "SW";
}
if (heading <= 292.5)
{
return "W";
}
if (heading <= 337.5)
{
return "NW";
}
return "N";
}
// Checks whether A is between B-range and B+range, all modulo 360
// e.g. A = 5, B = 5, range = 10 == true
// A = -6, B = 5, range = 10 == false

View File

@ -104,7 +104,7 @@ using Value = std::variant<String, Number, Object, Array, True, False, Null>;
*/
struct Object
{
std::unordered_map<std::string, Value> values;
std::unordered_map<std::string_view, Value> values;
};
/**

View File

@ -44,13 +44,13 @@ struct Comparator
bool operator()(const Object &lhs, const Object &rhs) const
{
std::set<std::string> lhs_keys;
std::set<std::string_view> lhs_keys;
for (const auto &key_value : lhs.values)
{
lhs_keys.insert(key_value.first);
}
std::set<std::string> rhs_keys;
std::set<std::string_view> rhs_keys;
for (const auto &key_value : rhs.values)
{
rhs_keys.insert(key_value.first);
@ -60,7 +60,7 @@ struct Comparator
{
if (rhs_keys.find(key) == rhs_keys.end())
{
reason = rhs_path + " doesn't have key \"" + key + "\"";
reason = rhs_path + " doesn't have key \"" + std::string(key) + "\"";
return false;
}
}
@ -69,7 +69,7 @@ struct Comparator
{
if (lhs_keys.find(key) == lhs_keys.end())
{
reason = lhs_path + " doesn't have key \"" + key + "\"";
reason = lhs_path + " doesn't have key \"" + std::string(key) + "\"";
return false;
}
}
@ -81,10 +81,11 @@ struct Comparator
const auto &rhs_child = rhs.values.find(key)->second;
const auto &lhs_child = lhs.values.find(key)->second;
auto is_same =
std::visit(Comparator(reason, lhs_path + "." + key, rhs_path + "." + key),
lhs_child,
rhs_child);
auto is_same = std::visit(Comparator(reason,
lhs_path + "." + std::string(key),
rhs_path + "." + std::string(key)),
lhs_child,
rhs_child);
if (!is_same)
{
return false;

View File

@ -97,7 +97,7 @@ template <typename Out> struct Renderer
void operator()(const Null &) { write<>("null"); }
private:
void write(const std::string &str);
void write(std::string_view str);
void write(const char *str, size_t size);
void write(char ch);
@ -110,7 +110,7 @@ template <typename Out> struct Renderer
Out &out;
};
template <> void Renderer<std::vector<char>>::write(const std::string &str)
template <> void Renderer<std::vector<char>>::write(std::string_view str)
{
out.insert(out.end(), str.begin(), str.end());
}
@ -122,7 +122,7 @@ template <> void Renderer<std::vector<char>>::write(const char *str, size_t size
template <> void Renderer<std::vector<char>>::write(char ch) { out.push_back(ch); }
template <> void Renderer<std::ostream>::write(const std::string &str) { out << str; }
template <> void Renderer<std::ostream>::write(std::string_view str) { out << str; }
template <> void Renderer<std::ostream>::write(const char *str, size_t size)
{
@ -131,7 +131,7 @@ template <> void Renderer<std::ostream>::write(const char *str, size_t size)
template <> void Renderer<std::ostream>::write(char ch) { out << ch; }
template <> void Renderer<std::string>::write(const std::string &str) { out += str; }
template <> void Renderer<std::string>::write(std::string_view str) { out += str; }
template <> void Renderer<std::string>::write(const char *str, size_t size)
{

View File

@ -35,6 +35,10 @@ function setup()
turn_bias = 1.4,
use_public_transport = true,
-- Exclude narrow ways, in particular to route with cargo bike
width = nil, -- Cargo bike could 0.5 width, in meters
exclude_cargo_bike = false,
allowed_start_modes = Set {
mode.cycling,
mode.pushing_bike
@ -243,6 +247,27 @@ function process_node(profile, node, result)
end
end
if profile.exclude_cargo_bike then
local cargo_bike = node:get_value_by_key("cargo_bike")
if cargo_bike and cargo_bike == "no" then
result.barrier = true
end
end
-- width
if profile.width then
-- From barrier=cycle_barrier or other barriers
local maxwidth_physical = node:get_value_by_key("maxwidth:physical")
local maxwidth_physical_meter = maxwidth_physical and Measure.parse_value_meters(maxwidth_physical) or 99
local opening = node:get_value_by_key("opening")
local opening_meter = opening and Measure.parse_value_meters(opening) or 99
local width_meter = math.min(maxwidth_physical_meter, opening_meter)
if width_meter and width_meter < profile.width then
result.barrier = true
end
end
-- check if node is a traffic light
result.traffic_lights = TrafficSignal.get_value(node)
end
@ -299,6 +324,8 @@ function handle_bicycle_tags(profile,way,result,data)
bike_push_handler(profile,way,result,data)
-- width should be after bike_push
width_handler(profile,way,result,data)
-- maxspeed
limit( result, data.maxspeed, data.maxspeed_forward, data.maxspeed_backward )
@ -453,6 +480,27 @@ function cycleway_handler(profile,way,result,data)
end
end
function width_handler(profile,way,result,data)
if profile.exclude_cargo_bike then
local cargo_bike = way:get_value_by_key("cargo_bike")
if cargo_bike and cargo_bike == "no" then
result.forward_mode = mode.inaccessible
result.backward_mode = mode.inaccessible
end
end
if profile.width then
local width = way:get_value_by_key("width")
if width then
local width_meter = Measure.parse_value_meters(width)
if width_meter and width_meter < profile.width then
result.forward_mode = mode.inaccessible
result.backward_mode = mode.inaccessible
end
end
end
end
function bike_push_handler(profile,way,result,data)
-- pushing bikes - if no other mode found
if result.forward_mode == mode.inaccessible or result.backward_mode == mode.inaccessible or

View File

@ -93,7 +93,7 @@ function run_benchmarks_for_folder {
echo "Took: ${DIFF}s"
done
done
for ALGORITHM in ch mld; do
for BENCH in nearest table trip route match; do
echo "Running random $BENCH $ALGORITHM"

View File

@ -9,12 +9,17 @@
#include <rapidjson/document.h>
#include <sstream>
#include <stdexcept>
#include <unordered_set>
using namespace osrm;
namespace
{
// we use std::string_view as a key in the object, so since here we have dynamic keys we have to
// "hold" them somewhere okay for tests...
static std::unordered_set<std::string> gKeysHolder;
void convert(const rapidjson::Value &value, json::Value &result)
{
if (value.IsString())
@ -32,7 +37,8 @@ void convert(const rapidjson::Value &value, json::Value &result)
{
json::Value member;
convert(itr->value, member);
object.values.emplace(itr->name.GetString(), std::move(member));
auto keyItr = gKeysHolder.emplace(itr->name.GetString()).first;
object.values.emplace(*keyItr, std::move(member));
}
result = std::move(object);
}
@ -122,6 +128,7 @@ int main(int argc, char **argv)
if (std::string{out_vec.begin(), out_vec.end()} != out_str || out_str != out_ss_str)
{
std::cerr << "Vector/string results are not equal\n";
throw std::logic_error("Vector/stringstream/string results are not equal");
}
return EXIT_SUCCESS;

View File

@ -6752,7 +6752,8 @@ namespace sol {
static_assert(std::is_constructible<T, Args&&...>::value, "T must be constructible with Args");
*this = nullopt;
this->construct(std::forward<Args>(args)...);
new (static_cast<void*>(this)) optional(std::in_place, std::forward<Args>(args)...);
return **this;
}
/// Swaps this optional with the other.

View File

@ -17,7 +17,6 @@ const static std::string IO_TOO_SMALL_FILE = "file_too_small_test_io.tmp";
const static std::string IO_CORRUPT_FINGERPRINT_FILE = "corrupt_fingerprint_file_test_io.tmp";
const static std::string IO_INCOMPATIBLE_FINGERPRINT_FILE =
"incompatible_fingerprint_file_test_io.tmp";
const static std::string IO_TEXT_FILE = "plain_text_file.tmp";
using namespace osrm;