Compare commits
No commits in common. "master" and "v0.1" have entirely different histories.
7
.babelrc
@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
"plugins": ["transform-class-properties"],
|
|
||||||
"presets": [
|
|
||||||
"@babel/preset-env",
|
|
||||||
"@babel/preset-react"
|
|
||||||
]
|
|
||||||
}
|
|
@ -1,90 +0,0 @@
|
|||||||
---
|
|
||||||
Language: Cpp
|
|
||||||
# BasedOnStyle: LLVM
|
|
||||||
AccessModifierOffset: -2
|
|
||||||
AlignAfterOpenBracket: Align
|
|
||||||
AlignConsecutiveAssignments: false
|
|
||||||
AlignConsecutiveDeclarations: false
|
|
||||||
AlignEscapedNewlinesLeft: false
|
|
||||||
AlignOperands: true
|
|
||||||
AlignTrailingComments: true
|
|
||||||
AllowAllParametersOfDeclarationOnNextLine: true
|
|
||||||
AllowShortBlocksOnASingleLine: true
|
|
||||||
AllowShortCaseLabelsOnASingleLine: false
|
|
||||||
AllowShortFunctionsOnASingleLine: All
|
|
||||||
AllowShortIfStatementsOnASingleLine: false
|
|
||||||
AllowShortLoopsOnASingleLine: false
|
|
||||||
AlwaysBreakAfterDefinitionReturnType: None
|
|
||||||
AlwaysBreakAfterReturnType: None
|
|
||||||
AlwaysBreakBeforeMultilineStrings: false
|
|
||||||
AlwaysBreakTemplateDeclarations: false
|
|
||||||
BinPackArguments: false
|
|
||||||
BinPackParameters: false
|
|
||||||
BraceWrapping:
|
|
||||||
AfterClass: true
|
|
||||||
AfterControlStatement: true
|
|
||||||
AfterEnum: true
|
|
||||||
AfterFunction: true
|
|
||||||
AfterNamespace: true
|
|
||||||
AfterObjCDeclaration: true
|
|
||||||
AfterStruct: true
|
|
||||||
AfterUnion: true
|
|
||||||
BeforeCatch: true
|
|
||||||
BeforeElse: true
|
|
||||||
IndentBraces: true
|
|
||||||
BreakBeforeBinaryOperators: false
|
|
||||||
BreakBeforeBraces: Allman
|
|
||||||
BreakBeforeTernaryOperators: true
|
|
||||||
BreakConstructorInitializersBeforeComma: false
|
|
||||||
ColumnLimit: 100
|
|
||||||
CommentPragmas: '^ IWYU pragma:'
|
|
||||||
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
|
||||||
ConstructorInitializerIndentWidth: 4
|
|
||||||
ContinuationIndentWidth: 4
|
|
||||||
Cpp11BracedListStyle: true
|
|
||||||
DerivePointerAlignment: false
|
|
||||||
DisableFormat: false
|
|
||||||
ExperimentalAutoDetectBinPacking: false
|
|
||||||
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
|
|
||||||
IncludeCategories:
|
|
||||||
- Regex: '^<'
|
|
||||||
Priority: 3
|
|
||||||
- Regex: '^"(osrm|util|engine|extract|contract)/'
|
|
||||||
Priority: 2
|
|
||||||
- Regex: '.*'
|
|
||||||
Priority: 1
|
|
||||||
IndentCaseLabels: false
|
|
||||||
IndentWidth: 4
|
|
||||||
IndentWrappedFunctionNames: false
|
|
||||||
KeepEmptyLinesAtTheStartOfBlocks: true
|
|
||||||
MacroBlockBegin: ''
|
|
||||||
MacroBlockEnd: ''
|
|
||||||
MaxEmptyLinesToKeep: 1
|
|
||||||
NamespaceIndentation: None
|
|
||||||
ObjCBlockIndentWidth: 2
|
|
||||||
ObjCSpaceAfterProperty: false
|
|
||||||
ObjCSpaceBeforeProtocolList: true
|
|
||||||
PenaltyBreakBeforeFirstCallParameter: 19
|
|
||||||
PenaltyBreakComment: 300
|
|
||||||
PenaltyBreakFirstLessLess: 120
|
|
||||||
PenaltyBreakString: 1000
|
|
||||||
PenaltyExcessCharacter: 1000000
|
|
||||||
PenaltyReturnTypeOnItsOwnLine: 60
|
|
||||||
PointerAlignment: Right
|
|
||||||
ReflowComments: true
|
|
||||||
SortIncludes: true
|
|
||||||
SpaceAfterCStyleCast: false
|
|
||||||
SpaceBeforeAssignmentOperators: true
|
|
||||||
SpaceBeforeParens: ControlStatements
|
|
||||||
SpaceInEmptyParentheses: false
|
|
||||||
SpacesBeforeTrailingComments: 1
|
|
||||||
SpacesInAngles: false
|
|
||||||
SpacesInContainerLiterals: true
|
|
||||||
SpacesInCStyleCastParentheses: false
|
|
||||||
SpacesInParentheses: false
|
|
||||||
SpacesInSquareBrackets: false
|
|
||||||
Standard: Cpp11
|
|
||||||
TabWidth: 8
|
|
||||||
UseTab: Never
|
|
||||||
...
|
|
||||||
|
|
101
.clang-tidy
@ -1,101 +0,0 @@
|
|||||||
---
|
|
||||||
Checks: >
|
|
||||||
bugprone-*,
|
|
||||||
-bugprone-narrowing-conversions,
|
|
||||||
-bugprone-easily-swappable-parameters,
|
|
||||||
-bugprone-branch-clone,
|
|
||||||
-bugprone-misplaced-widening-cast,
|
|
||||||
-bugprone-exception-escape,
|
|
||||||
-bugprone-implicit-widening-of-multiplication-result,
|
|
||||||
-bugprone-integer-division,
|
|
||||||
-bugprone-reserved-identifier,
|
|
||||||
-bugprone-unhandled-self-assignment,
|
|
||||||
-bugprone-forward-declaration-namespace,
|
|
||||||
-bugprone-sizeof-expression,
|
|
||||||
-bugprone-throw-keyword-missing,
|
|
||||||
-bugprone-chained-comparison,
|
|
||||||
-bugprone-incorrect-enable-if,
|
|
||||||
-bugprone-switch-missing-default-case,
|
|
||||||
-bugprone-empty-catch,
|
|
||||||
-bugprone-unchecked-optional-access,
|
|
||||||
-clang-analyzer-*,
|
|
||||||
-clang-diagnostic-deprecated-declarations,
|
|
||||||
-clang-diagnostic-constant-conversion,
|
|
||||||
cppcoreguidelines-avoid-goto,
|
|
||||||
cppcoreguidelines-no-malloc,
|
|
||||||
cppcoreguidelines-virtual-class-destructor,
|
|
||||||
google-*,
|
|
||||||
-google-build-explicit-make-pair,
|
|
||||||
-google-build-using-namespace,
|
|
||||||
-google-explicit-constructor,
|
|
||||||
-google-default-arguments,
|
|
||||||
-google-readability-braces-around-statements,
|
|
||||||
-google-readability-casting,
|
|
||||||
-google-readability-namespace-comments,
|
|
||||||
-google-readability-function,
|
|
||||||
-google-readability-todo,
|
|
||||||
-google-runtime-int,
|
|
||||||
-google-build-namespaces,
|
|
||||||
-google-runtime-references,
|
|
||||||
-google-readability-function-size,
|
|
||||||
llvm-*,
|
|
||||||
-llvm-namespace-comment,
|
|
||||||
-llvm-qualified-auto,
|
|
||||||
-llvm-include-order,
|
|
||||||
-llvm-else-after-return,
|
|
||||||
-llvm-header-guard,
|
|
||||||
-llvm-twine-local,
|
|
||||||
misc-*,
|
|
||||||
-misc-argument-comment,
|
|
||||||
-misc-const-correctness,
|
|
||||||
-misc-non-private-member-variables-in-classes,
|
|
||||||
-misc-unconventional-assign-operator,
|
|
||||||
-misc-no-recursion,
|
|
||||||
-misc-misplaced-const,
|
|
||||||
-misc-definitions-in-headers,
|
|
||||||
-misc-unused-parameters,
|
|
||||||
-misc-include-cleaner,
|
|
||||||
modernize-concat-nested-namespaces,
|
|
||||||
modernize-use-using,
|
|
||||||
performance-*,
|
|
||||||
-performance-no-int-to-ptr,
|
|
||||||
-performance-enum-size,
|
|
||||||
-performance-avoid-endl,
|
|
||||||
readability-*,
|
|
||||||
-readability-avoid-const-params-in-decls,
|
|
||||||
-readability-braces-around-statements,
|
|
||||||
-readability-container-size-empty,
|
|
||||||
-readability-convert-member-functions-to-static,
|
|
||||||
-readability-const-return-type,
|
|
||||||
-readability-function-cognitive-complexity,
|
|
||||||
-readability-function-size,
|
|
||||||
-readability-identifier-naming,
|
|
||||||
-readability-implicit-bool-conversion,
|
|
||||||
-readability-magic-numbers,
|
|
||||||
-readability-else-after-return,
|
|
||||||
-readability-inconsistent-declaration-parameter-name,
|
|
||||||
-readability-isolate-declaration,
|
|
||||||
-readability-identifier-length,
|
|
||||||
-readability-redundant-declaration,
|
|
||||||
-readability-uppercase-literal-suffix,
|
|
||||||
-readability-named-parameter,
|
|
||||||
-readability-qualified-auto,
|
|
||||||
-readability-suspicious-call-argument,
|
|
||||||
-readability-redundant-access-specifiers,
|
|
||||||
-readability-redundant-member-init,
|
|
||||||
-readability-static-definition-in-anonymous-namespace,
|
|
||||||
-readability-use-anyofallof,
|
|
||||||
-readability-simplify-boolean-expr,
|
|
||||||
-readability-make-member-function-const,
|
|
||||||
-readability-redundant-string-init,
|
|
||||||
-readability-non-const-parameter,
|
|
||||||
-readability-redundant-inline-specifier,
|
|
||||||
-readability-avoid-nested-conditional-operator,
|
|
||||||
-readability-avoid-return-with-void-value,
|
|
||||||
-readability-redundant-casting,
|
|
||||||
-readability-static-accessed-through-instance
|
|
||||||
|
|
||||||
WarningsAsErrors: '*'
|
|
||||||
HeaderFilterRegex: '.*'
|
|
||||||
|
|
||||||
|
|
14
.cncc.style
@ -1,14 +0,0 @@
|
|||||||
# Kind-specific patterns to check AST nodes against. Both python-clang and
|
|
||||||
# libclang docs explain CursorKind, with differences in detail. See also:
|
|
||||||
# - https://github.com/llvm-mirror/clang/blob/aca4fe314a55cacae29e1548cb7bfd2119c6df4c/bindings/python/clang/cindex.py#L599
|
|
||||||
# - http://clang.llvm.org/doxygen/group__CINDEX.html#gaaccc432245b4cd9f2d470913f9ef0013
|
|
||||||
# - https://docs.python.org/2/library/re.html#regular-expression-syntax
|
|
||||||
|
|
||||||
class_decl: '^([A-Z]+[a-z]+)+$'
|
|
||||||
struct_decl: '^([A-Z]+[a-z]+)+$'
|
|
||||||
field_decl: '^[a-z_]+$'
|
|
||||||
var_decl: '^[a-z]+[a-z0-9_]*$'
|
|
||||||
parm_decl: '^[a-z]*[a-z0-9_]*$'
|
|
||||||
namespace: '^[a-z_]*$'
|
|
||||||
cxx_method: '^([A-Z]+[a-z]+)+$'
|
|
||||||
function_decl: '^[a-z]+([A-Z]+[a-z]+)*$'
|
|
@ -1,2 +0,0 @@
|
|||||||
test
|
|
||||||
build
|
|
@ -1,30 +0,0 @@
|
|||||||
# EditorConfig is awesome: http://EditorConfig.org
|
|
||||||
#
|
|
||||||
# NOTE: Keep settings in sync with the master .clang-format file
|
|
||||||
#
|
|
||||||
# top-most EditorConfig file
|
|
||||||
root = true
|
|
||||||
|
|
||||||
# CMake configuration files
|
|
||||||
[{CMakeLists.txt,CMakeSettings.json,*.cmake}]
|
|
||||||
indent_size = 2
|
|
||||||
indent_style = space
|
|
||||||
trim_trailing_whitespace = true
|
|
||||||
|
|
||||||
# CI configuration files
|
|
||||||
[{.travis.yml,appveyor.yml}]
|
|
||||||
indent_size = 2
|
|
||||||
indent_style = space
|
|
||||||
trim_trailing_whitespace = true
|
|
||||||
|
|
||||||
# Unix shell scripts
|
|
||||||
[*.sh]
|
|
||||||
end_of_line = lf
|
|
||||||
indent_style = space
|
|
||||||
trim_trailing_whitespace = true
|
|
||||||
|
|
||||||
# Windows shell scripts
|
|
||||||
[*.bat]
|
|
||||||
end_of_line = crlf
|
|
||||||
indent_style = space
|
|
||||||
trim_trailing_whitespace = true
|
|
@ -1,2 +0,0 @@
|
|||||||
features/support/flatbuffers.js
|
|
||||||
features/support/fbresult_generated.js
|
|
28
.eslintrc
@ -1,28 +0,0 @@
|
|||||||
{
|
|
||||||
"rules": {
|
|
||||||
"indent": [
|
|
||||||
2,
|
|
||||||
4
|
|
||||||
],
|
|
||||||
"quotes": [
|
|
||||||
1,
|
|
||||||
"single"
|
|
||||||
],
|
|
||||||
"linebreak-style": [
|
|
||||||
2,
|
|
||||||
"unix"
|
|
||||||
],
|
|
||||||
"semi": [
|
|
||||||
2,
|
|
||||||
"always"
|
|
||||||
],
|
|
||||||
"no-console": [
|
|
||||||
1
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"env": {
|
|
||||||
"es6": true,
|
|
||||||
"node": true
|
|
||||||
},
|
|
||||||
"extends": "eslint:recommended"
|
|
||||||
}
|
|
18
.gitattributes
vendored
@ -1,18 +0,0 @@
|
|||||||
# Set the default behavior, in case people don't have core.autocrlf set.
|
|
||||||
* text=auto
|
|
||||||
|
|
||||||
# Explicitly declare text files you want to always be normalized and converted
|
|
||||||
# to native line endings on checkout.
|
|
||||||
*.cpp text
|
|
||||||
*.hpp text
|
|
||||||
|
|
||||||
# Declare files that will always have CRLF line endings on checkout.
|
|
||||||
*.bat text eol=crlf
|
|
||||||
*.cmd text eol=crlf
|
|
||||||
*.ps1 text eol=crlf
|
|
||||||
|
|
||||||
# Declare files that will always have LF line endings on checkout.
|
|
||||||
*.sh text eol=lf
|
|
||||||
|
|
||||||
# https://eslint.org/docs/latest/rules/linebreak-style#using-this-rule-with-version-control-systems
|
|
||||||
*.js text eol=lf
|
|
@ -1,65 +0,0 @@
|
|||||||
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 }}
|
|
30
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@ -1,30 +0,0 @@
|
|||||||
---
|
|
||||||
name: Bug Report
|
|
||||||
about: Report issue with osrm-backend
|
|
||||||
labels: Bug Report
|
|
||||||
---
|
|
||||||
|
|
||||||
# Issue
|
|
||||||
|
|
||||||
Please describe the issue you are seeing with OSRM.
|
|
||||||
Images are a good way to illustrate your problem.
|
|
||||||
|
|
||||||
**Note**: If your issue relates to the demo site (https://map.project-osrm.org) or routing provided on openstreetmap.org, be aware that they use separate [profile settings](https://github.com/fossgis-routing-server/cbf-routing-profiles) from those provided by default in `osrm-backend`.
|
|
||||||
If your issue relates to the demo site or openstreetmap.org behaviour, please check these profiles first to see if they explain the behaviour before creating an issue here.
|
|
||||||
|
|
||||||
# Steps to reproduce
|
|
||||||
|
|
||||||
Please provide the steps required to reproduce your problem.
|
|
||||||
- `osrm-backend` version being used
|
|
||||||
- OSM extract that was processed
|
|
||||||
- Processing commands (e.g. CH vs MLD processing)
|
|
||||||
- Server queries
|
|
||||||
|
|
||||||
If you're reporting an issue with https://map.project-osrm.org, please provide a link to the problematic request.
|
|
||||||
|
|
||||||
# Specifications
|
|
||||||
|
|
||||||
Please provide details of your development environment.
|
|
||||||
- Library/dependency versions
|
|
||||||
- Operating system
|
|
||||||
- Hardware
|
|
10
.github/ISSUE_TEMPLATE/feature.md
vendored
@ -1,10 +0,0 @@
|
|||||||
---
|
|
||||||
name: Feature Request
|
|
||||||
about: Request a new feature in osrm-backend
|
|
||||||
labels: Feature Request
|
|
||||||
---
|
|
||||||
|
|
||||||
# Feature
|
|
||||||
|
|
||||||
Please describe the feature you would like to see in OSRM.
|
|
||||||
Images are often a good way to illustrate your requested feature.
|
|
19
.github/PULL_REQUEST_TEMPLATE.md
vendored
@ -1,19 +0,0 @@
|
|||||||
# Issue
|
|
||||||
|
|
||||||
What issue is this PR targeting? If there is no issue that addresses the problem, please open a corresponding issue and link it here.
|
|
||||||
|
|
||||||
Please read our [documentation](https://github.com/Project-OSRM/osrm-backend/blob/master/docs/releasing.md) on release and version management.
|
|
||||||
If your PR is still work in progress please attach the relevant label.
|
|
||||||
|
|
||||||
## Tasklist
|
|
||||||
|
|
||||||
- [ ] CHANGELOG.md entry ([How to write a changelog entry](http://keepachangelog.com/en/1.0.0/#how))
|
|
||||||
- [ ] update relevant [Wiki pages](https://github.com/Project-OSRM/osrm-backend/wiki)
|
|
||||||
- [ ] add tests (see [testing documentation](https://github.com/Project-OSRM/osrm-backend/blob/master/docs/testing.md))
|
|
||||||
- [ ] review
|
|
||||||
- [ ] adjust for comments
|
|
||||||
- [ ] cherry pick to release branch
|
|
||||||
|
|
||||||
## Requirements / Relations
|
|
||||||
|
|
||||||
Link any requirements here. Other pull requests this PR is based on?
|
|
84
.github/workflows/osrm-backend-docker.yml
vendored
@ -1,84 +0,0 @@
|
|||||||
name: build and publish container image
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- 'v*'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
publish:
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
docker-base-image: ["debian", "alpine"]
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Check out the repo
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Set up QEMU
|
|
||||||
uses: docker/setup-qemu-action@v1
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v1
|
|
||||||
|
|
||||||
- name: Docker meta
|
|
||||||
id: meta
|
|
||||||
uses: docker/metadata-action@v3
|
|
||||||
with:
|
|
||||||
images: ghcr.io/${{ github.repository }}
|
|
||||||
|
|
||||||
- name: Docker meta - debug
|
|
||||||
id: metadebug
|
|
||||||
uses: docker/metadata-action@v3
|
|
||||||
with:
|
|
||||||
images: ghcr.io/${{ github.repository }}
|
|
||||||
flavor: |
|
|
||||||
latest=true
|
|
||||||
suffix=-debug,onlatest=true
|
|
||||||
|
|
||||||
- name: Docker meta - assertions
|
|
||||||
id: metaassertions
|
|
||||||
uses: docker/metadata-action@v3
|
|
||||||
with:
|
|
||||||
images: ghcr.io/${{ github.repository }}
|
|
||||||
flavor: |
|
|
||||||
latest=true
|
|
||||||
suffix=-assertions,onlatest=true
|
|
||||||
|
|
||||||
- name: Log in to GitHub Docker Registry
|
|
||||||
uses: docker/login-action@v1
|
|
||||||
with:
|
|
||||||
registry: ghcr.io
|
|
||||||
username: ${{ github.actor }}
|
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Build container image - debug
|
|
||||||
uses: docker/build-push-action@v2
|
|
||||||
with:
|
|
||||||
push: true
|
|
||||||
platforms: linux/amd64,linux/arm64
|
|
||||||
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 container image - assertions
|
|
||||||
uses: docker/build-push-action@v2
|
|
||||||
with:
|
|
||||||
push: true
|
|
||||||
platforms: linux/amd64,linux/arm64
|
|
||||||
file: ./docker/Dockerfile-${{ matrix.docker-base-image }}
|
|
||||||
tags: ${{ steps.metaassertions.outputs.tags }}
|
|
||||||
build-args: |
|
|
||||||
DOCKER_TAG=${{ join(steps.metaassertions.outputs.tags ) }}-${{ matrix.docker-base-image }}
|
|
||||||
|
|
||||||
# build and publish "normal" image as last to get it listed on top
|
|
||||||
- name: Build container image - normal
|
|
||||||
uses: docker/build-push-action@v2
|
|
||||||
with:
|
|
||||||
push: true
|
|
||||||
platforms: linux/amd64,linux/arm64
|
|
||||||
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 }}
|
|
786
.github/workflows/osrm-backend.yml
vendored
@ -1,786 +0,0 @@
|
|||||||
name: osrm-backend CI
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
tags:
|
|
||||||
- v[1-9]+.[0-9]+.[0-9]+
|
|
||||||
- v[1-9]+.[0-9]+.[0-9]+-[a-zA-Z]+.[0-9]+
|
|
||||||
- v[1-9]+.[0-9]+-[0-9a-zA-Z]+
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
|
|
||||||
env:
|
|
||||||
CCACHE_TEMPDIR: /tmp/.ccache-temp
|
|
||||||
CCACHE_COMPRESS: 1
|
|
||||||
CASHER_TIME_OUT: 599 # one second less than 10m to avoid 10m timeout error: https://github.com/Project-OSRM/osrm-backend/issues/2742
|
|
||||||
CMAKE_VERSION: 3.21.2
|
|
||||||
ENABLE_NODE_BINDINGS: "ON"
|
|
||||||
|
|
||||||
concurrency:
|
|
||||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
|
||||||
cancel-in-progress: true
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
windows-release-node:
|
|
||||||
needs: format-taginfo-docs
|
|
||||||
runs-on: windows-2022
|
|
||||||
continue-on-error: false
|
|
||||||
env:
|
|
||||||
BUILD_TYPE: Release
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- run: pip install "conan<2.0.0"
|
|
||||||
- run: conan --version
|
|
||||||
- run: cmake --version
|
|
||||||
- uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: 18
|
|
||||||
- run: node --version
|
|
||||||
- run: npm --version
|
|
||||||
- name: Prepare environment
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
PACKAGE_JSON_VERSION=$(node -e "console.log(require('./package.json').version)")
|
|
||||||
echo PUBLISH=$([[ "${GITHUB_REF:-}" == "refs/tags/v${PACKAGE_JSON_VERSION}" ]] && echo "On" || echo "Off") >> $GITHUB_ENV
|
|
||||||
- run: npm install --ignore-scripts
|
|
||||||
- run: npm link --ignore-scripts
|
|
||||||
- name: Build
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
mkdir build
|
|
||||||
cd build
|
|
||||||
cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_CONAN=ON -DENABLE_NODE_BINDINGS=ON ..
|
|
||||||
cmake --build . --config Release
|
|
||||||
|
|
||||||
# TODO: MSVC goes out of memory when building our tests
|
|
||||||
# - name: Run tests
|
|
||||||
# shell: bash
|
|
||||||
# run: |
|
|
||||||
# cd build
|
|
||||||
# cmake --build . --config Release --target tests
|
|
||||||
# # TODO: run tests
|
|
||||||
# - name: Run node tests
|
|
||||||
# shell: bash
|
|
||||||
# run: |
|
|
||||||
# ./lib/binding/osrm-extract.exe -p profiles/car.lua test/data/monaco.osm.pbf
|
|
||||||
|
|
||||||
# mkdir -p test/data/ch
|
|
||||||
# cp test/data/monaco.osrm* test/data/ch/
|
|
||||||
# ./lib/binding/osrm-contract.exe test/data/ch/monaco.osrm
|
|
||||||
|
|
||||||
# ./lib/binding/osrm-datastore.exe test/data/ch/monaco.osrm
|
|
||||||
# node test/nodejs/index.js
|
|
||||||
- name: Build Node package
|
|
||||||
shell: bash
|
|
||||||
run: ./scripts/ci/node_package.sh
|
|
||||||
- name: Publish Node package
|
|
||||||
if: ${{ env.PUBLISH == 'On' }}
|
|
||||||
uses: ncipollo/release-action@v1
|
|
||||||
with:
|
|
||||||
allowUpdates: true
|
|
||||||
artifactErrorsFailBuild: true
|
|
||||||
artifacts: build/stage/**/*.tar.gz
|
|
||||||
omitBody: true
|
|
||||||
omitBodyDuringUpdate: true
|
|
||||||
omitName: true
|
|
||||||
omitNameDuringUpdate: true
|
|
||||||
replacesArtifacts: true
|
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
format-taginfo-docs:
|
|
||||||
runs-on: ubuntu-22.04
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- name: Use Node.js
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: 18
|
|
||||||
- name: Enable Node.js cache
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: ~/.npm
|
|
||||||
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-node-
|
|
||||||
- name: Prepare environment
|
|
||||||
run: |
|
|
||||||
npm ci --ignore-scripts
|
|
||||||
clang-format-15 --version
|
|
||||||
- name: Run checks
|
|
||||||
run: |
|
|
||||||
./scripts/check_taginfo.py taginfo.json profiles/car.lua
|
|
||||||
./scripts/format.sh && ./scripts/error_on_dirty.sh
|
|
||||||
node ./scripts/validate_changelog.js
|
|
||||||
npm run docs && ./scripts/error_on_dirty.sh
|
|
||||||
npm audit --production
|
|
||||||
|
|
||||||
docker-image-matrix:
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
docker-base-image: ["debian", "alpine"]
|
|
||||||
needs: format-taginfo-docs
|
|
||||||
runs-on: ubuntu-22.04
|
|
||||||
continue-on-error: false
|
|
||||||
steps:
|
|
||||||
- name: Check out the repo
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
- name: Enable osm.pbf cache
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: berlin-latest.osm.pbf
|
|
||||||
key: v1-berlin-osm-pbf
|
|
||||||
restore-keys: |
|
|
||||||
v1-berlin-osm-pbf
|
|
||||||
- name: Docker build
|
|
||||||
run: |
|
|
||||||
docker build -t osrm-backend-local -f docker/Dockerfile-${{ matrix.docker-base-image }} .
|
|
||||||
- name: Test Docker image
|
|
||||||
run: |
|
|
||||||
if [ ! -f "${PWD}/berlin-latest.osm.pbf" ]; then
|
|
||||||
wget http://download.geofabrik.de/europe/germany/berlin-latest.osm.pbf
|
|
||||||
fi
|
|
||||||
TAG=osrm-backend-local
|
|
||||||
# when `--memory-swap` value equals `--memory` it means container won't use swap
|
|
||||||
# see https://docs.docker.com/config/containers/resource_constraints/#--memory-swap-details
|
|
||||||
MEMORY_ARGS="--memory=1g --memory-swap=1g"
|
|
||||||
docker run $MEMORY_ARGS -t -v "${PWD}:/data" "${TAG}" osrm-extract --dump-nbg-graph -p /opt/car.lua /data/berlin-latest.osm.pbf
|
|
||||||
docker run $MEMORY_ARGS -t -v "${PWD}:/data" "${TAG}" osrm-components /data/berlin-latest.osrm.nbg /data/berlin-latest.geojson
|
|
||||||
if [ ! -s "${PWD}/berlin-latest.geojson" ]
|
|
||||||
then
|
|
||||||
>&2 echo "No berlin-latest.geojson found"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
# removing `.osrm.nbg` to check that whole pipeline works without it
|
|
||||||
rm -rf "${PWD}/berlin-latest.osrm.nbg"
|
|
||||||
|
|
||||||
docker run $MEMORY_ARGS -t -v "${PWD}:/data" "${TAG}" osrm-partition /data/berlin-latest.osrm
|
|
||||||
docker run $MEMORY_ARGS -t -v "${PWD}:/data" "${TAG}" osrm-customize /data/berlin-latest.osrm
|
|
||||||
docker run $MEMORY_ARGS --name=osrm-container -t -p 5000:5000 -v "${PWD}:/data" "${TAG}" osrm-routed --algorithm mld /data/berlin-latest.osrm &
|
|
||||||
curl --retry-delay 3 --retry 10 --retry-all-errors "http://127.0.0.1:5000/route/v1/driving/13.388860,52.517037;13.385983,52.496891?steps=true"
|
|
||||||
docker stop osrm-container
|
|
||||||
|
|
||||||
build-test-publish:
|
|
||||||
needs: format-taginfo-docs
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- name: gcc-13-debug-cov
|
|
||||||
continue-on-error: false
|
|
||||||
node: 20
|
|
||||||
runs-on: ubuntu-24.04
|
|
||||||
BUILD_TOOLS: ON
|
|
||||||
BUILD_TYPE: Debug
|
|
||||||
CCOMPILER: gcc-13
|
|
||||||
CUCUMBER_TIMEOUT: 20000
|
|
||||||
CXXCOMPILER: g++-13
|
|
||||||
ENABLE_COVERAGE: ON
|
|
||||||
|
|
||||||
- name: clang-18-debug-asan-ubsan
|
|
||||||
continue-on-error: false
|
|
||||||
node: 20
|
|
||||||
runs-on: ubuntu-24.04
|
|
||||||
BUILD_TOOLS: ON
|
|
||||||
BUILD_TYPE: Debug
|
|
||||||
CCOMPILER: clang-18
|
|
||||||
CUCUMBER_TIMEOUT: 20000
|
|
||||||
CXXCOMPILER: clang++-18
|
|
||||||
ENABLE_SANITIZER: ON
|
|
||||||
TARGET_ARCH: x86_64-asan-ubsan
|
|
||||||
OSRM_CONNECTION_RETRIES: 10
|
|
||||||
OSRM_CONNECTION_EXP_BACKOFF_COEF: 1.5
|
|
||||||
|
|
||||||
- name: clang-18-release
|
|
||||||
continue-on-error: false
|
|
||||||
node: 18
|
|
||||||
runs-on: ubuntu-24.04
|
|
||||||
BUILD_TOOLS: ON
|
|
||||||
BUILD_TYPE: Release
|
|
||||||
CCOMPILER: clang-18
|
|
||||||
CXXCOMPILER: clang++-18
|
|
||||||
CUCUMBER_TIMEOUT: 60000
|
|
||||||
ENABLE_LTO: OFF
|
|
||||||
|
|
||||||
- name: clang-18-debug
|
|
||||||
continue-on-error: false
|
|
||||||
node: 18
|
|
||||||
runs-on: ubuntu-24.04
|
|
||||||
BUILD_TOOLS: ON
|
|
||||||
BUILD_TYPE: Debug
|
|
||||||
CCOMPILER: clang-18
|
|
||||||
CXXCOMPILER: clang++-18
|
|
||||||
CUCUMBER_TIMEOUT: 60000
|
|
||||||
ENABLE_LTO: OFF
|
|
||||||
|
|
||||||
- name: clang-18-debug-clang-tidy
|
|
||||||
continue-on-error: false
|
|
||||||
node: 18
|
|
||||||
runs-on: ubuntu-24.04
|
|
||||||
BUILD_TOOLS: ON
|
|
||||||
BUILD_TYPE: Debug
|
|
||||||
CCOMPILER: clang-18
|
|
||||||
CXXCOMPILER: clang++-18
|
|
||||||
CUCUMBER_TIMEOUT: 60000
|
|
||||||
ENABLE_CLANG_TIDY: ON
|
|
||||||
|
|
||||||
|
|
||||||
- name: clang-17-release
|
|
||||||
continue-on-error: false
|
|
||||||
node: 18
|
|
||||||
runs-on: ubuntu-24.04
|
|
||||||
BUILD_TOOLS: ON
|
|
||||||
BUILD_TYPE: Release
|
|
||||||
CCOMPILER: clang-17
|
|
||||||
CXXCOMPILER: clang++-17
|
|
||||||
CUCUMBER_TIMEOUT: 60000
|
|
||||||
ENABLE_LTO: OFF
|
|
||||||
|
|
||||||
- name: clang-16-release
|
|
||||||
continue-on-error: false
|
|
||||||
node: 18
|
|
||||||
runs-on: ubuntu-24.04
|
|
||||||
BUILD_TOOLS: ON
|
|
||||||
BUILD_TYPE: Release
|
|
||||||
CCOMPILER: clang-16
|
|
||||||
CXXCOMPILER: clang++-16
|
|
||||||
CUCUMBER_TIMEOUT: 60000
|
|
||||||
ENABLE_LTO: OFF
|
|
||||||
|
|
||||||
- name: conan-linux-debug-asan-ubsan
|
|
||||||
continue-on-error: false
|
|
||||||
node: 18
|
|
||||||
runs-on: ubuntu-24.04
|
|
||||||
BUILD_TOOLS: ON
|
|
||||||
BUILD_TYPE: Release
|
|
||||||
CCOMPILER: clang-18
|
|
||||||
CXXCOMPILER: clang++-18
|
|
||||||
ENABLE_CONAN: ON
|
|
||||||
ENABLE_SANITIZER: ON
|
|
||||||
ENABLE_LTO: OFF
|
|
||||||
|
|
||||||
- name: conan-linux-release
|
|
||||||
continue-on-error: false
|
|
||||||
node: 18
|
|
||||||
runs-on: ubuntu-24.04
|
|
||||||
BUILD_TOOLS: ON
|
|
||||||
BUILD_TYPE: Release
|
|
||||||
CCOMPILER: clang-18
|
|
||||||
CXXCOMPILER: clang++-18
|
|
||||||
ENABLE_CONAN: ON
|
|
||||||
ENABLE_LTO: OFF
|
|
||||||
|
|
||||||
- name: gcc-14-release
|
|
||||||
continue-on-error: false
|
|
||||||
node: 20
|
|
||||||
runs-on: ubuntu-24.04
|
|
||||||
BUILD_TOOLS: ON
|
|
||||||
BUILD_TYPE: Release
|
|
||||||
CCOMPILER: gcc-14
|
|
||||||
CXXCOMPILER: g++-14
|
|
||||||
CXXFLAGS: '-Wno-array-bounds -Wno-uninitialized'
|
|
||||||
|
|
||||||
- name: gcc-13-release
|
|
||||||
continue-on-error: false
|
|
||||||
node: 20
|
|
||||||
runs-on: ubuntu-24.04
|
|
||||||
BUILD_TOOLS: ON
|
|
||||||
BUILD_TYPE: Release
|
|
||||||
CCOMPILER: gcc-13
|
|
||||||
CXXCOMPILER: g++-13
|
|
||||||
CXXFLAGS: '-Wno-array-bounds -Wno-uninitialized'
|
|
||||||
|
|
||||||
- name: gcc-12-release
|
|
||||||
continue-on-error: false
|
|
||||||
node: 20
|
|
||||||
runs-on: ubuntu-22.04
|
|
||||||
BUILD_TOOLS: ON
|
|
||||||
BUILD_TYPE: Release
|
|
||||||
CCOMPILER: gcc-12
|
|
||||||
CXXCOMPILER: g++-12
|
|
||||||
CXXFLAGS: '-Wno-array-bounds -Wno-uninitialized'
|
|
||||||
|
|
||||||
- name: conan-linux-release-node
|
|
||||||
build_node_package: true
|
|
||||||
continue-on-error: false
|
|
||||||
node: 20
|
|
||||||
runs-on: ubuntu-24.04
|
|
||||||
BUILD_TYPE: Release
|
|
||||||
CCOMPILER: clang-16
|
|
||||||
CXXCOMPILER: clang++-16
|
|
||||||
ENABLE_CONAN: ON
|
|
||||||
NODE_PACKAGE_TESTS_ONLY: ON
|
|
||||||
|
|
||||||
- name: conan-linux-debug-node
|
|
||||||
build_node_package: true
|
|
||||||
continue-on-error: false
|
|
||||||
node: 20
|
|
||||||
runs-on: ubuntu-24.04
|
|
||||||
BUILD_TYPE: Debug
|
|
||||||
CCOMPILER: clang-16
|
|
||||||
CXXCOMPILER: clang++-16
|
|
||||||
ENABLE_CONAN: ON
|
|
||||||
NODE_PACKAGE_TESTS_ONLY: ON
|
|
||||||
|
|
||||||
- name: conan-macos-x64-release-node
|
|
||||||
build_node_package: true
|
|
||||||
continue-on-error: true
|
|
||||||
node: 20
|
|
||||||
runs-on: macos-13 # x86_64
|
|
||||||
BUILD_TYPE: Release
|
|
||||||
CCOMPILER: clang
|
|
||||||
CXXCOMPILER: clang++
|
|
||||||
CUCUMBER_TIMEOUT: 60000
|
|
||||||
ENABLE_ASSERTIONS: ON
|
|
||||||
ENABLE_CONAN: ON
|
|
||||||
|
|
||||||
- name: conan-macos-arm64-release-node
|
|
||||||
build_node_package: true
|
|
||||||
continue-on-error: true
|
|
||||||
node: 20
|
|
||||||
runs-on: macos-14 # arm64
|
|
||||||
BUILD_TYPE: Release
|
|
||||||
CCOMPILER: clang
|
|
||||||
CXXCOMPILER: clang++
|
|
||||||
CUCUMBER_TIMEOUT: 60000
|
|
||||||
ENABLE_ASSERTIONS: ON
|
|
||||||
ENABLE_CONAN: ON
|
|
||||||
|
|
||||||
name: ${{ matrix.name}}
|
|
||||||
continue-on-error: ${{ matrix.continue-on-error }}
|
|
||||||
runs-on: ${{ matrix.runs-on }}
|
|
||||||
env:
|
|
||||||
BUILD_TOOLS: ${{ matrix.BUILD_TOOLS }}
|
|
||||||
BUILD_TYPE: ${{ matrix.BUILD_TYPE }}
|
|
||||||
BUILD_SHARED_LIBS: ${{ matrix.BUILD_SHARED_LIBS }}
|
|
||||||
CCOMPILER: ${{ matrix.CCOMPILER }}
|
|
||||||
CFLAGS: ${{ matrix.CFLAGS }}
|
|
||||||
CUCUMBER_TIMEOUT: ${{ matrix.CUCUMBER_TIMEOUT }}
|
|
||||||
CXXCOMPILER: ${{ matrix.CXXCOMPILER }}
|
|
||||||
CXXFLAGS: ${{ matrix.CXXFLAGS }}
|
|
||||||
ENABLE_ASSERTIONS: ${{ matrix.ENABLE_ASSERTIONS }}
|
|
||||||
ENABLE_CLANG_TIDY: ${{ matrix.ENABLE_CLANG_TIDY }}
|
|
||||||
ENABLE_COVERAGE: ${{ matrix.ENABLE_COVERAGE }}
|
|
||||||
ENABLE_CONAN: ${{ matrix.ENABLE_CONAN }}
|
|
||||||
ENABLE_SANITIZER: ${{ matrix.ENABLE_SANITIZER }}
|
|
||||||
NODE_PACKAGE_TESTS_ONLY: ${{ matrix.NODE_PACKAGE_TESTS_ONLY }}
|
|
||||||
TARGET_ARCH: ${{ matrix.TARGET_ARCH }}
|
|
||||||
OSRM_CONNECTION_RETRIES: ${{ matrix.OSRM_CONNECTION_RETRIES }}
|
|
||||||
OSRM_CONNECTION_EXP_BACKOFF_COEF: ${{ matrix.OSRM_CONNECTION_EXP_BACKOFF_COEF }}
|
|
||||||
ENABLE_LTO: ${{ matrix.ENABLE_LTO }}
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- name: Build machine architecture
|
|
||||||
run: uname -m
|
|
||||||
- name: Use Node.js
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: ${{ matrix.node }}
|
|
||||||
- name: Enable Node.js cache
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: ~/.npm
|
|
||||||
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-node-
|
|
||||||
- name: Enable compiler cache
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: ~/.ccache
|
|
||||||
key: ccache-${{ matrix.name }}-${{ github.sha }}
|
|
||||||
restore-keys: |
|
|
||||||
ccache-${{ matrix.name }}-
|
|
||||||
- name: Enable Conan cache
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: ~/.conan
|
|
||||||
key: v9-conan-${{ matrix.name }}-${{ github.sha }}
|
|
||||||
restore-keys: |
|
|
||||||
v9-conan-${{ matrix.name }}-
|
|
||||||
- name: Enable test cache
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: ${{github.workspace}}/test/cache
|
|
||||||
key: v4-test-${{ matrix.name }}-${{ github.sha }}
|
|
||||||
restore-keys: |
|
|
||||||
v4-test-${{ matrix.name }}-
|
|
||||||
- name: Prepare environment
|
|
||||||
run: |
|
|
||||||
echo "CCACHE_DIR=$HOME/.ccache" >> $GITHUB_ENV
|
|
||||||
mkdir -p $HOME/.ccache
|
|
||||||
|
|
||||||
PACKAGE_JSON_VERSION=$(node -e "console.log(require('./package.json').version)")
|
|
||||||
echo PUBLISH=$([[ "${GITHUB_REF:-}" == "refs/tags/v${PACKAGE_JSON_VERSION}" ]] && echo "On" || echo "Off") >> $GITHUB_ENV
|
|
||||||
echo "OSRM_INSTALL_DIR=${GITHUB_WORKSPACE}/install-osrm" >> $GITHUB_ENV
|
|
||||||
echo "OSRM_BUILD_DIR=${GITHUB_WORKSPACE}/build-osrm" >> $GITHUB_ENV
|
|
||||||
if [[ "$ENABLE_SANITIZER" == 'ON' ]]; then
|
|
||||||
# We can only set this after checkout once we know the workspace directory
|
|
||||||
echo "LSAN_OPTIONS=print_suppressions=0:suppressions=${GITHUB_WORKSPACE}/scripts/ci/leaksanitizer.conf" >> $GITHUB_ENV
|
|
||||||
echo "UBSAN_OPTIONS=symbolize=1:halt_on_error=1:print_stacktrace=1:suppressions=${GITHUB_WORKSPACE}/scripts/ci/undefinedsanitizer.conf" >> $GITHUB_ENV
|
|
||||||
echo "ASAN_OPTIONS=print_suppressions=0:suppressions=${GITHUB_WORKSPACE}/scripts/ci/addresssanitizer.conf" >> $GITHUB_ENV
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "${RUNNER_OS}" == "Linux" ]]; then
|
|
||||||
echo "JOBS=$((`nproc` + 1))" >> $GITHUB_ENV
|
|
||||||
elif [[ "${RUNNER_OS}" == "macOS" ]]; then
|
|
||||||
echo "JOBS=$((`sysctl -n hw.ncpu` + 1))" >> $GITHUB_ENV
|
|
||||||
fi
|
|
||||||
# See: https://github.com/actions/toolkit/issues/946#issuecomment-1590016041
|
|
||||||
# We need it to be able to access system folders while restoring cached Boost below
|
|
||||||
- name: Give tar root ownership
|
|
||||||
if: runner.os == 'Linux' && matrix.ENABLE_CONAN != 'ON'
|
|
||||||
run: sudo chown root /bin/tar && sudo chmod u+s /bin/tar
|
|
||||||
- name: Cache Boost
|
|
||||||
if: runner.os == 'Linux' && matrix.ENABLE_CONAN != 'ON'
|
|
||||||
id: cache-boost
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
/usr/local/include/boost
|
|
||||||
/usr/local/lib/libboost*
|
|
||||||
key: v1-boost-${{ runner.os }}-${{ runner.arch }}-${{ matrix.runs-on }}
|
|
||||||
restore-keys: |
|
|
||||||
v1-boost-${{ runner.os }}-${{ runner.arch }}-${{ matrix.runs-on }}
|
|
||||||
|
|
||||||
- name: Install Boost
|
|
||||||
if: steps.cache-boost.outputs.cache-hit != 'true' && runner.os == 'Linux' && matrix.ENABLE_CONAN != 'ON'
|
|
||||||
run: |
|
|
||||||
BOOST_VERSION="1.85.0"
|
|
||||||
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}*
|
|
||||||
|
|
||||||
- name: Install dev dependencies
|
|
||||||
run: |
|
|
||||||
python3 -m pip install "conan<2.0.0" || python3 -m pip install "conan<2.0.0" --break-system-packages
|
|
||||||
|
|
||||||
# workaround for issue that GitHub Actions seems to not adding it to PATH after https://github.com/actions/runner-images/pull/6499
|
|
||||||
# and that's why CI cannot find conan executable installed above
|
|
||||||
if [[ "${RUNNER_OS}" == "macOS" ]]; then
|
|
||||||
echo "/Library/Frameworks/Python.framework/Versions/Current/bin" >> $GITHUB_PATH
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ccache
|
|
||||||
if [[ "${RUNNER_OS}" == "Linux" ]]; then
|
|
||||||
sudo apt-get update -y && sudo apt-get install ccache
|
|
||||||
elif [[ "${RUNNER_OS}" == "macOS" ]]; then
|
|
||||||
brew install ccache
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Linux dev packages
|
|
||||||
if [ "${ENABLE_CONAN}" != "ON" ]; then
|
|
||||||
sudo apt-get update -y
|
|
||||||
sudo apt-get install -y libbz2-dev libxml2-dev libzip-dev liblua5.2-dev
|
|
||||||
if [[ "${CCOMPILER}" != clang-* ]]; then
|
|
||||||
sudo apt-get install -y ${CXXCOMPILER}
|
|
||||||
fi
|
|
||||||
if [[ "${ENABLE_COVERAGE}" == "ON" ]]; then
|
|
||||||
sudo apt-get install -y lcov
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# TBB
|
|
||||||
TBB_VERSION=2021.12.0
|
|
||||||
if [[ "${RUNNER_OS}" == "Linux" ]]; then
|
|
||||||
TBB_URL="https://github.com/oneapi-src/oneTBB/releases/download/v${TBB_VERSION}/oneapi-tbb-${TBB_VERSION}-lin.tgz"
|
|
||||||
elif [[ "${RUNNER_OS}" == "macOS" ]]; then
|
|
||||||
TBB_URL="https://github.com/oneapi-src/oneTBB/releases/download/v${TBB_VERSION}/oneapi-tbb-${TBB_VERSION}-mac.tgz"
|
|
||||||
fi
|
|
||||||
wget --tries 5 ${TBB_URL} -O onetbb.tgz
|
|
||||||
tar zxvf onetbb.tgz
|
|
||||||
sudo cp -a oneapi-tbb-${TBB_VERSION}/lib/. /usr/local/lib/
|
|
||||||
sudo cp -a oneapi-tbb-${TBB_VERSION}/include/. /usr/local/include/
|
|
||||||
- name: Add Clang 18 to list of Conan compilers # workaround for the issue that Conan 1.x doesn't know about Clang 18
|
|
||||||
if: ${{ matrix.ENABLE_CONAN == 'ON' && matrix.CCOMPILER == 'clang-18' }}
|
|
||||||
run: |
|
|
||||||
sudo wget https://github.com/mikefarah/yq/releases/download/v4.9.6/yq_linux_amd64 -O /usr/bin/yq && sudo chmod +x /usr/bin/yq
|
|
||||||
|
|
||||||
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}
|
|
||||||
ccache --max-size=256M
|
|
||||||
npm ci --ignore-scripts
|
|
||||||
if [[ "${ENABLE_COVERAGE}" == "ON" ]]; then
|
|
||||||
lcov --directory . --zerocounters # clean cached files
|
|
||||||
fi
|
|
||||||
echo "CC=${CCOMPILER}" >> $GITHUB_ENV
|
|
||||||
echo "CXX=${CXXCOMPILER}" >> $GITHUB_ENV
|
|
||||||
if [[ "${RUNNER_OS}" == "macOS" ]]; then
|
|
||||||
# missing from GCC path, needed for conan builds of libiconv, for example.
|
|
||||||
sudo xcode-select --switch /Library/Developer/CommandLineTools
|
|
||||||
echo "LIBRARY_PATH=${LIBRARY_PATH}:/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib" >> $GITHUB_ENV
|
|
||||||
echo "CPATH=${CPATH}:/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include" >> $GITHUB_ENV
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Build and install OSRM
|
|
||||||
run: |
|
|
||||||
echo "Using ${JOBS} jobs"
|
|
||||||
pushd ${OSRM_BUILD_DIR}
|
|
||||||
|
|
||||||
ccache --zero-stats
|
|
||||||
cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
|
|
||||||
-DENABLE_CONAN=${ENABLE_CONAN:-OFF} \
|
|
||||||
-DENABLE_ASSERTIONS=${ENABLE_ASSERTIONS:-OFF} \
|
|
||||||
-DENABLE_CLANG_TIDY=${ENABLE_CLANG_TIDY:-OFF} \
|
|
||||||
-DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS:-OFF} \
|
|
||||||
-DENABLE_COVERAGE=${ENABLE_COVERAGE:-OFF} \
|
|
||||||
-DENABLE_NODE_BINDINGS=${ENABLE_NODE_BINDINGS:-OFF} \
|
|
||||||
-DENABLE_SANITIZER=${ENABLE_SANITIZER:-OFF} \
|
|
||||||
-DBUILD_TOOLS=${BUILD_TOOLS:-OFF} \
|
|
||||||
-DENABLE_CCACHE=ON \
|
|
||||||
-DENABLE_LTO=${ENABLE_LTO:-ON} \
|
|
||||||
-DCMAKE_INSTALL_PREFIX=${OSRM_INSTALL_DIR}
|
|
||||||
make --jobs=${JOBS}
|
|
||||||
|
|
||||||
if [[ "${NODE_PACKAGE_TESTS_ONLY}" != "ON" ]]; then
|
|
||||||
make tests --jobs=${JOBS}
|
|
||||||
make benchmarks --jobs=${JOBS}
|
|
||||||
|
|
||||||
sudo make install
|
|
||||||
if [[ "${RUNNER_OS}" == "Linux" ]]; then
|
|
||||||
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${OSRM_INSTALL_DIR}/lib" >> $GITHUB_ENV
|
|
||||||
fi
|
|
||||||
echo "PKG_CONFIG_PATH=${OSRM_INSTALL_DIR}/lib/pkgconfig" >> $GITHUB_ENV
|
|
||||||
fi
|
|
||||||
popd
|
|
||||||
- name: Build example
|
|
||||||
if: ${{ matrix.NODE_PACKAGE_TESTS_ONLY != 'ON' }}
|
|
||||||
run: |
|
|
||||||
mkdir example/build && pushd example/build
|
|
||||||
cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE}
|
|
||||||
make --jobs=${JOBS}
|
|
||||||
popd
|
|
||||||
- name: Run all tests
|
|
||||||
if: ${{ matrix.NODE_PACKAGE_TESTS_ONLY != 'ON' }}
|
|
||||||
run: |
|
|
||||||
make -C test/data benchmark
|
|
||||||
|
|
||||||
# macOS SIP strips the linker path. Reset this inside the running shell
|
|
||||||
export LD_LIBRARY_PATH=${{ env.LD_LIBRARY_PATH }}
|
|
||||||
./example/build/osrm-example test/data/mld/monaco.osrm
|
|
||||||
|
|
||||||
# All tests assume to be run from the build directory
|
|
||||||
pushd ${OSRM_BUILD_DIR}
|
|
||||||
for i in ./unit_tests/*-tests ; do echo Running $i ; $i ; done
|
|
||||||
if [ -z "${ENABLE_SANITIZER}" ]; then
|
|
||||||
npm run nodejs-tests
|
|
||||||
fi
|
|
||||||
popd
|
|
||||||
npm test
|
|
||||||
|
|
||||||
- name: Use Node 18
|
|
||||||
if: ${{ matrix.NODE_PACKAGE_TESTS_ONLY == 'ON' }}
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: 18
|
|
||||||
- name: Run Node package tests on Node 18
|
|
||||||
if: ${{ matrix.NODE_PACKAGE_TESTS_ONLY == 'ON' }}
|
|
||||||
run: |
|
|
||||||
node --version
|
|
||||||
npm run nodejs-tests
|
|
||||||
- name: Use Node 20
|
|
||||||
if: ${{ matrix.NODE_PACKAGE_TESTS_ONLY == 'ON' }}
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: 20
|
|
||||||
- name: Run Node package tests on Node 20
|
|
||||||
if: ${{ matrix.NODE_PACKAGE_TESTS_ONLY == 'ON' }}
|
|
||||||
run: |
|
|
||||||
node --version
|
|
||||||
npm run nodejs-tests
|
|
||||||
- name: Use Node latest
|
|
||||||
if: ${{ matrix.NODE_PACKAGE_TESTS_ONLY == 'ON' }}
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: latest
|
|
||||||
- name: Run Node package tests on Node-latest
|
|
||||||
if: ${{ matrix.NODE_PACKAGE_TESTS_ONLY == 'ON' }}
|
|
||||||
run: |
|
|
||||||
node --version
|
|
||||||
npm run nodejs-tests
|
|
||||||
|
|
||||||
- name: Upload test logs
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
if: failure()
|
|
||||||
with:
|
|
||||||
name: logs
|
|
||||||
path: test/logs/
|
|
||||||
|
|
||||||
# - name: Generate code coverage
|
|
||||||
# if: ${{ matrix.ENABLE_COVERAGE == 'ON' }}
|
|
||||||
# run: |
|
|
||||||
# lcov --directory . --capture --output-file coverage.info # capture coverage info
|
|
||||||
# lcov --remove coverage.info '/usr/*' --output-file coverage.info # filter out system
|
|
||||||
# lcov --list coverage.info #debug info
|
|
||||||
|
|
||||||
# # Uploading report to CodeCov
|
|
||||||
# - name: Upload code coverage
|
|
||||||
# if: ${{ matrix.ENABLE_COVERAGE == 'ON' }}
|
|
||||||
# uses: codecov/codecov-action@v4
|
|
||||||
# with:
|
|
||||||
# files: coverage.info
|
|
||||||
# name: codecov-osrm-backend
|
|
||||||
# fail_ci_if_error: true
|
|
||||||
# verbose: true
|
|
||||||
- name: Build Node package
|
|
||||||
if: ${{ matrix.build_node_package }}
|
|
||||||
run: ./scripts/ci/node_package.sh
|
|
||||||
- name: Publish Node package
|
|
||||||
if: ${{ matrix.build_node_package && env.PUBLISH == 'On' }}
|
|
||||||
uses: ncipollo/release-action@v1
|
|
||||||
with:
|
|
||||||
allowUpdates: true
|
|
||||||
artifactErrorsFailBuild: true
|
|
||||||
artifacts: build/stage/**/*.tar.gz
|
|
||||||
omitBody: true
|
|
||||||
omitBodyDuringUpdate: true
|
|
||||||
omitName: true
|
|
||||||
omitNameDuringUpdate: true
|
|
||||||
replacesArtifacts: true
|
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
- name: Show CCache statistics
|
|
||||||
run: |
|
|
||||||
ccache -p
|
|
||||||
ccache -s
|
|
||||||
|
|
||||||
benchmarks:
|
|
||||||
if: github.event_name == 'pull_request'
|
|
||||||
needs: [format-taginfo-docs]
|
|
||||||
runs-on: self-hosted
|
|
||||||
env:
|
|
||||||
CCOMPILER: clang-16
|
|
||||||
CXXCOMPILER: clang++-16
|
|
||||||
CC: clang-16
|
|
||||||
CXX: clang++-16
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
PR_NUMBER: ${{ github.event.pull_request.number }}
|
|
||||||
GITHUB_REPOSITORY: ${{ github.repository }}
|
|
||||||
RUN_BIG_BENCHMARK: ${{ contains(github.event.pull_request.labels.*.name, 'Performance') }}
|
|
||||||
steps:
|
|
||||||
- name: Checkout PR Branch
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
ref: ${{ github.head_ref }}
|
|
||||||
path: pr
|
|
||||||
- name: Activate virtualenv
|
|
||||||
run: |
|
|
||||||
python3 -m venv .venv
|
|
||||||
source .venv/bin/activate
|
|
||||||
echo PATH=$PATH >> $GITHUB_ENV
|
|
||||||
pip install "conan<2.0.0" "requests==2.31.0" "numpy==1.26.4"
|
|
||||||
- name: Prepare data
|
|
||||||
run: |
|
|
||||||
if [ "$RUN_BIG_BENCHMARK" = "true" ]; then
|
|
||||||
rm -rf ~/data.osm.pbf
|
|
||||||
wget http://download.geofabrik.de/europe/poland-latest.osm.pbf -O ~/data.osm.pbf --quiet
|
|
||||||
gunzip -c ./pr/test/data/poland_gps_traces.csv.gz > ~/gps_traces.csv
|
|
||||||
else
|
|
||||||
if [ ! -f "~/data.osm.pbf" ]; then
|
|
||||||
wget http://download.geofabrik.de/europe/germany/berlin-latest.osm.pbf -O ~/data.osm.pbf
|
|
||||||
else
|
|
||||||
echo "Using cached data.osm.pbf"
|
|
||||||
fi
|
|
||||||
gunzip -c ./pr/test/data/berlin_gps_traces.csv.gz > ~/gps_traces.csv
|
|
||||||
fi
|
|
||||||
- name: Prepare environment
|
|
||||||
run: |
|
|
||||||
echo "CCACHE_DIR=$HOME/.ccache" >> $GITHUB_ENV
|
|
||||||
mkdir -p $HOME/.ccache
|
|
||||||
ccache --zero-stats
|
|
||||||
ccache --max-size=256M
|
|
||||||
- name: Checkout Base Branch
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
ref: ${{ github.event.pull_request.base.ref }}
|
|
||||||
path: base
|
|
||||||
- name: Build Base Branch
|
|
||||||
run: |
|
|
||||||
cd base
|
|
||||||
npm ci --ignore-scripts
|
|
||||||
cd ..
|
|
||||||
mkdir base/build
|
|
||||||
cd base/build
|
|
||||||
cmake -DENABLE_CONAN=ON -DCMAKE_BUILD_TYPE=Release -DENABLE_NODE_BINDINGS=ON ..
|
|
||||||
make -j$(nproc)
|
|
||||||
make -j$(nproc) benchmarks
|
|
||||||
cd ..
|
|
||||||
make -C test/data
|
|
||||||
- name: Build PR Branch
|
|
||||||
run: |
|
|
||||||
cd pr
|
|
||||||
npm ci --ignore-scripts
|
|
||||||
cd ..
|
|
||||||
mkdir -p pr/build
|
|
||||||
cd pr/build
|
|
||||||
cmake -DENABLE_CONAN=ON -DCMAKE_BUILD_TYPE=Release -DENABLE_NODE_BINDINGS=ON ..
|
|
||||||
make -j$(nproc)
|
|
||||||
make -j$(nproc) benchmarks
|
|
||||||
cd ..
|
|
||||||
make -C test/data
|
|
||||||
# we run benchmarks in tmpfs to avoid impact of disk IO
|
|
||||||
- name: Create folder for tmpfs
|
|
||||||
run: |
|
|
||||||
# if by any chance it was mounted before(e.g. due to previous job failed), unmount it
|
|
||||||
sudo umount ~/benchmarks | true
|
|
||||||
rm -rf ~/benchmarks
|
|
||||||
mkdir -p ~/benchmarks
|
|
||||||
# see https://llvm.org/docs/Benchmarking.html
|
|
||||||
- name: Run PR Benchmarks
|
|
||||||
run: |
|
|
||||||
sudo cset shield -c 2-3 -k on
|
|
||||||
sudo mount -t tmpfs -o size=4g none ~/benchmarks
|
|
||||||
cp -rf pr/build ~/benchmarks/build
|
|
||||||
cp -rf pr/lib ~/benchmarks/lib
|
|
||||||
mkdir -p ~/benchmarks/test
|
|
||||||
cp -rf pr/test/data ~/benchmarks/test/data
|
|
||||||
cp -rf pr/profiles ~/benchmarks/profiles
|
|
||||||
|
|
||||||
sudo cset shield --exec -- ./pr/scripts/ci/run_benchmarks.sh -f ~/benchmarks -r $(pwd)/pr_results -s $(pwd)/pr -b ~/benchmarks/build -o ~/data.osm.pbf -g ~/gps_traces.csv
|
|
||||||
sudo umount ~/benchmarks
|
|
||||||
sudo cset shield --reset
|
|
||||||
- name: Run Base Benchmarks
|
|
||||||
run: |
|
|
||||||
sudo cset shield -c 2-3 -k on
|
|
||||||
sudo mount -t tmpfs -o size=4g none ~/benchmarks
|
|
||||||
cp -rf base/build ~/benchmarks/build
|
|
||||||
cp -rf base/lib ~/benchmarks/lib
|
|
||||||
mkdir -p ~/benchmarks/test
|
|
||||||
cp -rf base/test/data ~/benchmarks/test/data
|
|
||||||
cp -rf base/profiles ~/benchmarks/profiles
|
|
||||||
|
|
||||||
# TODO: remove it when base branch will have this file at needed location
|
|
||||||
if [ ! -f ~/benchmarks/test/data/portugal_to_korea.json ]; then
|
|
||||||
cp base/src/benchmarks/portugal_to_korea.json ~/benchmarks/test/data/portugal_to_korea.json
|
|
||||||
fi
|
|
||||||
# we intentionally use scripts from PR branch to be able to update them and see results in the same PR
|
|
||||||
sudo cset shield --exec -- cset shield --exec -- ./pr/scripts/ci/run_benchmarks.sh -f ~/benchmarks -r $(pwd)/base_results -s $(pwd)/pr -b ~/benchmarks/build -o ~/data.osm.pbf -g ~/gps_traces.csv
|
|
||||||
sudo umount ~/benchmarks
|
|
||||||
sudo cset shield --reset
|
|
||||||
- name: Post Benchmark Results
|
|
||||||
run: |
|
|
||||||
python3 pr/scripts/ci/post_benchmark_results.py base_results pr_results
|
|
||||||
- name: Show CCache statistics
|
|
||||||
run: |
|
|
||||||
ccache -p
|
|
||||||
ccache -s
|
|
||||||
|
|
||||||
ci-complete:
|
|
||||||
runs-on: ubuntu-22.04
|
|
||||||
needs: [build-test-publish, docker-image-matrix, windows-release-node, benchmarks]
|
|
||||||
steps:
|
|
||||||
- run: echo "CI complete"
|
|
||||||
|
|
29
.github/workflows/stale.yml
vendored
@ -1,29 +0,0 @@
|
|||||||
name: 'Close stale issues'
|
|
||||||
on:
|
|
||||||
# NOTE: uncomment if you want to test changes to this file in PRs CI
|
|
||||||
# pull_request:
|
|
||||||
# branches:
|
|
||||||
# - master
|
|
||||||
schedule:
|
|
||||||
- cron: '30 1 * * *' # every day at 1:30am
|
|
||||||
permissions:
|
|
||||||
issues: write
|
|
||||||
pull-requests: write
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
stale:
|
|
||||||
runs-on: ubuntu-24.04
|
|
||||||
steps:
|
|
||||||
- uses: actions/stale@v9
|
|
||||||
with:
|
|
||||||
operations-per-run: 3000
|
|
||||||
stale-issue-message: 'This issue seems to be stale. It will be closed in 30 days if no further activity occurs.'
|
|
||||||
stale-pr-message: 'This PR seems to be stale. Is it still relevant?'
|
|
||||||
days-before-issue-stale: 180 # 6 months
|
|
||||||
days-before-issue-close: 30 # 1 month
|
|
||||||
days-before-pr-stale: 180 # 6 months
|
|
||||||
days-before-pr-close: -1 # never close PRs
|
|
||||||
exempt-issue-labels: 'Do Not Stale,Feature Request,Performance,Bug Report,CI,Starter Task,Refactor,Guidance'
|
|
||||||
|
|
||||||
|
|
||||||
|
|
109
.gitignore
vendored
@ -1,107 +1,2 @@
|
|||||||
# pre compiled dependencies #
|
/.settings
|
||||||
#############################
|
/.project
|
||||||
osrm-deps
|
|
||||||
|
|
||||||
.ycm_extra_conf.py
|
|
||||||
|
|
||||||
# Compiled source #
|
|
||||||
###################
|
|
||||||
*.com
|
|
||||||
*.class
|
|
||||||
*.dll
|
|
||||||
*.exe
|
|
||||||
*.o
|
|
||||||
*.so
|
|
||||||
|
|
||||||
# Packages #
|
|
||||||
############
|
|
||||||
# it's better to unpack these files and commit the raw source
|
|
||||||
# git has its own built in compression methods
|
|
||||||
*.7z
|
|
||||||
*.dmg
|
|
||||||
*.gz
|
|
||||||
*.iso
|
|
||||||
*.jar
|
|
||||||
*.rar
|
|
||||||
*.tar
|
|
||||||
*.zip
|
|
||||||
|
|
||||||
# Logs and databases #
|
|
||||||
######################
|
|
||||||
*.log
|
|
||||||
*.sql
|
|
||||||
*.sqlite
|
|
||||||
|
|
||||||
# OS generated files #
|
|
||||||
######################
|
|
||||||
.DS_Store
|
|
||||||
ehthumbs.db
|
|
||||||
Icon?
|
|
||||||
Thumbs.db
|
|
||||||
|
|
||||||
# build related files #
|
|
||||||
#######################
|
|
||||||
/_build*
|
|
||||||
/build/
|
|
||||||
/example/build/
|
|
||||||
/test/data/monaco.osrm*
|
|
||||||
/test/data/ch
|
|
||||||
/test/data/mld
|
|
||||||
/cmake/postinst
|
|
||||||
|
|
||||||
# Eclipse related files #
|
|
||||||
#########################
|
|
||||||
.setting*
|
|
||||||
.scb
|
|
||||||
.cproject
|
|
||||||
.project
|
|
||||||
|
|
||||||
# Visual Studio (Code) related files #
|
|
||||||
######################################
|
|
||||||
/.vs*
|
|
||||||
/*.local.bat
|
|
||||||
/CMakeSettings.json
|
|
||||||
/.cache
|
|
||||||
|
|
||||||
# Jetbrains related files #
|
|
||||||
###########################
|
|
||||||
.idea/
|
|
||||||
|
|
||||||
# Compiled Binary Files #
|
|
||||||
####################################
|
|
||||||
/osrm-extract
|
|
||||||
/osrm-io-benchmark
|
|
||||||
/osrm-components
|
|
||||||
/osrm-routed
|
|
||||||
/osrm-datastore
|
|
||||||
/osrm-prepare
|
|
||||||
/osrm-unlock-all
|
|
||||||
/osrm-cli
|
|
||||||
/osrm-check-hsgr
|
|
||||||
/osrm-springclean
|
|
||||||
/nohup.out
|
|
||||||
|
|
||||||
# Sandbox folder #
|
|
||||||
###################
|
|
||||||
/sandbox/
|
|
||||||
|
|
||||||
# Test related files #
|
|
||||||
######################
|
|
||||||
/test/profile.lua
|
|
||||||
/test/cache
|
|
||||||
/test/speeds.csv
|
|
||||||
/test/penalties.csv
|
|
||||||
node_modules
|
|
||||||
|
|
||||||
# Deprecated config file #
|
|
||||||
##########################
|
|
||||||
/server.ini
|
|
||||||
|
|
||||||
*.swp
|
|
||||||
|
|
||||||
# local lua debugging file
|
|
||||||
debug.lua
|
|
||||||
|
|
||||||
# node-osrm artifacts
|
|
||||||
lib/binding
|
|
||||||
|
|
||||||
|
0
.gitmodules
vendored
16
.npmignore
@ -1,16 +0,0 @@
|
|||||||
*
|
|
||||||
!README.md
|
|
||||||
!CHANGELOG.md
|
|
||||||
!CONTRIBUTING.MD
|
|
||||||
!LICENCE.TXT
|
|
||||||
!package.json
|
|
||||||
!package-lock.json
|
|
||||||
!yarn.lock
|
|
||||||
!docs
|
|
||||||
!example
|
|
||||||
!taginfo.json
|
|
||||||
!lib/*.js
|
|
||||||
!profiles/*
|
|
||||||
!profiles/lib/*
|
|
||||||
!profiles/examples/*
|
|
||||||
!scripts/node_install.sh
|
|
1102
CHANGELOG.md
755
CMakeLists.txt
@ -1,755 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 3.18)
|
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
||||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
||||||
|
|
||||||
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR AND NOT MSVC_IDE)
|
|
||||||
message(FATAL_ERROR "In-source builds are not allowed.
|
|
||||||
Please create a directory and run cmake from there, passing the path to this source directory as the last argument.
|
|
||||||
This process created the file `CMakeCache.txt' and the directory `CMakeFiles'. Please delete them.")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# detect if this is included as subproject and if so expose
|
|
||||||
# some variables to its parent scope
|
|
||||||
get_directory_property(BUILD_AS_SUBPROJECT PARENT_DIRECTORY)
|
|
||||||
if(BUILD_AS_SUBPROJECT)
|
|
||||||
message(STATUS "Building libosrm as subproject.")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# set OSRM_BUILD_DIR location (might be used in various scripts)
|
|
||||||
if (NOT WIN32 AND NOT DEFINED ENV{OSRM_BUILD_DIR})
|
|
||||||
set(ENV{OSRM_BUILD_DIR} ${CMAKE_CURRENT_BINARY_DIR})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
option(ENABLE_CONAN "Use conan for dependencies" OFF)
|
|
||||||
option(ENABLE_CCACHE "Speed up incremental rebuilds via ccache" ON)
|
|
||||||
option(BUILD_TOOLS "Build OSRM tools" OFF)
|
|
||||||
option(BUILD_PACKAGE "Build OSRM package" OFF)
|
|
||||||
option(BUILD_ROUTED "Build osrm-routed HTTP server" ON)
|
|
||||||
option(ENABLE_ASSERTIONS "Use assertions in release mode" OFF)
|
|
||||||
option(ENABLE_DEBUG_LOGGING "Use debug logging in release mode" OFF)
|
|
||||||
option(ENABLE_COVERAGE "Build with coverage instrumentalisation" OFF)
|
|
||||||
option(ENABLE_SANITIZER "Use memory sanitizer for Debug build" OFF)
|
|
||||||
option(ENABLE_LTO "Use Link Time Optimisation" ON)
|
|
||||||
option(ENABLE_FUZZING "Fuzz testing using LLVM's libFuzzer" OFF)
|
|
||||||
option(ENABLE_NODE_BINDINGS "Build NodeJs bindings" OFF)
|
|
||||||
option(ENABLE_CLANG_TIDY "Enables clang-tidy checks" OFF)
|
|
||||||
|
|
||||||
|
|
||||||
if (ENABLE_CLANG_TIDY)
|
|
||||||
find_program(CLANG_TIDY_COMMAND NAMES clang-tidy)
|
|
||||||
if(NOT CLANG_TIDY_COMMAND)
|
|
||||||
message(FATAL_ERROR "ENABLE_CLANG_TIDY is ON but clang-tidy is not found!")
|
|
||||||
else()
|
|
||||||
message(STATUS "Found clang-tidy at ${CLANG_TIDY_COMMAND}")
|
|
||||||
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND};--warnings-as-errors=*;--header-filter=.*")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
|
||||||
|
|
||||||
# be compatible with version handling before cmake 3.x
|
|
||||||
if (POLICY CMP0057)
|
|
||||||
cmake_policy(SET CMP0057 NEW)
|
|
||||||
endif()
|
|
||||||
if (POLICY CMP0074)
|
|
||||||
cmake_policy(SET CMP0074 NEW)
|
|
||||||
endif()
|
|
||||||
if (POLICY CMP0167)
|
|
||||||
cmake_policy(SET CMP0167 NEW)
|
|
||||||
endif()
|
|
||||||
project(OSRM C CXX)
|
|
||||||
|
|
||||||
|
|
||||||
if(ENABLE_LTO AND (CMAKE_BUILD_TYPE MATCHES Release OR CMAKE_BUILD_TYPE MATCHES MinRelSize OR CMAKE_BUILD_TYPE MATCHES RelWithDebInfo))
|
|
||||||
include(CheckIPOSupported)
|
|
||||||
check_ipo_supported(RESULT LTO_SUPPORTED OUTPUT error)
|
|
||||||
if(LTO_SUPPORTED)
|
|
||||||
message(STATUS "IPO / LTO enabled")
|
|
||||||
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
|
|
||||||
else()
|
|
||||||
message(FATAL_ERROR "IPO / LTO not supported: <${error}>")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# add @loader_path/$ORIGIN to rpath to make binaries relocatable
|
|
||||||
if (APPLE)
|
|
||||||
set(CMAKE_BUILD_RPATH "@loader_path")
|
|
||||||
else()
|
|
||||||
set(CMAKE_BUILD_RPATH "\$ORIGIN")
|
|
||||||
# https://stackoverflow.com/questions/6324131/rpath-origin-not-having-desired-effect
|
|
||||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,origin")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
include(JSONParser)
|
|
||||||
file(READ "package.json" packagejsonraw)
|
|
||||||
sbeParseJson(packagejson packagejsonraw)
|
|
||||||
|
|
||||||
# This regex is not strict enough, but the correct one is too complicated for cmake matching.
|
|
||||||
# https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
|
|
||||||
if (packagejson.version MATCHES "^([0-9]+)\.([0-9]+)\.([0-9]+)([-+][0-9a-zA-Z.-]+)?$")
|
|
||||||
set(OSRM_VERSION_MAJOR ${CMAKE_MATCH_1})
|
|
||||||
set(OSRM_VERSION_MINOR ${CMAKE_MATCH_2})
|
|
||||||
set(OSRM_VERSION_PATCH ${CMAKE_MATCH_3})
|
|
||||||
set(OSRM_VERSION_PRERELEASE_BUILD ${CMAKE_MATCH_4})
|
|
||||||
|
|
||||||
set(OSRM_VERSION packagejson.version)
|
|
||||||
else()
|
|
||||||
message(FATAL_ERROR "Version from package.json cannot be parsed, expected semver compatible label, but found ${packagejson.version}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (MSVC)
|
|
||||||
add_definitions("-DOSRM_PROJECT_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}\"")
|
|
||||||
else()
|
|
||||||
add_definitions(-DOSRM_PROJECT_DIR="${CMAKE_CURRENT_SOURCE_DIR}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# these two functions build up custom variables:
|
|
||||||
# DEPENDENCIES_INCLUDE_DIRS and OSRM_DEFINES
|
|
||||||
# These variables we want to pass to
|
|
||||||
# include_directories and add_definitions for both
|
|
||||||
# this build and for sharing externally via pkg-config
|
|
||||||
|
|
||||||
function(add_dependency_includes)
|
|
||||||
if(${ARGC} GREATER 0)
|
|
||||||
list(APPEND DEPENDENCIES_INCLUDE_DIRS "${ARGV}")
|
|
||||||
set(DEPENDENCIES_INCLUDE_DIRS "${DEPENDENCIES_INCLUDE_DIRS}" PARENT_SCOPE)
|
|
||||||
endif()
|
|
||||||
endfunction(add_dependency_includes)
|
|
||||||
|
|
||||||
function(add_dependency_defines defines)
|
|
||||||
list(APPEND OSRM_DEFINES "${defines}")
|
|
||||||
set(OSRM_DEFINES "${OSRM_DEFINES}" PARENT_SCOPE)
|
|
||||||
endfunction(add_dependency_defines)
|
|
||||||
|
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
||||||
include(CheckCXXCompilerFlag)
|
|
||||||
include(FindPackageHandleStandardArgs)
|
|
||||||
include(GNUInstallDirs)
|
|
||||||
|
|
||||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
|
||||||
message(STATUS "Building on a 64 bit system")
|
|
||||||
else()
|
|
||||||
message(FATAL_ERROR "Building on a 32 bit system is not supported")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}/include/)
|
|
||||||
include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/include/)
|
|
||||||
include_directories(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/generated/include/)
|
|
||||||
include_directories(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/third_party/sol2/include)
|
|
||||||
|
|
||||||
set(BOOST_COMPONENTS date_time iostreams program_options thread unit_test_framework)
|
|
||||||
|
|
||||||
configure_file(
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/include/util/version.hpp.in
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/include/util/version.hpp
|
|
||||||
)
|
|
||||||
file(GLOB UtilGlob src/util/*.cpp src/util/*/*.cpp)
|
|
||||||
file(GLOB ExtractorGlob src/extractor/*.cpp src/extractor/*/*.cpp)
|
|
||||||
file(GLOB GuidanceGlob src/guidance/*.cpp src/extractor/intersection/*.cpp)
|
|
||||||
file(GLOB PartitionerGlob src/partitioner/*.cpp)
|
|
||||||
file(GLOB CustomizerGlob src/customize/*.cpp)
|
|
||||||
file(GLOB ContractorGlob src/contractor/*.cpp)
|
|
||||||
file(GLOB UpdaterGlob src/updater/*.cpp)
|
|
||||||
file(GLOB StorageGlob src/storage/*.cpp)
|
|
||||||
file(GLOB ServerGlob src/server/*.cpp src/server/**/*.cpp)
|
|
||||||
file(GLOB EngineGlob src/engine/*.cpp src/engine/**/*.cpp)
|
|
||||||
file(GLOB ErrorcodesGlob src/osrm/errorcodes.cpp)
|
|
||||||
|
|
||||||
add_library(UTIL OBJECT ${UtilGlob})
|
|
||||||
add_library(EXTRACTOR OBJECT ${ExtractorGlob})
|
|
||||||
add_library(GUIDANCE OBJECT ${GuidanceGlob})
|
|
||||||
add_library(PARTITIONER OBJECT ${PartitionerGlob})
|
|
||||||
add_library(CUSTOMIZER OBJECT ${CustomizerGlob})
|
|
||||||
add_library(CONTRACTOR OBJECT ${ContractorGlob})
|
|
||||||
add_library(UPDATER OBJECT ${UpdaterGlob})
|
|
||||||
add_library(STORAGE OBJECT ${StorageGlob})
|
|
||||||
add_library(ENGINE OBJECT ${EngineGlob})
|
|
||||||
|
|
||||||
if (BUILD_ROUTED)
|
|
||||||
add_library(SERVER OBJECT ${ServerGlob})
|
|
||||||
add_executable(osrm-routed src/tools/routed.cpp $<TARGET_OBJECTS:SERVER> $<TARGET_OBJECTS:UTIL>)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set_target_properties(UTIL PROPERTIES LINKER_LANGUAGE CXX)
|
|
||||||
|
|
||||||
add_executable(osrm-extract src/tools/extract.cpp)
|
|
||||||
add_executable(osrm-partition src/tools/partition.cpp)
|
|
||||||
add_executable(osrm-customize src/tools/customize.cpp)
|
|
||||||
add_executable(osrm-contract src/tools/contract.cpp)
|
|
||||||
add_executable(osrm-datastore src/tools/store.cpp $<TARGET_OBJECTS:MICROTAR> $<TARGET_OBJECTS:UTIL>)
|
|
||||||
add_library(osrm src/osrm/osrm.cpp $<TARGET_OBJECTS:ENGINE> $<TARGET_OBJECTS:STORAGE> $<TARGET_OBJECTS:MICROTAR> $<TARGET_OBJECTS:UTIL>)
|
|
||||||
add_library(osrm_contract src/osrm/contractor.cpp $<TARGET_OBJECTS:CONTRACTOR> $<TARGET_OBJECTS:UTIL>)
|
|
||||||
add_library(osrm_extract src/osrm/extractor.cpp $<TARGET_OBJECTS:EXTRACTOR> $<TARGET_OBJECTS:MICROTAR> $<TARGET_OBJECTS:UTIL>)
|
|
||||||
add_library(osrm_guidance $<TARGET_OBJECTS:GUIDANCE> $<TARGET_OBJECTS:UTIL>)
|
|
||||||
add_library(osrm_partition src/osrm/partitioner.cpp $<TARGET_OBJECTS:PARTITIONER> $<TARGET_OBJECTS:MICROTAR> $<TARGET_OBJECTS:UTIL>)
|
|
||||||
add_library(osrm_customize src/osrm/customizer.cpp $<TARGET_OBJECTS:CUSTOMIZER> $<TARGET_OBJECTS:MICROTAR> $<TARGET_OBJECTS:UTIL>)
|
|
||||||
add_library(osrm_update $<TARGET_OBJECTS:UPDATER> $<TARGET_OBJECTS:MICROTAR> $<TARGET_OBJECTS:UTIL>)
|
|
||||||
add_library(osrm_store $<TARGET_OBJECTS:STORAGE> $<TARGET_OBJECTS:MICROTAR> $<TARGET_OBJECTS:UTIL>)
|
|
||||||
|
|
||||||
# Explicitly set the build type to Release if no other type is specified
|
|
||||||
# on the command line. Without this, cmake defaults to an unoptimized,
|
|
||||||
# non-debug build, which almost nobody wants.
|
|
||||||
if(NOT CMAKE_BUILD_TYPE)
|
|
||||||
message(STATUS "No build type specified, defaulting to Release")
|
|
||||||
set(CMAKE_BUILD_TYPE Release)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(CMAKE_BUILD_TYPE MATCHES Debug)
|
|
||||||
message(STATUS "Configuring OSRM in debug mode")
|
|
||||||
elseif(CMAKE_BUILD_TYPE MATCHES Release)
|
|
||||||
message(STATUS "Configuring OSRM in release mode")
|
|
||||||
elseif(CMAKE_BUILD_TYPE MATCHES RelWithDebInfo)
|
|
||||||
message(STATUS "Configuring OSRM in release mode with debug flags")
|
|
||||||
elseif(CMAKE_BUILD_TYPE MATCHES MinRelSize)
|
|
||||||
message(STATUS "Configuring OSRM in release mode with minimized size")
|
|
||||||
else()
|
|
||||||
message(STATUS "Unrecognized build type - will use cmake defaults")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Additional logic for the different build types
|
|
||||||
if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES RelWithDebInfo)
|
|
||||||
message(STATUS "Configuring debug mode flags")
|
|
||||||
set(ENABLE_ASSERTIONS ON)
|
|
||||||
set(ENABLE_DEBUG_LOGGING ON)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
|
||||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -fno-inline -fno-omit-frame-pointer")
|
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-inline -fno-omit-frame-pointer")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
|
||||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -ggdb")
|
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Og -ggdb")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(MAYBE_COVERAGE_LIBRARIES "")
|
|
||||||
if (ENABLE_COVERAGE)
|
|
||||||
if (NOT CMAKE_BUILD_TYPE MATCHES "Debug")
|
|
||||||
message(ERROR "ENABLE_COVERAGE=ON only makes sense with a Debug build")
|
|
||||||
endif()
|
|
||||||
message(STATUS "Enabling coverage")
|
|
||||||
set(MAYBE_COVERAGE_LIBRARIES "-lgcov")
|
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -ftest-coverage -fprofile-arcs")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
|
|
||||||
if (ENABLE_SANITIZER)
|
|
||||||
set(SANITIZER_FLAGS "-g -fsanitize=address -fsanitize-address-use-after-scope -fsanitize=undefined -fno-omit-frame-pointer")
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SANITIZER_FLAGS}")
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SANITIZER_FLAGS}")
|
|
||||||
set(OSRM_CXXFLAGS "${OSRM_CXXFLAGS} ${SANITIZER_FLAGS}")
|
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${SANITIZER_FLAGS}")
|
|
||||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${SANITIZER_FLAGS}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Configuring compilers
|
|
||||||
include(cmake/warnings.cmake)
|
|
||||||
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC -fcolor-diagnostics -ftemplate-depth=1024")
|
|
||||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
|
||||||
set(COLOR_FLAG "-fdiagnostics-color=auto")
|
|
||||||
check_cxx_compiler_flag("-fdiagnostics-color=auto" HAS_COLOR_FLAG)
|
|
||||||
if(NOT HAS_COLOR_FLAG)
|
|
||||||
set(COLOR_FLAG "")
|
|
||||||
endif()
|
|
||||||
# using GCC
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 ${COLOR_FLAG} -fPIC -ftemplate-depth=1024")
|
|
||||||
|
|
||||||
if(WIN32) # using mingw
|
|
||||||
add_dependency_defines(-DWIN32)
|
|
||||||
set(OPTIONAL_SOCKET_LIBS ws2_32 wsock32)
|
|
||||||
endif()
|
|
||||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
|
|
||||||
# using Intel C++
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-intel -wd10237 -Wall -ipo -fPIC")
|
|
||||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
|
||||||
# using Visual Studio C++
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj") # avoid compiler error C1128 from scripting_environment_lua.cpp
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /DWIN32_LEAN_AND_MEAN") # avoid compiler error C2011 from dual #include of winsock.h and winsock2.h
|
|
||||||
add_dependency_defines(-DBOOST_LIB_DIAGNOSTIC)
|
|
||||||
add_dependency_defines(-D_CRT_SECURE_NO_WARNINGS)
|
|
||||||
add_dependency_defines(-DNOMINMAX) # avoid min and max macros that can break compilation
|
|
||||||
add_dependency_defines(-D_WIN32_WINNT=0x0501)
|
|
||||||
add_dependency_defines(-DXML_STATIC)
|
|
||||||
find_library(ws2_32_LIBRARY_PATH ws2_32)
|
|
||||||
target_link_libraries(osrm-extract wsock32 ws2_32)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(UNIX AND NOT APPLE)
|
|
||||||
find_library(RT_LIB rt)
|
|
||||||
if (RT_LIB)
|
|
||||||
set(MAYBE_RT_LIBRARY -lrt)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
find_package(Threads REQUIRED)
|
|
||||||
|
|
||||||
# Third-party libraries
|
|
||||||
set(RAPIDJSON_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/rapidjson/include")
|
|
||||||
include_directories(SYSTEM ${RAPIDJSON_INCLUDE_DIR})
|
|
||||||
|
|
||||||
set(MICROTAR_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/microtar/src")
|
|
||||||
include_directories(SYSTEM ${MICROTAR_INCLUDE_DIR})
|
|
||||||
|
|
||||||
add_library(MICROTAR OBJECT "${CMAKE_CURRENT_SOURCE_DIR}/third_party/microtar/src/microtar.c")
|
|
||||||
set_property(TARGET MICROTAR PROPERTY POSITION_INDEPENDENT_CODE ON)
|
|
||||||
|
|
||||||
target_no_warning(MICROTAR unused-variable)
|
|
||||||
target_no_warning(MICROTAR format)
|
|
||||||
|
|
||||||
set(PROTOZERO_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/protozero/include")
|
|
||||||
include_directories(SYSTEM ${PROTOZERO_INCLUDE_DIR})
|
|
||||||
|
|
||||||
set(VTZERO_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/vtzero/include")
|
|
||||||
include_directories(SYSTEM ${VTZERO_INCLUDE_DIR})
|
|
||||||
|
|
||||||
set(FLATBUFFERS_BUILD_TESTS OFF CACHE BOOL "Disable the build of Flatbuffers tests and samples.")
|
|
||||||
set(FLATBUFFERS_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/flatbuffers")
|
|
||||||
set(FLATBUFFERS_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/flatbuffers/include")
|
|
||||||
include_directories(SYSTEM ${FLATBUFFERS_INCLUDE_DIR})
|
|
||||||
add_subdirectory(${FLATBUFFERS_SRC_DIR}
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/flatbuffers-build
|
|
||||||
EXCLUDE_FROM_ALL)
|
|
||||||
|
|
||||||
set(FMT_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/fmt/include")
|
|
||||||
add_compile_definitions(FMT_HEADER_ONLY)
|
|
||||||
include_directories(SYSTEM ${FMT_INCLUDE_DIR})
|
|
||||||
|
|
||||||
|
|
||||||
# see https://stackoverflow.com/questions/70898030/boost-link-error-using-conan-find-package
|
|
||||||
if (MSVC)
|
|
||||||
add_definitions(-DBOOST_ALL_NO_LIB)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(ENABLE_CONAN)
|
|
||||||
message(STATUS "Installing dependencies via Conan")
|
|
||||||
|
|
||||||
# Conan will generate Find*.cmake files to build directory, so we use them with the highest priority
|
|
||||||
list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_BINARY_DIR})
|
|
||||||
list(INSERT CMAKE_PREFIX_PATH 0 ${CMAKE_BINARY_DIR})
|
|
||||||
|
|
||||||
include(${CMAKE_CURRENT_LIST_DIR}/cmake/conan.cmake)
|
|
||||||
|
|
||||||
conan_check(REQUIRED)
|
|
||||||
|
|
||||||
set(CONAN_BOOST_VERSION "1.85.0@#14265ec82b25d91305bbb3b30d3357f8")
|
|
||||||
set(CONAN_BZIP2_VERSION "1.0.8@#d1b2d5816f25865acf978501dff1f897")
|
|
||||||
set(CONAN_EXPAT_VERSION "2.6.2@#2d385d0d50eb5561006a7ff9e356656b")
|
|
||||||
set(CONAN_LUA_VERSION "5.4.6@#658d6089093cf01992c2737ab2e96763")
|
|
||||||
set(CONAN_TBB_VERSION "2021.12.0@#e56e5b44be8d690530585dd3634c0106")
|
|
||||||
|
|
||||||
set(CONAN_SYSTEM_INCLUDES ON)
|
|
||||||
|
|
||||||
|
|
||||||
set(CONAN_ARGS
|
|
||||||
REQUIRES
|
|
||||||
"boost/${CONAN_BOOST_VERSION}"
|
|
||||||
"bzip2/${CONAN_BZIP2_VERSION}"
|
|
||||||
"expat/${CONAN_EXPAT_VERSION}"
|
|
||||||
"lua/${CONAN_LUA_VERSION}"
|
|
||||||
"onetbb/${CONAN_TBB_VERSION}"
|
|
||||||
BASIC_SETUP
|
|
||||||
GENERATORS cmake_find_package json # json generator generates a conanbuildinfo.json in the build folder so (non-CMake) projects can easily parse OSRM's dependencies
|
|
||||||
KEEP_RPATHS
|
|
||||||
NO_OUTPUT_DIRS
|
|
||||||
OPTIONS boost:without_stacktrace=True # Apple Silicon cross-compilation fails without it
|
|
||||||
BUILD missing
|
|
||||||
)
|
|
||||||
|
|
||||||
# Enable revisions in the conan config
|
|
||||||
execute_process(COMMAND ${CONAN_CMD} config set general.revisions_enabled=1 RESULT_VARIABLE RET_CODE)
|
|
||||||
if(NOT "${RET_CODE}" STREQUAL "0")
|
|
||||||
message(FATAL_ERROR "Error setting revisions for Conan: '${RET_CODE}'")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# explicitly say Conan to use x86 dependencies if build for x86 platforms (https://github.com/conan-io/cmake-conan/issues/141)
|
|
||||||
if(NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
|
|
||||||
conan_cmake_run("${CONAN_ARGS};ARCH;x86")
|
|
||||||
# cross-compilation for Apple Silicon
|
|
||||||
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64" AND CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64")
|
|
||||||
conan_cmake_run("${CONAN_ARGS};ARCH;armv8")
|
|
||||||
else()
|
|
||||||
conan_cmake_run("${CONAN_ARGS}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_dependency_includes(${CONAN_INCLUDE_DIRS_BOOST})
|
|
||||||
add_dependency_includes(${CONAN_INCLUDE_DIRS_BZIP2})
|
|
||||||
add_dependency_includes(${CONAN_INCLUDE_DIRS_EXPAT})
|
|
||||||
add_dependency_includes(${CONAN_INCLUDE_DIRS_LUA})
|
|
||||||
add_dependency_includes(${CONAN_INCLUDE_DIRS_TBB})
|
|
||||||
|
|
||||||
set(Boost_USE_STATIC_LIBS ON)
|
|
||||||
find_package(Boost REQUIRED COMPONENTS ${BOOST_COMPONENTS})
|
|
||||||
set(Boost_DATE_TIME_LIBRARY "${Boost_date_time_LIB_TARGETS}")
|
|
||||||
set(Boost_PROGRAM_OPTIONS_LIBRARY "${Boost_program_options_LIB_TARGETS}")
|
|
||||||
set(Boost_IOSTREAMS_LIBRARY "${Boost_iostreams_LIB_TARGETS}")
|
|
||||||
set(Boost_THREAD_LIBRARY "${Boost_thread_LIB_TARGETS}")
|
|
||||||
set(Boost_ZLIB_LIBRARY "${Boost_zlib_LIB_TARGETS}")
|
|
||||||
set(Boost_UNIT_TEST_FRAMEWORK_LIBRARY "${Boost_unit_test_framework_LIB_TARGETS}")
|
|
||||||
|
|
||||||
|
|
||||||
find_package(BZip2 REQUIRED)
|
|
||||||
find_package(EXPAT REQUIRED)
|
|
||||||
find_package(lua REQUIRED)
|
|
||||||
set(LUA_LIBRARIES ${lua_LIBRARIES})
|
|
||||||
|
|
||||||
find_package(TBB REQUIRED)
|
|
||||||
|
|
||||||
|
|
||||||
# note: we avoid calling find_package(Osmium ...) here to ensure that the
|
|
||||||
# expat and bzip2 are used from conan rather than the system
|
|
||||||
include_directories(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/third_party/libosmium/include)
|
|
||||||
else()
|
|
||||||
find_package(Boost 1.70 REQUIRED COMPONENTS ${BOOST_COMPONENTS})
|
|
||||||
add_dependency_includes(${Boost_INCLUDE_DIRS})
|
|
||||||
|
|
||||||
find_package(TBB REQUIRED)
|
|
||||||
add_dependency_includes(${TBB_INCLUDE_DIR})
|
|
||||||
set(TBB_LIBRARIES TBB::tbb)
|
|
||||||
|
|
||||||
find_package(EXPAT REQUIRED)
|
|
||||||
add_dependency_includes(${EXPAT_INCLUDE_DIRS})
|
|
||||||
|
|
||||||
find_package(BZip2 REQUIRED)
|
|
||||||
add_dependency_includes(${BZIP2_INCLUDE_DIR})
|
|
||||||
|
|
||||||
find_package(Lua 5.2 REQUIRED)
|
|
||||||
if (LUA_FOUND)
|
|
||||||
message(STATUS "Using Lua ${LUA_VERSION_STRING}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_dependency_includes(${LUA_INCLUDE_DIR})
|
|
||||||
|
|
||||||
# add a target to generate API documentation with Doxygen
|
|
||||||
find_package(Doxygen)
|
|
||||||
if(DOXYGEN_FOUND)
|
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
|
|
||||||
add_custom_target(doc
|
|
||||||
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
|
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
|
||||||
COMMENT "Generating API documentation with Doxygen" VERBATIM
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# note libosmium depends on expat and bzip2
|
|
||||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/third_party/libosmium/cmake")
|
|
||||||
if(NOT OSMIUM_INCLUDE_DIR)
|
|
||||||
set(OSMIUM_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/libosmium/include")
|
|
||||||
endif()
|
|
||||||
find_package(Osmium REQUIRED COMPONENTS io)
|
|
||||||
include_directories(SYSTEM ${OSMIUM_INCLUDE_DIR})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# prefix compilation with ccache by default if available and on clang or gcc
|
|
||||||
if(ENABLE_CCACHE AND (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU"))
|
|
||||||
find_program(CCACHE_FOUND ccache)
|
|
||||||
if(CCACHE_FOUND)
|
|
||||||
message(STATUS "Using ccache to speed up incremental builds")
|
|
||||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
|
|
||||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# even with conan builds we want to link to system zlib
|
|
||||||
# to ensure that osrm binaries play well with other binaries like nodejs
|
|
||||||
find_package(ZLIB REQUIRED)
|
|
||||||
add_dependency_includes(${ZLIB_INCLUDE_DIRS})
|
|
||||||
|
|
||||||
add_dependency_defines(-DBOOST_SPIRIT_USE_PHOENIX_V3)
|
|
||||||
add_dependency_defines(-DBOOST_RESULT_OF_USE_DECLTYPE)
|
|
||||||
|
|
||||||
# Workaround for https://github.com/boostorg/phoenix/issues/111
|
|
||||||
add_dependency_defines(-DBOOST_PHOENIX_STL_TUPLE_H_)
|
|
||||||
|
|
||||||
add_definitions(${OSRM_DEFINES})
|
|
||||||
include_directories(SYSTEM ${DEPENDENCIES_INCLUDE_DIRS})
|
|
||||||
|
|
||||||
set(BOOST_BASE_LIBRARIES
|
|
||||||
${Boost_DATE_TIME_LIBRARY}
|
|
||||||
${Boost_IOSTREAMS_LIBRARY}
|
|
||||||
${Boost_THREAD_LIBRARY})
|
|
||||||
|
|
||||||
set(BOOST_ENGINE_LIBRARIES
|
|
||||||
${Boost_ZLIB_LIBRARY}
|
|
||||||
${Boost_REGEX_LIBRARY}
|
|
||||||
${BOOST_BASE_LIBRARIES})
|
|
||||||
|
|
||||||
# Binaries
|
|
||||||
target_link_libraries(osrm-datastore osrm_store ${Boost_PROGRAM_OPTIONS_LIBRARY})
|
|
||||||
target_link_libraries(osrm-extract osrm_extract ${Boost_PROGRAM_OPTIONS_LIBRARY})
|
|
||||||
target_link_libraries(osrm-partition osrm_partition ${Boost_PROGRAM_OPTIONS_LIBRARY})
|
|
||||||
target_link_libraries(osrm-customize osrm_customize ${Boost_PROGRAM_OPTIONS_LIBRARY})
|
|
||||||
target_link_libraries(osrm-contract osrm_contract ${Boost_PROGRAM_OPTIONS_LIBRARY})
|
|
||||||
if (BUILD_ROUTED)
|
|
||||||
target_link_libraries(osrm-routed osrm ${Boost_PROGRAM_OPTIONS_LIBRARY} ${OPTIONAL_SOCKET_LIBS} ${ZLIB_LIBRARY})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(EXTRACTOR_LIBRARIES
|
|
||||||
${BZIP2_LIBRARIES}
|
|
||||||
${BOOST_BASE_LIBRARIES}
|
|
||||||
${CMAKE_THREAD_LIBS_INIT}
|
|
||||||
${EXPAT_LIBRARIES}
|
|
||||||
${LUA_LIBRARIES}
|
|
||||||
${OSMIUM_LIBRARIES}
|
|
||||||
${TBB_LIBRARIES}
|
|
||||||
${ZLIB_LIBRARY}
|
|
||||||
${MAYBE_COVERAGE_LIBRARIES})
|
|
||||||
set(GUIDANCE_LIBRARIES
|
|
||||||
${BOOST_BASE_LIBRARIES}
|
|
||||||
${CMAKE_THREAD_LIBS_INIT}
|
|
||||||
${LUA_LIBRARIES}
|
|
||||||
${TBB_LIBRARIES}
|
|
||||||
${MAYBE_COVERAGE_LIBRARIES})
|
|
||||||
set(PARTITIONER_LIBRARIES
|
|
||||||
${BOOST_ENGINE_LIBRARIES}
|
|
||||||
${CMAKE_THREAD_LIBS_INIT}
|
|
||||||
${TBB_LIBRARIES}
|
|
||||||
${MAYBE_RT_LIBRARY}
|
|
||||||
${MAYBE_COVERAGE_LIBRARIES}
|
|
||||||
${ZLIB_LIBRARY})
|
|
||||||
set(CUSTOMIZER_LIBRARIES
|
|
||||||
${BOOST_ENGINE_LIBRARIES}
|
|
||||||
${CMAKE_THREAD_LIBS_INIT}
|
|
||||||
${TBB_LIBRARIES}
|
|
||||||
${MAYBE_RT_LIBRARY}
|
|
||||||
${MAYBE_COVERAGE_LIBRARIES})
|
|
||||||
set(UPDATER_LIBRARIES
|
|
||||||
${BOOST_BASE_LIBRARIES}
|
|
||||||
${CMAKE_THREAD_LIBS_INIT}
|
|
||||||
${TBB_LIBRARIES}
|
|
||||||
${MAYBE_RT_LIBRARY}
|
|
||||||
${MAYBE_COVERAGE_LIBRARIES}
|
|
||||||
${ZLIB_LIBRARY})
|
|
||||||
set(CONTRACTOR_LIBRARIES
|
|
||||||
${BOOST_BASE_LIBRARIES}
|
|
||||||
${CMAKE_THREAD_LIBS_INIT}
|
|
||||||
${LUA_LIBRARIES}
|
|
||||||
${TBB_LIBRARIES}
|
|
||||||
${MAYBE_RT_LIBRARY}
|
|
||||||
${MAYBE_COVERAGE_LIBRARIES})
|
|
||||||
set(ENGINE_LIBRARIES
|
|
||||||
${BOOST_ENGINE_LIBRARIES}
|
|
||||||
${CMAKE_THREAD_LIBS_INIT}
|
|
||||||
${TBB_LIBRARIES}
|
|
||||||
${MAYBE_RT_LIBRARY}
|
|
||||||
${MAYBE_COVERAGE_LIBRARIES}
|
|
||||||
${ZLIB_LIBRARY})
|
|
||||||
set(STORAGE_LIBRARIES
|
|
||||||
${BOOST_BASE_LIBRARIES}
|
|
||||||
${CMAKE_THREAD_LIBS_INIT}
|
|
||||||
${TBB_LIBRARIES}
|
|
||||||
${MAYBE_RT_LIBRARY}
|
|
||||||
${MAYBE_COVERAGE_LIBRARIES})
|
|
||||||
set(UTIL_LIBRARIES
|
|
||||||
${BOOST_BASE_LIBRARIES}
|
|
||||||
${CMAKE_THREAD_LIBS_INIT}
|
|
||||||
${TBB_LIBRARIES}
|
|
||||||
${MAYBE_COVERAGE_LIBRARIES}
|
|
||||||
${ZLIB_LIBRARY})
|
|
||||||
|
|
||||||
# Libraries
|
|
||||||
target_link_libraries(osrm ${ENGINE_LIBRARIES})
|
|
||||||
target_link_libraries(osrm_update ${UPDATER_LIBRARIES})
|
|
||||||
target_link_libraries(osrm_contract ${CONTRACTOR_LIBRARIES} osrm_update osrm_store)
|
|
||||||
target_link_libraries(osrm_extract osrm_guidance ${EXTRACTOR_LIBRARIES})
|
|
||||||
target_link_libraries(osrm_partition ${PARTITIONER_LIBRARIES})
|
|
||||||
target_link_libraries(osrm_customize ${CUSTOMIZER_LIBRARIES} osrm_update osrm_store)
|
|
||||||
target_link_libraries(osrm_store ${STORAGE_LIBRARIES})
|
|
||||||
|
|
||||||
# BUILD_COMPONENTS
|
|
||||||
add_executable(osrm-components src/tools/components.cpp $<TARGET_OBJECTS:MICROTAR> $<TARGET_OBJECTS:UTIL>)
|
|
||||||
target_link_libraries(osrm-components ${TBB_LIBRARIES} ${BOOST_BASE_LIBRARIES} ${UTIL_LIBRARIES})
|
|
||||||
install(TARGETS osrm-components DESTINATION bin)
|
|
||||||
|
|
||||||
if(BUILD_TOOLS)
|
|
||||||
message(STATUS "Activating OSRM internal tools")
|
|
||||||
add_executable(osrm-io-benchmark src/tools/io-benchmark.cpp $<TARGET_OBJECTS:UTIL>)
|
|
||||||
target_link_libraries(osrm-io-benchmark ${BOOST_BASE_LIBRARIES} ${TBB_LIBRARIES})
|
|
||||||
|
|
||||||
install(TARGETS osrm-io-benchmark DESTINATION bin)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (ENABLE_ASSERTIONS)
|
|
||||||
message(STATUS "Enabling assertions")
|
|
||||||
add_definitions(-DBOOST_ENABLE_ASSERT_HANDLER)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (ENABLE_DEBUG_LOGGING)
|
|
||||||
message(STATUS "Enabling debug logging")
|
|
||||||
add_definitions(-DENABLE_DEBUG_LOGGING)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Add RPATH info to executables so that when they are run after being installed
|
|
||||||
# (i.e., from /usr/local/bin/) the linker can find library dependencies. For
|
|
||||||
# more info see http://www.cmake.org/Wiki/CMake_RPATH_handling
|
|
||||||
set_property(TARGET osrm-extract PROPERTY INSTALL_RPATH_USE_LINK_PATH TRUE)
|
|
||||||
set_property(TARGET osrm-partition PROPERTY INSTALL_RPATH_USE_LINK_PATH TRUE)
|
|
||||||
set_property(TARGET osrm-contract PROPERTY INSTALL_RPATH_USE_LINK_PATH TRUE)
|
|
||||||
set_property(TARGET osrm-datastore PROPERTY INSTALL_RPATH_USE_LINK_PATH TRUE)
|
|
||||||
if (BUILD_ROUTED)
|
|
||||||
set_property(TARGET osrm-routed PROPERTY INSTALL_RPATH_USE_LINK_PATH TRUE)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
file(GLOB FlatbuffersGlob third_party/flatbuffers/include/flatbuffers/*.h)
|
|
||||||
file(GLOB LibraryGlob include/osrm/*.hpp)
|
|
||||||
file(GLOB ParametersGlob include/engine/api/*_parameters.hpp)
|
|
||||||
set(ApiHeader include/engine/api/base_result.hpp)
|
|
||||||
set(EngineHeader include/engine/status.hpp include/engine/engine_config.hpp include/engine/hint.hpp include/engine/bearing.hpp include/engine/approach.hpp include/engine/phantom_node.hpp)
|
|
||||||
set(UtilHeader include/util/coordinate.hpp include/util/json_container.hpp include/util/typedefs.hpp include/util/alias.hpp include/util/exception.hpp include/util/bearing.hpp)
|
|
||||||
set(ExtractorHeader include/extractor/extractor.hpp include/storage/io_config.hpp include/extractor/extractor_config.hpp include/extractor/travel_mode.hpp)
|
|
||||||
set(PartitionerHeader include/partitioner/partitioner.hpp include/partitioner/partitioner_config.hpp)
|
|
||||||
set(ContractorHeader include/contractor/contractor.hpp include/contractor/contractor_config.hpp)
|
|
||||||
set(StorageHeader include/storage/storage.hpp include/storage/io_config.hpp include/storage/storage_config.hpp)
|
|
||||||
install(FILES ${EngineHeader} DESTINATION include/osrm/engine)
|
|
||||||
install(FILES ${UtilHeader} DESTINATION include/osrm/util)
|
|
||||||
install(FILES ${StorageHeader} DESTINATION include/osrm/storage)
|
|
||||||
install(FILES ${ExtractorHeader} DESTINATION include/osrm/extractor)
|
|
||||||
install(FILES ${PartitionerHeader} DESTINATION include/osrm/partitioner)
|
|
||||||
install(FILES ${ContractorHeader} DESTINATION include/osrm/contractor)
|
|
||||||
install(FILES ${LibraryGlob} DESTINATION include/osrm)
|
|
||||||
install(FILES ${ParametersGlob} DESTINATION include/osrm/engine/api)
|
|
||||||
install(FILES ${ApiHeader} DESTINATION include/osrm/engine/api)
|
|
||||||
install(FILES ${FlatbuffersGlob} DESTINATION include/flatbuffers)
|
|
||||||
install(TARGETS osrm-extract DESTINATION bin)
|
|
||||||
install(TARGETS osrm-partition DESTINATION bin)
|
|
||||||
install(TARGETS osrm-customize DESTINATION bin)
|
|
||||||
install(TARGETS osrm-contract DESTINATION bin)
|
|
||||||
install(TARGETS osrm-datastore DESTINATION bin)
|
|
||||||
if (BUILD_ROUTED)
|
|
||||||
install(TARGETS osrm-routed DESTINATION bin)
|
|
||||||
endif()
|
|
||||||
install(TARGETS osrm DESTINATION lib)
|
|
||||||
install(TARGETS osrm_extract DESTINATION lib)
|
|
||||||
install(TARGETS osrm_partition DESTINATION lib)
|
|
||||||
install(TARGETS osrm_customize DESTINATION lib)
|
|
||||||
install(TARGETS osrm_update DESTINATION lib)
|
|
||||||
install(TARGETS osrm_contract DESTINATION lib)
|
|
||||||
install(TARGETS osrm_store DESTINATION lib)
|
|
||||||
install(TARGETS osrm_guidance DESTINATION lib)
|
|
||||||
|
|
||||||
|
|
||||||
# Install profiles and support library to /usr/local/share/osrm/profiles by default
|
|
||||||
set(DefaultProfilesDir profiles)
|
|
||||||
install(DIRECTORY ${DefaultProfilesDir} DESTINATION share/osrm)
|
|
||||||
|
|
||||||
# Install data geojson files to /usr/local/share/osrm/data by default
|
|
||||||
set(DefaultProfilesDir data)
|
|
||||||
install(DIRECTORY ${DefaultProfilesDir} DESTINATION share/osrm)
|
|
||||||
|
|
||||||
# Setup exporting variables for pkgconfig and subproject
|
|
||||||
#
|
|
||||||
|
|
||||||
if(BUILD_PACKAGE)
|
|
||||||
include(CPackConfig)
|
|
||||||
include(CPack)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
function(JOIN VALUES GLUE OUTPUT)
|
|
||||||
string (REPLACE ";" "${GLUE}" _TMP_STR "${VALUES}")
|
|
||||||
set (${OUTPUT} "${_TMP_STR}" PARENT_SCOPE)
|
|
||||||
endfunction()
|
|
||||||
|
|
||||||
JOIN("${OSRM_DEFINES}" " " TMP_OSRM_DEFINES)
|
|
||||||
set(LibOSRM_CXXFLAGS "${OSRM_CXXFLAGS} ${TMP_OSRM_DEFINES}")
|
|
||||||
set(LibOSRM_LDFLAGS "${OSRM_LDFLAGS}")
|
|
||||||
|
|
||||||
if(BUILD_AS_SUBPROJECT)
|
|
||||||
set(LibOSRM_CXXFLAGS "${LibOSRM_CXXFLAGS}" PARENT_SCOPE)
|
|
||||||
set(LibOSRM_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include" PARENT_SCOPE)
|
|
||||||
set(LibOSRM_LIBRARY_DIR "${CMAKE_CURRENT_BINARY_DIR}" PARENT_SCOPE)
|
|
||||||
set(LibOSRM_LIBRARIES "osrm" PARENT_SCOPE)
|
|
||||||
set(LibOSRM_DEPENDENT_LIBRARIES "${ENGINE_LIBRARIES}" PARENT_SCOPE)
|
|
||||||
set(LibOSRM_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/include"
|
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/osrm"
|
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/third_party"
|
|
||||||
"${DEPENDENCIES_INCLUDE_DIRS}" PARENT_SCOPE)
|
|
||||||
set(LibOSRM_LIBRARY_DIRS "${LibOSRM_LIBRARY_DIR}" PARENT_SCOPE)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# pkgconfig defines
|
|
||||||
set(PKGCONFIG_OSRM_CXXFLAGS "${LibOSRM_CXXFLAGS}")
|
|
||||||
set(PKGCONFIG_OSRM_LDFLAGS "${LibOSRM_LDFLAGS}")
|
|
||||||
set(PKGCONFIG_LIBRARY_DIR "${CMAKE_INSTALL_PREFIX}/lib")
|
|
||||||
set(PKGCONFIG_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/include")
|
|
||||||
|
|
||||||
list(APPEND DEPENDENCIES_INCLUDE_DIRS "${PKGCONFIG_INCLUDE_DIR}")
|
|
||||||
list(APPEND DEPENDENCIES_INCLUDE_DIRS "${PKGCONFIG_INCLUDE_DIR}/osrm")
|
|
||||||
JOIN("-I${DEPENDENCIES_INCLUDE_DIRS}" " -I" PKGCONFIG_OSRM_INCLUDE_FLAGS)
|
|
||||||
|
|
||||||
# Boost uses imported targets, we need to use a generator expression to extract
|
|
||||||
# the link libraries to be written to the pkg-config file.
|
|
||||||
# Conan & TBB define dependencies as CMake targets too, that's why we do the same for them.
|
|
||||||
foreach(engine_lib ${ENGINE_LIBRARIES})
|
|
||||||
if("${engine_lib}" MATCHES "^Boost.*" OR "${engine_lib}" MATCHES "^CONAN_LIB.*" OR "${engine_lib}" MATCHES "^TBB.*")
|
|
||||||
list(APPEND PKGCONFIG_DEPENDENT_LIBRARIES "$<TARGET_LINKER_FILE:${engine_lib}>")
|
|
||||||
else()
|
|
||||||
list(APPEND PKGCONFIG_DEPENDENT_LIBRARIES "${engine_lib}")
|
|
||||||
endif()
|
|
||||||
endforeach(engine_lib)
|
|
||||||
JOIN("${PKGCONFIG_DEPENDENT_LIBRARIES}" " " PKGCONFIG_OSRM_DEPENDENT_LIBRARIES)
|
|
||||||
|
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/pkgconfig.in pkgconfig.configured @ONLY)
|
|
||||||
file(GENERATE
|
|
||||||
OUTPUT
|
|
||||||
${PROJECT_BINARY_DIR}/libosrm.pc
|
|
||||||
INPUT
|
|
||||||
${PROJECT_BINARY_DIR}/pkgconfig.configured)
|
|
||||||
|
|
||||||
install(FILES ${PROJECT_BINARY_DIR}/libosrm.pc DESTINATION ${PKGCONFIG_LIBRARY_DIR}/pkgconfig)
|
|
||||||
|
|
||||||
# uninstall target
|
|
||||||
configure_file(
|
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
|
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake"
|
|
||||||
IMMEDIATE @ONLY)
|
|
||||||
|
|
||||||
add_custom_target(uninstall
|
|
||||||
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake)
|
|
||||||
|
|
||||||
|
|
||||||
# Modular build system: each directory registered here provides its own CMakeLists.txt
|
|
||||||
add_subdirectory(unit_tests)
|
|
||||||
add_subdirectory(src/benchmarks)
|
|
||||||
|
|
||||||
if (ENABLE_NODE_BINDINGS)
|
|
||||||
add_subdirectory(src/nodejs)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
|
|
||||||
if (ENABLE_FUZZING)
|
|
||||||
# Requires libosrm being built with sanitizers; make configurable and default to ubsan
|
|
||||||
set(FUZZ_SANITIZER "undefined" CACHE STRING "Sanitizer to be used for Fuzz testing")
|
|
||||||
set_property(CACHE FUZZ_SANITIZER PROPERTY STRINGS "undefined" "integer" "address" "memory" "thread" "leak")
|
|
||||||
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize-coverage=edge,indirect-calls,8bit-counters -fsanitize=address")
|
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address")
|
|
||||||
set(OSRM_LDFLAGS "${OSRM_LDFLAGS} -fsanitize=address")
|
|
||||||
|
|
||||||
message(STATUS "Using -fsanitize=${FUZZ_SANITIZER} for Fuzz testing")
|
|
||||||
|
|
||||||
add_subdirectory(fuzz)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
# add headers sanity check target that includes all headers independently
|
|
||||||
set(check_headers_dir "${PROJECT_BINARY_DIR}/check-headers")
|
|
||||||
file(GLOB_RECURSE headers_to_check
|
|
||||||
${PROJECT_BINARY_DIR}/*.hpp
|
|
||||||
${PROJECT_SOURCE_DIR}/include/*.hpp)
|
|
||||||
foreach(header ${headers_to_check})
|
|
||||||
if ("${header}" MATCHES ".*/include/nodejs/.*")
|
|
||||||
# we do not check NodeJS bindings headers
|
|
||||||
continue()
|
|
||||||
endif()
|
|
||||||
get_filename_component(filename ${header} NAME_WE)
|
|
||||||
set(filename "${check_headers_dir}/${filename}.cpp")
|
|
||||||
if (NOT EXISTS ${filename})
|
|
||||||
file(WRITE ${filename} "#include \"${header}\"\n")
|
|
||||||
endif()
|
|
||||||
list(APPEND sources ${filename})
|
|
||||||
endforeach()
|
|
||||||
add_library(check-headers STATIC EXCLUDE_FROM_ALL ${sources})
|
|
||||||
set_target_properties(check-headers PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${check_headers_dir})
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
|||||||
# Code of conduct
|
|
||||||
|
|
||||||
Everyone is invited to participate in Project OSRM’s open source projects and public discussions: we want to create a welcoming and friendly environment. Harassment of participants or other unethical and unprofessional behavior will not be tolerated in our spaces. The [Contributor Covenant](http://contributor-covenant.org) applies to all projects under the Project-OSRM organization and we ask that you please read [the full text](http://contributor-covenant.org/version/1/2/0/).
|
|
@ -1,81 +0,0 @@
|
|||||||
# Everyone
|
|
||||||
|
|
||||||
Please take some time to review our [code of conduct](CODE-OF-CONDUCT.md) to help guide your interactions with others on this project.
|
|
||||||
|
|
||||||
# User
|
|
||||||
|
|
||||||
Before you open a new issue, please search for older ones that cover the same issue.
|
|
||||||
In general "me too" comments/issues are frowned upon.
|
|
||||||
You can add a :+1: emoji reaction to the issue if you want to express interest in this.
|
|
||||||
|
|
||||||
# Developer
|
|
||||||
|
|
||||||
We use `clang-format` version `15` to consistently format the code base. There is a helper script under `scripts/format.sh`.
|
|
||||||
The format is automatically checked by the `mason-linux-release` job of a Travis CI build.
|
|
||||||
To save development time a local hook `.git/hooks/pre-push`
|
|
||||||
```
|
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
remote="$1"
|
|
||||||
if [ x"$remote" = xorigin ] ; then
|
|
||||||
if [ $(git rev-parse --abbrev-ref HEAD) = master ] ; then
|
|
||||||
echo "Rejected push to $remote/master" ; exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
./scripts/format.sh && ./scripts/error_on_dirty.sh
|
|
||||||
if [ $? -ne 0 ] ; then
|
|
||||||
echo "Unstaged format changes" ; exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
```
|
|
||||||
could check code format, modify a local repository and reject push due to unstaged formatting changes.
|
|
||||||
Also `pre-push` hook rejects direct pushes to `origin/master`.
|
|
||||||
|
|
||||||
⚠️ `scripts/format.sh` checks all local files that match `*.cpp` or `*.hpp` patterns.
|
|
||||||
|
|
||||||
|
|
||||||
In general changes that affect the API and/or increase the memory consumption need to be discussed first.
|
|
||||||
Often we don't include changes that would increase the memory consumption a lot if they are not generally usable (e.g. elevation data is a good example).
|
|
||||||
|
|
||||||
## Pull Request
|
|
||||||
|
|
||||||
Every pull-request that changes the API needs to update the docs in `docs/http.md` and add an entry to `CHANGELOG.md`.
|
|
||||||
Breaking changes need to have a BREAKING prefix. See the [releasing documentation](docs/releasing.md) on how this affects the version.
|
|
||||||
|
|
||||||
Early feedback is also important.
|
|
||||||
You will see that a lot of the PR have tags like `[not ready]` or `[wip]`.
|
|
||||||
We like to open PRs as soon as we are starting to work on something to make it visible to the rest of the team.
|
|
||||||
If your work is going in entirely the wrong direction, there is a good chance someone will pick up on this before it is too late.
|
|
||||||
Everyone is encouraged to read PRs of other people and give feedback.
|
|
||||||
|
|
||||||
For every significant code change we require a pull request review before it is merged.
|
|
||||||
If your pull request modifies the API this need to be signed of by a team discussion.
|
|
||||||
This means you will need to find another member of the team with commit access and request a review of your pull request.
|
|
||||||
|
|
||||||
Once your pull request is reviewed you can merge it! If you don't have commit access, ping someone that has commit access.
|
|
||||||
If you do have commit access there are in general two accepted styles to merging:
|
|
||||||
|
|
||||||
1. Make sure the branch is up to date with `master`. Run `git rebase master` to find out.
|
|
||||||
2. Once that is ensured you can either:
|
|
||||||
- Click the nice green merge button (for a non-fast-forward merge)
|
|
||||||
- Merge by hand using a fast-forward merge
|
|
||||||
|
|
||||||
Which merge you prefer is up to personal preference. In general it is recommended to use fast-forward merges because it creates a history that is sequential and easier to understand.
|
|
||||||
|
|
||||||
# Maintainer
|
|
||||||
|
|
||||||
## Doing a release
|
|
||||||
|
|
||||||
There is an in-depth guide around how to push out a release once it is ready [here](docs/releasing.md).
|
|
||||||
|
|
||||||
## The API
|
|
||||||
|
|
||||||
Changes to the API need to be discussed and signed off by the team. Breaking changes even more so than additive changes.
|
|
||||||
|
|
||||||
## Milestones
|
|
||||||
|
|
||||||
If a pull request or an issue is applicable for the current or next milestone, depends on the target version number.
|
|
||||||
Since we use semantic versioning we restrict breaking changes to major releases.
|
|
||||||
After a Release Candidate is released we usually don't change the API anymore if it is not critical.
|
|
||||||
Bigger code changes after a RC was released should also be avoided.
|
|
||||||
|
|
44
Doxyfile.in
@ -1,44 +0,0 @@
|
|||||||
PROJECT_NAME = "Project OSRM"
|
|
||||||
PROJECT_BRIEF = "Open Source Routing Machine"
|
|
||||||
BUILTIN_STL_SUPPORT = YES
|
|
||||||
|
|
||||||
EXTRACT_ALL = YES
|
|
||||||
EXTRACT_PRIVATE = YES
|
|
||||||
EXTRACT_PACKAGE = YES
|
|
||||||
EXTRACT_STATIC = YES
|
|
||||||
EXTRACT_LOCAL_CLASSES = YES
|
|
||||||
EXTRACT_ANON_NSPACES = YES
|
|
||||||
|
|
||||||
QUIET = YES
|
|
||||||
|
|
||||||
INPUT = @CMAKE_CURRENT_SOURCE_DIR@
|
|
||||||
USE_MDFILE_AS_MAINPAGE = @CMAKE_CURRENT_SOURCE_DIR@/README.md
|
|
||||||
FILE_PATTERNS = *.h *.hpp *.c *.cc *.cpp *.md
|
|
||||||
RECURSIVE = YES
|
|
||||||
|
|
||||||
EXCLUDE = @CMAKE_CURRENT_SOURCE_DIR@/third_party \
|
|
||||||
@CMAKE_CURRENT_SOURCE_DIR@/build \
|
|
||||||
@CMAKE_CURRENT_SOURCE_DIR@/node_modules \
|
|
||||||
@CMAKE_CURRENT_SOURCE_DIR@/unit_tests \
|
|
||||||
@CMAKE_CURRENT_SOURCE_DIR@/benchmarks \
|
|
||||||
@CMAKE_CURRENT_SOURCE_DIR@/features
|
|
||||||
|
|
||||||
SOURCE_BROWSER = YES
|
|
||||||
|
|
||||||
CLANG_ASSISTED_PARSING = NO
|
|
||||||
|
|
||||||
HTML_COLORSTYLE_HUE = 217
|
|
||||||
HTML_COLORSTYLE_SAT = 71
|
|
||||||
HTML_COLORSTYLE_GAMMA = 50
|
|
||||||
|
|
||||||
GENERATE_TREEVIEW = YES
|
|
||||||
|
|
||||||
HAVE_DOT = @DOXYGEN_DOT_FOUND@
|
|
||||||
CALL_GRAPH = YES
|
|
||||||
CALLER_GRAPH = YES
|
|
||||||
|
|
||||||
DOT_IMAGE_FORMAT = svg
|
|
||||||
INTERACTIVE_SVG = YES
|
|
||||||
DOT_GRAPH_MAX_NODES = 500
|
|
||||||
DOT_TRANSPARENT = YES
|
|
||||||
DOT_MULTI_TARGETS = YES
|
|
22
LICENSE.TXT
@ -1,22 +0,0 @@
|
|||||||
Copyright (c) 2017, Project OSRM contributors
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or
|
|
||||||
other materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
|
||||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
||||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
191
README.md
@ -1,191 +0,0 @@
|
|||||||
## Open Source Routing Machine
|
|
||||||
|
|
||||||
|
|
||||||
[](https://github.com/Project-OSRM/osrm-backend/actions/workflows/osrm-backend.yml) [](https://codecov.io/gh/Project-OSRM/osrm-backend) [](https://discord.gg/es9CdcCXcb)
|
|
||||||
|
|
||||||
High performance routing engine written in C++ designed to run on OpenStreetMap data.
|
|
||||||
|
|
||||||
The following services are available via HTTP API, C++ library interface and NodeJs wrapper:
|
|
||||||
- Nearest - Snaps coordinates to the street network and returns the nearest matches
|
|
||||||
- Route - Finds the fastest route between coordinates
|
|
||||||
- Table - Computes the duration or distances of the fastest route between all pairs of supplied coordinates
|
|
||||||
- Match - Snaps noisy GPS traces to the road network in the most plausible way
|
|
||||||
- Trip - Solves the Traveling Salesman Problem using a greedy heuristic
|
|
||||||
- Tile - Generates Mapbox Vector Tiles with internal routing metadata
|
|
||||||
|
|
||||||
To quickly try OSRM use our [demo server](http://map.project-osrm.org) which comes with both the backend and a frontend on top.
|
|
||||||
|
|
||||||
For a quick introduction about how the road network is represented in OpenStreetMap and how to map specific road network features have a look at [the OSM wiki on routing](https://wiki.openstreetmap.org/wiki/Routing) or [this guide about mapping for navigation](https://web.archive.org/web/20221206013651/https://labs.mapbox.com/mapping/mapping-for-navigation/).
|
|
||||||
|
|
||||||
Related [Project-OSRM](https://github.com/Project-OSRM) repositories:
|
|
||||||
- [osrm-frontend](https://github.com/Project-OSRM/osrm-frontend) - User-facing frontend with map. The demo server runs this on top of the backend
|
|
||||||
- [osrm-text-instructions](https://github.com/Project-OSRM/osrm-text-instructions) - Text instructions from OSRM route response
|
|
||||||
- [osrm-backend-docker](https://github.com/project-osrm/osrm-backend/pkgs/container/osrm-backend) - Ready to use Docker images
|
|
||||||
|
|
||||||
## Documentation
|
|
||||||
|
|
||||||
### Full documentation
|
|
||||||
|
|
||||||
- [Hosted documentation](http://project-osrm.org)
|
|
||||||
- [osrm-routed HTTP API documentation](docs/http.md)
|
|
||||||
- [libosrm API documentation](docs/libosrm.md)
|
|
||||||
|
|
||||||
## Contact
|
|
||||||
|
|
||||||
- Discord: [join](https://discord.gg/es9CdcCXcb)
|
|
||||||
- IRC: `irc.oftc.net`, channel: `#osrm` ([Webchat](https://webchat.oftc.net))
|
|
||||||
- Mailinglist: `https://lists.openstreetmap.org/listinfo/osrm-talk`
|
|
||||||
|
|
||||||
## Quick Start
|
|
||||||
|
|
||||||
The easiest and quickest way to setup your own routing engine is to use Docker images we provide.
|
|
||||||
|
|
||||||
There are two pre-processing pipelines available:
|
|
||||||
- Contraction Hierarchies (CH)
|
|
||||||
- Multi-Level Dijkstra (MLD)
|
|
||||||
|
|
||||||
we recommend using MLD by default except for special use-cases such as very large distance matrices where CH is still a better fit for the time being.
|
|
||||||
In the following we explain the MLD pipeline.
|
|
||||||
If you want to use the CH pipeline instead replace `osrm-partition` and `osrm-customize` with a single `osrm-contract` and change the algorithm option for `osrm-routed` to `--algorithm ch`.
|
|
||||||
|
|
||||||
### Using Docker
|
|
||||||
|
|
||||||
We base our Docker images ([backend](https://github.com/Project-OSRM/osrm-backend/pkgs/container/osrm-backend), [frontend](https://hub.docker.com/r/osrm/osrm-frontend/)) on Debian and make sure they are as lightweight as possible. Older backend versions can be found on [Docker Hub](https://hub.docker.com/r/osrm/osrm-backend/).
|
|
||||||
|
|
||||||
Download OpenStreetMap extracts for example from [Geofabrik](http://download.geofabrik.de/)
|
|
||||||
|
|
||||||
wget http://download.geofabrik.de/europe/germany/berlin-latest.osm.pbf
|
|
||||||
|
|
||||||
Pre-process the extract with the car profile and start a routing engine HTTP server on port 5000
|
|
||||||
|
|
||||||
docker run -t -v "${PWD}:/data" ghcr.io/project-osrm/osrm-backend osrm-extract -p /opt/car.lua /data/berlin-latest.osm.pbf || echo "osrm-extract failed"
|
|
||||||
|
|
||||||
The flag `-v "${PWD}:/data"` creates the directory `/data` inside the docker container and makes the current working directory `"${PWD}"` available there. The file `/data/berlin-latest.osm.pbf` inside the container is referring to `"${PWD}/berlin-latest.osm.pbf"` on the host.
|
|
||||||
|
|
||||||
docker run -t -v "${PWD}:/data" ghcr.io/project-osrm/osrm-backend osrm-partition /data/berlin-latest.osrm || echo "osrm-partition failed"
|
|
||||||
docker run -t -v "${PWD}:/data" ghcr.io/project-osrm/osrm-backend osrm-customize /data/berlin-latest.osrm || echo "osrm-customize failed"
|
|
||||||
|
|
||||||
Note there is no `berlin-latest.osrm` file, but multiple `berlin-latest.osrm.*` files, i.e. `berlin-latest.osrm` is not file path, but "base" path referring to set of files and there is an option to omit this `.osrm` suffix completely(e.g. `osrm-partition /data/berlin-latest`).
|
|
||||||
|
|
||||||
docker run -t -i -p 5000:5000 -v "${PWD}:/data" ghcr.io/project-osrm/osrm-backend osrm-routed --algorithm mld /data/berlin-latest.osrm
|
|
||||||
|
|
||||||
Make requests against the HTTP server
|
|
||||||
|
|
||||||
curl "http://127.0.0.1:5000/route/v1/driving/13.388860,52.517037;13.385983,52.496891?steps=true"
|
|
||||||
|
|
||||||
Optionally start a user-friendly frontend on port 9966, and open it up in your browser
|
|
||||||
|
|
||||||
docker run -p 9966:9966 osrm/osrm-frontend
|
|
||||||
xdg-open 'http://127.0.0.1:9966'
|
|
||||||
|
|
||||||
In case Docker complains about not being able to connect to the Docker daemon make sure you are in the `docker` group.
|
|
||||||
|
|
||||||
sudo usermod -aG docker $USER
|
|
||||||
|
|
||||||
After adding yourself to the `docker` group make sure to log out and back in again with your terminal.
|
|
||||||
|
|
||||||
We support the following images in the Container Registry:
|
|
||||||
|
|
||||||
Name | Description
|
|
||||||
-----|------
|
|
||||||
`latest` | `master` compiled with release flag
|
|
||||||
`latest-assertions` | `master` compiled with with release flag, assertions enabled and debug symbols
|
|
||||||
`latest-debug` | `master` compiled with debug flag
|
|
||||||
`<tag>` | specific tag compiled with release flag
|
|
||||||
`<tag>-debug` | specific tag compiled with debug flag
|
|
||||||
|
|
||||||
### Building from Source
|
|
||||||
|
|
||||||
The following targets Ubuntu 22.04.
|
|
||||||
For instructions how to build on different distributions, macOS or Windows see our [Wiki](https://github.com/Project-OSRM/osrm-backend/wiki).
|
|
||||||
|
|
||||||
Install dependencies
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo apt install build-essential git cmake pkg-config \
|
|
||||||
libbz2-dev libxml2-dev libzip-dev libboost-all-dev \
|
|
||||||
lua5.2 liblua5.2-dev libtbb-dev
|
|
||||||
```
|
|
||||||
|
|
||||||
Compile and install OSRM binaries
|
|
||||||
|
|
||||||
```bash
|
|
||||||
mkdir -p build
|
|
||||||
cd build
|
|
||||||
cmake ..
|
|
||||||
cmake --build .
|
|
||||||
sudo cmake --build . --target install
|
|
||||||
```
|
|
||||||
|
|
||||||
### Request Against the Demo Server
|
|
||||||
|
|
||||||
Read the [API usage policy](https://github.com/Project-OSRM/osrm-backend/wiki/Demo-server).
|
|
||||||
|
|
||||||
Simple query with instructions and alternatives on Berlin:
|
|
||||||
|
|
||||||
```
|
|
||||||
curl "https://router.project-osrm.org/route/v1/driving/13.388860,52.517037;13.385983,52.496891?steps=true&alternatives=true"
|
|
||||||
```
|
|
||||||
|
|
||||||
### Using the Node.js Bindings
|
|
||||||
|
|
||||||
The Node.js bindings provide read-only access to the routing engine.
|
|
||||||
We provide API documentation and examples [here](docs/nodejs/api.md).
|
|
||||||
|
|
||||||
You will need a modern `libstdc++` toolchain (`>= GLIBCXX_3.4.26`) for binary compatibility if you want to use the pre-built binaries.
|
|
||||||
For older Ubuntu systems you can upgrade your standard library for example with:
|
|
||||||
|
|
||||||
```
|
|
||||||
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
|
|
||||||
sudo apt-get update -y
|
|
||||||
sudo apt-get install -y libstdc++-9-dev
|
|
||||||
```
|
|
||||||
|
|
||||||
You can install the Node.js bindings via `npm install @project-osrm/osrm` or from this repository either via
|
|
||||||
|
|
||||||
npm install
|
|
||||||
|
|
||||||
which will check and use pre-built binaries if they're available for this release and your Node version, or via
|
|
||||||
|
|
||||||
npm install --build-from-source
|
|
||||||
|
|
||||||
to always force building the Node.js bindings from source.
|
|
||||||
|
|
||||||
#### Unscoped packages
|
|
||||||
|
|
||||||
Prior to v5.27.0, the `osrm` Node package was unscoped. If you are upgrading from an old package, you will need to do the following:
|
|
||||||
|
|
||||||
```
|
|
||||||
npm uninstall osrm --save
|
|
||||||
npm install @project-osrm/osrm --save
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Package docs
|
|
||||||
|
|
||||||
For usage details have a look [these API docs](docs/nodejs/api.md).
|
|
||||||
|
|
||||||
An exemplary implementation by a 3rd party with Docker and Node.js can be found [here](https://github.com/door2door-io/osrm-express-server-demo).
|
|
||||||
|
|
||||||
|
|
||||||
## References in publications
|
|
||||||
|
|
||||||
When using the code in a (scientific) publication, please cite
|
|
||||||
|
|
||||||
```
|
|
||||||
@inproceedings{luxen-vetter-2011,
|
|
||||||
author = {Luxen, Dennis and Vetter, Christian},
|
|
||||||
title = {Real-time routing with OpenStreetMap data},
|
|
||||||
booktitle = {Proceedings of the 19th ACM SIGSPATIAL International Conference on Advances in Geographic Information Systems},
|
|
||||||
series = {GIS '11},
|
|
||||||
year = {2011},
|
|
||||||
isbn = {978-1-4503-1031-4},
|
|
||||||
location = {Chicago, Illinois},
|
|
||||||
pages = {513--516},
|
|
||||||
numpages = {4},
|
|
||||||
url = {http://doi.acm.org/10.1145/2093973.2094062},
|
|
||||||
doi = {10.1145/2093973.2094062},
|
|
||||||
acmid = {2094062},
|
|
||||||
publisher = {ACM},
|
|
||||||
address = {New York, NY, USA},
|
|
||||||
}
|
|
||||||
```
|
|
39
WebContent/L.DashedPolyline.js
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
// dashed polyline
|
||||||
|
L.DashedPolyline = L.Polyline.extend({
|
||||||
|
initialize: function(latlngs, options) {
|
||||||
|
L.Polyline.prototype.initialize.call(this, latlngs, options);
|
||||||
|
},
|
||||||
|
|
||||||
|
options: {
|
||||||
|
dashed: true
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// svg rendering
|
||||||
|
L.DashedPolyline = !L.Browser.svg ? L.DashedPolyline : L.DashedPolyline.extend({
|
||||||
|
_updateStyle: function () {
|
||||||
|
L.Polyline.prototype._updateStyle.call(this);
|
||||||
|
if (this.options.stroke) {
|
||||||
|
if (this.options.dashed == true)
|
||||||
|
this._path.setAttribute('stroke-dasharray', '8,6');
|
||||||
|
else
|
||||||
|
this._path.setAttribute('stroke-dasharray', '');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// vml rendering
|
||||||
|
L.DashedPolyline = L.Browser.svg || !L.Browser.vml ? L.DashedPolyline : L.DashedPolyline.extend({
|
||||||
|
_updateStyle: function () {
|
||||||
|
L.Polyline.prototype._updateStyle.call(this);
|
||||||
|
if (this.options.stroke) {
|
||||||
|
if (this.options.dashed == true)
|
||||||
|
this._stroke.dashstyle = "dash";
|
||||||
|
else
|
||||||
|
this._stroke.dashstyle = "solid";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
});
|
30
WebContent/L.MouseMarker.js
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
L.MouseMarker = L.Marker.extend({
|
||||||
|
initialize: function (latlng, options) {
|
||||||
|
L.Marker.prototype.initialize.apply(this, arguments);
|
||||||
|
},
|
||||||
|
|
||||||
|
// _initInteraction: function (){
|
||||||
|
// L.Marker.prototype._initInteraction.apply(this, arguments);
|
||||||
|
// if (this.options.clickable)
|
||||||
|
// L.DomEvent.addListener(this._icon, 'mousemove', this._fireMouseEvent, this);
|
||||||
|
// },
|
||||||
|
|
||||||
|
// _fireMouseEvent: function (e) {
|
||||||
|
// this.fire(e.type, {
|
||||||
|
// latlng: this._map.mouseEventToLatLng(e),
|
||||||
|
// layerPoint: this._map.mouseEventToLayerPoint(e)
|
||||||
|
// });
|
||||||
|
// L.DomEvent.stopPropagation(e);
|
||||||
|
// },
|
||||||
|
|
||||||
|
_onMouseClick: function (e) {
|
||||||
|
L.DomEvent.stopPropagation(e);
|
||||||
|
if (this.dragging && this.dragging.moved()) { return; }
|
||||||
|
this.fire(e.type, {
|
||||||
|
altKey: e.altKey,
|
||||||
|
ctrlKey: e.ctrlKey,
|
||||||
|
shiftKey: e.shiftKey,
|
||||||
|
button: e.button
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
13
WebContent/OSRM.Browser.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
// OSRM browser detection
|
||||||
|
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
var useragent = navigator.userAgent;
|
||||||
|
|
||||||
|
OSRM.Browser = {
|
||||||
|
FF3: useragent.search(/Firefox\/3/),
|
||||||
|
IE6_9: useragent.search(/MSIE (6|7|8|9)/),
|
||||||
|
};
|
||||||
|
}());
|
||||||
|
|
||||||
|
// (runs anonymous function to prevent local variables cluttering global namespace)
|
62
WebContent/OSRM.GUI.js
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
// GUI functionality
|
||||||
|
|
||||||
|
|
||||||
|
OSRM.GUI = {
|
||||||
|
|
||||||
|
// show/hide main-gui
|
||||||
|
toggleMain: function() {
|
||||||
|
// show main-gui
|
||||||
|
if( document.getElementById('main-wrapper').style.left == "-410px" ) {
|
||||||
|
getElementsByClassName(document,'leaflet-control-zoom')[0].style.visibility="hidden";
|
||||||
|
getElementsByClassName(document,'leaflet-control-zoom')[0].style.left="420px";
|
||||||
|
getElementsByClassName(document,'leaflet-control-zoom')[0].style.top="5px";
|
||||||
|
|
||||||
|
document.getElementById('blob-wrapper').style.visibility="hidden";
|
||||||
|
document.getElementById('main-wrapper').style.left="5px";
|
||||||
|
if( OSRM.Browser.FF3!=-1 || OSRM.Browser.IE6_9!=-1 ) {
|
||||||
|
getElementsByClassName(document,'leaflet-control-zoom')[0].style.visibility="visible";
|
||||||
|
}
|
||||||
|
// hide main-gui
|
||||||
|
} else {
|
||||||
|
getElementsByClassName(document,'leaflet-control-zoom')[0].style.visibility="hidden";
|
||||||
|
getElementsByClassName(document,'leaflet-control-zoom')[0].style.left="30px";
|
||||||
|
getElementsByClassName(document,'leaflet-control-zoom')[0].style.top="5px";
|
||||||
|
|
||||||
|
document.getElementById('main-wrapper').style.left="-410px";
|
||||||
|
if( OSRM.Browser.FF3!=-1 || OSRM.Browser.IE6_9!=-1 ) {
|
||||||
|
document.getElementById('blob-wrapper').style.visibility="visible";
|
||||||
|
getElementsByClassName(document,'leaflet-control-zoom')[0].style.visibility="visible";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// execute after animation
|
||||||
|
if( OSRM.Browser.FF3==-1 && OSRM.Browser.IE6_9==-1 ) {
|
||||||
|
document.getElementById('main-wrapper').addEventListener("transitionend", OSRM.GUI.onMainTransitionEnd, false);
|
||||||
|
document.getElementById('main-wrapper').addEventListener("webkitTransitionEnd", OSRM.GUI.onMainTransitionEnd, false);
|
||||||
|
document.getElementById('main-wrapper').addEventListener("oTransitionEnd", OSRM.GUI.onMainTransitionEnd, false);
|
||||||
|
document.getElementById('main-wrapper').addEventListener("MSTransitionEnd", OSRM.GUI.onMainTransitionEnd, false);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// do stuff after main-gui animation finished
|
||||||
|
onMainTransitionEnd: function() {
|
||||||
|
// after hiding main-gui
|
||||||
|
if( document.getElementById('main-wrapper').style.left == "-410px" ) {
|
||||||
|
document.getElementById('blob-wrapper').style.visibility="visible";
|
||||||
|
getElementsByClassName(document,'leaflet-control-zoom')[0].style.visibility="visible";
|
||||||
|
// after showing main-gui
|
||||||
|
} else {
|
||||||
|
getElementsByClassName(document,'leaflet-control-zoom')[0].style.visibility="visible";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// show/hide small options bubble
|
||||||
|
toggleOptions: function() {
|
||||||
|
if(document.getElementById('options-box').style.visibility=="visible") {
|
||||||
|
document.getElementById('options-box').style.visibility="hidden";
|
||||||
|
} else {
|
||||||
|
document.getElementById('options-box').style.visibility="visible";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
};
|
77
WebContent/OSRM.JSONP.js
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
// OSRM JSONP call wrapper
|
||||||
|
// w/ DOM cleaning, fencing, timout handling
|
||||||
|
|
||||||
|
OSRM.JSONP = {
|
||||||
|
fences: {},
|
||||||
|
callbacks: {},
|
||||||
|
timeouts: {},
|
||||||
|
timers: {},
|
||||||
|
|
||||||
|
TIMEOUT: OSRM.DEFAULTS.JSONP_TIMEOUT,
|
||||||
|
|
||||||
|
late: function() { },//console.log("reply too late");},
|
||||||
|
empty: function() { },//console.log("empty callback");},
|
||||||
|
|
||||||
|
call: function(source, callback_function, timeout_function, timeout, id) {
|
||||||
|
// only one active JSONP call per id
|
||||||
|
if (OSRM.JSONP.fences[id] == true)
|
||||||
|
return false;
|
||||||
|
OSRM.JSONP.fences[id] = true;
|
||||||
|
|
||||||
|
// console.log("[status] jsonp init for "+id);
|
||||||
|
// console.log("[status] jsonp request ",source);
|
||||||
|
|
||||||
|
// wrap timeout function
|
||||||
|
OSRM.JSONP.timeouts[id] = function(response) {
|
||||||
|
timeout_function(response);
|
||||||
|
|
||||||
|
// var jsonp = document.getElementById('jsonp_'+id); // clean DOM
|
||||||
|
// if(jsonp)
|
||||||
|
// jsonp.parentNode.removeChild(jsonp);
|
||||||
|
OSRM.JSONP.callbacks[id] = OSRM.JSONP.late; // clean functions
|
||||||
|
OSRM.JSONP.timeouts[id] = OSRM.JSONP.late;
|
||||||
|
OSRM.JSONP.fences[id] = undefined; // clean fence
|
||||||
|
|
||||||
|
// console.log("timeout: "+id); // at the end - otherwise racing conditions may happen
|
||||||
|
// document.getElementById('information-box').innerHTML += "timeout:" + id + "<br>";
|
||||||
|
};
|
||||||
|
|
||||||
|
// wrap callback function
|
||||||
|
OSRM.JSONP.callbacks[id] = function(response) {
|
||||||
|
clearTimeout(OSRM.JSONP.timers[id]); // clear timeout timer
|
||||||
|
OSRM.JSONP.timers[id] = undefined;
|
||||||
|
|
||||||
|
if( OSRM.JSONP.fences[id] == undefined ) // fence to prevent execution after timeout function (when precompiled!)
|
||||||
|
return;
|
||||||
|
|
||||||
|
callback_function(response); // actual wrapped callback
|
||||||
|
|
||||||
|
// var jsonp = document.getElementById('jsonp_'+id); // clean DOM
|
||||||
|
// if(jsonp)
|
||||||
|
// jsonp.parentNode.removeChild(jsonp);
|
||||||
|
OSRM.JSONP.callbacks[id] = OSRM.JSONP.late; // clean functions
|
||||||
|
OSRM.JSONP.timeouts[id] = OSRM.JSONP.late;
|
||||||
|
OSRM.JSONP.fences[id] = undefined; // clean fence
|
||||||
|
|
||||||
|
// console.log("[status] jsonp response for "+id); // at the end - otherwise racing conditions may happen
|
||||||
|
// document.getElementById('information-box').innerHTML += "callback:" + id + "<br>";
|
||||||
|
};
|
||||||
|
|
||||||
|
// clean DOM (cannot reuse script element with all browsers, unfortunately)
|
||||||
|
var jsonp = document.getElementById('jsonp_'+id);
|
||||||
|
if(jsonp)
|
||||||
|
jsonp.parentNode.removeChild(jsonp);
|
||||||
|
|
||||||
|
// add script to DOM
|
||||||
|
var script = document.createElement('script');
|
||||||
|
script.type = 'text/javascript';
|
||||||
|
script.id = 'jsonp_'+id;
|
||||||
|
script.src = source + "&json_callback=OSRM.JSONP.callbacks."+id + "&jsonp=OSRM.JSONP.callbacks."+id;
|
||||||
|
document.head.appendChild(script);
|
||||||
|
|
||||||
|
// start timeout timer
|
||||||
|
OSRM.JSONP.timers[id] = setTimeout(OSRM.JSONP.timeouts[id], timeout);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
73
WebContent/OSRM.Localization.js
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
// localization
|
||||||
|
|
||||||
|
OSRM.Localization = {
|
||||||
|
language: "en",
|
||||||
|
|
||||||
|
translate: function(text) {
|
||||||
|
if( OSRM.Localization[OSRM.Localization.language][text] )
|
||||||
|
return OSRM.Localization[OSRM.Localization.language][text];
|
||||||
|
else if( OSRM.Localization[OSRM.Localization.language][text] )
|
||||||
|
return OSRM.Localization[OSRM.Localization.language][text];
|
||||||
|
else
|
||||||
|
return text;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
OSRM.loc = OSRM.Localization.translate;
|
||||||
|
|
||||||
|
OSRM.Localization["de"] = {
|
||||||
|
//gui
|
||||||
|
"GUI_START": "Start",
|
||||||
|
"GUI_END": "Ende",
|
||||||
|
"GUI_RESET": "Reset",
|
||||||
|
"GUI_SEARCH": "Suchen",
|
||||||
|
"GUI_ROUTE": "Route",
|
||||||
|
"GUI_REVERSE": "Umdrehen",
|
||||||
|
"GUI_OPTIONS": "Optionen",
|
||||||
|
"GUI_HIGHLIGHT_UNNAMED_ROADS": "Unbenannte Stra<72>en hervorheben",
|
||||||
|
"GUI_START_TOOLTIP": "Startposition eingeben",
|
||||||
|
"GUI_END_TOOLTIP": "Zielposition eingeben",
|
||||||
|
"GUI_LEGAL_NOTICE": "GUI2 v0.1 120313 - OSRM hosting by <a href='http://algo2.iti.kit.edu/'>KIT</a> - Geocoder by <a href='http://www.osm.org/'>OSM</a>",
|
||||||
|
// geocoder
|
||||||
|
"SEARCH_RESULTS": "Suchergebnisse",
|
||||||
|
"TIMED_OUT": "Zeit<69>berschreitung",
|
||||||
|
"NO_RESULTS_FOUND": "Keine Ergebnisse gefunden",
|
||||||
|
// routing
|
||||||
|
"ROUTE_DESCRIPTION": "Routenbeschreibung",
|
||||||
|
"GET_LINK": "Generiere Link",
|
||||||
|
"LINK_TO_ROUTE": "Link zur Route",
|
||||||
|
"LINK_TO_ROUTE_TIMEOUT": "nicht möglich",
|
||||||
|
"GPX_FILE": "GPX Datei",
|
||||||
|
"DISTANCE": "Distanz",
|
||||||
|
"DURATION": "Dauer",
|
||||||
|
"YOUR_ROUTE_IS_BEING_COMPUTED": "Ihre Route wird berechnet",
|
||||||
|
"NO_ROUTE_FOUND": "Keine Route hierher m<>glich",
|
||||||
|
};
|
||||||
|
|
||||||
|
OSRM.Localization["en"] = {
|
||||||
|
//gui
|
||||||
|
"GUI_START": "Start",
|
||||||
|
"GUI_END": "End",
|
||||||
|
"GUI_RESET": "Reset",
|
||||||
|
"GUI_SEARCH": "Search",
|
||||||
|
"GUI_ROUTE": "Route",
|
||||||
|
"GUI_REVERSE": "Reverse",
|
||||||
|
"GUI_OPTIONS": "Options",
|
||||||
|
"GUI_HIGHLIGHT_UNNAMED_ROADS": "Highlight unnamed streets",
|
||||||
|
"GUI_START_TOOLTIP": "Enter start",
|
||||||
|
"GUI_END_TOOLTIP": "Enter destination",
|
||||||
|
"GUI_LEGAL_NOTICE": "GUI2 v0.1 120313 - OSRM hosting by <a href='http://algo2.iti.kit.edu/'>KIT</a> - Geocoder by <a href='http://www.osm.org/'>OSM</a>",
|
||||||
|
// geocoder
|
||||||
|
"SEARCH_RESULTS": "Search Results",
|
||||||
|
"TIMED_OUT": "Timed Out",
|
||||||
|
"NO_RESULTS_FOUND": "No results found",
|
||||||
|
//routing
|
||||||
|
"ROUTE_DESCRIPTION": "Route Description",
|
||||||
|
"GET_LINK": "Generate Link",
|
||||||
|
"LINK_TO_ROUTE": "Route Link",
|
||||||
|
"LINK_TO_ROUTE_TIMEOUT": "not available",
|
||||||
|
"GPX_FILE": "GPX File",
|
||||||
|
"DISTANCE": "Distance",
|
||||||
|
"DURATION": "Duration",
|
||||||
|
"YOUR_ROUTE_IS_BEING_COMPUTED": "Your route is being computed",
|
||||||
|
"NO_ROUTE_FOUND": "No route possible",
|
||||||
|
};
|
194
WebContent/OSRM.Markers.js
Normal file
@ -0,0 +1,194 @@
|
|||||||
|
// OSRM.Marker class
|
||||||
|
// + sub-classes
|
||||||
|
|
||||||
|
|
||||||
|
// base class
|
||||||
|
OSRM.Marker = function( label, style, position ) {
|
||||||
|
this.label = label ? label : "marker";
|
||||||
|
this.position = position ? position : new L.LatLng(0,0);
|
||||||
|
|
||||||
|
this.marker = new L.MouseMarker( this.position, style );
|
||||||
|
this.marker.parent = this;
|
||||||
|
|
||||||
|
this.shown = false;
|
||||||
|
this.hint = undefined;
|
||||||
|
};
|
||||||
|
OSRM.extend( OSRM.Marker,{
|
||||||
|
show: function() {
|
||||||
|
map.addLayer(this.marker);
|
||||||
|
this.shown = true;
|
||||||
|
},
|
||||||
|
hide: function() {
|
||||||
|
map.removeLayer(this.marker);
|
||||||
|
this.shown = false;
|
||||||
|
},
|
||||||
|
setPosition: function( position ) {
|
||||||
|
this.position = position;
|
||||||
|
this.marker.setLatLng( position );
|
||||||
|
this.hint = undefined;
|
||||||
|
},
|
||||||
|
getPosition: function() {
|
||||||
|
return this.position;
|
||||||
|
},
|
||||||
|
getLat: function() {
|
||||||
|
return this.position.lat;
|
||||||
|
},
|
||||||
|
getLng: function() {
|
||||||
|
return this.position.lng;
|
||||||
|
},
|
||||||
|
isShown: function() {
|
||||||
|
return this.shown;
|
||||||
|
},
|
||||||
|
centerView: function(zooming) {
|
||||||
|
var zoom = OSRM.DEFAULTS.ZOOM_LEVEL;
|
||||||
|
if( zooming == false )
|
||||||
|
zoom = map.getZoom();
|
||||||
|
//map.setView( new L.LatLng( this.position.lat, this.position.lng-0.02), zoom); // dirty hack
|
||||||
|
map.setView( new L.LatLng( this.position.lat, this.position.lng), zoom);
|
||||||
|
},
|
||||||
|
toString: function() {
|
||||||
|
return "OSRM.Marker: \""+this.label+"\", "+this.position+")";
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// highlight marker
|
||||||
|
OSRM.HighlightMarker = function( label, style, position) {
|
||||||
|
OSRM.HighlightMarker.prototype.base.constructor.apply( this, arguments );
|
||||||
|
this.label = label ? label : "highlight_marker";
|
||||||
|
};
|
||||||
|
OSRM.inheritFrom( OSRM.HighlightMarker, OSRM.Marker );
|
||||||
|
OSRM.extend( OSRM.HighlightMarker, {
|
||||||
|
toString: function() {
|
||||||
|
return "OSRM.HighlightMarker: \""+this.label+"\", "+this.position+")";
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// route marker
|
||||||
|
OSRM.RouteMarker = function ( label, style, position ) {
|
||||||
|
OSRM.RouteMarker.prototype.base.constructor.apply( this, arguments );
|
||||||
|
this.label = label ? label : "route_marker";
|
||||||
|
|
||||||
|
this.marker.on( 'click', this.onClick );
|
||||||
|
this.marker.on( 'drag', this.onDrag );
|
||||||
|
this.marker.on( 'dragstart', this.onDragStart );
|
||||||
|
this.marker.on( 'dragend', this.onDragEnd );
|
||||||
|
};
|
||||||
|
OSRM.inheritFrom( OSRM.RouteMarker, OSRM.Marker );
|
||||||
|
OSRM.extend( OSRM.RouteMarker, {
|
||||||
|
onClick: function(e) {
|
||||||
|
// if(!e.ctrlKey)
|
||||||
|
// return;
|
||||||
|
for( var i=0; i<my_markers.route.length; i++) {
|
||||||
|
if( my_markers.route[i].marker === this ) {
|
||||||
|
my_markers.removeMarker( i );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getRoute(OSRM.FULL_DESCRIPTION);
|
||||||
|
my_markers.highlight.hide();
|
||||||
|
},
|
||||||
|
onDrag: function(e) {
|
||||||
|
// OSRM.debug.log("[event] drag event");
|
||||||
|
this.parent.setPosition( e.target.getLatLng() );
|
||||||
|
if(OSRM.dragging == true) // TODO: hack to deal with drag events after dragend event
|
||||||
|
getRoute(OSRM.NO_DESCRIPTION);
|
||||||
|
else
|
||||||
|
getRoute(OSRM.FULL_DESCRIPTION);
|
||||||
|
|
||||||
|
updateLocation( this.parent.label );
|
||||||
|
},
|
||||||
|
onDragStart: function(e) {
|
||||||
|
// OSRM.debug.log("[event] dragstart event");
|
||||||
|
OSRM.dragging = true;
|
||||||
|
|
||||||
|
// hack to store id of dragged marker
|
||||||
|
for( var i=0; i<my_markers.route.length; i++)
|
||||||
|
if( my_markers.route[i].marker === this ) {
|
||||||
|
OSRM.dragid = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
my_markers.highlight.hide();
|
||||||
|
if (my_route.isShown()) {
|
||||||
|
my_route.showOldRoute();
|
||||||
|
}
|
||||||
|
|
||||||
|
updateLocation( this.parent.label );
|
||||||
|
},
|
||||||
|
onDragEnd: function(e) {
|
||||||
|
// OSRM.debug.log("[event] dragend event");
|
||||||
|
getRoute(OSRM.FULL_DESCRIPTION);
|
||||||
|
if (my_route.isShown()) {
|
||||||
|
my_route.hideOldRoute();
|
||||||
|
my_route.hideUnnamedRoute(); // provides better visuals
|
||||||
|
}
|
||||||
|
OSRM.dragging = false;
|
||||||
|
|
||||||
|
updateLocation( this.parent.label );
|
||||||
|
},
|
||||||
|
toString: function() {
|
||||||
|
return "OSRM.RouteMarker: \""+this.label+"\", "+this.position+")";
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
//marker array class
|
||||||
|
OSRM.Markers = function() {
|
||||||
|
this.route = new Array();
|
||||||
|
this.highlight = new OSRM.HighlightMarker("highlight", {draggable:false,icon:OSRM.icons['marker-highlight']});;
|
||||||
|
};
|
||||||
|
OSRM.extend( OSRM.Markers,{
|
||||||
|
removeAll: function() {
|
||||||
|
for(var i=0; i<this.route.length;i++)
|
||||||
|
this.route[i].hide();
|
||||||
|
this.route.splice(0, this.route.length);
|
||||||
|
},
|
||||||
|
removeVias: function() {
|
||||||
|
// assert correct route array s - v - t
|
||||||
|
for(var i=1; i<this.route.length-1;i++)
|
||||||
|
this.route[i].hide();
|
||||||
|
this.route.splice(1, this.route.length-2);
|
||||||
|
},
|
||||||
|
setSource: function(position) {
|
||||||
|
// source node is always first node
|
||||||
|
if( this.route[0] && this.route[0].label == OSRM.SOURCE_MARKER_LABEL )
|
||||||
|
this.route[0].setPosition(position);
|
||||||
|
else
|
||||||
|
this.route.splice(0,0, new OSRM.RouteMarker("source", {draggable:true,icon:OSRM.icons['marker-source']}, position));
|
||||||
|
return 0;
|
||||||
|
},
|
||||||
|
setTarget: function(position) {
|
||||||
|
// target node is always last node
|
||||||
|
if( this.route[this.route.length-1] && this.route[ this.route.length-1 ].label == OSRM.TARGET_MARKER_LABEL )
|
||||||
|
this.route[this.route.length-1].setPosition(position);
|
||||||
|
else
|
||||||
|
this.route.splice( this.route.length,0, new OSRM.RouteMarker("target", {draggable:true,icon:OSRM.icons['marker-target']}, position));
|
||||||
|
return this.route.length-1;
|
||||||
|
},
|
||||||
|
setVia: function(id, position) {
|
||||||
|
// via nodes only between source and target nodes
|
||||||
|
if( this.route.length<2 || id > this.route.length-2 )
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
this.route.splice(id+1,0, new OSRM.RouteMarker("via", {draggable:true,icon:OSRM.icons['marker-via']}, position));
|
||||||
|
return id+1;
|
||||||
|
},
|
||||||
|
removeMarker: function(id) {
|
||||||
|
if( id >= this.route.length )
|
||||||
|
return;
|
||||||
|
|
||||||
|
// also remove vias if source or target are removed
|
||||||
|
if( id==0 && this.route[0].label == OSRM.SOURCE_MARKER_LABEL )
|
||||||
|
this.removeVias();
|
||||||
|
else if( id == this.route.length-1 && this.route[ this.route.length-1 ].label == OSRM.TARGET_MARKER_LABEL ) {
|
||||||
|
this.removeVias();
|
||||||
|
id = this.route.length-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.route[id].hide();
|
||||||
|
this.route.splice(id, 1);
|
||||||
|
}
|
||||||
|
});
|
169
WebContent/OSRM.Route.js
Normal file
@ -0,0 +1,169 @@
|
|||||||
|
// OSRM route classes
|
||||||
|
|
||||||
|
|
||||||
|
// base route class
|
||||||
|
OSRM.SimpleRoute = function (label, style) {
|
||||||
|
this.label = (label ? label : "route");
|
||||||
|
this.route = new L.DashedPolyline();
|
||||||
|
this.route.setLatLngs( [] );
|
||||||
|
if(style) this.route.setStyle( style );
|
||||||
|
|
||||||
|
this.shown = false;
|
||||||
|
|
||||||
|
this.route.on('click', this.onClick);
|
||||||
|
};
|
||||||
|
OSRM.extend( OSRM.SimpleRoute,{
|
||||||
|
show: function() {
|
||||||
|
map.addLayer(this.route);
|
||||||
|
this.shown = true;
|
||||||
|
},
|
||||||
|
hide: function() {
|
||||||
|
map.removeLayer(this.route);
|
||||||
|
this.shown = false;
|
||||||
|
},
|
||||||
|
isShown: function() {
|
||||||
|
return this.shown;
|
||||||
|
},
|
||||||
|
getPositions: function() {
|
||||||
|
return this.route.getLatLngs();
|
||||||
|
},
|
||||||
|
setPositions: function(positions) {
|
||||||
|
this.route.setLatLngs( positions );
|
||||||
|
},
|
||||||
|
setStyle: function(style) {
|
||||||
|
this.route.setStyle(style);
|
||||||
|
},
|
||||||
|
centerView: function() {
|
||||||
|
var bounds = new L.LatLngBounds( this.getPositions() );
|
||||||
|
bounds._southWest.lng-=1.02; // dirty hack
|
||||||
|
map.fitBounds( bounds );
|
||||||
|
},
|
||||||
|
onClick: function(e) {
|
||||||
|
if(my_route.isRoute())
|
||||||
|
findViaPosition( e.latlng );
|
||||||
|
},
|
||||||
|
toString: function() {
|
||||||
|
return "OSRM.Route("+ this.label + ", " + this.route.getLatLngs().length + " points)";
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// multiroute class (several separate route parts)
|
||||||
|
OSRM.MultiRoute = function (label) {
|
||||||
|
this.label = (label ? label : "multiroute");
|
||||||
|
this.route = new L.LayerGroup();
|
||||||
|
|
||||||
|
this.shown = false;
|
||||||
|
};
|
||||||
|
OSRM.extend( OSRM.MultiRoute,{
|
||||||
|
show: function() {
|
||||||
|
map.addLayer(this.route);
|
||||||
|
this.shown = true;
|
||||||
|
},
|
||||||
|
hide: function() {
|
||||||
|
map.removeLayer(this.route);
|
||||||
|
this.shown = false;
|
||||||
|
},
|
||||||
|
isShown: function() {
|
||||||
|
return this.shown;
|
||||||
|
},
|
||||||
|
addRoute: function(positions) {
|
||||||
|
var line = new L.DashedPolyline( positions );
|
||||||
|
line.on('click', function(e) { my_route.fire('click',e); });
|
||||||
|
this.route.addLayer( line );
|
||||||
|
},
|
||||||
|
clearRoutes: function() {
|
||||||
|
this.route.clearLayers();
|
||||||
|
},
|
||||||
|
setStyle: function(style) {
|
||||||
|
this.route.invoke('setStyle', style);
|
||||||
|
},
|
||||||
|
toString: function() {
|
||||||
|
return "OSRM.MultiRoute("+ this.label + ")";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// main route class
|
||||||
|
OSRM.Route = function() {
|
||||||
|
this._current_route = new OSRM.SimpleRoute("current" , {dashed:false} );
|
||||||
|
this._old_route = new OSRM.SimpleRoute("old", {dashed:false,color:"#123"} );
|
||||||
|
this._unnamed_route = new OSRM.MultiRoute("unnamed");
|
||||||
|
|
||||||
|
this._current_route_style = {dashed:false,color:'#0033FF', weight:5};
|
||||||
|
this._current_noroute_style = {dashed:true, color:'#222222', weight:2};
|
||||||
|
this._old_route_style = {dashed:false,color:'#112233', weight:5};
|
||||||
|
this._old_noroute_style = {dashed:true, color:'#000000', weight:2};
|
||||||
|
this._unnamed_route_style = {dashed:false, color:'#FF00FF', weight:10};
|
||||||
|
this._old_unnamed_route_style = {dashed:false, color:'#990099', weight:10};
|
||||||
|
|
||||||
|
this._noroute = OSRM.Route.ROUTE;
|
||||||
|
};
|
||||||
|
OSRM.Route.NOROUTE = true;
|
||||||
|
OSRM.Route.ROUTE = false;
|
||||||
|
OSRM.extend( OSRM.Route,{
|
||||||
|
|
||||||
|
showRoute: function(positions, noroute) {
|
||||||
|
this._noroute = noroute;
|
||||||
|
this._current_route.setPositions( positions );
|
||||||
|
if ( this._noroute == OSRM.Route.NOROUTE )
|
||||||
|
this._current_route.setStyle( this._current_noroute_style );
|
||||||
|
else
|
||||||
|
this._current_route.setStyle( this._current_route_style );
|
||||||
|
this._current_route.show();
|
||||||
|
//this._raiseUnnamedRoute();
|
||||||
|
},
|
||||||
|
hideRoute: function() {
|
||||||
|
this._current_route.hide();
|
||||||
|
this._unnamed_route.hide();
|
||||||
|
},
|
||||||
|
|
||||||
|
showUnnamedRoute: function(positions) {
|
||||||
|
this._unnamed_route.clearRoutes();
|
||||||
|
for(var i=0; i<positions.length; i++) {
|
||||||
|
this._unnamed_route.addRoute(positions[i]);
|
||||||
|
}
|
||||||
|
this._unnamed_route.setStyle( this._unnamed_route_style );
|
||||||
|
this._unnamed_route.show();
|
||||||
|
},
|
||||||
|
hideUnnamedRoute: function() {
|
||||||
|
this._unnamed_route.hide();
|
||||||
|
},
|
||||||
|
// TODO: hack to put unnamed_route above old_route -> easier way in Leaglet 0.4+
|
||||||
|
_raiseUnnamedRoute: function() {
|
||||||
|
if(this._unnamed_route.isShown()) {
|
||||||
|
this._unnamed_route.hide();
|
||||||
|
this._unnamed_route.show();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
showOldRoute: function() {
|
||||||
|
this._old_route.setPositions( this._current_route.getPositions() );
|
||||||
|
if ( this._noroute == OSRM.Route.NOROUTE)
|
||||||
|
this._old_route.setStyle( this._old_noroute_style );
|
||||||
|
else
|
||||||
|
this._old_route.setStyle( this._old_route_style );
|
||||||
|
this._old_route.show();
|
||||||
|
this._raiseUnnamedRoute();
|
||||||
|
// change color of unnamed route highlighting - no separate object as dragged route does not have unnamed route highlighting
|
||||||
|
this._unnamed_route.setStyle( this._old_unnamed_route_style );
|
||||||
|
},
|
||||||
|
hideOldRoute: function() {
|
||||||
|
this._old_route.hide();
|
||||||
|
},
|
||||||
|
|
||||||
|
isShown: function() {
|
||||||
|
return this._current_route.isShown();
|
||||||
|
},
|
||||||
|
isRoute: function() {
|
||||||
|
return !(this._noroute);
|
||||||
|
},
|
||||||
|
getPositions: function() {
|
||||||
|
return this._current_route.getPositions();
|
||||||
|
},
|
||||||
|
fire: function(type,event) {
|
||||||
|
this._current_route.route.fire(type,event);
|
||||||
|
},
|
||||||
|
centerView: function() {
|
||||||
|
this._current_route.centerView();
|
||||||
|
}
|
||||||
|
});
|
12
WebContent/OSRM.Routing.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
// OSRM route class
|
||||||
|
|
||||||
|
|
||||||
|
OSRM.TheRoute = {
|
||||||
|
|
||||||
|
};
|
||||||
|
OSRM.extend( OSRM.TheRoute, {
|
||||||
|
|
||||||
|
show: function() {},
|
||||||
|
hide: function() {},
|
||||||
|
|
||||||
|
});
|
27
WebContent/OSRM.base.js
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
// OSRM base class
|
||||||
|
|
||||||
|
OSRM = {};
|
||||||
|
OSRM.VERSION = '0.1';
|
||||||
|
|
||||||
|
// inheritance helper function (convenience function)
|
||||||
|
OSRM._inheritFromHelper = function() {};
|
||||||
|
OSRM.inheritFrom = function( sub_class, base_class ) {
|
||||||
|
OSRM._inheritFromHelper.prototype = base_class.prototype;
|
||||||
|
sub_class.prototype = new OSRM._inheritFromHelper();
|
||||||
|
sub_class.prototype.constructor = sub_class;
|
||||||
|
sub_class.prototype.base = base_class.prototype;
|
||||||
|
};
|
||||||
|
|
||||||
|
// class prototype extending helper function (convenience function)
|
||||||
|
OSRM.extend = function( target_class, properties ) {
|
||||||
|
for( property in properties ) {
|
||||||
|
target_class.prototype[property] = properties[property];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// usage:
|
||||||
|
// SubClass = function() {
|
||||||
|
// SubClass.prototype.base.constructor.apply(this, arguments);
|
||||||
|
// }
|
||||||
|
// OSRM.inheritFrom( SubClass, BaseClass );
|
||||||
|
// OSRM.extend( SubClass, { property:value } );
|
14
WebContent/OSRM.config.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// OSRM config file
|
||||||
|
// (has to be loaded directly after OSRM.base!)
|
||||||
|
|
||||||
|
OSRM.DEFAULTS = {
|
||||||
|
HOST_ROUTING_URL: 'http://router.project-osrm.org/viaroute',
|
||||||
|
HOST_SHORTENER_URL: 'http://map.project-osrm.org/shorten/',
|
||||||
|
WEBSITE_URL: 'http://map.project-osrm.org/',
|
||||||
|
JSONP_TIMEOUT: 2000,
|
||||||
|
ZOOM_LEVEL: 14,
|
||||||
|
ONLOAD_LATITUDE: 48.84,
|
||||||
|
ONLOAD_LONGITUDE: 10.10,
|
||||||
|
ONLOAD_SOURCE: "",
|
||||||
|
ONLOAD_TARGET: "",
|
||||||
|
};
|
49
WebContent/OSRM.debug.js
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
// debug code for OSRM
|
||||||
|
// (works faster than console.log in time-critical events)
|
||||||
|
|
||||||
|
OSRM.debug = {};
|
||||||
|
|
||||||
|
|
||||||
|
// add elements to DOM
|
||||||
|
OSRM.debug.init = function() {
|
||||||
|
//create DOM objects for debug output
|
||||||
|
var wrapper = document.createElement('div');
|
||||||
|
wrapper.id = "OSRM.debug-wrapper";
|
||||||
|
wrapper.className = "gui-wrapper";
|
||||||
|
wrapper.style.cssText = "width:410px;height:95%;top:5px;right:50px;";
|
||||||
|
|
||||||
|
var box = document.createElement('div');
|
||||||
|
box.id = "OSRM.debug-box";
|
||||||
|
box.className = "gui-box";
|
||||||
|
box.style.cssText = "width:390px;top:0px;bottom:0px;";
|
||||||
|
|
||||||
|
var clear = document.createElement('a');
|
||||||
|
clear.id = "OSRM.debug-clear";
|
||||||
|
clear.className = "button not-selectable";
|
||||||
|
clear.innerHTML = "clear";
|
||||||
|
clear.onclick = OSRM.debug.clear;
|
||||||
|
|
||||||
|
OSRM.debug.content= document.createElement('div');
|
||||||
|
OSRM.debug.content.id = "OSRM.debug-content";
|
||||||
|
OSRM.debug.content.style.cssText = "position:absolute;bottom:0px;top:20px;width:380px;font-size:11px;overflow:auto;margin:5px;";
|
||||||
|
|
||||||
|
// add elements
|
||||||
|
document.body.appendChild(wrapper);
|
||||||
|
wrapper.appendChild(box);
|
||||||
|
box.appendChild(clear);
|
||||||
|
box.appendChild(OSRM.debug.content);
|
||||||
|
};
|
||||||
|
if(document.addEventListener) // FF, CH
|
||||||
|
document.addEventListener("DOMContentLoaded", OSRM.debug.init, false);
|
||||||
|
else // IE
|
||||||
|
OSRM.debug.init();
|
||||||
|
|
||||||
|
|
||||||
|
// working functions
|
||||||
|
OSRM.debug.log = function(text) {
|
||||||
|
OSRM.debug.content.innerHTML += text + "<hr style='border:none; margin:2px; height:1px; color:#F0F0F0; background:#F0F0F0;'/>";
|
||||||
|
OSRM.debug.content.scrollTop = OSRM.debug.content.scrollHeight;
|
||||||
|
};
|
||||||
|
OSRM.debug.clear = function() {
|
||||||
|
OSRM.debug.content.innerHTML = "";
|
||||||
|
};
|
164
WebContent/geocoder.js
Normal file
@ -0,0 +1,164 @@
|
|||||||
|
// some constants
|
||||||
|
OSRM.GEOCODE_POST = 'http://nominatim.openstreetmap.org/search?format=json';
|
||||||
|
OSRM.REVERSE_GEOCODE_POST = 'http://nominatim.openstreetmap.org/reverse?format=json';
|
||||||
|
OSRM.SOURCE_MARKER_LABEL = "source";
|
||||||
|
OSRM.TARGET_MARKER_LABEL = "target";
|
||||||
|
|
||||||
|
|
||||||
|
// update locations in input boxes
|
||||||
|
function updateLocation(marker_id) {
|
||||||
|
if (marker_id == OSRM.SOURCE_MARKER_LABEL) {
|
||||||
|
document.getElementById("input-source-name").value = my_markers.route[0].getPosition().lat.toFixed(6) + ", " + my_markers.route[0].getPosition().lng.toFixed(6);
|
||||||
|
} else if (marker_id == OSRM.TARGET_MARKER_LABEL) {
|
||||||
|
document.getElementById("input-target-name").value = my_markers.route[my_markers.route.length-1].getPosition().lat.toFixed(6) + ", " + my_markers.route[my_markers.route.length-1].getPosition().lng.toFixed(6);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function updateReverseGeocoder(marker_id) {
|
||||||
|
if (marker_id == OSRM.SOURCE_MARKER_LABEL) {
|
||||||
|
document.getElementById("input-source-name").value = my_markers.route[0].getPosition().lat.toFixed(6) + ", " + my_markers.route[0].getPosition().lng.toFixed(6);
|
||||||
|
callReverseGeocoder("source", my_markers.route[0].getPosition().lat, my_markers.route[0].getPosition().lng);
|
||||||
|
} else if (marker_id == OSRM.TARGET_MARKER_LABEL) {
|
||||||
|
document.getElementById("input-target-name").value = my_markers.route[my_markers.route.length-1].getPosition().lat.toFixed(6) + ", " + my_markers.route[my_markers.route.length-1].getPosition().lng.toFixed(6);
|
||||||
|
callReverseGeocoder("target", my_markers.route[my_markers.route.length-1].getPosition().lat, my_markers.route[my_markers.route.length-1].getPosition().lng);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function updateLocations() {
|
||||||
|
if( my_markers.route[0] && my_markers.route[0].label == OSRM.SOURCE_MARKER_LABEL) {
|
||||||
|
document.getElementById("input-source-name").value = my_markers.route[0].getPosition().lat.toFixed(6) + ", " + my_markers.route[0].getPosition().lng.toFixed(6);
|
||||||
|
callReverseGeocoder("source", my_markers.route[0].getPosition().lat, my_markers.route[0].getPosition().lng);
|
||||||
|
//OSRM.debug.log("[call1] reverse geocoder");
|
||||||
|
}
|
||||||
|
|
||||||
|
if( my_markers.route[my_markers.route.length-1] && my_markers.route[ my_markers.route.length-1 ].label == OSRM.TARGET_MARKER_LABEL) {
|
||||||
|
document.getElementById("input-target-name").value = my_markers.route[my_markers.route.length-1].getPosition().lat.toFixed(6) + ", " + my_markers.route[my_markers.route.length-1].getPosition().lng.toFixed(6);
|
||||||
|
callReverseGeocoder("target", my_markers.route[my_markers.route.length-1].getPosition().lat, my_markers.route[my_markers.route.length-1].getPosition().lng);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function timeout_ReverseGeocoder() {
|
||||||
|
//OSRM.debug.log("[timeout] reverse geocoder");
|
||||||
|
}
|
||||||
|
|
||||||
|
//prepare request and call reverse geocoder
|
||||||
|
function callReverseGeocoder(marker_id, lat, lon) {
|
||||||
|
//build request
|
||||||
|
if (marker_id == OSRM.SOURCE_MARKER_LABEL) {
|
||||||
|
var src= OSRM.REVERSE_GEOCODE_POST + "&lat=" + lat + "&lon=" + lon;
|
||||||
|
OSRM.JSONP.call( src, showReverseGeocoderResults_Source, timeout_ReverseGeocoder, OSRM.JSONP.TIMEOUT, "reverse_geocoder_source" );
|
||||||
|
//OSRM.debug.log("[call2] reverse geocoder");
|
||||||
|
} else if (marker_id == OSRM.TARGET_MARKER_LABEL) {
|
||||||
|
var src = OSRM.REVERSE_GEOCODE_POST + "&lat=" + lat + "&lon=" + lon;
|
||||||
|
OSRM.JSONP.call( src, showReverseGeocoderResults_Target, timeout_ReverseGeocoder, OSRM.JSONP.TIMEOUT, "reverse_geocoder_target" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//processing JSONP response of reverse geocoder
|
||||||
|
//(with wrapper functions for source/target jsonp)
|
||||||
|
function showReverseGeocoderResults_Source(response) { showReverseGeocoderResults(OSRM.SOURCE_MARKER_LABEL, response); }
|
||||||
|
function showReverseGeocoderResults_Target(response) { showReverseGeocoderResults(OSRM.TARGET_MARKER_LABEL, response); }
|
||||||
|
function showReverseGeocoderResults(marker_id, response) {
|
||||||
|
//OSRM.debug.log("[inner] reverse geocoder");
|
||||||
|
if(response){
|
||||||
|
if(response.address == undefined)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var address = "";
|
||||||
|
if( response.address.road)
|
||||||
|
address += response.address.road;
|
||||||
|
if( response.address.city) {
|
||||||
|
if( response.address.road)
|
||||||
|
address += ", ";
|
||||||
|
address += response.address.city;
|
||||||
|
}
|
||||||
|
if( address == "" )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(marker_id == OSRM.SOURCE_MARKER_LABEL)
|
||||||
|
document.getElementById("input-source-name").value = address;
|
||||||
|
else if(marker_id == OSRM.TARGET_MARKER_LABEL)
|
||||||
|
document.getElementById("input-target-name").value = address;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// prepare request and call geocoder
|
||||||
|
function callGeocoder(marker_id, query) {
|
||||||
|
//geo coordinate given?
|
||||||
|
if(query.match(/^\s*[-+]?[0-9]*\.?[0-9]+\s*[,;]\s*[-+]?[0-9]*\.?[0-9]+\s*$/)){
|
||||||
|
var coord = query.split(/[,;]/);
|
||||||
|
onclickGeocoderResult(marker_id, coord[0], coord[1]);
|
||||||
|
// updateReverseGeocoder(marker_id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//build request
|
||||||
|
if (marker_id == OSRM.SOURCE_MARKER_LABEL) {
|
||||||
|
var src= OSRM.GEOCODE_POST + "&q=" + query;
|
||||||
|
OSRM.JSONP.call( src, showGeocoderResults_Source, showGeocoderResults_Timeout, OSRM.JSONP.TIMEOUT, "geocoder_source" );
|
||||||
|
} else if (marker_id == OSRM.TARGET_MARKER_LABEL) {
|
||||||
|
var src = OSRM.GEOCODE_POST + "&q=" + query;
|
||||||
|
OSRM.JSONP.call( src, showGeocoderResults_Target, showGeocoderResults_Timeout, OSRM.JSONP.TIMEOUT, "geocoder_target" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// helper function for clicks on geocoder search results
|
||||||
|
function onclickGeocoderResult(marker_id, lat, lon) {
|
||||||
|
var index;
|
||||||
|
if( marker_id == OSRM.SOURCE_MARKER_LABEL )
|
||||||
|
index = my_markers.setSource( new L.LatLng(lat, lon) );
|
||||||
|
else if( marker_id == OSRM.TARGET_MARKER_LABEL )
|
||||||
|
index = my_markers.setTarget( new L.LatLng(lat, lon) );
|
||||||
|
else
|
||||||
|
index = -1; // search via positions not yet implemented
|
||||||
|
|
||||||
|
my_markers.route[index].show();
|
||||||
|
my_markers.route[index].centerView();
|
||||||
|
getRoute(OSRM.FULL_DESCRIPTION);
|
||||||
|
}
|
||||||
|
|
||||||
|
// processing JSONP response of geocoder
|
||||||
|
// (with wrapper functions for source/target jsonp)
|
||||||
|
function showGeocoderResults_Source(response) { showGeocoderResults(OSRM.SOURCE_MARKER_LABEL, response); }
|
||||||
|
function showGeocoderResults_Target(response) { showGeocoderResults(OSRM.TARGET_MARKER_LABEL, response); }
|
||||||
|
function showGeocoderResults(marker_id, response) {
|
||||||
|
if(response){
|
||||||
|
if(response.length == 0) {
|
||||||
|
showGeocoderResults_Empty();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var html = "";
|
||||||
|
html += '<table class="results-table">';
|
||||||
|
for(var i=0; i < response.length; i++){
|
||||||
|
var result = response[i];
|
||||||
|
|
||||||
|
//odd or even ?
|
||||||
|
var rowstyle='results-odd';
|
||||||
|
if(i%2==0) { rowstyle='results-even'; }
|
||||||
|
|
||||||
|
html += '<tr class="'+rowstyle+'">';
|
||||||
|
html += '<td class="result-counter"><span">'+(i+1)+'.</span></td>';
|
||||||
|
html += '<td class="result-items">';
|
||||||
|
|
||||||
|
if(result.display_name){
|
||||||
|
html += '<div class="result-item" onclick="onclickGeocoderResult(\''+marker_id+'\', '+result.lat+', '+result.lon+');">'+result.display_name+'</div>';
|
||||||
|
}
|
||||||
|
html += "</td></tr>";
|
||||||
|
}
|
||||||
|
html += '</table>';
|
||||||
|
|
||||||
|
document.getElementById('information-box-headline').innerHTML = OSRM.loc("SEARCH_RESULTS")+":";
|
||||||
|
document.getElementById('information-box').innerHTML = html;
|
||||||
|
|
||||||
|
onclickGeocoderResult(marker_id, response[0].lat, response[0].lon);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function showGeocoderResults_Empty() {
|
||||||
|
document.getElementById('information-box-headline').innerHTML = OSRM.loc("SEARCH_RESULTS")+":";
|
||||||
|
document.getElementById('information-box').innerHTML = "<br><p style='font-size:14px;font-weight:bold;text-align:center;'>"+OSRM.loc("NO_RESULTS_FOUND")+".<p>";
|
||||||
|
}
|
||||||
|
function showGeocoderResults_Timeout() {
|
||||||
|
document.getElementById('information-box-headline').innerHTML = OSRM.loc("SEARCH_RESULTS")+":";
|
||||||
|
document.getElementById('information-box').innerHTML = "<br><p style='font-size:14px;font-weight:bold;text-align:center;'>"+OSRM.loc("TIMED_OUT")+".<p>";
|
||||||
|
}
|
BIN
WebContent/images/cancel.png
Normal file
After Width: | Height: | Size: 429 B |
BIN
WebContent/images/cancel_active.png
Normal file
After Width: | Height: | Size: 447 B |
BIN
WebContent/images/cancel_hover.png
Normal file
After Width: | Height: | Size: 440 B |
BIN
WebContent/images/continue.png
Normal file
After Width: | Height: | Size: 414 B |
BIN
WebContent/images/default.png
Normal file
After Width: | Height: | Size: 240 B |
BIN
WebContent/images/marker-highlight.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
WebContent/images/marker-source.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
WebContent/images/marker-target.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
WebContent/images/marker-via.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
WebContent/images/markers.pdf
Normal file
BIN
WebContent/images/osrm-logo.png
Normal file
After Width: | Height: | Size: 9.0 KiB |
BIN
WebContent/images/round-about-big.png
Normal file
After Width: | Height: | Size: 716 B |
BIN
WebContent/images/round-about.png
Normal file
After Width: | Height: | Size: 617 B |
BIN
WebContent/images/sharp-left.png
Normal file
After Width: | Height: | Size: 530 B |
BIN
WebContent/images/sharp-right.png
Normal file
After Width: | Height: | Size: 746 B |
BIN
WebContent/images/slight-left.png
Normal file
After Width: | Height: | Size: 635 B |
BIN
WebContent/images/slight-right.png
Normal file
After Width: | Height: | Size: 607 B |
BIN
WebContent/images/turn-left.png
Normal file
After Width: | Height: | Size: 676 B |
BIN
WebContent/images/turn-right.png
Normal file
After Width: | Height: | Size: 656 B |
BIN
WebContent/images/u-turn.png
Normal file
After Width: | Height: | Size: 778 B |
BIN
WebContent/leaflet/images/layers.png
Normal file
After Width: | Height: | Size: 3.6 KiB |
BIN
WebContent/leaflet/images/marker-shadow.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
WebContent/leaflet/images/marker.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
WebContent/leaflet/images/popup-close.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
WebContent/leaflet/images/zoom-in.png
Normal file
After Width: | Height: | Size: 963 B |
BIN
WebContent/leaflet/images/zoom-out.png
Normal file
After Width: | Height: | Size: 959 B |
5670
WebContent/leaflet/leaflet-src.js
Normal file
323
WebContent/leaflet/leaflet.css
Normal file
@ -0,0 +1,323 @@
|
|||||||
|
/* required styles */
|
||||||
|
|
||||||
|
.leaflet-map-pane,
|
||||||
|
.leaflet-tile,
|
||||||
|
.leaflet-marker-icon,
|
||||||
|
.leaflet-marker-shadow,
|
||||||
|
.leaflet-tile-pane,
|
||||||
|
.leaflet-overlay-pane,
|
||||||
|
.leaflet-shadow-pane,
|
||||||
|
.leaflet-marker-pane,
|
||||||
|
.leaflet-popup-pane,
|
||||||
|
.leaflet-overlay-pane svg,
|
||||||
|
.leaflet-zoom-box,
|
||||||
|
.leaflet-image-layer { /* TODO optimize classes */
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
|
.leaflet-container {
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
.leaflet-tile-pane, .leaflet-container {
|
||||||
|
-webkit-transform: translate3d(0,0,0);
|
||||||
|
}
|
||||||
|
.leaflet-tile,
|
||||||
|
.leaflet-marker-icon,
|
||||||
|
.leaflet-marker-shadow {
|
||||||
|
-moz-user-select: none;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
.leaflet-marker-icon,
|
||||||
|
.leaflet-marker-shadow {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
.leaflet-clickable {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.leaflet-container img {
|
||||||
|
max-width: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.leaflet-tile-pane { z-index: 2; }
|
||||||
|
|
||||||
|
.leaflet-objects-pane { z-index: 3; }
|
||||||
|
.leaflet-overlay-pane { z-index: 4; }
|
||||||
|
.leaflet-shadow-pane { z-index: 5; }
|
||||||
|
.leaflet-marker-pane { z-index: 6; }
|
||||||
|
.leaflet-popup-pane { z-index: 7; }
|
||||||
|
|
||||||
|
.leaflet-zoom-box {
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.leaflet-tile {
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
.leaflet-tile-loaded {
|
||||||
|
visibility: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
a.leaflet-active {
|
||||||
|
outline: 2px solid orange;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Leaflet controls */
|
||||||
|
|
||||||
|
.leaflet-control {
|
||||||
|
position: relative;
|
||||||
|
z-index: 7;
|
||||||
|
}
|
||||||
|
.leaflet-top,
|
||||||
|
.leaflet-bottom {
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
|
.leaflet-top {
|
||||||
|
top: 0;
|
||||||
|
}
|
||||||
|
.leaflet-right {
|
||||||
|
right: 0;
|
||||||
|
}
|
||||||
|
.leaflet-bottom {
|
||||||
|
bottom: 0;
|
||||||
|
}
|
||||||
|
.leaflet-left {
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
.leaflet-control {
|
||||||
|
float: left;
|
||||||
|
clear: both;
|
||||||
|
}
|
||||||
|
.leaflet-right .leaflet-control {
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
.leaflet-top .leaflet-control {
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
.leaflet-bottom .leaflet-control {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
.leaflet-left .leaflet-control {
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
|
.leaflet-right .leaflet-control {
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.leaflet-control-zoom, .leaflet-control-layers {
|
||||||
|
-moz-border-radius: 7px;
|
||||||
|
-webkit-border-radius: 7px;
|
||||||
|
border-radius: 7px;
|
||||||
|
}
|
||||||
|
.leaflet-control-zoom {
|
||||||
|
padding: 5px;
|
||||||
|
background: rgba(0, 0, 0, 0.25);
|
||||||
|
}
|
||||||
|
.leaflet-control-zoom a {
|
||||||
|
background-color: rgba(255, 255, 255, 0.75);
|
||||||
|
}
|
||||||
|
.leaflet-control-zoom a, .leaflet-control-layers a {
|
||||||
|
background-position: 50% 50%;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
.leaflet-control-zoom a {
|
||||||
|
-moz-border-radius: 4px;
|
||||||
|
-webkit-border-radius: 4px;
|
||||||
|
border-radius: 4px;
|
||||||
|
width: 19px;
|
||||||
|
height: 19px;
|
||||||
|
}
|
||||||
|
.leaflet-control-zoom a:hover {
|
||||||
|
background-color: #fff;
|
||||||
|
}
|
||||||
|
.leaflet-big-buttons .leaflet-control-zoom a {
|
||||||
|
width: 27px;
|
||||||
|
height: 27px;
|
||||||
|
}
|
||||||
|
.leaflet-control-zoom-in {
|
||||||
|
background-image: url(images/zoom-in.png);
|
||||||
|
margin-bottom: 5px;
|
||||||
|
}
|
||||||
|
.leaflet-control-zoom-out {
|
||||||
|
background-image: url(images/zoom-out.png);
|
||||||
|
}
|
||||||
|
|
||||||
|
.leaflet-control-layers {
|
||||||
|
-moz-box-shadow: 0 0 7px #999;
|
||||||
|
-webkit-box-shadow: 0 0 7px #999;
|
||||||
|
box-shadow: 0 0 7px #999;
|
||||||
|
|
||||||
|
background: #f8f8f9;
|
||||||
|
}
|
||||||
|
.leaflet-control-layers a {
|
||||||
|
background-image: url(images/layers.png);
|
||||||
|
width: 36px;
|
||||||
|
height: 36px;
|
||||||
|
}
|
||||||
|
.leaflet-big-buttons .leaflet-control-layers a {
|
||||||
|
width: 44px;
|
||||||
|
height: 44px;
|
||||||
|
}
|
||||||
|
.leaflet-control-layers .leaflet-control-layers-list,
|
||||||
|
.leaflet-control-layers-expanded .leaflet-control-layers-toggle {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.leaflet-control-layers-expanded .leaflet-control-layers-list {
|
||||||
|
display: block;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
.leaflet-control-layers-expanded {
|
||||||
|
padding: 6px 10px 6px 6px;
|
||||||
|
font: 12px/1.5 "Helvetica Neue", Arial, Helvetica, sans-serif;
|
||||||
|
color: #333;
|
||||||
|
background: #fff;
|
||||||
|
}
|
||||||
|
.leaflet-control-layers input {
|
||||||
|
margin-top: 2px;
|
||||||
|
position: relative;
|
||||||
|
top: 1px;
|
||||||
|
}
|
||||||
|
.leaflet-control-layers label {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
.leaflet-control-layers-separator {
|
||||||
|
height: 0;
|
||||||
|
border-top: 1px solid #ddd;
|
||||||
|
margin: 5px -10px 5px -6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.leaflet-container .leaflet-control-attribution {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0 5px;
|
||||||
|
|
||||||
|
font: 11px/1.5 "Helvetica Neue", Arial, Helvetica, sans-serif;
|
||||||
|
color: #333;
|
||||||
|
|
||||||
|
background-color: rgba(255, 255, 255, 0.7);
|
||||||
|
|
||||||
|
-moz-box-shadow: 0 0 7px #ccc;
|
||||||
|
-webkit-box-shadow: 0 0 7px #ccc;
|
||||||
|
box-shadow: 0 0 7px #ccc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Fade animations */
|
||||||
|
|
||||||
|
.leaflet-fade-anim .leaflet-tile {
|
||||||
|
opacity: 0;
|
||||||
|
|
||||||
|
-webkit-transition: opacity 0.2s linear;
|
||||||
|
-moz-transition: opacity 0.2s linear;
|
||||||
|
-o-transition: opacity 0.2s linear;
|
||||||
|
transition: opacity 0.2s linear;
|
||||||
|
}
|
||||||
|
.leaflet-fade-anim .leaflet-tile-loaded {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.leaflet-fade-anim .leaflet-popup {
|
||||||
|
opacity: 0;
|
||||||
|
|
||||||
|
-webkit-transition: opacity 0.2s linear;
|
||||||
|
-moz-transition: opacity 0.2s linear;
|
||||||
|
-o-transition: opacity 0.2s linear;
|
||||||
|
transition: opacity 0.2s linear;
|
||||||
|
}
|
||||||
|
.leaflet-fade-anim .leaflet-map-pane .leaflet-popup {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.leaflet-zoom-anim .leaflet-tile {
|
||||||
|
-webkit-transition: none;
|
||||||
|
-moz-transition: none;
|
||||||
|
-o-transition: none;
|
||||||
|
transition: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.leaflet-zoom-anim .leaflet-objects-pane {
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Popup layout */
|
||||||
|
|
||||||
|
.leaflet-popup {
|
||||||
|
position: absolute;
|
||||||
|
text-align: center;
|
||||||
|
-webkit-transform: translate3d(0,0,0);
|
||||||
|
}
|
||||||
|
.leaflet-popup-content-wrapper {
|
||||||
|
padding: 1px;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
.leaflet-popup-content {
|
||||||
|
margin: 19px;
|
||||||
|
}
|
||||||
|
.leaflet-popup-tip-container {
|
||||||
|
margin: 0 auto;
|
||||||
|
width: 40px;
|
||||||
|
height: 16px;
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
.leaflet-popup-tip {
|
||||||
|
width: 15px;
|
||||||
|
height: 15px;
|
||||||
|
padding: 1px;
|
||||||
|
|
||||||
|
margin: -8px auto 0;
|
||||||
|
|
||||||
|
-moz-transform: rotate(45deg);
|
||||||
|
-webkit-transform: rotate(45deg);
|
||||||
|
-ms-transform: rotate(45deg);
|
||||||
|
-o-transform: rotate(45deg);
|
||||||
|
transform: rotate(45deg);
|
||||||
|
}
|
||||||
|
.leaflet-popup-close-button {
|
||||||
|
position: absolute;
|
||||||
|
top: 9px;
|
||||||
|
right: 9px;
|
||||||
|
|
||||||
|
width: 10px;
|
||||||
|
height: 10px;
|
||||||
|
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
.leaflet-popup-content p {
|
||||||
|
margin: 18px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Visual appearance */
|
||||||
|
|
||||||
|
.leaflet-container {
|
||||||
|
background: #ddd;
|
||||||
|
}
|
||||||
|
.leaflet-container a {
|
||||||
|
color: #0078A8;
|
||||||
|
}
|
||||||
|
.leaflet-zoom-box {
|
||||||
|
border: 2px dotted #05f;
|
||||||
|
background: white;
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
|
||||||
|
background: white;
|
||||||
|
|
||||||
|
box-shadow: 0 1px 10px #888;
|
||||||
|
-moz-box-shadow: 0 1px 10px #888;
|
||||||
|
-webkit-box-shadow: 0 1px 14px #999;
|
||||||
|
}
|
||||||
|
.leaflet-popup-content-wrapper {
|
||||||
|
-moz-border-radius: 20px;
|
||||||
|
-webkit-border-radius: 20px;
|
||||||
|
border-radius: 20px;
|
||||||
|
}
|
||||||
|
.leaflet-popup-content {
|
||||||
|
font: 12px/1.4 "Helvetica Neue", Arial, Helvetica, sans-serif;
|
||||||
|
}
|
||||||
|
.leaflet-popup-close-button {
|
||||||
|
background: white url(images/popup-close.png);
|
||||||
|
}
|
48
WebContent/leaflet/leaflet.ie.css
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
.leaflet-tile {
|
||||||
|
filter: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.leaflet-vml-shape {
|
||||||
|
width: 1px;
|
||||||
|
height: 1px;
|
||||||
|
}
|
||||||
|
.lvml {
|
||||||
|
behavior: url(#default#VML);
|
||||||
|
display: inline-block;
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
|
|
||||||
|
.leaflet-control {
|
||||||
|
display: inline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.leaflet-popup-tip {
|
||||||
|
width: 21px;
|
||||||
|
_width: 27px;
|
||||||
|
margin: 0 auto;
|
||||||
|
_margin-top: -3px;
|
||||||
|
|
||||||
|
filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678);
|
||||||
|
-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)";
|
||||||
|
}
|
||||||
|
.leaflet-popup-tip-container {
|
||||||
|
margin-top: -1px;
|
||||||
|
}
|
||||||
|
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
|
||||||
|
border: 1px solid #bbb;
|
||||||
|
}
|
||||||
|
|
||||||
|
.leaflet-control-zoom {
|
||||||
|
filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#3F000000',EndColorStr='#3F000000');
|
||||||
|
}
|
||||||
|
.leaflet-control-zoom a {
|
||||||
|
background-color: #eee;
|
||||||
|
}
|
||||||
|
.leaflet-control-zoom a:hover {
|
||||||
|
background-color: #fff;
|
||||||
|
}
|
||||||
|
.leaflet-control-layers-toggle {
|
||||||
|
}
|
||||||
|
.leaflet-control-attribution, .leaflet-control-layers {
|
||||||
|
background: white;
|
||||||
|
}
|
6
WebContent/leaflet/leaflet.js
Normal file
286
WebContent/main.css
Normal file
@ -0,0 +1,286 @@
|
|||||||
|
/* styles for map */
|
||||||
|
body {
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
html, body, #map {
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
#map {
|
||||||
|
z-index: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* styles for gui */
|
||||||
|
.vquad
|
||||||
|
{
|
||||||
|
height:10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gui-wrapper
|
||||||
|
{
|
||||||
|
position:absolute;
|
||||||
|
border-radius:10px;
|
||||||
|
-moz-border-radius:10px;
|
||||||
|
-webkit-border-radius:10px;
|
||||||
|
background-color:#666666;
|
||||||
|
background-color:rgba(0, 0, 0, 0.25);
|
||||||
|
transition:left 1s;
|
||||||
|
-moz-transition:left 1s;
|
||||||
|
-webkit-transition:left 1s;
|
||||||
|
-o-transition:left 1s;
|
||||||
|
-ms-transition:left 1s;
|
||||||
|
}
|
||||||
|
.gui-box
|
||||||
|
{
|
||||||
|
position:absolute;
|
||||||
|
background-color:#ffffff;
|
||||||
|
background-color:rgba(255,255,255,1);
|
||||||
|
border-radius:10px;
|
||||||
|
-moz-border-radius:10px;
|
||||||
|
-webkit-border-radius:10px;
|
||||||
|
margin:5px;
|
||||||
|
padding:5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#main-wrapper
|
||||||
|
{
|
||||||
|
width:410px;
|
||||||
|
height:95%;
|
||||||
|
top:5px;
|
||||||
|
left:5px;
|
||||||
|
}
|
||||||
|
#main-input
|
||||||
|
{
|
||||||
|
width:390px;
|
||||||
|
height:200px;
|
||||||
|
}
|
||||||
|
#main-output
|
||||||
|
{
|
||||||
|
width:390px;
|
||||||
|
top:220px;
|
||||||
|
bottom:0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#blob-wrapper
|
||||||
|
{
|
||||||
|
left:-5px;
|
||||||
|
top:5px;
|
||||||
|
width:36px;
|
||||||
|
height:36px;
|
||||||
|
border-top-left-radius:0px;
|
||||||
|
border-bottom-left-radius:0px;
|
||||||
|
-moz-border-radius-topleft:0px;
|
||||||
|
-moz-border-radius-bottomleft:0px;
|
||||||
|
-webkit-border-top-left-radius:0px;
|
||||||
|
-webkit-border-bottom-left-radius:0px;
|
||||||
|
visibility:hidden;
|
||||||
|
}
|
||||||
|
#blob-input
|
||||||
|
{
|
||||||
|
width:26px;
|
||||||
|
height:26px;
|
||||||
|
border-top-left-radius:0px;
|
||||||
|
border-bottom-left-radius:0px;
|
||||||
|
-moz-border-radius-topleft:0px;
|
||||||
|
-moz-border-radius-bottomleft:0px;
|
||||||
|
-webkit-border-top-left-radius:0px;
|
||||||
|
-webkit-border-bottom-left-radius:0px;
|
||||||
|
padding:0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main-toggle
|
||||||
|
{
|
||||||
|
cursor:pointer;
|
||||||
|
position:absolute;
|
||||||
|
right:5px;
|
||||||
|
top:5px;
|
||||||
|
width:16px;
|
||||||
|
height:16px;
|
||||||
|
background-image:url("images/cancel.png");
|
||||||
|
}
|
||||||
|
.main-toggle:hover
|
||||||
|
{
|
||||||
|
background-image:url("images/cancel_hover.png");
|
||||||
|
}
|
||||||
|
.main-toggle:active
|
||||||
|
{
|
||||||
|
background-image:url("images/cancel_active.png");
|
||||||
|
}
|
||||||
|
|
||||||
|
.main-options
|
||||||
|
{
|
||||||
|
font-size:10px;
|
||||||
|
}
|
||||||
|
#options-toggle
|
||||||
|
{
|
||||||
|
cursor:pointer;
|
||||||
|
color:#0000ff
|
||||||
|
}
|
||||||
|
#options-toggle:hover
|
||||||
|
{
|
||||||
|
color:#ff0000
|
||||||
|
}
|
||||||
|
#options-box
|
||||||
|
{
|
||||||
|
visibility:hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
#osrm-logo
|
||||||
|
{
|
||||||
|
display: block;
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
|
width: 200px;
|
||||||
|
height: 50px;
|
||||||
|
text-align:center;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-box
|
||||||
|
{
|
||||||
|
width: 250px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.full
|
||||||
|
{
|
||||||
|
width:100%;
|
||||||
|
}
|
||||||
|
.right
|
||||||
|
{
|
||||||
|
text-align:right;
|
||||||
|
}
|
||||||
|
.center
|
||||||
|
{
|
||||||
|
text-align:center;
|
||||||
|
}
|
||||||
|
|
||||||
|
#information-box
|
||||||
|
{
|
||||||
|
position:absolute;
|
||||||
|
bottom:15px;
|
||||||
|
top:60px;
|
||||||
|
width:380px;
|
||||||
|
font-size:12px;
|
||||||
|
overflow:auto;
|
||||||
|
margin:5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.route-summary
|
||||||
|
{
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
#gpx-link
|
||||||
|
{
|
||||||
|
color:#0000ff;
|
||||||
|
text-decoration:none;
|
||||||
|
cursor:pointer;
|
||||||
|
}
|
||||||
|
#gpx-link:hover
|
||||||
|
{
|
||||||
|
color:#ff0000;
|
||||||
|
}
|
||||||
|
.results-table
|
||||||
|
{
|
||||||
|
border-spacing:0px;
|
||||||
|
}
|
||||||
|
.results-odd
|
||||||
|
{
|
||||||
|
background-color: #FAF3E9; //#ffffff;
|
||||||
|
}
|
||||||
|
.results-even
|
||||||
|
{
|
||||||
|
background-color: #F2DE9C; //#ffffe0;
|
||||||
|
}
|
||||||
|
.result-counter
|
||||||
|
{
|
||||||
|
text-align:right;
|
||||||
|
vertical-align: top;
|
||||||
|
width:30px;
|
||||||
|
font-weight:bold;
|
||||||
|
padding-left:5px;
|
||||||
|
padding-right:5px;
|
||||||
|
padding-top:1px;
|
||||||
|
padding-bottom:1px;
|
||||||
|
}
|
||||||
|
.result-items
|
||||||
|
{
|
||||||
|
text-align:left;
|
||||||
|
vertical-align: middle;
|
||||||
|
width:100%;
|
||||||
|
padding-left:1px;
|
||||||
|
padding-right:1px;
|
||||||
|
padding-top:1px;
|
||||||
|
padding-bottom:1px;
|
||||||
|
}
|
||||||
|
.result-direction
|
||||||
|
{
|
||||||
|
width:30px;
|
||||||
|
padding-left:1px;
|
||||||
|
padding-right:1px;
|
||||||
|
padding-top:1px;
|
||||||
|
padding-bottom:1px;
|
||||||
|
}
|
||||||
|
.result-item
|
||||||
|
{
|
||||||
|
cursor:pointer;
|
||||||
|
color:#000000
|
||||||
|
}
|
||||||
|
.result-item:hover
|
||||||
|
{
|
||||||
|
color:#ff0000
|
||||||
|
}
|
||||||
|
|
||||||
|
#legal-notice
|
||||||
|
{
|
||||||
|
position:absolute;
|
||||||
|
right:0px;
|
||||||
|
bottom:0px;
|
||||||
|
padding:5px;
|
||||||
|
font-size:10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* generally useful styles (above buttons, so that they get their special cursor!)*/
|
||||||
|
.not-selectable
|
||||||
|
{
|
||||||
|
cursor:default;
|
||||||
|
-moz-user-select: -moz-none;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-selectable
|
||||||
|
{
|
||||||
|
cursor:default;
|
||||||
|
-moz-user-select: text;
|
||||||
|
-webkit-user-select: text;
|
||||||
|
-ms-user-select: text;
|
||||||
|
user-select: text;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* buttons */
|
||||||
|
.button
|
||||||
|
{
|
||||||
|
cursor:pointer;
|
||||||
|
padding:2px 10px 2px 10px;
|
||||||
|
border-radius:5px;
|
||||||
|
-moz-border-radius:5px;
|
||||||
|
background-color:#EEEEEE;
|
||||||
|
border:1px solid #999999;
|
||||||
|
color:#333333;
|
||||||
|
text-decoration:none;
|
||||||
|
font-size:11px;
|
||||||
|
outline-style:none;
|
||||||
|
}
|
||||||
|
.button:hover
|
||||||
|
{
|
||||||
|
background-color:#F9F9F9;
|
||||||
|
color:#000000;
|
||||||
|
}
|
||||||
|
.button:active
|
||||||
|
{
|
||||||
|
background-color:#F4F4F4;
|
||||||
|
color:#FF0000;
|
||||||
|
}
|
111
WebContent/main.html
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
<html>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- head -->
|
||||||
|
<head>
|
||||||
|
|
||||||
|
<!-- metatags -->
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
||||||
|
<title>OSRM Website</title>
|
||||||
|
<meta name="description" content="OSRM Website"/>
|
||||||
|
<meta name="author" content="Dennis Schieferdecker" />
|
||||||
|
|
||||||
|
<!-- stylesheets -->
|
||||||
|
<link rel="stylesheet" href="leaflet/leaflet.css" type="text/css"/>
|
||||||
|
<link rel="stylesheet" href="main.css" type="text/css"/>
|
||||||
|
|
||||||
|
<!-- scripts -->
|
||||||
|
<script src="leaflet/leaflet-src.js" type="text/javascript"></script>
|
||||||
|
<!--[if lte IE 8]><link rel="stylesheet" href="leaflet/leaflet.ie.css" type="text/css"/><![endif]-->
|
||||||
|
<script src="L.DashedPolyline.js" type="text/javascript"></script>
|
||||||
|
<script src="L.MouseMarker.js" type="text/javascript"></script>
|
||||||
|
|
||||||
|
<script src="OSRM.base.js" type="text/javascript"></script>
|
||||||
|
<script src="OSRM.config.js" type="text/javascript"></script>
|
||||||
|
<!-- <script defer="defer" src="OSRM.debug.js" type="text/javascript"></script> -->
|
||||||
|
|
||||||
|
<script src="OSRM.Browser.js" type="text/javascript"></script>
|
||||||
|
<script src="OSRM.GUI.js" type="text/javascript"></script>
|
||||||
|
<script src="OSRM.JSONP.js" type="text/javascript"></script>
|
||||||
|
<script src="OSRM.Markers.js" type="text/javascript"></script>
|
||||||
|
<script src="OSRM.Route.js" type="text/javascript"></script>
|
||||||
|
<script src="OSRM.Localization.js" type="text/javascript"></script>
|
||||||
|
|
||||||
|
<script src="main.js" type="text/javascript"></script>
|
||||||
|
<script src="routing.js" type="text/javascript"></script>
|
||||||
|
|
||||||
|
<script src="geocoder.js" type="text/javascript"></script>
|
||||||
|
<script src="via.js" type="text/javascript"></script>
|
||||||
|
|
||||||
|
<script src="utils.js" type="text/javascript"></script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- body -->
|
||||||
|
<body onload="init();">
|
||||||
|
|
||||||
|
<!--map-->
|
||||||
|
<div id="map"></div>
|
||||||
|
|
||||||
|
<!-- show ui blob -->
|
||||||
|
<div id="blob-wrapper" class="gui-wrapper">
|
||||||
|
<div id="blob-input" class="gui-box">
|
||||||
|
<div class="main-toggle" onclick="OSRM.GUI.toggleMain()"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- show main gui -->
|
||||||
|
<div id="main-wrapper" class="gui-wrapper">
|
||||||
|
|
||||||
|
<!-- input box -->
|
||||||
|
<div class="gui-box not-selectable" id="main-input">
|
||||||
|
<div class="main-toggle" onclick="OSRM.GUI.toggleMain()"></div>
|
||||||
|
<img id="osrm-logo" alt="OSRM Logo" src="images/osrm-logo.png" />
|
||||||
|
|
||||||
|
<!-- source/target input -->
|
||||||
|
<table class="full">
|
||||||
|
<tr>
|
||||||
|
<td id="gui-search-source-label">Start:</td>
|
||||||
|
<td><input id="input-source-name" class="input-box" type="text" value="" title="Startposition eingeben" onkeypress="if(event.keyCode==13) {callGeocoder(OSRM.SOURCE_MARKER_LABEL, document.getElementById('input-source-name').value);}" /></td>
|
||||||
|
<!-- <td class="right"><a class="button not-selectable" id="gui-here-target" onclick="">i</a></td> -->
|
||||||
|
<td class="right"><a class="button not-selectable" id="gui-search-source" onclick="callGeocoder(OSRM.SOURCE_MARKER_LABEL, document.getElementById('input-source-name').value);">Suchen</a></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td id="gui-search-target-label">Ende:</td>
|
||||||
|
<td><input id="input-target-name" class="input-box" type="text" value="" title="Zielposition eingeben" onkeypress="if(event.keyCode==13) {callGeocoder(OSRM.TARGET_MARKER_LABEL, document.getElementById('input-target-name').value);}" /></td>
|
||||||
|
<!-- <td class="right"><a class="button not-selectable" id="gui-here-target" onclick="">i</a></td> -->
|
||||||
|
<td class="right"><a class="button not-selectable" id="gui-search-target" onclick="callGeocoder(OSRM.TARGET_MARKER_LABEL, document.getElementById('input-target-name').value);">Suchen</a></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<!-- action buttons -->
|
||||||
|
<div class="vquad"></div>
|
||||||
|
<table style="width:100%">
|
||||||
|
<tr>
|
||||||
|
<td> <a class="button not-selectable" id="gui-reset" onclick="resetRouting();">Reset</a></td>
|
||||||
|
<td class="center"> <a class="button not-selectable" id="gui-reverse" onclick="reverseRouting();">Reverse</a></td>
|
||||||
|
<td class="right"> <a class="button not-selectable" id="gui-route" onclick="startRouting();">Route</a></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<!-- options -->
|
||||||
|
<div class="vquad"></div>
|
||||||
|
<div class="main-options not-selectable" id="options-toggle" onclick="OSRM.GUI.toggleOptions()">Options</div>
|
||||||
|
<div class="main-options not-selectable" id="options-box">
|
||||||
|
<input type="checkbox" id="option-highlight-nonames" name="main-options" value="highlight-nonames" onclick="getRoute(OSRM.FULL_DESCRIPTION)" /><span id="gui-option-highlight-nonames-label">Unbenannte Straßen hervorheben</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- output box -->
|
||||||
|
<div class="gui-box not-selectable" id="main-output">
|
||||||
|
<div id="information-box-headline"></div>
|
||||||
|
<div id="information-box"></div>
|
||||||
|
<div id="legal-notice">GUI2 v0.1 120313 - OSRM hosting by <a href='http://algo2.iti.kit.edu/'>KIT</a> - Geocoder by <a href='http://www.osm.org/'>OSM</a></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
214
WebContent/main.js
Normal file
@ -0,0 +1,214 @@
|
|||||||
|
var map;
|
||||||
|
|
||||||
|
|
||||||
|
function init() {
|
||||||
|
prefetchImages();
|
||||||
|
prefetchIcons();
|
||||||
|
|
||||||
|
initLocale();
|
||||||
|
initMap();
|
||||||
|
initRouting();
|
||||||
|
|
||||||
|
// check if the URL contains some GET parameter, e.g. for the route
|
||||||
|
checkURL();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// prefetch images
|
||||||
|
OSRM.images = Array();
|
||||||
|
function prefetchImages() {
|
||||||
|
var images = [ 'images/marker-source.png',
|
||||||
|
'images/marker-target.png',
|
||||||
|
'images/marker-via.png',
|
||||||
|
'images/marker-highlight.png'
|
||||||
|
];
|
||||||
|
|
||||||
|
for(var i=0; i<images.length; i++) {
|
||||||
|
OSRM.images[i] = new Image();
|
||||||
|
OSRM.images[i].src = images[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// prefetch icons
|
||||||
|
OSRM.icons = Array();
|
||||||
|
function prefetchIcons() {
|
||||||
|
var images = [ 'marker-source',
|
||||||
|
'marker-target',
|
||||||
|
'marker-via',
|
||||||
|
'marker-highlight',
|
||||||
|
];
|
||||||
|
|
||||||
|
for(var i=0; i<images.length; i++)
|
||||||
|
OSRM.icons[images[i]] = new L.Icon('images/'+images[i]+'.png');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// init localization
|
||||||
|
function initLocale() {
|
||||||
|
document.getElementById("gui-route").innerHTML = OSRM.loc("GUI_ROUTE");
|
||||||
|
document.getElementById("gui-reset").innerHTML = OSRM.loc("GUI_RESET");
|
||||||
|
document.getElementById("gui-reverse").innerHTML = OSRM.loc("GUI_REVERSE");
|
||||||
|
document.getElementById("gui-option-highlight-nonames-label").innerHTML = OSRM.loc("GUI_HIGHLIGHT_UNNAMED_ROADS");
|
||||||
|
document.getElementById("options-toggle").innerHTML = OSRM.loc("GUI_OPTIONS");
|
||||||
|
document.getElementById("gui-search-source").innerHTML = OSRM.loc("GUI_SEARCH");
|
||||||
|
document.getElementById("gui-search-target").innerHTML = OSRM.loc("GUI_SEARCH");
|
||||||
|
document.getElementById("gui-search-source-label").innerHTML = OSRM.loc("GUI_START")+":";
|
||||||
|
document.getElementById("gui-search-target-label").innerHTML = OSRM.loc("GUI_END")+":";
|
||||||
|
document.getElementById("input-source-name").title = OSRM.loc("GUI_START_TOOLTIP");
|
||||||
|
document.getElementById("input-target-name").title = OSRM.loc("GUI_END_TOOLTIP");
|
||||||
|
document.getElementById("legal-notice").innerHTML = OSRM.loc("GUI_LEGAL_NOTICE");
|
||||||
|
|
||||||
|
document.getElementById('input-source-name').value = OSRM.DEFAULTS.ONLOAD_SOURCE;
|
||||||
|
document.getElementById('input-target-name').value = OSRM.DEFAULTS.ONLOAD_TARGET;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// centering on geolocation
|
||||||
|
function callbak_centerOnGeolocation( position ) {
|
||||||
|
map.setView( new L.LatLng( position.coords.latitude, position.coords.longitude-0.02), OSRM.DEFAULTS.ZOOM_LEVEL);
|
||||||
|
}
|
||||||
|
function centerOnGeolocation() {
|
||||||
|
if (navigator.geolocation)
|
||||||
|
navigator.geolocation.getCurrentPosition( callbak_centerOnGeolocation );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// init map
|
||||||
|
function initMap() {
|
||||||
|
var osmorgURL = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
|
||||||
|
osmorgAttribution = 'Map data © 2011 OpenStreetMap contributors, Imagery © 2011 Mapnik',
|
||||||
|
osmorgOptions = {maxZoom: 18, attribution: osmorgAttribution};
|
||||||
|
|
||||||
|
var osmdeURL = 'http://{s}.tile.openstreetmap.de/tiles/osmde/{z}/{x}/{y}.png',
|
||||||
|
osmdeAttribution = 'Map data © 2011 OpenStreetMap contributors, Imagery © 2011 Mapnik',
|
||||||
|
osmdeOptions = {maxZoom: 18, attribution: osmdeAttribution};
|
||||||
|
|
||||||
|
var mapquestURL = 'http://otile{s}.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.png',
|
||||||
|
mapquestAttribution = 'Map data © 2011 OpenStreetMap contributors, Imagery © 2011 MapQuest',
|
||||||
|
mapquestOptions = {maxZoom: 18, attribution: mapquestAttribution, subdomains: '1234'};
|
||||||
|
|
||||||
|
var cloudmadeURL = 'http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/997/256/{z}/{x}/{y}.png',
|
||||||
|
cloudmadeAttribution = 'Map data © 2011 OpenStreetMap contributors, Imagery © 2011 CloudMade',
|
||||||
|
cloudmadeOptions = {maxZoom: 18, attribution: cloudmadeAttribution};
|
||||||
|
|
||||||
|
var osmorg = new L.TileLayer(osmorgURL, osmorgOptions),
|
||||||
|
osmde = new L.TileLayer(osmdeURL, osmdeOptions),
|
||||||
|
mapquest = new L.TileLayer(mapquestURL, mapquestOptions),
|
||||||
|
cloudmade = new L.TileLayer(cloudmadeURL, cloudmadeOptions);
|
||||||
|
|
||||||
|
map = new L.Map('map', {
|
||||||
|
center: new L.LatLng(51.505, -0.09),
|
||||||
|
zoom: 13,
|
||||||
|
zoomAnimation: false, // uncomment to remove animations and hiding of routes during zoom
|
||||||
|
fadeAnimation: false,
|
||||||
|
layers: [osmorg]
|
||||||
|
});
|
||||||
|
|
||||||
|
var baseMaps = {
|
||||||
|
"osm.org": osmorg,
|
||||||
|
"osm.de": osmde,
|
||||||
|
"MapQuest": mapquest,
|
||||||
|
"CloudMade": cloudmade
|
||||||
|
};
|
||||||
|
|
||||||
|
var overlayMaps = {};
|
||||||
|
var layersControl = new L.Control.Layers(baseMaps, overlayMaps);
|
||||||
|
map.addControl(layersControl);
|
||||||
|
|
||||||
|
getElementsByClassName(document,'leaflet-control-zoom')[0].style.left="420px";
|
||||||
|
getElementsByClassName(document,'leaflet-control-zoom')[0].style.top="5px";
|
||||||
|
|
||||||
|
map.setView( new L.LatLng( OSRM.DEFAULTS.ONLOAD_LATITUDE, OSRM.DEFAULTS.ONLOAD_LONGITUDE-0.02), OSRM.DEFAULTS.ZOOM_LEVEL);
|
||||||
|
map.on('zoomend', function(e) { getRoute(OSRM.FULL_DESCRIPTION); });
|
||||||
|
|
||||||
|
map.on('click', function(e) {
|
||||||
|
if( !my_markers.route[0] || my_markers.route[0].label != OSRM.SOURCE_MARKER_LABEL) {
|
||||||
|
index = my_markers.setSource( e.latlng );
|
||||||
|
my_markers.route[index].show();
|
||||||
|
my_markers.route[index].centerView(false);
|
||||||
|
getRoute(OSRM.FULL_DESCRIPTION);
|
||||||
|
updateLocation("source");
|
||||||
|
// updateReverseGeocoder("source");
|
||||||
|
}
|
||||||
|
else if( !my_markers.route[my_markers.route.length-1] || my_markers.route[ my_markers.route.length-1 ].label != OSRM.TARGET_MARKER_LABEL) {
|
||||||
|
index = my_markers.setTarget( e.latlng );
|
||||||
|
my_markers.route[index].show();
|
||||||
|
my_markers.route[index].centerView(false);
|
||||||
|
getRoute(OSRM.FULL_DESCRIPTION);
|
||||||
|
updateLocation("target");
|
||||||
|
// updateReverseGeocoder("target");
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
// onmousemove test
|
||||||
|
// map.on('mousemove', function(e) { console.log("pos: " + e.latlng); });
|
||||||
|
// map.on('mousemove', function(e) {
|
||||||
|
// var objs = new Array;
|
||||||
|
// var obj = null;
|
||||||
|
// do {
|
||||||
|
// obj = document.elementFromPoint(e.layerPoint.x, e.layerPoint.y);
|
||||||
|
//
|
||||||
|
// if (obj == null)
|
||||||
|
// break;
|
||||||
|
// if (obj == document.body)
|
||||||
|
// break;
|
||||||
|
// if (obj instanceof SVGPathElement)
|
||||||
|
// break;
|
||||||
|
//
|
||||||
|
// objs.push(obj);
|
||||||
|
// obj.style.display = 'none';
|
||||||
|
// } while(true);
|
||||||
|
// for(var i=0; i<objs.length; ++i)
|
||||||
|
// objs[i].style.display ='';
|
||||||
|
//
|
||||||
|
// if (obj == null)
|
||||||
|
// return;
|
||||||
|
//
|
||||||
|
// if (obj instanceof SVGPathElement)
|
||||||
|
// xroute.route.fire('mousemove',e);
|
||||||
|
// else
|
||||||
|
// xroute.route.fire('mouseout',e);
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// parse URL GET parameters if existing
|
||||||
|
function checkURL(){
|
||||||
|
var called_url = document.location.search.substr(1,document.location.search.length);
|
||||||
|
if( called_url != '') {
|
||||||
|
var positions = [];
|
||||||
|
|
||||||
|
// parse input (currently only parses start, dest, via)
|
||||||
|
var splitted_url = called_url.split('&');
|
||||||
|
for(var i=0; i<splitted_url.length; i++) {
|
||||||
|
var name_val = splitted_url[i].split('=');
|
||||||
|
if(name_val.length!=2)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var coordinates = unescape(name_val[1]).split(',');
|
||||||
|
if(coordinates.length!=2)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if(name_val[0] == 'loc')
|
||||||
|
positions.push ( new L.LatLng( coordinates[0], coordinates[1]) );
|
||||||
|
}
|
||||||
|
|
||||||
|
// draw via points
|
||||||
|
if( positions.length > 0)
|
||||||
|
my_markers.setSource( positions[0] );
|
||||||
|
for(var i=1; i<positions.length-1;i++)
|
||||||
|
my_markers.setVia( i-1, positions[i] );
|
||||||
|
if(positions.length > 1)
|
||||||
|
my_markers.setTarget( positions[positions.length-1] );
|
||||||
|
for(var i=0; i<my_markers.route.length;i++)
|
||||||
|
my_markers.route[i].show();
|
||||||
|
|
||||||
|
// compute route
|
||||||
|
getRoute(OSRM.FULL_DESCRIPTION);
|
||||||
|
|
||||||
|
var bounds = new L.LatLngBounds( positions );
|
||||||
|
//bounds._southWest.lng-=1.02; // dirty hacks
|
||||||
|
map.fitBounds( bounds );
|
||||||
|
//my_route.centerView();
|
||||||
|
}
|
||||||
|
}
|
423
WebContent/routing.js
Normal file
@ -0,0 +1,423 @@
|
|||||||
|
var my_route = undefined;
|
||||||
|
var my_markers = undefined;
|
||||||
|
|
||||||
|
OSRM.NO_DESCRIPTION = 0;
|
||||||
|
OSRM.FULL_DESCRIPTION = 1;
|
||||||
|
OSRM.dragging = false;
|
||||||
|
OSRM.pending = false;
|
||||||
|
OSRM.pendingTimer = undefined;
|
||||||
|
|
||||||
|
// init data
|
||||||
|
function initRouting() {
|
||||||
|
my_route = new OSRM.Route();
|
||||||
|
my_markers = new OSRM.Markers();
|
||||||
|
}
|
||||||
|
|
||||||
|
// decode compressed route geometry
|
||||||
|
function decodeRouteGeometry(encoded, precision) {
|
||||||
|
precision = Math.pow(10, -precision);
|
||||||
|
var len = encoded.length, index=0, lat=0, lng = 0, array = [];
|
||||||
|
while (index < len) {
|
||||||
|
var b, shift = 0, result = 0;
|
||||||
|
do {
|
||||||
|
b = encoded.charCodeAt(index++) - 63;
|
||||||
|
result |= (b & 0x1f) << shift;
|
||||||
|
shift += 5;
|
||||||
|
} while (b >= 0x20);
|
||||||
|
var dlat = ((result & 1) ? ~(result >> 1) : (result >> 1));
|
||||||
|
lat += dlat;
|
||||||
|
shift = 0;
|
||||||
|
result = 0;
|
||||||
|
do {
|
||||||
|
b = encoded.charCodeAt(index++) - 63;
|
||||||
|
result |= (b & 0x1f) << shift;
|
||||||
|
shift += 5;
|
||||||
|
} while (b >= 0x20);
|
||||||
|
var dlng = ((result & 1) ? ~(result >> 1) : (result >> 1));
|
||||||
|
lng += dlng;
|
||||||
|
array.push([lat * precision, lng * precision]);
|
||||||
|
}
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
// display a transmitted route
|
||||||
|
function timeoutRouteSimple() {
|
||||||
|
showNoRouteGeometry();
|
||||||
|
showNoRouteDescription();
|
||||||
|
document.getElementById('information-box').innerHTML = "<br><p style='font-size:14px;font-weight:bold;text-align:center;'>"+OSRM.loc("TIMED_OUT")+".<p>";
|
||||||
|
}
|
||||||
|
function timeoutRoute() {
|
||||||
|
showNoRouteGeometry();
|
||||||
|
my_route.hideUnnamedRoute();
|
||||||
|
showNoRouteDescription();
|
||||||
|
document.getElementById('information-box').innerHTML = "<br><p style='font-size:14px;font-weight:bold;text-align:center;'>"+OSRM.loc("TIMED_OUT")+".<p>";
|
||||||
|
}
|
||||||
|
function showRouteSimple(response) {
|
||||||
|
if(!response)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (OSRM.JSONP.fences.route) // prevent simple routing when real routing is done!
|
||||||
|
return;
|
||||||
|
|
||||||
|
if( response.status == 207) {
|
||||||
|
showNoRouteGeometry();
|
||||||
|
showNoRouteDescription();
|
||||||
|
document.getElementById('information-box').innerHTML = "<br><p style='font-size:14px;font-weight:bold;text-align:center;'>"+OSRM.loc("YOUR_ROUTE_IS_BEING_COMPUTED")+".<p>";
|
||||||
|
} else {
|
||||||
|
showRouteGeometry(response);
|
||||||
|
showRouteDescriptionSimple(response);
|
||||||
|
}
|
||||||
|
updateHints(response);
|
||||||
|
|
||||||
|
// if(OSRM.pending) {
|
||||||
|
// clearTimeout(OSRM.pendingTimer);
|
||||||
|
// OSRM.pendingTimer = setTimeout(timeoutDrag,100); // dirty dirty!
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
function showRoute(response) {
|
||||||
|
if(!response)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(response.status == 207) {
|
||||||
|
showNoRouteGeometry();
|
||||||
|
my_route.hideUnnamedRoute();
|
||||||
|
showNoRouteDescription();
|
||||||
|
document.getElementById('information-box').innerHTML = "<br><p style='font-size:14px;font-weight:bold;text-align:center;'>"+OSRM.loc("NO_ROUTE_FOUND")+".<p>";
|
||||||
|
} else {
|
||||||
|
showRouteGeometry(response);
|
||||||
|
showRouteNonames(response);
|
||||||
|
showRouteDescription(response);
|
||||||
|
snapRoute();
|
||||||
|
}
|
||||||
|
updateHints(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
function showNoRouteGeometry() {
|
||||||
|
var positions = [];
|
||||||
|
for(var i=0; i<my_markers.route.length;i++)
|
||||||
|
positions.push( my_markers.route[i].getPosition() );
|
||||||
|
|
||||||
|
my_route.showRoute(positions, OSRM.Route.NOROUTE);
|
||||||
|
}
|
||||||
|
function showRouteGeometry(response) {
|
||||||
|
via_points = response.via_points.slice(0);
|
||||||
|
|
||||||
|
var geometry = decodeRouteGeometry(response.route_geometry, 5);
|
||||||
|
|
||||||
|
var points = [];
|
||||||
|
for( var i=0; i < geometry.length; i++) {
|
||||||
|
points.push( new L.LatLng(geometry[i][0], geometry[i][1]) );
|
||||||
|
}
|
||||||
|
my_route.showRoute(points, OSRM.Route.ROUTE);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onClickRouteDescription(geometry_index) {
|
||||||
|
var positions = my_route.getPositions();
|
||||||
|
|
||||||
|
my_markers.highlight.setPosition( positions[geometry_index] );
|
||||||
|
my_markers.highlight.show();
|
||||||
|
my_markers.highlight.centerView();
|
||||||
|
}
|
||||||
|
function onClickCreateShortcut(src){
|
||||||
|
OSRM.JSONP.call(OSRM.DEFAULTS.HOST_SHORTENER_URL+src+'&jsonp=showRouteLink', showRouteLink, showRouteLink_TimeOut, 2000, 'shortener');
|
||||||
|
}
|
||||||
|
function showRouteLink(response){
|
||||||
|
document.getElementById('route-link').innerHTML = '[<a id="gpx-link" href="' +response.ShortURL+ '">'+OSRM.loc("LINK_TO_ROUTE")+'</a>]';
|
||||||
|
}
|
||||||
|
function showRouteLink_TimeOut(){
|
||||||
|
document.getElementById('route-link').innerHTML = '['+OSRM.loc("LINK_TO_ROUTE_TIMEOUT")+']';
|
||||||
|
}
|
||||||
|
function showRouteDescription(response) {
|
||||||
|
// compute query string
|
||||||
|
var query_string = '?z='+ map.getZoom();
|
||||||
|
for(var i=0; i<my_markers.route.length; i++)
|
||||||
|
query_string += '&loc=' + my_markers.route[i].getLat() + ',' + my_markers.route[i].getLng();
|
||||||
|
|
||||||
|
// create link to the route
|
||||||
|
var route_link ='<span class="route-summary" id="route-link">[<a id="gpx-link" onclick="onClickCreateShortcut(\'' + OSRM.DEFAULTS.WEBSITE_URL + query_string + '\')">'+OSRM.loc("GET_LINK")+'</a>]</span>';
|
||||||
|
//var route_link ='<span class="route-summary" id="route-link">[<a id="gpx-link" href="#" onclick="onClickCreateShortcut(\'' + document.URL + query_string + '\')">'+OSRM.loc("GET_LINK")+'</a>]</span>';
|
||||||
|
|
||||||
|
// create GPX link
|
||||||
|
var gpx_link = '<span class="route-summary">[<a id="gpx-link" onClick="javascript: document.location.href=\'' + OSRM.DEFAULTS.HOST_ROUTING_URL + query_string + '&output=gpx\';">'+OSRM.loc("GPX_FILE")+'</a>]</span>';
|
||||||
|
|
||||||
|
// create route description
|
||||||
|
var route_desc = "";
|
||||||
|
route_desc += '<table class="results-table">';
|
||||||
|
|
||||||
|
for(var i=0; i < response.route_instructions.length; i++){
|
||||||
|
//odd or even ?
|
||||||
|
var rowstyle='results-odd';
|
||||||
|
if(i%2==0) { rowstyle='results-even'; }
|
||||||
|
|
||||||
|
route_desc += '<tr class="'+rowstyle+'">';
|
||||||
|
|
||||||
|
route_desc += '<td class="result-directions">';
|
||||||
|
route_desc += '<img width="18px" src="images/'+getDirectionIcon(response.route_instructions[i][0])+'"/>';
|
||||||
|
route_desc += "</td>";
|
||||||
|
|
||||||
|
//route_desc += '<td class="result-counter"><span">'+(i+1)+'.</span></td>';
|
||||||
|
|
||||||
|
route_desc += '<td class="result-items">';
|
||||||
|
route_desc += '<span class="result-item" onclick="onClickRouteDescription('+response.route_instructions[i][3]+')">'
|
||||||
|
+ response.route_instructions[i][0] + ' on ';
|
||||||
|
if( response.route_instructions[i][2] > 0 )
|
||||||
|
route_desc += response.route_instructions[i][1] + ' for '
|
||||||
|
+ getDistanceWithUnit(response.route_instructions[i][2])
|
||||||
|
+ '</span>';
|
||||||
|
route_desc += "</td>";
|
||||||
|
|
||||||
|
route_desc += "</tr>";
|
||||||
|
}
|
||||||
|
|
||||||
|
route_desc += '</table>';
|
||||||
|
headline = "";
|
||||||
|
headline += OSRM.loc("ROUTE_DESCRIPTION")+":<br>";
|
||||||
|
headline += '<div style="float:left;width:70%">';
|
||||||
|
headline += "<span class='route-summary'>"
|
||||||
|
+ OSRM.loc("DISTANCE")+": " + getDistanceWithUnit(response.route_summary.total_distance)
|
||||||
|
+ " - "
|
||||||
|
+ OSRM.loc("DURATION")+": " + secondsToTime(response.route_summary.total_time)
|
||||||
|
+ "</span>";
|
||||||
|
headline += '</div>';
|
||||||
|
headline += '<div style="float:left;text-align:right;width:30%;">'+route_link+'<br>'+gpx_link+'</div>';
|
||||||
|
|
||||||
|
var output = "";
|
||||||
|
output += route_desc;
|
||||||
|
|
||||||
|
document.getElementById('information-box-headline').innerHTML = headline;
|
||||||
|
document.getElementById('information-box').innerHTML = output;
|
||||||
|
}
|
||||||
|
function showRouteDescriptionSimple(response) {
|
||||||
|
headline = OSRM.loc("ROUTE_DESCRIPTION")+":<br>";
|
||||||
|
headline += "<span class='route-summary'>"
|
||||||
|
+ OSRM.loc("DISTANCE")+": " + getDistanceWithUnit(response.route_summary.total_distance)
|
||||||
|
+ " - "
|
||||||
|
+ OSRM.loc("DURATION")+": " + secondsToTime(response.route_summary.total_time)
|
||||||
|
+ "</span>";
|
||||||
|
headline += '<br><br>';
|
||||||
|
|
||||||
|
document.getElementById('information-box-headline').innerHTML = headline;
|
||||||
|
document.getElementById('information-box').innerHTML = "<br><p style='font-size:14px;font-weight:bold;text-align:center;'>"+OSRM.loc("YOUR_ROUTE_IS_BEING_COMPUTED")+".<p>";
|
||||||
|
}
|
||||||
|
function showNoRouteDescription() {
|
||||||
|
headline = OSRM.loc("ROUTE_DESCRIPTION")+":<br>";
|
||||||
|
headline += "<span class='route-summary'>"
|
||||||
|
+ OSRM.loc("DISTANCE")+": N/A"
|
||||||
|
+ " - "
|
||||||
|
+ OSRM.loc("DURATION")+": N/A"
|
||||||
|
+ "</span>";
|
||||||
|
headline += '<br><br>';
|
||||||
|
|
||||||
|
document.getElementById('information-box-headline').innerHTML = headline;
|
||||||
|
document.getElementById('information-box').innerHTML = "<br><p style='font-size:14px;font-weight:bold;text-align:center;'>"+OSRM.loc("YOUR_ROUTE_IS_BEING_COMPUTED")+".<p>";
|
||||||
|
}
|
||||||
|
|
||||||
|
function showRouteNonames(response) {
|
||||||
|
// do not display unnamed streets?
|
||||||
|
if( document.getElementById('option-highlight-nonames').checked == false) {
|
||||||
|
my_route.hideUnnamedRoute();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// mark geometry positions where unnamed/named streets switch
|
||||||
|
var named = [];
|
||||||
|
for (var i = 0; i < response.route_instructions.length; i++) {
|
||||||
|
if( response.route_instructions[i][1] == '' )
|
||||||
|
named[ response.route_instructions[i][3] ] = false; // no street name
|
||||||
|
else
|
||||||
|
named[ response.route_instructions[i][3] ] = true; // yes street name
|
||||||
|
}
|
||||||
|
|
||||||
|
// aggregate geometry for unnamed streets
|
||||||
|
var geometry = decodeRouteGeometry(response.route_geometry, 5);
|
||||||
|
var is_named = true;
|
||||||
|
var current_positions = [];
|
||||||
|
var all_positions = [];
|
||||||
|
for( var i=0; i < geometry.length; i++) {
|
||||||
|
current_positions.push( new L.LatLng(geometry[i][0], geometry[i][1]) );
|
||||||
|
|
||||||
|
// still named/unnamed?
|
||||||
|
if( (named[i] == is_named || named[i] == undefined) && i != geometry.length-1 )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// switch between named/unnamed!
|
||||||
|
if(is_named == false)
|
||||||
|
all_positions.push( current_positions );
|
||||||
|
current_positions = [];
|
||||||
|
current_positions.push( new L.LatLng(geometry[i][0], geometry[i][1]) );
|
||||||
|
is_named = named[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
// display unnamed streets
|
||||||
|
my_route.showUnnamedRoute(all_positions);
|
||||||
|
}
|
||||||
|
|
||||||
|
// function for dragging and drawing routes
|
||||||
|
function getRoute(do_description) {
|
||||||
|
|
||||||
|
// if source or target are not set -> hide route
|
||||||
|
if( my_markers.route.length < 2 ) {
|
||||||
|
my_route.hideRoute();
|
||||||
|
//my_markers.removeVias(); // TODO: do I need this?
|
||||||
|
//my_markers.highlight.hide();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// prepare JSONP call
|
||||||
|
var type = undefined;
|
||||||
|
var callback = undefined;
|
||||||
|
var timeout = undefined;
|
||||||
|
|
||||||
|
var source = OSRM.DEFAULTS.HOST_ROUTING_URL;
|
||||||
|
source += '?z=' + map.getZoom() + '&output=json' + '&geomformat=cmp';
|
||||||
|
if(my_markers.checksum)
|
||||||
|
source += '&checksum=' + my_markers.checksum;
|
||||||
|
for(var i=0; i<my_markers.route.length; i++) {
|
||||||
|
source += '&loc=' + my_markers.route[i].getLat() + ',' + my_markers.route[i].getLng();
|
||||||
|
if( my_markers.route[i].hint)
|
||||||
|
source += '&hint=' + my_markers.route[i].hint;
|
||||||
|
}
|
||||||
|
|
||||||
|
// decide whether it is a dragging call or a normal one
|
||||||
|
if (do_description) {
|
||||||
|
callback = showRoute;
|
||||||
|
timeout = timeoutRoute;
|
||||||
|
source +='&instructions=true';
|
||||||
|
type = 'route';
|
||||||
|
} else {
|
||||||
|
callback = showRouteSimple;
|
||||||
|
timeout = timeoutRouteSimple;
|
||||||
|
source +='&instructions=false';
|
||||||
|
type = 'dragging';
|
||||||
|
}
|
||||||
|
|
||||||
|
// do call
|
||||||
|
var called = OSRM.JSONP.call(source, callback, timeout, OSRM.JSONP.TIMEOUT, type);
|
||||||
|
|
||||||
|
// TODO: guarantee to do last drag
|
||||||
|
if(called == false && !do_description) {
|
||||||
|
clearTimeout(OSRM.pendingTimer);
|
||||||
|
OSRM.pendingTimer = setTimeout(timeoutDrag,OSRM.JSONP.TIMEOUT);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
clearTimeout(OSRM.pendingTimer);
|
||||||
|
}
|
||||||
|
// if(called == false && !do_description) {
|
||||||
|
// OSRM.pending = true;
|
||||||
|
// } else {
|
||||||
|
// clearTimeout(OSRM.pendingTimer);
|
||||||
|
// OSRM.pending = false;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
function timeoutDrag() {
|
||||||
|
my_markers.route[OSRM.dragid].hint = undefined;
|
||||||
|
getRoute(OSRM.NO_DESCRIPTION);
|
||||||
|
}
|
||||||
|
|
||||||
|
function startRouting() {
|
||||||
|
getRoute(OSRM.FULL_DESCRIPTION);
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetRouting() {
|
||||||
|
document.getElementById('input-source-name').value = "";
|
||||||
|
document.getElementById('input-target-name').value = "";
|
||||||
|
|
||||||
|
my_route.hideRoute();
|
||||||
|
my_markers.removeAll();
|
||||||
|
my_markers.highlight.hide();
|
||||||
|
|
||||||
|
document.getElementById('information-box').innerHTML = "";
|
||||||
|
document.getElementById('information-box-headline').innerHTML = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateHints(response) {
|
||||||
|
var hint_locations = response.hint_data.locations;
|
||||||
|
my_markers.checksum = response.hint_data.checksum;
|
||||||
|
for(var i=0; i<hint_locations.length; i++)
|
||||||
|
my_markers.route[i].hint = hint_locations[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
function snapRoute() {
|
||||||
|
var positions = my_route.getPositions();
|
||||||
|
|
||||||
|
my_markers.route[0].setPosition( positions[0] );
|
||||||
|
my_markers.route[my_markers.route.length-1].setPosition( positions[positions.length-1] );
|
||||||
|
for(var i=0; i<via_points.length; i++)
|
||||||
|
my_markers.route[i+1].setPosition( new L.LatLng(via_points[i][0], via_points[i][1]) );
|
||||||
|
|
||||||
|
updateLocation( "source" );
|
||||||
|
updateLocation( "target" );
|
||||||
|
}
|
||||||
|
|
||||||
|
function positionsToInput() {
|
||||||
|
if(my_markers.route[0].label == OSRM.SOURCE_MARKER_LABEL) {
|
||||||
|
document.getElementById('input-source-name').value = my_markers.route[0].getPosition().lat.toFixed(6)+","+my_markers.route[0].getPosition().lng.toFixed(6);
|
||||||
|
}
|
||||||
|
if(my_markers.route[my_markers.route.length-1].label == OSRM.TARGET_MARKER_LABEL) {
|
||||||
|
document.getElementById('input-target-name').value = my_markers.route[my_markers.route.length-1].getPosition().lat.toFixed(6)+","+my_markers.route[my_markers.route.length-1].getPosition().lng.toFixed(6);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function reverseRouting() {
|
||||||
|
// invert input boxes
|
||||||
|
var tmp = document.getElementById("input-source-name").value;
|
||||||
|
document.getElementById("input-source-name").value = document.getElementById("input-target-name").value;
|
||||||
|
document.getElementById("input-target-name").value = tmp;
|
||||||
|
|
||||||
|
// invert route
|
||||||
|
my_markers.route.reverse();
|
||||||
|
if(my_markers.route.length == 1) {
|
||||||
|
if(my_markers.route[0].label == OSRM.TARGET_MARKER_LABEL) {
|
||||||
|
my_markers.route[0].label = OSRM.SOURCE_MARKER_LABEL;
|
||||||
|
my_markers.route[0].marker.setIcon( new L.Icon('images/marker-source.png') );
|
||||||
|
} else if(my_markers.route[0].label == OSRM.SOURCE_MARKER_LABEL) {
|
||||||
|
my_markers.route[0].label = OSRM.TARGET_MARKER_LABEL;
|
||||||
|
my_markers.route[0].marker.setIcon( new L.Icon('images/marker-target.png') );
|
||||||
|
}
|
||||||
|
} else if(my_markers.route.length > 1){
|
||||||
|
my_markers.route[0].label = OSRM.SOURCE_MARKER_LABEL;
|
||||||
|
my_markers.route[0].marker.setIcon( new L.Icon('images/marker-source.png') );
|
||||||
|
|
||||||
|
my_markers.route[my_markers.route.length-1].label = OSRM.TARGET_MARKER_LABEL;
|
||||||
|
my_markers.route[my_markers.route.length-1].marker.setIcon( new L.Icon('images/marker-target.png') );
|
||||||
|
}
|
||||||
|
|
||||||
|
// recompute route
|
||||||
|
getRoute(OSRM.FULL_DESCRIPTION);
|
||||||
|
my_markers.highlight.hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------
|
||||||
|
function getDirectionIcon(name) {
|
||||||
|
var directions = {
|
||||||
|
"Turn left":"turn-left.png",
|
||||||
|
"Turn right":"turn-right.png",
|
||||||
|
"U-Turn":"u-turn.png",
|
||||||
|
"Head":"continue.png",
|
||||||
|
"Continue":"continue.png",
|
||||||
|
"Turn slight left":"slight-left.png",
|
||||||
|
"Turn slight right":"slight-right.png",
|
||||||
|
"Turn sharp left":"sharp-left.png",
|
||||||
|
"Turn sharp right":"sharp-right.png",
|
||||||
|
"Enter round-about and leave at first exit":"round-about.png",
|
||||||
|
"Enter round-about and leave at second exit":"round-about.png",
|
||||||
|
"Enter round-about and leave at third exit":"round-about.png",
|
||||||
|
"Enter round-about and leave at forth exit":"round-about.png",
|
||||||
|
"Enter round-about and leave at fifth exit":"round-about.png",
|
||||||
|
"Enter round-about and leave at sixth exit":"round-about.png",
|
||||||
|
"Enter round-about and leave at seventh exit":"round-about.png",
|
||||||
|
"Enter round-about and leave at eighth exit":"round-about.png",
|
||||||
|
"Enter round-about and leave at nineth exit":"round-about.png",
|
||||||
|
"Enter round-about and leave at tenth exit":"round-about.png",
|
||||||
|
"Enter round-about and leave at one of the too many exit":"round-about.png",
|
||||||
|
};
|
||||||
|
|
||||||
|
if( directions[name] )
|
||||||
|
return directions[name];
|
||||||
|
else
|
||||||
|
return "default.png";
|
||||||
|
}
|
27
WebContent/test.html
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
|
||||||
|
<script src="leaflet/leaflet-src.js"></script>
|
||||||
|
<script src="OSRM.js"></script>
|
||||||
|
<script src="OSRM.Markers.js"></script>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
function testSnippet()
|
||||||
|
{
|
||||||
|
var marker = new OSRM.RouteMarker("source",undefined,new L.Icon('images/marker-source.png'));
|
||||||
|
marker.yyy();
|
||||||
|
for(a in marker)
|
||||||
|
alert(a);
|
||||||
|
alert(marker);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<h1>Test Javascript Snippets</h1>
|
||||||
|
<p id="output">This could be your output.</p>
|
||||||
|
|
||||||
|
<button type="button" onclick="testSnippet()">Run Snippet</button>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
69
WebContent/utils.js
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
// compatibility mode for old browser
|
||||||
|
function getElementsByClassName(node, classname) {
|
||||||
|
var a = [];
|
||||||
|
var re = new RegExp('(^| )'+classname+'( |$)');
|
||||||
|
var els = node.getElementsByTagName("*");
|
||||||
|
for(var i=0,j=els.length; i<j; i++)
|
||||||
|
if(re.test(els[i].className))a.push(els[i]);
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
document.head = document.head || document.getElementsByTagName('head')[0];
|
||||||
|
|
||||||
|
// ------------------------------------------------------
|
||||||
|
|
||||||
|
// human readable time
|
||||||
|
function secondsToTime(seconds){
|
||||||
|
seconds = parseInt(seconds);
|
||||||
|
minutes = parseInt(seconds/60);
|
||||||
|
seconds = seconds%60;
|
||||||
|
hours = parseInt(minutes/60);
|
||||||
|
minutes = minutes%60;
|
||||||
|
if(hours==0){
|
||||||
|
return minutes+' min';
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return hours+' h '+minutes+' min';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// human readable distance
|
||||||
|
function getDistanceWithUnit(distance){
|
||||||
|
distance = parseInt(distance);
|
||||||
|
if(distance >= 1000){ return (parseInt(distance/1000))+' km'; }
|
||||||
|
else{ return distance+' m'; }
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------
|
||||||
|
|
||||||
|
// distance between two points
|
||||||
|
function distanceBetweenPoint(x1, y1, x2, y2) {
|
||||||
|
var a = x1 - x2;
|
||||||
|
var b = y1 - y2;
|
||||||
|
return Math.sqrt(a*a + b*b);
|
||||||
|
}
|
||||||
|
|
||||||
|
// distance from a point to a line or segment
|
||||||
|
// (x,y) point
|
||||||
|
// (x0,y0) line point A
|
||||||
|
// (x1,y1) line point B
|
||||||
|
// o specifies if the distance should respect the limits of the segment (overLine = true)
|
||||||
|
// or if it should consider the segment as an infinite line (overLine = false);
|
||||||
|
// if false returns the distance from the point to the line,
|
||||||
|
// otherwise the distance from the point to the segment
|
||||||
|
function dotLineLength(x, y, x0, y0, x1, y1, o){
|
||||||
|
function lineLength(x, y, x0, y0){return Math.sqrt((x -= x0) * x + (y -= y0) * y);}
|
||||||
|
|
||||||
|
if(o && !(o = function(x, y, x0, y0, x1, y1){
|
||||||
|
if(!(x1 - x0)) return {x: x0, y: y};
|
||||||
|
else if(!(y1 - y0)) return {x: x, y: y0};
|
||||||
|
var left, tg = -1 / ((y1 - y0) / (x1 - x0));
|
||||||
|
return {x: left = (x1 * (x * tg - y + y0) + x0 * (x * - tg + y - y1)) / (tg * (x1 - x0) + y0 - y1), y: tg * left - tg * x + y};
|
||||||
|
}(x, y, x0, y0, x1, y1) && o.x >= Math.min(x0, x1) && o.x <= Math.max(x0, x1) && o.y >= Math.min(y0, y1) && o.y <= Math.max(y0, y1))){
|
||||||
|
var l1 = lineLength(x, y, x0, y0), l2 = lineLength(x, y, x1, y1);
|
||||||
|
return l1 > l2 ? l2 : l1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var a = y0 - y1, b = x1 - x0, c = x0 * y1 - y0 * x1;
|
||||||
|
return Math.abs(a * x + b * y + c) / Math.sqrt(a * a + b * b);
|
||||||
|
}
|
||||||
|
};
|
42
WebContent/via.js
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
var via_points;
|
||||||
|
|
||||||
|
function findNearestRouteSegment( new_via ) {
|
||||||
|
var min_dist = Number.MAX_VALUE;
|
||||||
|
var min_index = undefined;
|
||||||
|
|
||||||
|
var positions = my_route.getPositions();
|
||||||
|
for(var i=0; i<positions.length-1; i++) {
|
||||||
|
var dist = dotLineLength( new_via.lng, new_via.lat, positions[i].lng, positions[i].lat, positions[i+1].lng, positions[i+1].lat, true);
|
||||||
|
if( dist < min_dist) {
|
||||||
|
min_dist = dist;
|
||||||
|
min_index = i+1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return min_index;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function findViaPosition( new_via_position ) {
|
||||||
|
// find route segment that is closest to click position (marked by last index)
|
||||||
|
var nearest_index = findNearestRouteSegment( new_via_position );
|
||||||
|
|
||||||
|
// find correct index to insert new via node
|
||||||
|
var new_via_index = via_points.length;
|
||||||
|
var via_index = Array();
|
||||||
|
for(var i=0; i<via_points.length; i++) {
|
||||||
|
via_index[i] = findNearestRouteSegment( new L.LatLng(via_points[i][0], via_points[i][1]) );
|
||||||
|
if(via_index[i] > nearest_index) {
|
||||||
|
new_via_index = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// add via node
|
||||||
|
var index = my_markers.setVia(new_via_index, new_via_position);
|
||||||
|
my_markers.route[index].show();
|
||||||
|
|
||||||
|
getRoute(OSRM.FULL_DESCRIPTION);
|
||||||
|
|
||||||
|
return new_via_index;
|
||||||
|
}
|
@ -1,44 +0,0 @@
|
|||||||
IF(NOT CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
|
||||||
MESSAGE(FATAL_ERROR "Cannot configure CPack to generate Debian/RPM packages on non-linux systems.")
|
|
||||||
ENDIF()
|
|
||||||
string(TOLOWER "${CMAKE_PROJECT_NAME}" CPACK_PACKAGE_NAME)
|
|
||||||
SET(CPACK_PACKAGE_VERSION_MAJOR ${OSRM_VERSION_MAJOR})
|
|
||||||
SET(CPACK_PACKAGE_VERSION_MINOR ${OSRM_VERSION_MINOR})
|
|
||||||
SET(CPACK_PACKAGE_VERSION_PATCH ${OSRM_VERSION_PATCH})
|
|
||||||
SET(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
|
|
||||||
|
|
||||||
SET(CPACK_INCLUDE_TOPLEVEL_DIRECTORY "FALSE")
|
|
||||||
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README.md")
|
|
||||||
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Open Source Routing Machine (OSRM) is a high-performance routing engine. It combines sophisticated routing algorithms with the open and free data of the OpenStreetMap.")
|
|
||||||
SET(CPACK_PACKAGE_CONTACT "Project OSRM <info@project-osrm.org>")
|
|
||||||
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE.TXT")
|
|
||||||
|
|
||||||
SET(CPACK_STRIP_FILES "TRUE")
|
|
||||||
file(GLOB_RECURSE ProfileGlob ${CMAKE_SOURCE_DIR}/profiles/*)
|
|
||||||
install(FILES ${ProfileGlob} DESTINATION "share/doc/${CPACK_PACKAGE_NAME}/profiles")
|
|
||||||
|
|
||||||
find_program(DPKG_PROGRAM dpkg DOC "dpkg program of Debian-based systems")
|
|
||||||
if(DPKG_PROGRAM)
|
|
||||||
SET(CPACK_GENERATOR "DEB")
|
|
||||||
execute_process(
|
|
||||||
COMMAND ${DPKG_PROGRAM} --print-architecture
|
|
||||||
OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE
|
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
||||||
)
|
|
||||||
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
|
|
||||||
SET(CPACK_DEBIAN_PACKAGE_SHLIBDEPS "ON")
|
|
||||||
else(DPKG_PROGRAM)
|
|
||||||
find_program(RPM_PROGRAM rpm DOC "rpm RPM-based systems")
|
|
||||||
find_program(RPMBUILD_PROGRAM rpm DOC "rpm RPM-based systems")
|
|
||||||
if(RPMBUILD_PROGRAM)
|
|
||||||
SET(CPACK_GENERATOR "RPM")
|
|
||||||
execute_process(
|
|
||||||
COMMAND ${RPM_PROGRAM} --eval %{_arch}
|
|
||||||
OUTPUT_VARIABLE CPACK_RPM_PACKAGE_ARCHITECTURE
|
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
||||||
)
|
|
||||||
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}.${CPACK_RPM_PACKAGE_ARCHITECTURE}")
|
|
||||||
# Exclude /usr/lib64/pkgconfig directory given that it is already owned by the pkg-config rpm package.
|
|
||||||
SET(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/usr/${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
|
||||||
endif(RPMBUILD_PROGRAM)
|
|
||||||
endif(DPKG_PROGRAM)
|
|
@ -1,19 +0,0 @@
|
|||||||
#
|
|
||||||
# Copyright (C) 2013 Emmanuel Roullit <emmanuel.roullit@gmail.com>
|
|
||||||
#
|
|
||||||
|
|
||||||
IF(NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
|
|
||||||
FIND_PROGRAM(DPKG_CMD dpkg)
|
|
||||||
IF(NOT DPKG_CMD)
|
|
||||||
EXECUTE_PROCESS(COMMAND uname -p
|
|
||||||
OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE
|
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
||||||
)
|
|
||||||
MESSAGE(STATUS "Can not find dpkg in your path, default to uname -p: ${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.")
|
|
||||||
ELSE(NOT DPKG_CMD)
|
|
||||||
EXECUTE_PROCESS(COMMAND "${DPKG_CMD}" --print-architecture
|
|
||||||
OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE
|
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
||||||
)
|
|
||||||
ENDIF(NOT DPKG_CMD)
|
|
||||||
ENDIF(NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
|
|
@ -1,205 +0,0 @@
|
|||||||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
||||||
# file Copyright.txt or https://cmake.org/licensing for details.
|
|
||||||
|
|
||||||
#.rst:
|
|
||||||
# FindLua
|
|
||||||
# -------
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# Locate Lua library This module defines
|
|
||||||
#
|
|
||||||
# ::
|
|
||||||
#
|
|
||||||
# LUA_FOUND - if false, do not try to link to Lua
|
|
||||||
# LUA_LIBRARIES - both lua and lualib
|
|
||||||
# LUA_INCLUDE_DIR - where to find lua.h
|
|
||||||
# LUA_VERSION_STRING - the version of Lua found
|
|
||||||
# LUA_VERSION_MAJOR - the major version of Lua
|
|
||||||
# LUA_VERSION_MINOR - the minor version of Lua
|
|
||||||
# LUA_VERSION_PATCH - the patch version of Lua
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# Note that the expected include convention is
|
|
||||||
#
|
|
||||||
# ::
|
|
||||||
#
|
|
||||||
# #include "lua.h"
|
|
||||||
#
|
|
||||||
# and not
|
|
||||||
#
|
|
||||||
# ::
|
|
||||||
#
|
|
||||||
# #include <lua/lua.h>
|
|
||||||
#
|
|
||||||
# This is because, the lua location is not standardized and may exist in
|
|
||||||
# locations other than lua/
|
|
||||||
|
|
||||||
if(NOT PKG_CONFIG_FOUND)
|
|
||||||
include(CMakeFindDependencyMacro)
|
|
||||||
find_dependency(PkgConfig)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
unset(_lua_include_subdirs)
|
|
||||||
unset(_lua_library_names)
|
|
||||||
unset(_lua_append_versions)
|
|
||||||
|
|
||||||
# this is a function only to have all the variables inside go away automatically
|
|
||||||
function(_lua_set_version_vars)
|
|
||||||
set(LUA_VERSIONS5 5.4 5.3 5.2 5.1 5.0)
|
|
||||||
|
|
||||||
if (Lua_FIND_VERSION_EXACT)
|
|
||||||
if (Lua_FIND_VERSION_COUNT GREATER 1)
|
|
||||||
set(_lua_append_versions ${Lua_FIND_VERSION_MAJOR}.${Lua_FIND_VERSION_MINOR})
|
|
||||||
endif ()
|
|
||||||
elseif (Lua_FIND_VERSION)
|
|
||||||
# once there is a different major version supported this should become a loop
|
|
||||||
if (NOT Lua_FIND_VERSION_MAJOR GREATER 5)
|
|
||||||
if (Lua_FIND_VERSION_COUNT EQUAL 1)
|
|
||||||
set(_lua_append_versions ${LUA_VERSIONS5})
|
|
||||||
else ()
|
|
||||||
foreach (subver IN LISTS LUA_VERSIONS5)
|
|
||||||
if (NOT subver VERSION_LESS ${Lua_FIND_VERSION})
|
|
||||||
list(APPEND _lua_append_versions ${subver})
|
|
||||||
endif ()
|
|
||||||
endforeach ()
|
|
||||||
endif ()
|
|
||||||
endif ()
|
|
||||||
else ()
|
|
||||||
# once there is a different major version supported this should become a loop
|
|
||||||
set(_lua_append_versions ${LUA_VERSIONS5})
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
list(APPEND _lua_include_subdirs "include/lua" "include")
|
|
||||||
|
|
||||||
foreach (ver IN LISTS _lua_append_versions)
|
|
||||||
string(REGEX MATCH "^([0-9]+)\\.([0-9]+)$" _ver "${ver}")
|
|
||||||
list(APPEND _lua_include_subdirs
|
|
||||||
include/lua${CMAKE_MATCH_1}${CMAKE_MATCH_2}
|
|
||||||
include/lua${CMAKE_MATCH_1}.${CMAKE_MATCH_2}
|
|
||||||
include/lua-${CMAKE_MATCH_1}.${CMAKE_MATCH_2}
|
|
||||||
)
|
|
||||||
list(APPEND _lua_library_names
|
|
||||||
lua${CMAKE_MATCH_1}${CMAKE_MATCH_2}
|
|
||||||
lua${CMAKE_MATCH_1}.${CMAKE_MATCH_2}
|
|
||||||
lua-${CMAKE_MATCH_1}.${CMAKE_MATCH_2}
|
|
||||||
lua.${CMAKE_MATCH_1}.${CMAKE_MATCH_2}
|
|
||||||
)
|
|
||||||
pkg_check_modules(LUA QUIET "lua${ver}")
|
|
||||||
list(APPEND _lua_include_subdirs ${LUA_INCLUDE_DIRS})
|
|
||||||
list(APPEND _lua_library_names ${LUA_LIBRARIES})
|
|
||||||
list(APPEND _lua_library_dirs ${LUA_LIBRARY_DIRS})
|
|
||||||
endforeach ()
|
|
||||||
|
|
||||||
set(_lua_include_subdirs "${_lua_include_subdirs}" PARENT_SCOPE)
|
|
||||||
set(_lua_library_names "${_lua_library_names}" PARENT_SCOPE)
|
|
||||||
set(_lua_append_versions "${_lua_append_versions}" PARENT_SCOPE)
|
|
||||||
set(_lua_library_dirs "${_lua_library_dirs}" PARENT_SCOPE)
|
|
||||||
endfunction(_lua_set_version_vars)
|
|
||||||
|
|
||||||
function(_lua_check_header_version _hdr_file)
|
|
||||||
# At least 5.[012] have different ways to express the version
|
|
||||||
# so all of them need to be tested. Lua 5.2 defines LUA_VERSION
|
|
||||||
# and LUA_RELEASE as joined by the C preprocessor, so avoid those.
|
|
||||||
file(STRINGS "${_hdr_file}" lua_version_strings
|
|
||||||
REGEX "^#define[ \t]+LUA_(RELEASE[ \t]+\"Lua [0-9]|VERSION([ \t]+\"Lua [0-9]|_[MR])).*")
|
|
||||||
|
|
||||||
string(REGEX REPLACE ".*;#define[ \t]+LUA_VERSION_MAJOR[ \t]+\"([0-9])\"[ \t]*;.*" "\\1" LUA_VERSION_MAJOR ";${lua_version_strings};")
|
|
||||||
if (LUA_VERSION_MAJOR MATCHES "^[0-9]+$")
|
|
||||||
string(REGEX REPLACE ".*;#define[ \t]+LUA_VERSION_MINOR[ \t]+\"([0-9])\"[ \t]*;.*" "\\1" LUA_VERSION_MINOR ";${lua_version_strings};")
|
|
||||||
string(REGEX REPLACE ".*;#define[ \t]+LUA_VERSION_RELEASE[ \t]+\"([0-9])\"[ \t]*;.*" "\\1" LUA_VERSION_PATCH ";${lua_version_strings};")
|
|
||||||
set(LUA_VERSION_STRING "${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}.${LUA_VERSION_PATCH}")
|
|
||||||
else ()
|
|
||||||
string(REGEX REPLACE ".*;#define[ \t]+LUA_RELEASE[ \t]+\"Lua ([0-9.]+)\"[ \t]*;.*" "\\1" LUA_VERSION_STRING ";${lua_version_strings};")
|
|
||||||
if (NOT LUA_VERSION_STRING MATCHES "^[0-9.]+$")
|
|
||||||
string(REGEX REPLACE ".*;#define[ \t]+LUA_VERSION[ \t]+\"Lua ([0-9.]+)\"[ \t]*;.*" "\\1" LUA_VERSION_STRING ";${lua_version_strings};")
|
|
||||||
endif ()
|
|
||||||
string(REGEX REPLACE "^([0-9]+)\\.[0-9.]*$" "\\1" LUA_VERSION_MAJOR "${LUA_VERSION_STRING}")
|
|
||||||
string(REGEX REPLACE "^[0-9]+\\.([0-9]+)[0-9.]*$" "\\1" LUA_VERSION_MINOR "${LUA_VERSION_STRING}")
|
|
||||||
string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]).*" "\\1" LUA_VERSION_PATCH "${LUA_VERSION_STRING}")
|
|
||||||
endif ()
|
|
||||||
foreach (ver IN LISTS _lua_append_versions)
|
|
||||||
if (ver STREQUAL "${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}")
|
|
||||||
set(LUA_VERSION_MAJOR ${LUA_VERSION_MAJOR} PARENT_SCOPE)
|
|
||||||
set(LUA_VERSION_MINOR ${LUA_VERSION_MINOR} PARENT_SCOPE)
|
|
||||||
set(LUA_VERSION_PATCH ${LUA_VERSION_PATCH} PARENT_SCOPE)
|
|
||||||
set(LUA_VERSION_STRING ${LUA_VERSION_STRING} PARENT_SCOPE)
|
|
||||||
return()
|
|
||||||
endif ()
|
|
||||||
endforeach ()
|
|
||||||
endfunction(_lua_check_header_version)
|
|
||||||
|
|
||||||
_lua_set_version_vars()
|
|
||||||
|
|
||||||
if (LUA_INCLUDE_DIR AND EXISTS "${LUA_INCLUDE_DIR}/lua.h")
|
|
||||||
_lua_check_header_version("${LUA_INCLUDE_DIR}/lua.h")
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
if (NOT LUA_VERSION_STRING)
|
|
||||||
foreach (subdir IN LISTS _lua_include_subdirs)
|
|
||||||
unset(LUA_INCLUDE_PREFIX CACHE)
|
|
||||||
find_path(LUA_INCLUDE_PREFIX ${subdir}/lua.h
|
|
||||||
HINTS
|
|
||||||
ENV LUA_DIR
|
|
||||||
PATHS
|
|
||||||
~/Library/Frameworks
|
|
||||||
/Library/Frameworks
|
|
||||||
/sw # Fink
|
|
||||||
/opt/local # DarwinPorts
|
|
||||||
/opt/csw # Blastwave
|
|
||||||
/opt
|
|
||||||
)
|
|
||||||
if (LUA_INCLUDE_PREFIX)
|
|
||||||
_lua_check_header_version("${LUA_INCLUDE_PREFIX}/${subdir}/lua.h")
|
|
||||||
if (LUA_VERSION_STRING)
|
|
||||||
set(LUA_INCLUDE_DIR "${LUA_INCLUDE_PREFIX}/${subdir}")
|
|
||||||
break()
|
|
||||||
endif ()
|
|
||||||
endif ()
|
|
||||||
endforeach ()
|
|
||||||
endif ()
|
|
||||||
unset(_lua_include_subdirs)
|
|
||||||
unset(_lua_append_versions)
|
|
||||||
|
|
||||||
find_library(LUA_LIBRARY
|
|
||||||
NAMES ${_lua_library_names} lua
|
|
||||||
HINTS
|
|
||||||
ENV LUA_DIR
|
|
||||||
PATH_SUFFIXES lib
|
|
||||||
PATHS
|
|
||||||
${_lua_library_dirs}
|
|
||||||
~/Library/Frameworks
|
|
||||||
/Library/Frameworks
|
|
||||||
/sw
|
|
||||||
/opt/local
|
|
||||||
/opt/csw
|
|
||||||
/opt
|
|
||||||
)
|
|
||||||
unset(_lua_library_names)
|
|
||||||
|
|
||||||
if (LUA_LIBRARY)
|
|
||||||
# include the math library for Unix
|
|
||||||
if (UNIX AND NOT APPLE AND NOT BEOS)
|
|
||||||
find_library(LUA_MATH_LIBRARY m)
|
|
||||||
set(LUA_LIBRARIES "${LUA_LIBRARY};${LUA_MATH_LIBRARY}")
|
|
||||||
|
|
||||||
# include dl library for statically-linked Lua library
|
|
||||||
get_filename_component(LUA_LIB_EXT ${LUA_LIBRARY} EXT)
|
|
||||||
if(LUA_LIB_EXT STREQUAL CMAKE_STATIC_LIBRARY_SUFFIX)
|
|
||||||
list(APPEND LUA_LIBRARIES ${CMAKE_DL_LIBS})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# For Windows and Mac, don't need to explicitly include the math library
|
|
||||||
else ()
|
|
||||||
set(LUA_LIBRARIES "${LUA_LIBRARY}")
|
|
||||||
endif ()
|
|
||||||
endif ()
|
|
||||||
include(FindPackageHandleStandardArgs)
|
|
||||||
# handle the QUIETLY and REQUIRED arguments and set LUA_FOUND to TRUE if
|
|
||||||
# all listed variables are TRUE
|
|
||||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua
|
|
||||||
REQUIRED_VARS LUA_LIBRARIES LUA_INCLUDE_DIR
|
|
||||||
VERSION_VAR LUA_VERSION_STRING)
|
|
||||||
|
|
||||||
mark_as_advanced(LUA_INCLUDE_DIR LUA_LIBRARY LUA_MATH_LIBRARY)
|
|
@ -1,456 +0,0 @@
|
|||||||
# - Find ThreadingBuildingBlocks include dirs and libraries
|
|
||||||
# Use this module by invoking find_package with the form:
|
|
||||||
# find_package(TBB
|
|
||||||
# [REQUIRED] # Fail with error if TBB is not found
|
|
||||||
# ) #
|
|
||||||
# Once done, this will define
|
|
||||||
#
|
|
||||||
# TBB_FOUND - system has TBB
|
|
||||||
# TBB_INCLUDE_DIRS - the TBB include directories
|
|
||||||
# TBB_LIBRARIES - TBB libraries to be lined, doesn't include malloc or
|
|
||||||
# malloc proxy
|
|
||||||
# TBB::tbb - imported target for the TBB library
|
|
||||||
#
|
|
||||||
# TBB_VERSION_MAJOR - Major Product Version Number
|
|
||||||
# TBB_VERSION_MINOR - Minor Product Version Number
|
|
||||||
# TBB_INTERFACE_VERSION - Engineering Focused Version Number
|
|
||||||
# TBB_COMPATIBLE_INTERFACE_VERSION - The oldest major interface version
|
|
||||||
# still supported. This uses the engineering
|
|
||||||
# focused interface version numbers.
|
|
||||||
#
|
|
||||||
# TBB_MALLOC_FOUND - system has TBB malloc library
|
|
||||||
# TBB_MALLOC_INCLUDE_DIRS - the TBB malloc include directories
|
|
||||||
# TBB_MALLOC_LIBRARIES - The TBB malloc libraries to be lined
|
|
||||||
# TBB::malloc - imported target for the TBB malloc library
|
|
||||||
#
|
|
||||||
# TBB_MALLOC_PROXY_FOUND - system has TBB malloc proxy library
|
|
||||||
# TBB_MALLOC_PROXY_INCLUDE_DIRS = the TBB malloc proxy include directories
|
|
||||||
# TBB_MALLOC_PROXY_LIBRARIES - The TBB malloc proxy libraries to be lined
|
|
||||||
# TBB::malloc_proxy - imported target for the TBB malloc proxy library
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# This module reads hints about search locations from variables:
|
|
||||||
# ENV TBB_ARCH_PLATFORM - for eg. set it to "mic" for Xeon Phi builds
|
|
||||||
# ENV TBB_ROOT or just TBB_ROOT - root directory of tbb installation
|
|
||||||
# ENV TBB_BUILD_PREFIX - specifies the build prefix for user built tbb
|
|
||||||
# libraries. Should be specified with ENV TBB_ROOT
|
|
||||||
# and optionally...
|
|
||||||
# ENV TBB_BUILD_DIR - if build directory is different than ${TBB_ROOT}/build
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# Modified by Robert Maynard from the original OGRE source
|
|
||||||
#
|
|
||||||
#-------------------------------------------------------------------
|
|
||||||
# This file is part of the CMake build system for OGRE
|
|
||||||
# (Object-oriented Graphics Rendering Engine)
|
|
||||||
# For the latest info, see http://www.ogre3d.org/
|
|
||||||
#
|
|
||||||
# The contents of this file are placed in the public domain. Feel
|
|
||||||
# free to make use of it in any way you like.
|
|
||||||
#-------------------------------------------------------------------
|
|
||||||
#
|
|
||||||
#=============================================================================
|
|
||||||
# Copyright 2010-2012 Kitware, Inc.
|
|
||||||
# Copyright 2012 Rolf Eike Beer <eike@sf-mail.de>
|
|
||||||
#
|
|
||||||
# Distributed under the OSI-approved BSD License (the "License");
|
|
||||||
# see accompanying file Copyright.txt for details.
|
|
||||||
#
|
|
||||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
||||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
# See the License for more information.
|
|
||||||
#=============================================================================
|
|
||||||
# (To distribute this file outside of CMake, substitute the full
|
|
||||||
# License text for the above reference.)
|
|
||||||
|
|
||||||
|
|
||||||
#=============================================================================
|
|
||||||
# FindTBB helper functions and macros
|
|
||||||
#
|
|
||||||
|
|
||||||
# Use TBBConfig.cmake if possible.
|
|
||||||
|
|
||||||
set(_tbb_find_quiet)
|
|
||||||
if (TBB_FIND_QUIETLY)
|
|
||||||
set(_tbb_find_quiet QUIET)
|
|
||||||
endif ()
|
|
||||||
set(_tbb_find_components)
|
|
||||||
set(_tbb_find_optional_components)
|
|
||||||
foreach (_tbb_find_component IN LISTS TBB_FIND_COMPONENTS)
|
|
||||||
if (TBB_FIND_REQUIRED_${_tbb_find_component})
|
|
||||||
list(APPEND _tbb_find_components "${_tbb_find_component}")
|
|
||||||
else ()
|
|
||||||
list(APPEND _tbb_find_optional_components "${_tbb_find_component}")
|
|
||||||
endif ()
|
|
||||||
endforeach ()
|
|
||||||
unset(_tbb_find_component)
|
|
||||||
find_package(TBB CONFIG ${_tbb_find_quiet}
|
|
||||||
COMPONENTS ${_tbb_find_components}
|
|
||||||
OPTIONAL_COMPONENTS ${_tbb_find_optional_components})
|
|
||||||
unset(_tbb_find_quiet)
|
|
||||||
unset(_tbb_find_components)
|
|
||||||
unset(_tbb_find_optional_components)
|
|
||||||
if (TBB_FOUND)
|
|
||||||
return ()
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
#====================================================
|
|
||||||
# Fix the library path in case it is a linker script
|
|
||||||
#====================================================
|
|
||||||
function(tbb_extract_real_library library real_library)
|
|
||||||
if(NOT UNIX OR NOT EXISTS ${library})
|
|
||||||
set(${real_library} "${library}" PARENT_SCOPE)
|
|
||||||
return()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
#Read in the first 4 bytes and see if they are the ELF magic number
|
|
||||||
set(_elf_magic "7f454c46")
|
|
||||||
file(READ ${library} _hex_data OFFSET 0 LIMIT 4 HEX)
|
|
||||||
if(_hex_data STREQUAL _elf_magic)
|
|
||||||
#we have opened a elf binary so this is what
|
|
||||||
#we should link to
|
|
||||||
set(${real_library} "${library}" PARENT_SCOPE)
|
|
||||||
return()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
file(READ ${library} _data OFFSET 0 LIMIT 1024)
|
|
||||||
if("${_data}" MATCHES "INPUT \\(([^(]+)\\)")
|
|
||||||
#extract out the .so name from REGEX MATCH command
|
|
||||||
set(_proper_so_name "${CMAKE_MATCH_1}")
|
|
||||||
|
|
||||||
#construct path to the real .so which is presumed to be in the same directory
|
|
||||||
#as the input file
|
|
||||||
get_filename_component(_so_dir "${library}" DIRECTORY)
|
|
||||||
set(${real_library} "${_so_dir}/${_proper_so_name}" PARENT_SCOPE)
|
|
||||||
else()
|
|
||||||
#unable to determine what this library is so just hope everything works
|
|
||||||
#and pass it unmodified.
|
|
||||||
set(${real_library} "${library}" PARENT_SCOPE)
|
|
||||||
endif()
|
|
||||||
endfunction()
|
|
||||||
|
|
||||||
#===============================================
|
|
||||||
# Do the final processing for the package find.
|
|
||||||
#===============================================
|
|
||||||
macro(findpkg_finish PREFIX TARGET_NAME)
|
|
||||||
if (${PREFIX}_INCLUDE_DIR AND ${PREFIX}_LIBRARY)
|
|
||||||
set(${PREFIX}_FOUND TRUE)
|
|
||||||
set (${PREFIX}_INCLUDE_DIRS ${${PREFIX}_INCLUDE_DIR})
|
|
||||||
set (${PREFIX}_LIBRARIES ${${PREFIX}_LIBRARY})
|
|
||||||
else ()
|
|
||||||
if (${PREFIX}_FIND_REQUIRED AND NOT ${PREFIX}_FIND_QUIETLY)
|
|
||||||
message(FATAL_ERROR "Required library ${PREFIX} not found.")
|
|
||||||
endif ()
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
if (NOT TARGET "TBB::${TARGET_NAME}")
|
|
||||||
if (${PREFIX}_LIBRARY_RELEASE)
|
|
||||||
tbb_extract_real_library(${${PREFIX}_LIBRARY_RELEASE} real_release)
|
|
||||||
endif ()
|
|
||||||
if (${PREFIX}_LIBRARY_DEBUG)
|
|
||||||
tbb_extract_real_library(${${PREFIX}_LIBRARY_DEBUG} real_debug)
|
|
||||||
endif ()
|
|
||||||
add_library(TBB::${TARGET_NAME} UNKNOWN IMPORTED)
|
|
||||||
set_target_properties(TBB::${TARGET_NAME} PROPERTIES
|
|
||||||
INTERFACE_INCLUDE_DIRECTORIES "${${PREFIX}_INCLUDE_DIR}")
|
|
||||||
if (${PREFIX}_LIBRARY_DEBUG AND ${PREFIX}_LIBRARY_RELEASE)
|
|
||||||
set_target_properties(TBB::${TARGET_NAME} PROPERTIES
|
|
||||||
IMPORTED_LOCATION "${real_release}"
|
|
||||||
IMPORTED_LOCATION_DEBUG "${real_debug}"
|
|
||||||
IMPORTED_LOCATION_RELEASE "${real_release}")
|
|
||||||
elseif (${PREFIX}_LIBRARY_RELEASE)
|
|
||||||
set_target_properties(TBB::${TARGET_NAME} PROPERTIES
|
|
||||||
IMPORTED_LOCATION "${real_release}")
|
|
||||||
elseif (${PREFIX}_LIBRARY_DEBUG)
|
|
||||||
set_target_properties(TBB::${TARGET_NAME} PROPERTIES
|
|
||||||
IMPORTED_LOCATION "${real_debug}")
|
|
||||||
endif ()
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
#mark the following variables as internal variables
|
|
||||||
mark_as_advanced(${PREFIX}_INCLUDE_DIR
|
|
||||||
${PREFIX}_LIBRARY
|
|
||||||
${PREFIX}_LIBRARY_DEBUG
|
|
||||||
${PREFIX}_LIBRARY_RELEASE)
|
|
||||||
endmacro()
|
|
||||||
|
|
||||||
#===============================================
|
|
||||||
# Generate debug names from given release names
|
|
||||||
#===============================================
|
|
||||||
macro(get_debug_names PREFIX)
|
|
||||||
foreach(i ${${PREFIX}})
|
|
||||||
set(${PREFIX}_DEBUG ${${PREFIX}_DEBUG} ${i}d ${i}D ${i}_d ${i}_D ${i}_debug ${i})
|
|
||||||
endforeach()
|
|
||||||
endmacro()
|
|
||||||
|
|
||||||
#===============================================
|
|
||||||
# See if we have env vars to help us find tbb
|
|
||||||
#===============================================
|
|
||||||
macro(getenv_path VAR)
|
|
||||||
set(ENV_${VAR} $ENV{${VAR}})
|
|
||||||
# replace won't work if var is blank
|
|
||||||
if (ENV_${VAR})
|
|
||||||
string( REGEX REPLACE "\\\\" "/" ENV_${VAR} ${ENV_${VAR}} )
|
|
||||||
endif ()
|
|
||||||
endmacro()
|
|
||||||
|
|
||||||
#===============================================
|
|
||||||
# Couple a set of release AND debug libraries
|
|
||||||
#===============================================
|
|
||||||
macro(make_library_set PREFIX)
|
|
||||||
if (${PREFIX}_RELEASE AND ${PREFIX}_DEBUG)
|
|
||||||
set(${PREFIX} optimized ${${PREFIX}_RELEASE} debug ${${PREFIX}_DEBUG})
|
|
||||||
elseif (${PREFIX}_RELEASE)
|
|
||||||
set(${PREFIX} ${${PREFIX}_RELEASE})
|
|
||||||
elseif (${PREFIX}_DEBUG)
|
|
||||||
set(${PREFIX} ${${PREFIX}_DEBUG})
|
|
||||||
endif ()
|
|
||||||
endmacro()
|
|
||||||
|
|
||||||
|
|
||||||
#=============================================================================
|
|
||||||
# Now to actually find TBB
|
|
||||||
#
|
|
||||||
|
|
||||||
# Get path, convert backslashes as ${ENV_${var}}
|
|
||||||
getenv_path(TBB_ROOT)
|
|
||||||
|
|
||||||
# initialize search paths
|
|
||||||
set(TBB_PREFIX_PATH ${TBB_ROOT} ${ENV_TBB_ROOT})
|
|
||||||
set(TBB_INC_SEARCH_PATH "")
|
|
||||||
set(TBB_LIB_SEARCH_PATH "")
|
|
||||||
|
|
||||||
|
|
||||||
# If user built from sources
|
|
||||||
set(TBB_BUILD_PREFIX $ENV{TBB_BUILD_PREFIX})
|
|
||||||
if (TBB_BUILD_PREFIX AND ENV_TBB_ROOT)
|
|
||||||
getenv_path(TBB_BUILD_DIR)
|
|
||||||
if (NOT ENV_TBB_BUILD_DIR)
|
|
||||||
set(ENV_TBB_BUILD_DIR ${ENV_TBB_ROOT}/build)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
# include directory under ${ENV_TBB_ROOT}/include
|
|
||||||
list(APPEND TBB_LIB_SEARCH_PATH
|
|
||||||
${ENV_TBB_BUILD_DIR}/${TBB_BUILD_PREFIX}_release
|
|
||||||
${ENV_TBB_BUILD_DIR}/${TBB_BUILD_PREFIX}_debug)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
|
|
||||||
# For Windows, let's assume that the user might be using the precompiled
|
|
||||||
# TBB packages from the main website. These use a rather awkward directory
|
|
||||||
# structure (at least for automatically finding the right files) depending
|
|
||||||
# on platform and compiler, but we'll do our best to accommodate it.
|
|
||||||
# Not adding the same effort for the precompiled linux builds, though. Those
|
|
||||||
# have different versions for CC compiler versions and linux kernels which
|
|
||||||
# will never adequately match the user's setup, so there is no feasible way
|
|
||||||
# to detect the "best" version to use. The user will have to manually
|
|
||||||
# select the right files. (Chances are the distributions are shipping their
|
|
||||||
# custom version of tbb, anyway, so the problem is probably nonexistent.)
|
|
||||||
if (WIN32 AND MSVC)
|
|
||||||
set(COMPILER_PREFIX "vc7.1")
|
|
||||||
if (MSVC_VERSION EQUAL 1400)
|
|
||||||
set(COMPILER_PREFIX "vc8")
|
|
||||||
elseif(MSVC_VERSION EQUAL 1500)
|
|
||||||
set(COMPILER_PREFIX "vc9")
|
|
||||||
elseif(MSVC_VERSION EQUAL 1600)
|
|
||||||
set(COMPILER_PREFIX "vc10")
|
|
||||||
elseif(MSVC_VERSION EQUAL 1700)
|
|
||||||
set(COMPILER_PREFIX "vc11")
|
|
||||||
elseif(MSVC_VERSION EQUAL 1800)
|
|
||||||
set(COMPILER_PREFIX "vc12")
|
|
||||||
elseif(MSVC_VERSION GREATER_EQUAL 1900)
|
|
||||||
set(COMPILER_PREFIX "vc14")
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
# for each prefix path, add ia32/64\${COMPILER_PREFIX}\lib to the lib search path
|
|
||||||
foreach (dir IN LISTS TBB_PREFIX_PATH)
|
|
||||||
if (CMAKE_CL_64)
|
|
||||||
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/ia64/${COMPILER_PREFIX}/lib)
|
|
||||||
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/ia64/${COMPILER_PREFIX})
|
|
||||||
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/intel64/${COMPILER_PREFIX}/lib)
|
|
||||||
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/intel64/${COMPILER_PREFIX})
|
|
||||||
else ()
|
|
||||||
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/ia32/${COMPILER_PREFIX}/lib)
|
|
||||||
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/ia32/${COMPILER_PREFIX})
|
|
||||||
endif ()
|
|
||||||
endforeach ()
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
# For OS X binary distribution, choose libc++ based libraries for Mavericks (10.9)
|
|
||||||
# and above and AppleClang
|
|
||||||
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND
|
|
||||||
NOT CMAKE_SYSTEM_VERSION VERSION_LESS 13.0)
|
|
||||||
set (USE_LIBCXX OFF)
|
|
||||||
cmake_policy(GET CMP0025 POLICY_VAR)
|
|
||||||
|
|
||||||
if (POLICY_VAR STREQUAL "NEW")
|
|
||||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
|
|
||||||
set (USE_LIBCXX ON)
|
|
||||||
endif ()
|
|
||||||
else ()
|
|
||||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
|
||||||
set (USE_LIBCXX ON)
|
|
||||||
endif ()
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
if (USE_LIBCXX)
|
|
||||||
foreach (dir IN LISTS TBB_PREFIX_PATH)
|
|
||||||
list (APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/libc++ ${dir}/libc++/lib)
|
|
||||||
endforeach ()
|
|
||||||
endif ()
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
# check compiler ABI
|
|
||||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
|
||||||
set(COMPILER_PREFIX)
|
|
||||||
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
|
|
||||||
list(APPEND COMPILER_PREFIX "gcc4.8")
|
|
||||||
endif()
|
|
||||||
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7)
|
|
||||||
list(APPEND COMPILER_PREFIX "gcc4.7")
|
|
||||||
endif()
|
|
||||||
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4)
|
|
||||||
list(APPEND COMPILER_PREFIX "gcc4.4")
|
|
||||||
endif()
|
|
||||||
list(APPEND COMPILER_PREFIX "gcc4.1")
|
|
||||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
|
||||||
set(COMPILER_PREFIX)
|
|
||||||
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.0) # Complete guess
|
|
||||||
list(APPEND COMPILER_PREFIX "gcc4.8")
|
|
||||||
endif()
|
|
||||||
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.6)
|
|
||||||
list(APPEND COMPILER_PREFIX "gcc4.7")
|
|
||||||
endif()
|
|
||||||
list(APPEND COMPILER_PREFIX "gcc4.4")
|
|
||||||
else() # Assume compatibility with 4.4 for other compilers
|
|
||||||
list(APPEND COMPILER_PREFIX "gcc4.4")
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
# if platform architecture is explicitly specified
|
|
||||||
set(TBB_ARCH_PLATFORM $ENV{TBB_ARCH_PLATFORM})
|
|
||||||
if (TBB_ARCH_PLATFORM)
|
|
||||||
foreach (dir IN LISTS TBB_PREFIX_PATH)
|
|
||||||
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/${TBB_ARCH_PLATFORM}/lib)
|
|
||||||
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/${TBB_ARCH_PLATFORM})
|
|
||||||
endforeach ()
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
foreach (dir IN LISTS TBB_PREFIX_PATH)
|
|
||||||
foreach (prefix IN LISTS COMPILER_PREFIX)
|
|
||||||
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
|
||||||
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/intel64)
|
|
||||||
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/intel64/${prefix})
|
|
||||||
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/intel64/lib)
|
|
||||||
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/intel64/${prefix}/lib)
|
|
||||||
else ()
|
|
||||||
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/ia32)
|
|
||||||
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/ia32/${prefix})
|
|
||||||
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/ia32/lib)
|
|
||||||
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/ia32/${prefix}/lib)
|
|
||||||
endif ()
|
|
||||||
endforeach()
|
|
||||||
endforeach ()
|
|
||||||
|
|
||||||
# add general search paths
|
|
||||||
foreach (dir IN LISTS TBB_PREFIX_PATH)
|
|
||||||
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib ${dir}/Lib ${dir}/lib/tbb
|
|
||||||
${dir}/Libs)
|
|
||||||
list(APPEND TBB_INC_SEARCH_PATH ${dir}/include ${dir}/Include
|
|
||||||
${dir}/include/tbb)
|
|
||||||
endforeach ()
|
|
||||||
|
|
||||||
set(TBB_LIBRARY_NAMES tbb)
|
|
||||||
get_debug_names(TBB_LIBRARY_NAMES)
|
|
||||||
|
|
||||||
|
|
||||||
find_path(TBB_INCLUDE_DIR
|
|
||||||
NAMES tbb/tbb.h
|
|
||||||
PATHS ${TBB_INC_SEARCH_PATH})
|
|
||||||
|
|
||||||
find_library(TBB_LIBRARY_RELEASE
|
|
||||||
NAMES ${TBB_LIBRARY_NAMES}
|
|
||||||
PATHS ${TBB_LIB_SEARCH_PATH})
|
|
||||||
find_library(TBB_LIBRARY_DEBUG
|
|
||||||
NAMES ${TBB_LIBRARY_NAMES_DEBUG}
|
|
||||||
PATHS ${TBB_LIB_SEARCH_PATH})
|
|
||||||
make_library_set(TBB_LIBRARY)
|
|
||||||
|
|
||||||
findpkg_finish(TBB tbb)
|
|
||||||
|
|
||||||
#if we haven't found TBB no point on going any further
|
|
||||||
if (NOT TBB_FOUND)
|
|
||||||
return()
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
#=============================================================================
|
|
||||||
# Look for TBB's malloc package
|
|
||||||
set(TBB_MALLOC_LIBRARY_NAMES tbbmalloc)
|
|
||||||
get_debug_names(TBB_MALLOC_LIBRARY_NAMES)
|
|
||||||
|
|
||||||
find_path(TBB_MALLOC_INCLUDE_DIR
|
|
||||||
NAMES tbb/tbb.h
|
|
||||||
PATHS ${TBB_INC_SEARCH_PATH})
|
|
||||||
|
|
||||||
find_library(TBB_MALLOC_LIBRARY_RELEASE
|
|
||||||
NAMES ${TBB_MALLOC_LIBRARY_NAMES}
|
|
||||||
PATHS ${TBB_LIB_SEARCH_PATH})
|
|
||||||
find_library(TBB_MALLOC_LIBRARY_DEBUG
|
|
||||||
NAMES ${TBB_MALLOC_LIBRARY_NAMES_DEBUG}
|
|
||||||
PATHS ${TBB_LIB_SEARCH_PATH})
|
|
||||||
make_library_set(TBB_MALLOC_LIBRARY)
|
|
||||||
|
|
||||||
findpkg_finish(TBB_MALLOC tbbmalloc)
|
|
||||||
|
|
||||||
#=============================================================================
|
|
||||||
# Look for TBB's malloc proxy package
|
|
||||||
set(TBB_MALLOC_PROXY_LIBRARY_NAMES tbbmalloc_proxy)
|
|
||||||
get_debug_names(TBB_MALLOC_PROXY_LIBRARY_NAMES)
|
|
||||||
|
|
||||||
find_path(TBB_MALLOC_PROXY_INCLUDE_DIR
|
|
||||||
NAMES tbb/tbbmalloc_proxy.h
|
|
||||||
PATHS ${TBB_INC_SEARCH_PATH})
|
|
||||||
|
|
||||||
find_library(TBB_MALLOC_PROXY_LIBRARY_RELEASE
|
|
||||||
NAMES ${TBB_MALLOC_PROXY_LIBRARY_NAMES}
|
|
||||||
PATHS ${TBB_LIB_SEARCH_PATH})
|
|
||||||
find_library(TBB_MALLOC_PROXY_LIBRARY_DEBUG
|
|
||||||
NAMES ${TBB_MALLOC_PROXY_LIBRARY_NAMES_DEBUG}
|
|
||||||
PATHS ${TBB_LIB_SEARCH_PATH})
|
|
||||||
make_library_set(TBB_MALLOC_PROXY_LIBRARY)
|
|
||||||
|
|
||||||
findpkg_finish(TBB_MALLOC_PROXY tbbmalloc_proxy)
|
|
||||||
|
|
||||||
|
|
||||||
#=============================================================================
|
|
||||||
#parse all the version numbers from tbb
|
|
||||||
if(NOT TBB_VERSION)
|
|
||||||
if (EXISTS "${TBB_INCLUDE_DIR}/oneapi/tbb/version.h")
|
|
||||||
file(STRINGS
|
|
||||||
"${TBB_INCLUDE_DIR}/oneapi/tbb/version.h"
|
|
||||||
TBB_VERSION_CONTENTS
|
|
||||||
REGEX "VERSION")
|
|
||||||
else()
|
|
||||||
#only read the start of the file
|
|
||||||
file(STRINGS
|
|
||||||
"${TBB_INCLUDE_DIR}/tbb/tbb_stddef.h"
|
|
||||||
TBB_VERSION_CONTENTS
|
|
||||||
REGEX "VERSION")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
string(REGEX REPLACE
|
|
||||||
".*#define TBB_VERSION_MAJOR ([0-9]+).*" "\\1"
|
|
||||||
TBB_VERSION_MAJOR "${TBB_VERSION_CONTENTS}")
|
|
||||||
|
|
||||||
string(REGEX REPLACE
|
|
||||||
".*#define TBB_VERSION_MINOR ([0-9]+).*" "\\1"
|
|
||||||
TBB_VERSION_MINOR "${TBB_VERSION_CONTENTS}")
|
|
||||||
|
|
||||||
string(REGEX REPLACE
|
|
||||||
".*#define TBB_INTERFACE_VERSION ([0-9]+).*" "\\1"
|
|
||||||
TBB_INTERFACE_VERSION "${TBB_VERSION_CONTENTS}")
|
|
||||||
|
|
||||||
string(REGEX REPLACE
|
|
||||||
".*#define TBB_COMPATIBLE_INTERFACE_VERSION ([0-9]+).*" "\\1"
|
|
||||||
TBB_COMPATIBLE_INTERFACE_VERSION "${TBB_VERSION_CONTENTS}")
|
|
||||||
|
|
||||||
endif()
|
|
@ -1,290 +0,0 @@
|
|||||||
# https://github.com/sbellus/json-cmake/blob/9913da8800b95322d393894d3525d634568f305e/JSONParser.cmake
|
|
||||||
# MIT Licensed - https://github.com/sbellus/json-cmake/blob/master/LICENSE
|
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.18)
|
|
||||||
|
|
||||||
if (DEFINED JSonParserGuard)
|
|
||||||
return()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(JSonParserGuard yes)
|
|
||||||
|
|
||||||
macro(sbeParseJson prefix jsonString)
|
|
||||||
cmake_policy(PUSH)
|
|
||||||
|
|
||||||
set(json_string "${${jsonString}}")
|
|
||||||
string(LENGTH "${json_string}" json_jsonLen)
|
|
||||||
set(json_index 0)
|
|
||||||
set(json_AllVariables ${prefix})
|
|
||||||
set(json_ArrayNestingLevel 0)
|
|
||||||
set(json_MaxArrayNestingLevel 0)
|
|
||||||
|
|
||||||
_sbeParse(${prefix})
|
|
||||||
|
|
||||||
unset(json_index)
|
|
||||||
unset(json_AllVariables)
|
|
||||||
unset(json_jsonLen)
|
|
||||||
unset(json_string)
|
|
||||||
unset(json_value)
|
|
||||||
unset(json_inValue)
|
|
||||||
unset(json_name)
|
|
||||||
unset(json_inName)
|
|
||||||
unset(json_newPrefix)
|
|
||||||
unset(json_reservedWord)
|
|
||||||
unset(json_arrayIndex)
|
|
||||||
unset(json_char)
|
|
||||||
unset(json_end)
|
|
||||||
unset(json_ArrayNestingLevel)
|
|
||||||
foreach(json_nestingLevel RANGE ${json_MaxArrayNestingLevel})
|
|
||||||
unset(json_${json_nestingLevel}_arrayIndex)
|
|
||||||
endforeach()
|
|
||||||
unset(json_nestingLevel)
|
|
||||||
unset(json_MaxArrayNestingLevel)
|
|
||||||
|
|
||||||
cmake_policy(POP)
|
|
||||||
endmacro()
|
|
||||||
|
|
||||||
macro(sbeClearJson prefix)
|
|
||||||
foreach(json_var ${${prefix}})
|
|
||||||
unset(${json_var})
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
unset(${prefix})
|
|
||||||
unset(json_var)
|
|
||||||
endmacro()
|
|
||||||
|
|
||||||
macro(sbePrintJson prefix)
|
|
||||||
foreach(json_var ${${prefix}})
|
|
||||||
message("${json_var} = ${${json_var}}")
|
|
||||||
endforeach()
|
|
||||||
endmacro()
|
|
||||||
|
|
||||||
macro(_sbeParse prefix)
|
|
||||||
|
|
||||||
while(${json_index} LESS ${json_jsonLen})
|
|
||||||
string(SUBSTRING "${json_string}" ${json_index} 1 json_char)
|
|
||||||
|
|
||||||
if("\"" STREQUAL "${json_char}")
|
|
||||||
_sbeParseNameValue(${prefix})
|
|
||||||
elseif("{" STREQUAL "${json_char}")
|
|
||||||
_sbeMoveToNextNonEmptyCharacter()
|
|
||||||
_sbeParseObject(${prefix})
|
|
||||||
elseif("[" STREQUAL "${json_char}")
|
|
||||||
_sbeMoveToNextNonEmptyCharacter()
|
|
||||||
_sbeParseArray(${prefix})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(${json_index} LESS ${json_jsonLen})
|
|
||||||
string(SUBSTRING "${json_string}" ${json_index} 1 json_char)
|
|
||||||
else()
|
|
||||||
break()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if ("}" STREQUAL "${json_char}" OR "]" STREQUAL "${json_char}")
|
|
||||||
break()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
_sbeMoveToNextNonEmptyCharacter()
|
|
||||||
endwhile()
|
|
||||||
endmacro()
|
|
||||||
|
|
||||||
macro(_sbeParseNameValue prefix)
|
|
||||||
set(json_name "")
|
|
||||||
set(json_inName no)
|
|
||||||
|
|
||||||
while(${json_index} LESS ${json_jsonLen})
|
|
||||||
string(SUBSTRING "${json_string}" ${json_index} 1 json_char)
|
|
||||||
|
|
||||||
# check if name ends
|
|
||||||
if("\"" STREQUAL "${json_char}" AND json_inName)
|
|
||||||
set(json_inName no)
|
|
||||||
_sbeMoveToNextNonEmptyCharacter()
|
|
||||||
if(NOT ${json_index} LESS ${json_jsonLen})
|
|
||||||
break()
|
|
||||||
endif()
|
|
||||||
string(SUBSTRING "${json_string}" ${json_index} 1 json_char)
|
|
||||||
set(json_newPrefix ${prefix}.${json_name})
|
|
||||||
set(json_name "")
|
|
||||||
|
|
||||||
if(":" STREQUAL "${json_char}")
|
|
||||||
_sbeMoveToNextNonEmptyCharacter()
|
|
||||||
if(NOT ${json_index} LESS ${json_jsonLen})
|
|
||||||
break()
|
|
||||||
endif()
|
|
||||||
string(SUBSTRING "${json_string}" ${json_index} 1 json_char)
|
|
||||||
|
|
||||||
if("\"" STREQUAL "${json_char}")
|
|
||||||
_sbeParseValue(${json_newPrefix})
|
|
||||||
break()
|
|
||||||
elseif("{" STREQUAL "${json_char}")
|
|
||||||
_sbeMoveToNextNonEmptyCharacter()
|
|
||||||
_sbeParseObject(${json_newPrefix})
|
|
||||||
break()
|
|
||||||
elseif("[" STREQUAL "${json_char}")
|
|
||||||
_sbeMoveToNextNonEmptyCharacter()
|
|
||||||
_sbeParseArray(${json_newPrefix})
|
|
||||||
break()
|
|
||||||
else()
|
|
||||||
# reserved word starts
|
|
||||||
_sbeParseReservedWord(${json_newPrefix})
|
|
||||||
break()
|
|
||||||
endif()
|
|
||||||
else()
|
|
||||||
# name without value
|
|
||||||
list(APPEND ${json_AllVariables} ${json_newPrefix})
|
|
||||||
set(${json_newPrefix} "")
|
|
||||||
break()
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(json_inName)
|
|
||||||
# remove escapes
|
|
||||||
if("\\" STREQUAL "${json_char}")
|
|
||||||
math(EXPR json_index "${json_index} + 1")
|
|
||||||
if(NOT ${json_index} LESS ${json_jsonLen})
|
|
||||||
break()
|
|
||||||
endif()
|
|
||||||
string(SUBSTRING "${json_string}" ${json_index} 1 json_char)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(json_name "${json_name}${json_char}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# check if name starts
|
|
||||||
if("\"" STREQUAL "${json_char}" AND NOT json_inName)
|
|
||||||
set(json_inName yes)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
_sbeMoveToNextNonEmptyCharacter()
|
|
||||||
endwhile()
|
|
||||||
endmacro()
|
|
||||||
|
|
||||||
macro(_sbeParseReservedWord prefix)
|
|
||||||
set(json_reservedWord "")
|
|
||||||
set(json_end no)
|
|
||||||
while(${json_index} LESS ${json_jsonLen} AND NOT json_end)
|
|
||||||
string(SUBSTRING "${json_string}" ${json_index} 1 json_char)
|
|
||||||
|
|
||||||
if("," STREQUAL "${json_char}" OR "}" STREQUAL "${json_char}" OR "]" STREQUAL "${json_char}")
|
|
||||||
set(json_end yes)
|
|
||||||
else()
|
|
||||||
set(json_reservedWord "${json_reservedWord}${json_char}")
|
|
||||||
math(EXPR json_index "${json_index} + 1")
|
|
||||||
endif()
|
|
||||||
endwhile()
|
|
||||||
|
|
||||||
list(APPEND ${json_AllVariables} ${prefix})
|
|
||||||
string(STRIP "${json_reservedWord}" json_reservedWord)
|
|
||||||
set(${prefix} ${json_reservedWord})
|
|
||||||
endmacro()
|
|
||||||
|
|
||||||
macro(_sbeParseValue prefix)
|
|
||||||
cmake_policy(SET CMP0054 NEW) # turn off implicit expansions in if statement
|
|
||||||
|
|
||||||
set(json_value "")
|
|
||||||
set(json_inValue no)
|
|
||||||
|
|
||||||
while(${json_index} LESS ${json_jsonLen})
|
|
||||||
string(SUBSTRING "${json_string}" ${json_index} 1 json_char)
|
|
||||||
|
|
||||||
# check if json_value ends, it is ended by "
|
|
||||||
if("\"" STREQUAL "${json_char}" AND json_inValue)
|
|
||||||
set(json_inValue no)
|
|
||||||
|
|
||||||
set(${prefix} ${json_value})
|
|
||||||
list(APPEND ${json_AllVariables} ${prefix})
|
|
||||||
_sbeMoveToNextNonEmptyCharacter()
|
|
||||||
break()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(json_inValue)
|
|
||||||
# if " is escaped consume
|
|
||||||
if("\\" STREQUAL "${json_char}")
|
|
||||||
math(EXPR json_index "${json_index} + 1")
|
|
||||||
if(NOT ${json_index} LESS ${json_jsonLen})
|
|
||||||
break()
|
|
||||||
endif()
|
|
||||||
string(SUBSTRING "${json_string}" ${json_index} 1 json_char)
|
|
||||||
if(NOT "\"" STREQUAL "${json_char}")
|
|
||||||
# if it is not " then copy also escape character
|
|
||||||
set(json_char "\\${json_char}")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
_sbeAddEscapedCharacter("${json_char}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# check if value starts
|
|
||||||
if("\"" STREQUAL "${json_char}" AND NOT json_inValue)
|
|
||||||
set(json_inValue yes)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
math(EXPR json_index "${json_index} + 1")
|
|
||||||
endwhile()
|
|
||||||
endmacro()
|
|
||||||
|
|
||||||
macro(_sbeAddEscapedCharacter char)
|
|
||||||
string(CONCAT json_value "${json_value}" "${char}")
|
|
||||||
endmacro()
|
|
||||||
|
|
||||||
macro(_sbeParseObject prefix)
|
|
||||||
_sbeParse(${prefix})
|
|
||||||
_sbeMoveToNextNonEmptyCharacter()
|
|
||||||
endmacro()
|
|
||||||
|
|
||||||
macro(_sbeParseArray prefix)
|
|
||||||
math(EXPR json_ArrayNestingLevel "${json_ArrayNestingLevel} + 1")
|
|
||||||
set(json_${json_ArrayNestingLevel}_arrayIndex 0)
|
|
||||||
|
|
||||||
set(${prefix} "")
|
|
||||||
list(APPEND ${json_AllVariables} ${prefix})
|
|
||||||
|
|
||||||
while(${json_index} LESS ${json_jsonLen})
|
|
||||||
string(SUBSTRING "${json_string}" ${json_index} 1 json_char)
|
|
||||||
|
|
||||||
if("\"" STREQUAL "${json_char}")
|
|
||||||
# simple value
|
|
||||||
list(APPEND ${prefix} ${json_${json_ArrayNestingLevel}_arrayIndex})
|
|
||||||
_sbeParseValue(${prefix}_${json_${json_ArrayNestingLevel}_arrayIndex})
|
|
||||||
elseif("{" STREQUAL "${json_char}")
|
|
||||||
# object
|
|
||||||
_sbeMoveToNextNonEmptyCharacter()
|
|
||||||
list(APPEND ${prefix} ${json_${json_ArrayNestingLevel}_arrayIndex})
|
|
||||||
_sbeParseObject(${prefix}_${json_${json_ArrayNestingLevel}_arrayIndex})
|
|
||||||
else()
|
|
||||||
list(APPEND ${prefix} ${json_${json_ArrayNestingLevel}_arrayIndex})
|
|
||||||
_sbeParseReservedWord(${prefix}_${json_${json_ArrayNestingLevel}_arrayIndex})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT ${json_index} LESS ${json_jsonLen})
|
|
||||||
break()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
string(SUBSTRING "${json_string}" ${json_index} 1 json_char)
|
|
||||||
|
|
||||||
if("]" STREQUAL "${json_char}")
|
|
||||||
_sbeMoveToNextNonEmptyCharacter()
|
|
||||||
break()
|
|
||||||
elseif("," STREQUAL "${json_char}")
|
|
||||||
math(EXPR json_${json_ArrayNestingLevel}_arrayIndex "${json_${json_ArrayNestingLevel}_arrayIndex} + 1")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
_sbeMoveToNextNonEmptyCharacter()
|
|
||||||
endwhile()
|
|
||||||
|
|
||||||
if(${json_MaxArrayNestingLevel} LESS ${json_ArrayNestingLevel})
|
|
||||||
set(json_MaxArrayNestingLevel ${json_ArrayNestingLevel})
|
|
||||||
endif()
|
|
||||||
math(EXPR json_ArrayNestingLevel "${json_ArrayNestingLevel} - 1")
|
|
||||||
endmacro()
|
|
||||||
|
|
||||||
macro(_sbeMoveToNextNonEmptyCharacter)
|
|
||||||
math(EXPR json_index "${json_index} + 1")
|
|
||||||
if(${json_index} LESS ${json_jsonLen})
|
|
||||||
string(SUBSTRING "${json_string}" ${json_index} 1 json_char)
|
|
||||||
while(${json_char} MATCHES "[ \t\n\r]" AND ${json_index} LESS ${json_jsonLen})
|
|
||||||
math(EXPR json_index "${json_index} + 1")
|
|
||||||
string(SUBSTRING "${json_string}" ${json_index} 1 json_char)
|
|
||||||
endwhile()
|
|
||||||
endif()
|
|
||||||
endmacro()
|
|
@ -1,43 +0,0 @@
|
|||||||
# Based on @berenm's pull request https://github.com/quarnster/SublimeClang/pull/135
|
|
||||||
# Create the database with cmake with for example: cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..
|
|
||||||
# or you could have set(CMAKE_EXPORT_COMPILE_COMMANDS ON) in your CMakeLists.txt
|
|
||||||
# Usage within SublimeClang:
|
|
||||||
# "sublimeclang_options_script": "python ${home}/code/cmake_options_script.py ${project_path:build}/compile_commands.json",
|
|
||||||
|
|
||||||
|
|
||||||
import re
|
|
||||||
import os
|
|
||||||
import os.path
|
|
||||||
import pickle
|
|
||||||
import sys
|
|
||||||
import json
|
|
||||||
|
|
||||||
compilation_database_pattern = re.compile('(?<=\s)-[DIOUWfgs][^=\s]+(?:=\\"[^"]+\\"|=[^"]\S+)?')
|
|
||||||
|
|
||||||
def load_db(filename):
|
|
||||||
compilation_database = {}
|
|
||||||
with open(filename) as compilation_database_file:
|
|
||||||
compilation_database_entries = json.load(compilation_database_file)
|
|
||||||
|
|
||||||
total = len(compilation_database_entries)
|
|
||||||
entry = 0
|
|
||||||
for compilation_entry in compilation_database_entries:
|
|
||||||
entry = entry + 1
|
|
||||||
compilation_database[compilation_entry["file"]] = [ p.strip() for p in compilation_database_pattern.findall(compilation_entry["command"]) ]
|
|
||||||
return compilation_database
|
|
||||||
|
|
||||||
scriptpath = os.path.dirname(os.path.abspath(sys.argv[1]))
|
|
||||||
cache_file = "%s/cached_options.txt" % (scriptpath)
|
|
||||||
|
|
||||||
db = None
|
|
||||||
if os.access(cache_file, os.R_OK) == 0:
|
|
||||||
db = load_db(sys.argv[1])
|
|
||||||
with open(cache_file, "wb") as f:
|
|
||||||
pickle.dump(db, f)
|
|
||||||
else:
|
|
||||||
with open(cache_file) as f:
|
|
||||||
db = pickle.load(f)
|
|
||||||
|
|
||||||
if db and sys.argv[2] in db:
|
|
||||||
for option in db[sys.argv[2]]:
|
|
||||||
print option
|
|
@ -1,21 +0,0 @@
|
|||||||
if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
|
||||||
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
|
||||||
endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
|
||||||
|
|
||||||
file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
|
|
||||||
string(REGEX REPLACE "\n" ";" files "${files}")
|
|
||||||
foreach(file ${files})
|
|
||||||
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
|
|
||||||
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
|
|
||||||
exec_program(
|
|
||||||
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
|
|
||||||
OUTPUT_VARIABLE rm_out
|
|
||||||
RETURN_VALUE rm_retval
|
|
||||||
)
|
|
||||||
if(NOT "${rm_retval}" STREQUAL 0)
|
|
||||||
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
|
|
||||||
endif(NOT "${rm_retval}" STREQUAL 0)
|
|
||||||
else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
|
|
||||||
message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
|
|
||||||
endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
|
|
||||||
endforeach(file)
|
|
1026
cmake/conan.cmake
@ -1,11 +0,0 @@
|
|||||||
prefix=@CMAKE_INSTALL_PREFIX@
|
|
||||||
includedir=@PKGCONFIG_INCLUDE_DIR@
|
|
||||||
libdir=@PKGCONFIG_LIBRARY_DIR@
|
|
||||||
|
|
||||||
Name: libOSRM
|
|
||||||
Description: Project OSRM library
|
|
||||||
Version: @OSRM_VERSION@
|
|
||||||
Requires:
|
|
||||||
Libs: -L${libdir} -losrm @PKGCONFIG_OSRM_LDFLAGS@
|
|
||||||
Libs.private: @PKGCONFIG_OSRM_DEPENDENT_LIBRARIES@
|
|
||||||
Cflags: @PKGCONFIG_OSRM_INCLUDE_FLAGS@ @PKGCONFIG_OSRM_CXXFLAGS@
|
|
@ -1,88 +0,0 @@
|
|||||||
include (CheckCXXCompilerFlag)
|
|
||||||
include (CheckCCompilerFlag)
|
|
||||||
|
|
||||||
# Try to add -Wflag if compiler supports it
|
|
||||||
macro (add_warning flag)
|
|
||||||
string(REPLACE "-" "_" underscored_flag ${flag})
|
|
||||||
string(REPLACE "+" "x" underscored_flag ${underscored_flag})
|
|
||||||
|
|
||||||
check_cxx_compiler_flag("-W${flag}" SUPPORTS_CXXFLAG_${underscored_flag})
|
|
||||||
check_c_compiler_flag("-W${flag}" SUPPORTS_CFLAG_${underscored_flag})
|
|
||||||
|
|
||||||
if (SUPPORTS_CXXFLAG_${underscored_flag})
|
|
||||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -W${flag}")
|
|
||||||
else()
|
|
||||||
message (STATUS "Flag -W${flag} is unsupported")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (SUPPORTS_CFLAG_${underscored_flag})
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -W${flag}")
|
|
||||||
else()
|
|
||||||
message(STATUS "Flag -W${flag} is unsupported")
|
|
||||||
endif()
|
|
||||||
endmacro()
|
|
||||||
|
|
||||||
# Try to add -Wno flag if compiler supports it
|
|
||||||
macro (no_warning flag)
|
|
||||||
add_warning(no-${flag})
|
|
||||||
endmacro ()
|
|
||||||
|
|
||||||
|
|
||||||
# The same but only for specified target.
|
|
||||||
macro (target_add_warning target flag)
|
|
||||||
string (REPLACE "-" "_" underscored_flag ${flag})
|
|
||||||
string (REPLACE "+" "x" underscored_flag ${underscored_flag})
|
|
||||||
|
|
||||||
check_cxx_compiler_flag("-W${flag}" SUPPORTS_CXXFLAG_${underscored_flag})
|
|
||||||
|
|
||||||
if (SUPPORTS_CXXFLAG_${underscored_flag})
|
|
||||||
target_compile_options (${target} PRIVATE "-W${flag}")
|
|
||||||
else ()
|
|
||||||
message (STATUS "Flag -W${flag} is unsupported")
|
|
||||||
endif ()
|
|
||||||
endmacro ()
|
|
||||||
|
|
||||||
macro (target_no_warning target flag)
|
|
||||||
target_add_warning(${target} no-${flag})
|
|
||||||
endmacro ()
|
|
||||||
|
|
||||||
add_warning(all)
|
|
||||||
add_warning(extra)
|
|
||||||
add_warning(pedantic)
|
|
||||||
add_warning(error) # treat all warnings as errors
|
|
||||||
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
|
||||||
add_warning(strict-overflow=1)
|
|
||||||
endif()
|
|
||||||
add_warning(suggest-override)
|
|
||||||
add_warning(suggest-destructor-override)
|
|
||||||
add_warning(unused)
|
|
||||||
add_warning(unreachable-code)
|
|
||||||
add_warning(delete-incomplete)
|
|
||||||
add_warning(duplicated-cond)
|
|
||||||
add_warning(disabled-optimization)
|
|
||||||
add_warning(init-self)
|
|
||||||
add_warning(bool-compare)
|
|
||||||
add_warning(logical-not-parentheses)
|
|
||||||
add_warning(logical-op)
|
|
||||||
add_warning(misleading-indentation)
|
|
||||||
# `no-` prefix is part of warning name(i.e. doesn't mean we are disabling it)
|
|
||||||
add_warning(no-return-local-addr)
|
|
||||||
add_warning(odr)
|
|
||||||
add_warning(pointer-arith)
|
|
||||||
add_warning(redundant-decls)
|
|
||||||
add_warning(reorder)
|
|
||||||
add_warning(shift-negative-value)
|
|
||||||
add_warning(sizeof-array-argument)
|
|
||||||
add_warning(switch-bool)
|
|
||||||
add_warning(tautological-compare)
|
|
||||||
add_warning(trampolines)
|
|
||||||
# these warnings are not enabled by default
|
|
||||||
# no_warning(name-of-warning)
|
|
||||||
no_warning(deprecated-comma-subscript)
|
|
||||||
no_warning(comma-subscript)
|
|
||||||
no_warning(ambiguous-reversed-operator)
|
|
||||||
no_warning(restrict)
|
|
||||||
no_warning(free-nonheap-object)
|
|
||||||
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
|
||||||
no_warning(stringop-overflow)
|
|
||||||
endif()
|
|
@ -1,6 +0,0 @@
|
|||||||
coverage:
|
|
||||||
|
|
||||||
ignore:
|
|
||||||
- third_party/.*
|
|
||||||
|
|
||||||
comment: off
|
|
@ -1,7 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
default: '--strict --tags ~@stress --tags ~@todo --tags ~@mld --require features/support --require features/step_definitions',
|
|
||||||
ch: '--strict --tags ~@stress --tags ~@todo --tags ~@mld -f progress --require features/support --require features/step_definitions',
|
|
||||||
todo: '--strict --tags @todo --require features/support --require features/step_definitions',
|
|
||||||
all: '--strict --require features/support --require features/step_definitions',
|
|
||||||
mld: '--strict --tags ~@stress --tags ~@todo --tags ~@ch --require features/support --require features/step_definitions -f progress'
|
|
||||||
};
|
|
@ -1 +0,0 @@
|
|||||||
Dockerfile-debian
|
|
@ -1,79 +0,0 @@
|
|||||||
FROM alpine:3.21.2 AS alpine-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
|
|
||||||
ARG DOCKER_TAG
|
|
||||||
ARG BUILD_CONCURRENCY
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
RUN NPROC=${BUILD_CONCURRENCY:-$(nproc)} && \
|
|
||||||
echo "Building OSRM ${DOCKER_TAG}" && \
|
|
||||||
git show --format="%H" | head -n1 > /opt/OSRM_GITSHA && \
|
|
||||||
echo "Building OSRM gitsha $(cat /opt/OSRM_GITSHA)" && \
|
|
||||||
mkdir -p build && \
|
|
||||||
cd build && \
|
|
||||||
BUILD_TYPE="Release" && \
|
|
||||||
ENABLE_ASSERTIONS="Off" && \
|
|
||||||
BUILD_TOOLS="Off" && \
|
|
||||||
case ${DOCKER_TAG} in *"-debug"*) BUILD_TYPE="Debug";; esac && \
|
|
||||||
case ${DOCKER_TAG} in *"-assertions"*) BUILD_TYPE="RelWithDebInfo" && ENABLE_ASSERTIONS="On" && BUILD_TOOLS="On";; esac && \
|
|
||||||
echo "Building ${BUILD_TYPE} with ENABLE_ASSERTIONS=${ENABLE_ASSERTIONS} BUILD_TOOLS=${BUILD_TOOLS}" && \
|
|
||||||
cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DENABLE_ASSERTIONS=${ENABLE_ASSERTIONS} -DBUILD_TOOLS=${BUILD_TOOLS} -DENABLE_LTO=OFF && \
|
|
||||||
make -j${NPROC} install && \
|
|
||||||
cd ../profiles && \
|
|
||||||
cp -r * /opt && \
|
|
||||||
strip /usr/local/bin/* && \
|
|
||||||
rm -rf /src
|
|
||||||
|
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
COPY --from=builder /usr/local /usr/local
|
|
||||||
COPY --from=builder /opt /opt
|
|
||||||
|
|
||||||
RUN apk add --no-cache \
|
|
||||||
boost-date_time \
|
|
||||||
expat \
|
|
||||||
lua5.4 \
|
|
||||||
onetbb && \
|
|
||||||
ldconfig /usr/local/lib
|
|
||||||
|
|
||||||
RUN /usr/local/bin/osrm-extract --help && \
|
|
||||||
/usr/local/bin/osrm-routed --help && \
|
|
||||||
/usr/local/bin/osrm-contract --help && \
|
|
||||||
/usr/local/bin/osrm-partition --help && \
|
|
||||||
/usr/local/bin/osrm-customize --help
|
|
||||||
|
|
||||||
WORKDIR /opt
|
|
||||||
|
|
||||||
EXPOSE 5000
|
|
||||||
|
|
@ -1,76 +0,0 @@
|
|||||||
FROM debian:bookworm-slim AS builder
|
|
||||||
ARG DOCKER_TAG
|
|
||||||
ARG BUILD_CONCURRENCY
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
RUN NPROC=${BUILD_CONCURRENCY:-$(nproc)} && \
|
|
||||||
export CXXFLAGS="-Wno-array-bounds -Wno-uninitialized -Wno-stringop-overflow" && \
|
|
||||||
echo "Building OSRM ${DOCKER_TAG}" && \
|
|
||||||
git show --format="%H" | head -n1 > /opt/OSRM_GITSHA && \
|
|
||||||
echo "Building OSRM gitsha $(cat /opt/OSRM_GITSHA)" && \
|
|
||||||
mkdir -p build && \
|
|
||||||
cd build && \
|
|
||||||
BUILD_TYPE="Release" && \
|
|
||||||
ENABLE_ASSERTIONS="Off" && \
|
|
||||||
BUILD_TOOLS="Off" && \
|
|
||||||
case ${DOCKER_TAG} in *"-debug"*) BUILD_TYPE="Debug";; esac && \
|
|
||||||
case ${DOCKER_TAG} in *"-assertions"*) BUILD_TYPE="RelWithDebInfo" && ENABLE_ASSERTIONS="On" && BUILD_TOOLS="On";; esac && \
|
|
||||||
echo "Building ${BUILD_TYPE} with ENABLE_ASSERTIONS=${ENABLE_ASSERTIONS} BUILD_TOOLS=${BUILD_TOOLS}" && \
|
|
||||||
cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DENABLE_ASSERTIONS=${ENABLE_ASSERTIONS} -DBUILD_TOOLS=${BUILD_TOOLS} -DENABLE_LTO=On && \
|
|
||||||
make -j${NPROC} install && \
|
|
||||||
cd ../profiles && \
|
|
||||||
cp -r * /opt && \
|
|
||||||
strip /usr/local/bin/* && \
|
|
||||||
rm -rf /src
|
|
||||||
|
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
COPY --from=builder /usr/local /usr/local
|
|
||||||
COPY --from=builder /opt /opt
|
|
||||||
|
|
||||||
RUN apt-get update && \
|
|
||||||
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
|
|
||||||
ldconfig /usr/local/lib
|
|
||||||
|
|
||||||
RUN /usr/local/bin/osrm-extract --help && \
|
|
||||||
/usr/local/bin/osrm-routed --help && \
|
|
||||||
/usr/local/bin/osrm-contract --help && \
|
|
||||||
/usr/local/bin/osrm-partition --help && \
|
|
||||||
/usr/local/bin/osrm-customize --help
|
|
||||||
|
|
||||||
WORKDIR /opt
|
|
||||||
|
|
||||||
EXPOSE 5000
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
# We've placed the Dockerfile under docker/ so that the generically named
|
|
||||||
# hooks/ directory doesn't pollute the main directory. Because we need to
|
|
||||||
# COPY the source into the container, we need to use some -f gymnastics to
|
|
||||||
# ensure that "COPY . /src" is referring to the repo root, not the directory
|
|
||||||
# that contains the Dockerfile.
|
|
||||||
# This script gets executed with a pwd of wherever the Dockerfile is.
|
|
||||||
|
|
||||||
DOCKER_BUILD="docker build --build-arg BUILD_CONCURRENCY=${CONCURRENCY} --build-arg DOCKER_TAG=${DOCKER_TAG:?unset} -t ${IMAGE_NAME:?unset} -f"
|
|
||||||
|
|
||||||
$DOCKER_BUILD Dockerfile ..
|
|
||||||
$DOCKER_BUILD Dockerfile-alpine ..
|
|
@ -1,62 +0,0 @@
|
|||||||
# Developing / Debugging guidance code
|
|
||||||
|
|
||||||
When changing guidance code, it is easy to introduce problems somewhere in the network.
|
|
||||||
To get a better feeling of how your changes impact the OSRM experience, we offer ways of generating geojson output to inspect (e.g. with Mapbox Studio).
|
|
||||||
When you do changes, make sure to inspect a few areas for the impact of the changes.
|
|
||||||
|
|
||||||
## How to use GeoJson-Debugging
|
|
||||||
|
|
||||||
This is a short guide to describe usage of our GeoJson debug logging mechanism. It is synchronized to guarantee thread-safe logging.
|
|
||||||
|
|
||||||
## Outputting into a single file
|
|
||||||
To use it, the inclusion of `geojson_debug_logger.hpp` `geojson_debug_policies.hpp` from the `util` directory is required.
|
|
||||||
|
|
||||||
Geojson debugging requires a few simple steps to output data into a feature collection.
|
|
||||||
|
|
||||||
- Create a Scoped Guard that lives through the process and provide it with all required datastructures (it needs to span the lifetime of all your logging efforts)
|
|
||||||
- At the location of the output, simply call Write with your own parameters.
|
|
||||||
|
|
||||||
A guard (ScopedGeojsonLoggerGuard) requires a logging policy. Per default we provide a way of printing out node-ids as coordinates.
|
|
||||||
|
|
||||||
The initialisation to do so looks like this:
|
|
||||||
`util::ScopedGeojsonLoggerGuard<util::NodeIdVectorToLineString> geojson_guard( "debug.geojson", data-for-conversion);`
|
|
||||||
Make sure to give the guard a name, so it actually gets a lifetime.
|
|
||||||
|
|
||||||
The field `data-for-conversion` can be an arbitrary long set of features and needs to match the parameters used for constructing our policy (in this case `util::NodeIdVectorToLineString`).
|
|
||||||
|
|
||||||
The policy itself offers a `operator()` accepting a `vector` of `NodeID`.
|
|
||||||
|
|
||||||
For outputting data into our file (debug.geojson), we simply need to call the matching logging routine of the guard: `util::ScioedGeojsonLoggerGuard<util::NodeIdVectorToLineString>::Write(list_of_node_ids);`
|
|
||||||
(or `guard.Write(list_of_node_ids)` if you created an instance).
|
|
||||||
|
|
||||||
### Possible Scopeguard Location
|
|
||||||
Think of the scopeguard as you would do of any reference. If you wan't to access to logging during a call, the guard object must be alive and valid.
|
|
||||||
|
|
||||||
As an example: a good location to create a scopeguard to log decisions in the edge-based-graph-factory would be right before we run it ([here](https://github.com/Project-OSRM/osrm-backend/blob/a933b5d94943bf3edaf42c84a614a99650d23cba/src/extractor/extractor.cpp#L497)). If you put `util::ScopedGeojsonLoggerGuard<util::NodeIdVectorToLineString> geojson_guard( "debug.geojson", node_coordinate_vector);` at that location, you can then print `util::ScopedGeojsonLoggerGuard<util::NodeIdVectorToLineString>::Write(list_of_node_ids);` anywhere within the `edge-based-graph-factory`.
|
|
||||||
|
|
||||||
This location would enable calls for all guidance related pre-processing which is called in the edge-based-graph-factory.
|
|
||||||
Logging any turn-handler decisions, for example, would now be possible.
|
|
||||||
|
|
||||||
## Limitations
|
|
||||||
GeoJson debugging requires a single GeoJsonGuard (ScopedGeojsonLoggerGuard) for each desired output file.
|
|
||||||
For each set of template parameters, only the most recent guard will actually produce output.
|
|
||||||
|
|
||||||
`util::ScopedGeojsonLoggerGuard<util::NodeIdVectorToLineString> geojson_guard( "debug.geojson", data-for-conversion);`
|
|
||||||
|
|
||||||
`util::ScopedGeojsonLoggerGuard<util::NodeIdVectorToLineString> geojson_guard( "debug-2.geojson", data-for-conversion);`
|
|
||||||
|
|
||||||
Will not provide a way to write into two files, but only `debug-2` will actually contain features.
|
|
||||||
|
|
||||||
We cannot nest-these calls.
|
|
||||||
|
|
||||||
If we want to use the same policy for multiple files, we need to use different template parameters both for the logger and the guard.
|
|
||||||
|
|
||||||
`util::ScopedGeojsonLoggerGuard<util::NodeIdVectorToLineString,0> geojson_guard( "debug.geojson", data-for-conversion);`
|
|
||||||
|
|
||||||
`util::ScopedGeojsonLoggerGuard<util::NodeIdVectorToLineString,1> geojson_guard( "debug-2.geojson", data-for-conversion);`
|
|
||||||
|
|
||||||
as well as,
|
|
||||||
|
|
||||||
`util::ScopedGeojsonLoggerGuardr<util::NodeIdVectorToLineString,0>::Write(list_of_node_ids);`
|
|
||||||
|
|
||||||
`util::ScopedGeojsonLoggerGuardr<util::NodeIdVectorToLineString,1>::Write(list_of_node_ids);`
|
|
1125
docs/http.md
Before Width: | Height: | Size: 694 KiB |
@ -1,33 +0,0 @@
|
|||||||
## Introduction
|
|
||||||
|
|
||||||
OSRM can be used as a library (libosrm) via C++ instead of using it through the HTTP interface and `osrm-routed`. This allows for fine-tuning OSRM and has much less overhead. Here is a quick introduction into how to use `libosrm` in the upcoming v5 release.
|
|
||||||
|
|
||||||
Take a look at the example code that lives in the [example directory](https://github.com/Project-OSRM/osrm-backend/tree/master/example). Here is all you ever wanted to know about `libosrm`, that is a short description of what the types do and where to find documentation on it:
|
|
||||||
|
|
||||||
## Important interface objects
|
|
||||||
|
|
||||||
- [`EngineConfig`](https://github.com/Project-OSRM/osrm-backend/blob/master/include/engine/engine_config.hpp) - for initializing an OSRM instance we can configure certain properties and constraints. E.g. the storage config is the base path such as `france.osm.osrm` from which we derive and load `france.osm.osrm.*` auxiliary files. This also lets you set constraints such as the maximum number of locations allowed for specific services.
|
|
||||||
|
|
||||||
- [`OSRM`](https://github.com/Project-OSRM/osrm-backend/blob/master/include/osrm/osrm.hpp) - this is the main Routing Machine type with functions such as `Route` and `Table`. You initialize it with a `EngineConfig`. It does all the heavy lifting for you. Each function takes its own parameters, e.g. the `Route` function takes `RouteParameters`, and a out-reference to a JSON result that gets filled. The return value is a `Status`, indicating error or success.
|
|
||||||
|
|
||||||
- [`Status`](https://github.com/Project-OSRM/osrm-backend/blob/master/include/engine/status.hpp) - this is a type wrapping `Error` or `Ok` for indicating error or success, respectively.
|
|
||||||
|
|
||||||
- [`TableParameters`](https://github.com/Project-OSRM/osrm-backend/blob/master/include/engine/api/table_parameters.hpp) - this is an example of parameter types the Routing Machine functions expect. In this case `Table` expects its own parameters as `TableParameters`. You can see it wrapping two vectors, sources and destinations --- these are indices into your coordinates for the table service to construct a matrix from (empty sources or destinations means: use all of them). If you ask yourself where coordinates come from, you can see `TableParameters` inheriting from `BaseParameters`.
|
|
||||||
|
|
||||||
- [`BaseParameter`](https://github.com/Project-OSRM/osrm-backend/blob/master/include/engine/api/base_parameters.hpp) - this most importantly holds coordinates (and a few other optional properties that you don't need for basic usage); the specific parameter types inherit from `BaseParameters` to get these member attributes. That means your `TableParameters` type has `coordinates`, `sources` and `destination` member attributes (and a few other that we ignore for now).
|
|
||||||
|
|
||||||
- [`Coordinate`](https://github.com/Project-OSRM/osrm-backend/blob/master/include/util/coordinate.hpp) - this is a wrapper around a (longitude, latitude) pair. We really don't care about (lon,lat) vs (lat, lon) but we don't want you to accidentally mix them up, so both latitude and longitude are strictly typed wrappers around integers (fixed notation such as `13423240`) and floating points (floating notation such as `13.42324`).
|
|
||||||
|
|
||||||
- [Parameters for other services](https://github.com/Project-OSRM/osrm-backend/tree/master/include/engine/api) - here are all other `*Parameters` you need for other Routing Machine services.
|
|
||||||
|
|
||||||
- [JSON](https://github.com/Project-OSRM/osrm-backend/blob/master/include/util/json_container.hpp) - this is a sum type resembling JSON. The Routing Machine service functions take a out-ref to a JSON result and fill it accordingly. It is currently implemented using [mapbox/variant](https://github.com/mapbox/variant) which is similar to [Boost.Variant](http://www.boost.org/doc/libs/1_55_0/doc/html/variant.html). There are two ways to work with this sum type: either provide a visitor that acts on each type on visitation or use the `get` function in case you're sure about the structure. The JSON structure is written down in the [HTTP API](#http-api).
|
|
||||||
|
|
||||||
## Example
|
|
||||||
|
|
||||||
See [the example folder](https://github.com/Project-OSRM/osrm-backend/tree/master/example) in the OSRM repository.
|
|
||||||
|
|
||||||
## Workflow
|
|
||||||
|
|
||||||
- Create an `OSRM` instance initialized with a `EngineConfig`
|
|
||||||
- Call the service function on the `OSRM` object providing service specific `*Parameters`
|
|
||||||
- Check the return code and use the JSON result
|
|
@ -1,411 +0,0 @@
|
|||||||
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
|
|
||||||
|
|
||||||
## OSRM
|
|
||||||
|
|
||||||
The `OSRM` method is the main constructor for creating an OSRM instance.
|
|
||||||
An OSRM instance requires a `.osrm.*` dataset(`.osrm.*` because it contains several files), which is prepared by the OSRM toolchain.
|
|
||||||
You can create such a `.osrm.*` dataset by running the OSRM binaries we ship in `node_modules/osrm/lib/binding/` and default
|
|
||||||
profiles (e.g. for setting speeds and determining road types to route on) in `node_modules/osrm/profiles/`:
|
|
||||||
|
|
||||||
node_modules/osrm/lib/binding/osrm-extract data.osm.pbf -p node_modules/osrm/profiles/car.lua
|
|
||||||
node_modules/osrm/lib/binding/osrm-contract data.osrm
|
|
||||||
|
|
||||||
Consult the [osrm-backend](https://github.com/Project-OSRM/osrm-backend) documentation for further details.
|
|
||||||
|
|
||||||
Once you have a complete `network.osrm.*` dataset, you can calculate routes in javascript with this object.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var osrm = new OSRM('network.osrm');
|
|
||||||
```
|
|
||||||
|
|
||||||
**Parameters**
|
|
||||||
|
|
||||||
- `options` **([Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object) \| [String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String))** Options for creating an OSRM object or string to the `.osrm` file. (optional, default `{shared_memory:true}`)
|
|
||||||
- `options.algorithm` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** The algorithm to use for routing. Can be 'CH', or 'MLD'. Default is 'CH'.
|
|
||||||
Make sure you prepared the dataset with the correct toolchain.
|
|
||||||
- `options.shared_memory` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** Connects to the persistent shared memory datastore.
|
|
||||||
This requires you to run `osrm-datastore` prior to creating an `OSRM` object.
|
|
||||||
- `options.dataset_name` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Connects to the persistent shared memory datastore defined by `--dataset_name` option when running `osrm-datastore`.
|
|
||||||
This requires you to run `osrm-datastore --dataset_name` prior to creating an `OSRM` object.
|
|
||||||
- `options.memory_file` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** **DEPRECATED**
|
|
||||||
Old behaviour: Path to a file on disk to store the memory using mmap. Current behaviour: setting this value is the same as setting `mmap_memory: true`.
|
|
||||||
- `options.mmap_memory` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** Map on-disk files to virtual memory addresses (mmap), rather than loading into RAM.
|
|
||||||
- `options.path` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** The path to the `.osrm` files. This is mutually exclusive with setting {options.shared_memory} to true.
|
|
||||||
- `options.disable_feature_dataset` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Disables a feature dataset from being loaded into memory if not needed. Options: `ROUTE_STEPS`, `ROUTE_GEOMETRY`.
|
|
||||||
- `options.max_locations_trip` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Max. locations supported in trip query (default: unlimited).
|
|
||||||
- `options.max_locations_viaroute` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Max. locations supported in viaroute query (default: unlimited).
|
|
||||||
- `options.max_locations_distance_table` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Max. locations supported in distance table query (default: unlimited).
|
|
||||||
- `options.max_locations_map_matching` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Max. locations supported in map-matching query (default: unlimited).
|
|
||||||
- `options.max_radius_map_matching` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Max. radius size supported in map matching query (default: 5).
|
|
||||||
- `options.max_results_nearest` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Max. results supported in nearest query (default: unlimited).
|
|
||||||
- `options.max_alternatives` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Max. number of alternatives supported in alternative routes query (default: 3).
|
|
||||||
- `options.default_radius` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Default radius for queries (default: unlimited).
|
|
||||||
|
|
||||||
### route
|
|
||||||
|
|
||||||
Returns the fastest route between two or more coordinates while visiting the waypoints in order.
|
|
||||||
|
|
||||||
**Parameters**
|
|
||||||
|
|
||||||
- `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object literal containing parameters for the route query.
|
|
||||||
- `options.coordinates` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)?** The coordinates this request will use, coordinates as `[{lon},{lat}]` values, in decimal degrees.
|
|
||||||
- `options.bearings` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Limits the search to segments with given bearing in degrees towards true north in clockwise direction.
|
|
||||||
Can be `null` or an array of `[{value},{range}]` with `integer 0 .. 360,integer 0 .. 180`.
|
|
||||||
- `options.radiuses` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Limits the coordinate snapping to streets in the given radius in meters. Can be `null` (unlimited, default) or `double >= 0`.
|
|
||||||
- `options.hints` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Hints for the coordinate snapping. Array of base64 encoded strings.
|
|
||||||
- `options.exclude` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)?** List of classes to avoid, order does not matter.
|
|
||||||
- `options.generate_hints` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Whether or not adds a Hint to the response which can be used in subsequent requests. (optional, default `true`)
|
|
||||||
- `options.alternatives` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Search for alternative routes. (optional, default `false`)
|
|
||||||
- `options.alternatives` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** Search for up to this many alternative routes.
|
|
||||||
_Please note that even if alternative routes are requested, a result cannot be guaranteed._ (optional, default `0`)
|
|
||||||
- `options.steps` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Return route steps for each route leg. (optional, default `false`)
|
|
||||||
- `options.annotations` **([Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array) \| [Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean))** An array with strings of `duration`, `nodes`, `distance`, `weight`, `datasources`, `speed` or boolean for enabling/disabling all. (optional, default `false`)
|
|
||||||
- `options.geometries` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Returned route geometry format (influences overview and per step). Can also be `geojson`. (optional, default `polyline`)
|
|
||||||
- `options.overview` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Add overview geometry either `full`, `simplified` according to highest zoom level it could be display on, or not at all (`false`). (optional, default `simplified`)
|
|
||||||
- `options.continue_straight` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** Forces the route to keep going straight at waypoints and don't do a uturn even if it would be faster. Default value depends on the profile.
|
|
||||||
- `options.approaches` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Restrict the direction on the road network at a waypoint, relative to the input coordinate. Can be `null` (unrestricted, default), `curb` or `opposite`.
|
|
||||||
`null`/`true`/`false`
|
|
||||||
- `options.waypoints` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Indices to coordinates to treat as waypoints. If not supplied, all coordinates are waypoints. Must include first and last coordinate index.
|
|
||||||
- `options.format` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Which output format to use, either `json`, or [`flatbuffers`](https://github.com/Project-OSRM/osrm-backend/tree/master/include/engine/api/flatbuffers).
|
|
||||||
- `options.snapping` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Which edges can be snapped to, either `default`, or `any`. `default` only snaps to edges marked by the profile as `is_startpoint`, `any` will allow snapping to any edge in the routing graph.
|
|
||||||
- `options.skip_waypoints` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Removes waypoints from the response. Waypoints are still calculated, but not serialized. Could be useful in case you are interested in some other part of response and do not want to transfer waste data. (optional, default `false`)
|
|
||||||
- `callback` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)**
|
|
||||||
|
|
||||||
**Examples**
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var osrm = new OSRM("berlin-latest.osrm");
|
|
||||||
osrm.route({coordinates: [[52.519930,13.438640], [52.513191,13.415852]]}, function(err, result) {
|
|
||||||
if(err) throw err;
|
|
||||||
console.log(result.waypoints); // array of Waypoint objects representing all waypoints in order
|
|
||||||
console.log(result.routes); // array of Route objects ordered by descending recommendation rank
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** An array of [Waypoint](#waypoint) objects representing all waypoints in order AND an array of [`Route`](#route) objects ordered by descending recommendation rank.
|
|
||||||
|
|
||||||
### nearest
|
|
||||||
|
|
||||||
Snaps a coordinate to the street network and returns the nearest n matches.
|
|
||||||
|
|
||||||
Note: `coordinates` in the general options only supports a single `{longitude},{latitude}` entry.
|
|
||||||
|
|
||||||
**Parameters**
|
|
||||||
|
|
||||||
- `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object literal containing parameters for the nearest query.
|
|
||||||
- `options.coordinates` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)?** The coordinates this request will use, coordinates as `[{lon},{lat}]` values, in decimal degrees.
|
|
||||||
- `options.bearings` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Limits the search to segments with given bearing in degrees towards true north in clockwise direction.
|
|
||||||
Can be `null` or an array of `[{value},{range}]` with `integer 0 .. 360,integer 0 .. 180`.
|
|
||||||
- `options.radiuses` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Limits the coordinate snapping to streets in the given radius in meters. Can be `null` (unlimited, default) or `double >= 0`.
|
|
||||||
- `options.hints` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Hints for the coordinate snapping. Array of base64 encoded strings.
|
|
||||||
- `options.generate_hints` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Whether or not adds a Hint to the response which can be used in subsequent requests. (optional, default `true`)
|
|
||||||
- `options.number` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** Number of nearest segments that should be returned.
|
|
||||||
Must be an integer greater than or equal to `1`. (optional, default `1`)
|
|
||||||
- `options.approaches` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Restrict the direction on the road network at a waypoint, relative to the input coordinate. Can be `null` (unrestricted, default), `curb` or `opposite`.
|
|
||||||
- `options.format` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Which output format to use, either `json`, or [`flatbuffers`](https://github.com/Project-OSRM/osrm-backend/tree/master/include/engine/api/flatbuffers).
|
|
||||||
- `options.snapping` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Which edges can be snapped to, either `default`, or `any`. `default` only snaps to edges marked by the profile as `is_startpoint`, `any` will allow snapping to any edge in the routing graph.
|
|
||||||
- `callback` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)**
|
|
||||||
|
|
||||||
**Examples**
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var osrm = new OSRM('network.osrm');
|
|
||||||
var options = {
|
|
||||||
coordinates: [[13.388860,52.517037]],
|
|
||||||
number: 3,
|
|
||||||
bearings: [[0,20]]
|
|
||||||
};
|
|
||||||
osrm.nearest(options, function(err, response) {
|
|
||||||
console.log(response.waypoints); // array of Waypoint objects
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** containing `waypoints`.
|
|
||||||
**`waypoints`**: array of [`Ẁaypoint`](#waypoint) objects sorted by distance to the input coordinate.
|
|
||||||
Each object has an additional `distance` property, which is the distance in meters to the supplied input coordinate.
|
|
||||||
|
|
||||||
### table
|
|
||||||
|
|
||||||
Computes duration table for the given locations. Allows for both symmetric and asymmetric tables.
|
|
||||||
Optionally returns distance table.
|
|
||||||
|
|
||||||
**Parameters**
|
|
||||||
|
|
||||||
- `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object literal containing parameters for the table query.
|
|
||||||
- `options.coordinates` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)?** The coordinates this request will use, coordinates as `[{lon},{lat}]` values, in decimal degrees.
|
|
||||||
- `options.bearings` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Limits the search to segments with given bearing in degrees towards true north in clockwise direction.
|
|
||||||
Can be `null` or an array of `[{value},{range}]` with `integer 0 .. 360,integer 0 .. 180`.
|
|
||||||
- `options.radiuses` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Limits the coordinate snapping to streets in the given radius in meters. Can be `null` (unlimited, default) or `double >= 0`.
|
|
||||||
- `options.hints` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Hints for the coordinate snapping. Array of base64 encoded strings.
|
|
||||||
- `options.generate_hints` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Whether or not adds a Hint to the response which can be used in subsequent requests. (optional, default `true`)
|
|
||||||
- `options.sources` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)?** An array of `index` elements (`0 <= integer < #coordinates`) to use
|
|
||||||
location with given index as source. Default is to use all.
|
|
||||||
- `options.destinations` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)?** An array of `index` elements (`0 <= integer < #coordinates`) to use location with given index as destination. Default is to use all.
|
|
||||||
- `options.approaches` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Restrict the direction on the road network at a waypoint, relative to the input coordinate.. Can be `null` (unrestricted, default), `curb` or `opposite`.
|
|
||||||
- `options.fallback_speed` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Replace `null` responses in result with as-the-crow-flies estimates based on `fallback_speed`. Value is in metres/second.
|
|
||||||
- `options.fallback_coordinate` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Either `input` (default) or `snapped`. If using a `fallback_speed`, use either the user-supplied coordinate (`input`), or the snapped coordinate (`snapped`) for calculating the as-the-crow-flies distance between two points.
|
|
||||||
- `options.scale_factor` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Multiply the table duration values in the table by this number for more controlled input into a route optimization solver.
|
|
||||||
- `options.snapping` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Which edges can be snapped to, either `default`, or `any`. `default` only snaps to edges marked by the profile as `is_startpoint`, `any` will allow snapping to any edge in the routing graph.
|
|
||||||
- `options.annotations` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Return the requested table or tables in response. Can be `['duration']` (return the duration matrix, default), `[distance']` (return the distance matrix), or `['duration', distance']` (return both the duration matrix and the distance matrix).
|
|
||||||
- `callback` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)**
|
|
||||||
|
|
||||||
**Examples**
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var osrm = new OSRM('network.osrm');
|
|
||||||
var options = {
|
|
||||||
coordinates: [
|
|
||||||
[13.388860,52.517037],
|
|
||||||
[13.397634,52.529407],
|
|
||||||
[13.428555,52.523219]
|
|
||||||
]
|
|
||||||
};
|
|
||||||
osrm.table(options, function(err, response) {
|
|
||||||
console.log(response.durations); // array of arrays, matrix in row-major order
|
|
||||||
console.log(response.distances); // array of arrays, matrix in row-major order
|
|
||||||
console.log(response.sources); // array of Waypoint objects
|
|
||||||
console.log(response.destinations); // array of Waypoint objects
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** containing `durations`, `distances`, `sources`, and `destinations`.
|
|
||||||
**`durations`**: array of arrays that stores the matrix in row-major order. `durations[i][j]` gives the travel time from the i-th waypoint to the j-th waypoint.
|
|
||||||
Values are given in seconds.
|
|
||||||
**`distances`**: array of arrays that stores the matrix in row-major order. `distances[i][j]` gives the travel time from the i-th waypoint to the j-th waypoint.
|
|
||||||
Values are given in meters.
|
|
||||||
**`sources`**: array of [`Ẁaypoint`](#waypoint) objects describing all sources in order.
|
|
||||||
**`destinations`**: array of [`Ẁaypoint`](#waypoint) objects describing all destinations in order.
|
|
||||||
**`fallback_speed_cells`**: (optional) if `fallback_speed` is used, will be an array of arrays of `row,column` values, indicating which cells contain estimated values.
|
|
||||||
|
|
||||||
### tile
|
|
||||||
|
|
||||||
This generates [Mapbox Vector Tiles](https://mapbox.com/vector-tiles) that can be viewed with a
|
|
||||||
vector-tile capable slippy-map viewer. The tiles contain road geometries and metadata that can
|
|
||||||
be used to examine the routing graph. The tiles are generated directly from the data in-memory,
|
|
||||||
so are in sync with actual routing results, and let you examine which roads are actually
|
|
||||||
routable,
|
|
||||||
and what weights they have applied.
|
|
||||||
|
|
||||||
**Parameters**
|
|
||||||
|
|
||||||
- `ZXY` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** an array consisting of `x`, `y`, and `z` values representing tile coordinates like
|
|
||||||
[wiki.openstreetmap.org/wiki/Slippy_map_tilenames](https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames)
|
|
||||||
and are supported by vector tile viewers like [Mapbox GL JS](https://www.mapbox.com/mapbox-gl-js/api/).
|
|
||||||
- `callback` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)**
|
|
||||||
|
|
||||||
**Examples**
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var osrm = new OSRM('network.osrm');
|
|
||||||
osrm.tile([0, 0, 0], function(err, response) {
|
|
||||||
if (err) throw err;
|
|
||||||
fs.writeFileSync('./tile.vector.pbf', response); // write the buffer to a file
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
Returns **[Buffer](https://nodejs.org/api/buffer.html)** contains a Protocol Buffer encoded vector tile.
|
|
||||||
|
|
||||||
### match
|
|
||||||
|
|
||||||
Map matching matches given GPS points to the road network in the most plausible way.
|
|
||||||
Please note the request might result multiple sub-traces. Large jumps in the timestamps
|
|
||||||
(>60s) or improbable transitions lead to trace splits if a complete matching could
|
|
||||||
not be found. The algorithm might not be able to match all points. Outliers are removed
|
|
||||||
if they can not be matched successfully.
|
|
||||||
|
|
||||||
**Parameters**
|
|
||||||
|
|
||||||
- `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object literal containing parameters for the match query.
|
|
||||||
- `options.coordinates` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)?** The coordinates this request will use, coordinates as `[{lon},{lat}]` values, in decimal degrees.
|
|
||||||
- `options.bearings` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Limits the search to segments with given bearing in degrees towards true north in clockwise direction.
|
|
||||||
Can be `null` or an array of `[{value},{range}]` with `integer 0 .. 360,integer 0 .. 180`.
|
|
||||||
- `options.hints` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Hints for the coordinate snapping. Array of base64 encoded strings.
|
|
||||||
- `options.generate_hints` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Whether or not adds a Hint to the response which can be used in subsequent requests. (optional, default `true`)
|
|
||||||
- `options.steps` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Return route steps for each route. (optional, default `false`)
|
|
||||||
- `options.annotations` **([Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array) \| [Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean))** An array with strings of `duration`, `nodes`, `distance`, `weight`, `datasources`, `speed` or boolean for enabling/disabling all. (optional, default `false`)
|
|
||||||
- `options.geometries` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Returned route geometry format (influences overview and per step). Can also be `geojson`. (optional, default `polyline`)
|
|
||||||
- `options.overview` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Add overview geometry either `full`, `simplified` according to highest zoom level it could be display on, or not at all (`false`). (optional, default `simplified`)
|
|
||||||
- `options.timestamps` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)>?** Timestamp of the input location (integers, UNIX-like timestamp).
|
|
||||||
- `options.radiuses` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Standard deviation of GPS precision used for map matching. If applicable use GPS accuracy. Can be `null` for default value `5` meters or `double >= 0`.
|
|
||||||
- `options.gaps` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Allows the input track splitting based on huge timestamp gaps between points. Either `split` or `ignore`. (optional, default `split`)
|
|
||||||
- `options.tidy` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Allows the input track modification to obtain better matching quality for noisy tracks. (optional, default `false`)
|
|
||||||
- `options.waypoints` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Indices to coordinates to treat as waypoints. If not supplied, all coordinates are waypoints. Must include first and last coordinate index.
|
|
||||||
- `options.snapping` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Which edges can be snapped to, either `default`, or `any`. `default` only snaps to edges marked by the profile as `is_startpoint`, `any` will allow snapping to any edge in the routing graph.
|
|
||||||
- `callback` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)**
|
|
||||||
|
|
||||||
**Examples**
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var osrm = new OSRM('network.osrm');
|
|
||||||
var options = {
|
|
||||||
coordinates: [[13.393252,52.542648],[13.39478,52.543079],[13.397389,52.542107]],
|
|
||||||
timestamps: [1424684612, 1424684616, 1424684620]
|
|
||||||
};
|
|
||||||
osrm.match(options, function(err, response) {
|
|
||||||
if (err) throw err;
|
|
||||||
console.log(response.tracepoints); // array of Waypoint objects
|
|
||||||
console.log(response.matchings); // array of Route objects
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** containing `tracepoints` and `matchings`.
|
|
||||||
**`tracepoints`** Array of [`Ẁaypoint`](#waypoint) objects representing all points of the trace in order.
|
|
||||||
If the trace point was omitted by map matching because it is an outlier, the entry will be null.
|
|
||||||
Each `Waypoint` object has the following additional properties,
|
|
||||||
1) `matchings_index`: Index to the
|
|
||||||
[`Route`](#route) object in matchings the sub-trace was matched to,
|
|
||||||
2) `waypoint_index`: Index of
|
|
||||||
the waypoint inside the matched route.
|
|
||||||
3) `alternatives_count`: Number of probable alternative matchings for this trace point. A value of zero indicate that this point was matched unambiguously. Split the trace at these points for incremental map matching.
|
|
||||||
**`matchings`** is an array of [`Route`](#route) objects that assemble the trace. Each `Route` object has an additional `confidence` property,
|
|
||||||
which is the confidence of the matching. float value between `0` and `1`. `1` is very confident that the matching is correct.
|
|
||||||
|
|
||||||
### trip
|
|
||||||
|
|
||||||
The trip plugin solves the Traveling Salesman Problem using a greedy heuristic
|
|
||||||
(farthest-insertion algorithm) for 10 or _ more waypoints and uses brute force for less than 10
|
|
||||||
waypoints. The returned path does not have to be the shortest path, _ as TSP is NP-hard it is
|
|
||||||
only an approximation.
|
|
||||||
|
|
||||||
Note that all input coordinates have to be connected for the trip service to work.
|
|
||||||
Currently, not all combinations of `roundtrip`, `source` and `destination` are supported.
|
|
||||||
Right now, the following combinations are possible:
|
|
||||||
|
|
||||||
| roundtrip | source | destination | supported |
|
|
||||||
| :-------- | :----- | :---------- | :-------- |
|
|
||||||
| true | first | last | **yes** |
|
|
||||||
| true | first | any | **yes** |
|
|
||||||
| true | any | last | **yes** |
|
|
||||||
| true | any | any | **yes** |
|
|
||||||
| false | first | last | **yes** |
|
|
||||||
| false | first | any | no |
|
|
||||||
| false | any | last | no |
|
|
||||||
| false | any | any | no |
|
|
||||||
|
|
||||||
**Parameters**
|
|
||||||
|
|
||||||
- `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object literal containing parameters for the trip query.
|
|
||||||
- `options.coordinates` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)?** The coordinates this request will use, coordinates as `[{lon},{lat}]` values, in decimal degrees.
|
|
||||||
- `options.bearings` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Limits the search to segments with given bearing in degrees towards true north in clockwise direction.
|
|
||||||
Can be `null` or an array of `[{value},{range}]` with `integer 0 .. 360,integer 0 .. 180`.
|
|
||||||
- `options.radiuses` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Limits the coordinate snapping to streets in the given radius in meters. Can be `double >= 0` or `null` (unlimited, default).
|
|
||||||
- `options.hints` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Hints for the coordinate snapping. Array of base64 encoded strings.
|
|
||||||
- `options.generate_hints` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Whether or not adds a Hint to the response which can be used in subsequent requests. (optional, default `true`)
|
|
||||||
- `options.steps` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Return route steps for each route. (optional, default `false`)
|
|
||||||
- `options.annotations` **([Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array) \| [Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean))** An array with strings of `duration`, `nodes`, `distance`, `weight`, `datasources`, `speed` or boolean for enabling/disabling all. (optional, default `false`)
|
|
||||||
- `options.geometries` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Returned route geometry format (influences overview and per step). Can also be `geojson`. (optional, default `polyline`)
|
|
||||||
- `options.overview` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Add overview geometry either `full`, `simplified` (optional, default `simplified`)
|
|
||||||
- `options.roundtrip` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Return route is a roundtrip. (optional, default `true`)
|
|
||||||
- `options.source` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Return route starts at `any` or `first` coordinate. (optional, default `any`)
|
|
||||||
- `options.destination` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Return route ends at `any` or `last` coordinate. (optional, default `any`)
|
|
||||||
- `options.approaches` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Restrict the direction on the road network at a waypoint, relative to the input coordinate. Can be `null` (unrestricted, default), `curb` or `opposite`.
|
|
||||||
- `options.snapping` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Which edges can be snapped to, either `default`, or `any`. `default` only snaps to edges marked by the profile as `is_startpoint`, `any` will allow snapping to any edge in the routing graph.
|
|
||||||
- `callback` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)**
|
|
||||||
|
|
||||||
**Examples**
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var osrm = new OSRM('network.osrm');
|
|
||||||
var options = {
|
|
||||||
coordinates: [
|
|
||||||
[13.36761474609375, 52.51663871100423],
|
|
||||||
[13.374481201171875, 52.506191342034576]
|
|
||||||
],
|
|
||||||
source: "first",
|
|
||||||
destination: "last",
|
|
||||||
roundtrip: false
|
|
||||||
}
|
|
||||||
osrm.trip(options, function(err, response) {
|
|
||||||
if (err) throw err;
|
|
||||||
console.log(response.waypoints); // array of Waypoint objects
|
|
||||||
console.log(response.trips); // array of Route objects
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** containing `waypoints` and `trips`.
|
|
||||||
**`waypoints`**: an array of [`Waypoint`](#waypoint) objects representing all waypoints in input order.
|
|
||||||
Each Waypoint object has the following additional properties,
|
|
||||||
1) `trips_index`: index to trips of the sub-trip the point was matched to, and
|
|
||||||
2) `waypoint_index`: index of the point in the trip.
|
|
||||||
**`trips`**: an array of [`Route`](#route) objects that assemble the trace.
|
|
||||||
|
|
||||||
## Configuration
|
|
||||||
|
|
||||||
All plugins support a second additional object that is available to configure some NodeJS
|
|
||||||
specific behaviours.
|
|
||||||
|
|
||||||
**Parameters**
|
|
||||||
|
|
||||||
- `plugin_config` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Object literal containing parameters for the trip query.
|
|
||||||
- `plugin_config.format` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** The format of the result object to various API calls.
|
|
||||||
Valid options are `object` (default if `options.format` is
|
|
||||||
`json`), which returns a standard Javascript object, as described above, and `buffer`(default if
|
|
||||||
`options.format` is `flatbuffers`), which will return a NodeJS
|
|
||||||
**[Buffer](https://nodejs.org/api/buffer.html)** object, containing a JSON string or Flatbuffers
|
|
||||||
object. The latter has the advantage that it can be immediately serialized to disk/sent over the
|
|
||||||
network, and the generation of the string is performed outside the main NodeJS event loop. This
|
|
||||||
option is ignored by the `tile` plugin. Also note that `options.format` set to `flatbuffers`
|
|
||||||
cannot be used with `plugin_config.format` set to `object`. `json_buffer` is deprecated alias for
|
|
||||||
`buffer`.
|
|
||||||
|
|
||||||
**Examples**
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var osrm = new OSRM('network.osrm');
|
|
||||||
var options = {
|
|
||||||
coordinates: [
|
|
||||||
[13.36761474609375, 52.51663871100423],
|
|
||||||
[13.374481201171875, 52.506191342034576]
|
|
||||||
]
|
|
||||||
};
|
|
||||||
osrm.route(options, { format: "buffer" }, function(err, response) {
|
|
||||||
if (err) throw err;
|
|
||||||
console.log(response.toString("utf-8"));
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
## Responses
|
|
||||||
|
|
||||||
### Route
|
|
||||||
|
|
||||||
Represents a route through (potentially multiple) waypoints.
|
|
||||||
|
|
||||||
**Parameters**
|
|
||||||
|
|
||||||
- `external` **documentation** in
|
|
||||||
[`osrm-backend`](../http.md#route-object)
|
|
||||||
|
|
||||||
### RouteLeg
|
|
||||||
|
|
||||||
Represents a route between two waypoints.
|
|
||||||
|
|
||||||
**Parameters**
|
|
||||||
|
|
||||||
- `external` **documentation** in
|
|
||||||
[`osrm-backend`](../http.md#routeleg-object)
|
|
||||||
|
|
||||||
### RouteStep
|
|
||||||
|
|
||||||
A step consists of a maneuver such as a turn or merge, followed by a distance of travel along a
|
|
||||||
single way to the subsequent step.
|
|
||||||
|
|
||||||
**Parameters**
|
|
||||||
|
|
||||||
- `external` **documentation** in
|
|
||||||
[`osrm-backend`](../http.md#routestep-object)
|
|
||||||
|
|
||||||
### StepManeuver
|
|
||||||
|
|
||||||
**Parameters**
|
|
||||||
|
|
||||||
- `external` **documentation** in
|
|
||||||
[`osrm-backend`](../http.md#stepmaneuver-object)
|
|
||||||
|
|
||||||
### Waypoint
|
|
||||||
|
|
||||||
Object used to describe waypoint on a route.
|
|
||||||
|
|
||||||
**Parameters**
|
|
||||||
|
|
||||||
- `external` **documentation** in
|
|
||||||
[`osrm-backend`](../http.md#waypoint-object)
|
|
377
docs/profiles.md
@ -1,377 +0,0 @@
|
|||||||
# OSRM profiles
|
|
||||||
OSRM supports "profiles". Profiles representing routing behavior for different transport modes like car, bike and foot. You can also create profiles for variations like a fastest/shortest car profile or fastest/safest/greenest bicycles profile.
|
|
||||||
|
|
||||||
A profile describes whether or not it's possible to route along a particular type of way, whether we can pass a particular node, and how quickly we'll be traveling when we do. This feeds into the way the routing graph is created and thus influences the output routes.
|
|
||||||
|
|
||||||
## Available profiles
|
|
||||||
Out-of-the-box OSRM comes with profiles for car, bicycle and foot. You can easily modify these or create new ones if you like.
|
|
||||||
|
|
||||||
Profiles have a 'lua' extension, and are placed in 'profiles' directory.
|
|
||||||
|
|
||||||
When running OSRM preprocessing commands you specify the profile with the --profile (or the shorthand -p) option, for example:
|
|
||||||
|
|
||||||
`osrm-extract --profile ../profiles/car.lua planet-latest.osm.pbf`
|
|
||||||
|
|
||||||
## Processing flow
|
|
||||||
It's important to understand that profiles are used when preprocessing the OSM data, NOT at query time when routes are computed.
|
|
||||||
|
|
||||||
This means that after modifying a profile **you will need to extract, contract and reload the data again** and to see changes in the routing results. See [Processing Flow](https://github.com/Project-OSRM/osrm-backend/wiki/Processing-Flow) for more.
|
|
||||||
|
|
||||||
## Profiles are written in Lua
|
|
||||||
Profiles are not just configuration files. They are scripts written in the [Lua scripting language](http://www.lua.org). The reason for this is that OpenStreetMap data is complex, and it's not possible to simply define tag mappings. Lua scripting offers a powerful way to handle all the possible tag combinations found in OpenStreetMap nodes and ways.
|
|
||||||
|
|
||||||
## Basic structure of profiles
|
|
||||||
A profile will process every node and way in the OSM input data to determine what ways are routable in which direction, at what speed, etc.
|
|
||||||
|
|
||||||
A profile will typically:
|
|
||||||
|
|
||||||
- Define api version (required)
|
|
||||||
- Require library files (optional)
|
|
||||||
- Define setup function (required)
|
|
||||||
- Define process functions (some are required)
|
|
||||||
- Return functions table (required)
|
|
||||||
|
|
||||||
A profile can also define various local functions it needs.
|
|
||||||
|
|
||||||
Looking at [car.lua](../profiles/car.lua) as an example, at the top of the file the api version is defined and then required library files are included.
|
|
||||||
|
|
||||||
Then follows the `setup` function, which is called once when the profile is loaded. It returns a big hash table of configurations, specifying things like what speed to use for different way types. The configurations are used later in the various processing functions. Many adjustments can be done just by modifying this configuration table.
|
|
||||||
|
|
||||||
The setup function is also where you can do other setup, like loading an elevation data source if you want to consider that when processing ways.
|
|
||||||
|
|
||||||
Then come the `process_node` and `process_way` functions, which are called for each OSM node and way when extracting OpenStreetMap data with `osrm-extract`.
|
|
||||||
|
|
||||||
The `process_turn` function processes every possible turn in the network, and sets a penalty depending on the angle and turn of the movement.
|
|
||||||
|
|
||||||
Profiles can also define a `process_segment` function to handle differences in speed along an OSM way, for example to handle elevation. As you can see, this is not currently used in the car profile.
|
|
||||||
|
|
||||||
At the end of the file, a table is returned with references to the setup and processing functions the profile has defined.
|
|
||||||
|
|
||||||
## Understanding speed, weight and rate
|
|
||||||
When computing a route from A to B there can be different measures of what is the best route. That's why there's a need for different profiles.
|
|
||||||
|
|
||||||
Because speeds vary on different types of roads, the shortest and the fastest route are typically different. But there are many other possible preferences. For example a user might prefer a bicycle route that follow parks or other green areas, even though both duration and distance are a bit longer.
|
|
||||||
|
|
||||||
To handle this, OSRM doesn't simply choose the ways with the highest speed. Instead it uses the concepts of `weight` and `rate`. The rate is an abstract measure that you can assign to ways as you like to make some ways preferable to others. Routing will prefer ways with high rate.
|
|
||||||
|
|
||||||
The weight of a way is normally computed as length / rate. The weight can be thought of as the resistance or cost when passing the way. Routing will prefer ways with low weight.
|
|
||||||
|
|
||||||
You can also set the weight of a way to a fixed value. In this case it's not calculated based on the length or rate, and the rate is ignored.
|
|
||||||
|
|
||||||
You should set the speed to your best estimate of the actual speed that will be used on a particular way. This will result in the best estimated travel times.
|
|
||||||
|
|
||||||
If you want to prefer certain ways due to other factors than the speed, adjust the rate accordingly. If you adjust the speed, the time estimation will be skewed.
|
|
||||||
|
|
||||||
If you set the same rate on all ways, the result will be shortest path routing.
|
|
||||||
If you set rate = speed on all ways, the result will be fastest path routing.
|
|
||||||
If you want to prioritize certain streets, increase the rate on these.
|
|
||||||
|
|
||||||
## Elements
|
|
||||||
### api_version
|
|
||||||
A profile should set `api_version` at the top of your profile. This is done to ensure that older profiles are still supported when the api changes. If `api_version` is not defined, 0 will be assumed. The current api version is 4.
|
|
||||||
|
|
||||||
### Library files
|
|
||||||
The folder [profiles/lib/](../profiles/lib/) contains LUA library files for handling many common processing tasks.
|
|
||||||
|
|
||||||
File | Notes
|
|
||||||
------------------|------------------------------
|
|
||||||
way_handlers.lua | Functions for processing way tags
|
|
||||||
tags.lua | Functions for general parsing of OSM tags
|
|
||||||
set.lua | Defines the Set helper for handling sets of values
|
|
||||||
sequence.lua | Defines the Sequence helper for handling sequences of values
|
|
||||||
access.lua | Function for finding relevant access tags
|
|
||||||
destination.lua | Function for finding relevant destination tags
|
|
||||||
maxspeed.lua | Function for determining maximum speed
|
|
||||||
guidance.lua | Function for processing guidance attributes
|
|
||||||
|
|
||||||
They all return a table of functions when you use `require` to load them. You can either store this table and reference its functions later, or if you need only a single function you can store that directly.
|
|
||||||
|
|
||||||
### setup()
|
|
||||||
The `setup` function is called once when the profile is loaded and must return a table of configurations. It's also where you can do other global setup, like loading data sources that are used during processing.
|
|
||||||
|
|
||||||
Note that processing of data is parallelized and several unconnected LUA interpreters will be running at the same time. The `setup` function will be called once for each. Each LUA interpreter will have its own set of globals.
|
|
||||||
|
|
||||||
The following global properties can be set under `properties` in the hash you return in the `setup` function:
|
|
||||||
|
|
||||||
Attribute | Type | Notes
|
|
||||||
-------------------------------------|----------|----------------------------------------------------------------------------
|
|
||||||
weight_name | String | Name used in output for the routing weight property (default `'duration'`)
|
|
||||||
weight_precision | Unsigned | Decimal precision of edge weights (default `1`)
|
|
||||||
left_hand_driving | Boolean | Are vehicles assumed to drive on the left? (used in guidance, default `false`)
|
|
||||||
use_turn_restrictions | Boolean | Are turn restrictions followed? (default `false`)
|
|
||||||
continue_straight_at_waypoint | Boolean | Must the route continue straight on at a via point, or are U-turns allowed? (default `true`)
|
|
||||||
max_speed_for_map_matching | Float | Maximum vehicle speed to be assumed in matching (in m/s)
|
|
||||||
max_turn_weight | Float | Maximum turn penalty weight
|
|
||||||
force_split_edges | Boolean | True value forces a split of forward and backward edges of extracted ways and guarantees that `process_segment` will be called for all segments (default `false`)
|
|
||||||
|
|
||||||
|
|
||||||
The following additional global properties can be set in the hash you return in the `setup` function:
|
|
||||||
|
|
||||||
Attribute | Type | Notes
|
|
||||||
-------------------------------------|------------------|----------------------------------------------------------------------------
|
|
||||||
excludable | Sequence of Sets | Determines which class-combinations are supported by the `exclude` option at query time. E.g. `Sequence{Set{"ferry", "motorway"}, Set{"motorway"}}` will allow you to exclude ferries and motorways, or only motorways.
|
|
||||||
classes | Sequence | Determines the allowed classes that can be referenced using `{forward,backward}_classes` on the way in the `process_way` function.
|
|
||||||
restrictions | Sequence | Determines which turn restrictions will be used for this profile.
|
|
||||||
suffix_list | Set | List of name suffixes needed for determining if "Highway 101 NW" the same road as "Highway 101 ES".
|
|
||||||
relation_types | Sequence | Determines which relations should be cached for processing in this profile. It contains relations types
|
|
||||||
|
|
||||||
### process_node(profile, node, result, relations)
|
|
||||||
Process an OSM node to determine whether this node is a barrier or can be passed and whether passing it incurs a delay.
|
|
||||||
|
|
||||||
Argument | Description
|
|
||||||
---------|-------------------------------------------------------
|
|
||||||
profile | The configuration table you returned in `setup`.
|
|
||||||
node | The input node to process (read-only).
|
|
||||||
result | The output that you will modify.
|
|
||||||
relations| Storage of relations to access relations, where `node` is a member.
|
|
||||||
|
|
||||||
The following attributes can be set on `result`:
|
|
||||||
|
|
||||||
Attribute | Type | Notes
|
|
||||||
----------------|---------|---------------------------------------------------------
|
|
||||||
barrier | Boolean | Is it an impassable barrier?
|
|
||||||
traffic_lights | Boolean | Is it a traffic light (incurs delay in `process_turn`)?
|
|
||||||
|
|
||||||
### process_way(profile, way, result, relations)
|
|
||||||
Given an OpenStreetMap way, the `process_way` function will either return nothing (meaning we are not going to route over this way at all), or it will set up a result hash.
|
|
||||||
|
|
||||||
Argument | Description
|
|
||||||
---------|-------------------------------------------------------
|
|
||||||
profile | The configuration table you returned in `setup`.
|
|
||||||
way | The input way to process (read-only).
|
|
||||||
result | The output that you will modify.
|
|
||||||
relations| Storage of relations to access relations, where `way` is a member.
|
|
||||||
|
|
||||||
Importantly it will set `result.forward_mode` and `result.backward_mode` to indicate the travel mode in each direction, as well as set `result.forward_speed` and `result.backward_speed` to integer values representing the speed for traversing the way.
|
|
||||||
|
|
||||||
It will also set a number of other attributes on `result`.
|
|
||||||
|
|
||||||
Using the power of the scripting language you wouldn't typically see something as simple as a `result.forward_speed = 20` line within the `process_way` function. Instead `process_way` will examine the tag set on the way, process this information in various ways, calling other local functions and referencing the configuration in `profile`, etc., before arriving at the result.
|
|
||||||
|
|
||||||
The following attributes can be set on the result in `process_way`:
|
|
||||||
|
|
||||||
Attribute | Type | Notes
|
|
||||||
----------------------------------------|----------|--------------------------------------------------------------------------
|
|
||||||
forward_speed | Float | Speed on this way in km/h. Mandatory.
|
|
||||||
backward_speed | Float | ""
|
|
||||||
forward_rate | Float | Routing weight, expressed as meters/*weight* (e.g. for a fastest-route weighting, you would want this to be meters/second, so set it to forward_speed/3.6)
|
|
||||||
backward_rate | Float | ""
|
|
||||||
forward_mode | Enum | Mode of travel (e.g. `car`, `ferry`). Mandatory. Defined in `include/extractor/travel_mode.hpp`.
|
|
||||||
backward_mode | Enum | ""
|
|
||||||
forward_classes | Table | Mark this way as being of a specific class, e.g. `result.classes["toll"] = true`. This will be exposed in the API as `classes` on each `RouteStep`.
|
|
||||||
backward_classes | Table | ""
|
|
||||||
duration | Float | Alternative setter for duration of the whole way in both directions
|
|
||||||
weight | Float | Alternative setter for weight of the whole way in both directions
|
|
||||||
turn_lanes_forward | String | Directions for individual lanes (normalized OSM `turn:lanes` value)
|
|
||||||
turn_lanes_backward | String | ""
|
|
||||||
forward_restricted | Boolean | Is this a restricted access road? (e.g. private, or deliveries only; used to enable high turn penalty, so that way is only chosen for start/end of route)
|
|
||||||
backward_restricted | Boolean | ""
|
|
||||||
is_startpoint | Boolean | Can a journey start on this way? (e.g. ferry; if `false`, prevents snapping the start point to this way)
|
|
||||||
roundabout | Boolean | Is this part of a roundabout?
|
|
||||||
circular | Boolean | Is this part of a non-roundabout circular junction?
|
|
||||||
name | String | Name of the way
|
|
||||||
ref | String | Road number (equal to set `forward_ref` and `backward_ref` with one value)
|
|
||||||
forward_ref | String | Road number in forward way direction
|
|
||||||
backward_ref | String | Road number in backward way direction
|
|
||||||
destinations | String | The road's destinations
|
|
||||||
exits | String | The ramp's exit numbers or names
|
|
||||||
pronunciation | String | Name pronunciation
|
|
||||||
road_classification.motorway_class | Boolean | Guidance: way is a motorway
|
|
||||||
road_classification.link_class | Boolean | Guidance: way is a slip/link road
|
|
||||||
road_classification.road_priority_class | Enum | Guidance: order in priority list. Defined in `include/extractor/road_classification.hpp`
|
|
||||||
road_classification.may_be_ignored | Boolean | Guidance: way is non-highway
|
|
||||||
road_classification.num_lanes | Unsigned | Guidance: total number of lanes in way
|
|
||||||
|
|
||||||
### process_segment(profile, segment)
|
|
||||||
The `process_segment` function is called for every segment of OSM ways. A segment is a straight line between two OSM nodes.
|
|
||||||
|
|
||||||
On OpenStreetMap way cannot have different tags on different parts of a way. Instead you would split the way into several smaller ways. However many ways are long. For example, many ways pass hills without any change in tags.
|
|
||||||
|
|
||||||
Processing each segment of an OSM way makes it possible to have different speeds on different parts of a way based on external data like data about elevation, pollution, noise or scenic value and adjust weight and duration of the segment accordingly.
|
|
||||||
|
|
||||||
In the `process_segment` function you don't have access to OSM tags. Instead you use the geographical location of the start and end point of the way to look up information from another data source, like elevation data. See [rasterbot.lua](../profiles/rasterbot.lua) for an example.
|
|
||||||
|
|
||||||
The following attributes can be read and set on the result in `process_segment`:
|
|
||||||
|
|
||||||
Attribute | Read/write? | Type | Notes
|
|
||||||
-------------------|-------------|---------|----------------------------------------
|
|
||||||
source.lon | Read | Float | Co-ordinates of segment start
|
|
||||||
source.lat | Read | Float | ""
|
|
||||||
target.lon | Read | Float | Co-ordinates of segment end
|
|
||||||
target.lat | Read | Float | ""
|
|
||||||
distance | Read | Float | Length of segment
|
|
||||||
weight | Read/write | Float | Routing weight for this segment
|
|
||||||
duration | Read/write | Float | Duration for this segment
|
|
||||||
|
|
||||||
### process_turn(profile, turn)
|
|
||||||
The `process_turn` function is called for every possible turn in the network. Based on the angle and type of turn you assign the weight and duration of the movement.
|
|
||||||
|
|
||||||
The following attributes can be read and set on the result in `process_turn`:
|
|
||||||
|
|
||||||
Attribute | Read/write? | Type | Notes
|
|
||||||
--------------------- | ------------- | --------- | ------------------------------------------------------
|
|
||||||
angle | Read | Float | Angle of turn in degrees (`[-179, 180]`: `0`=straight, `180`=u turn, `+x`=x degrees to the right, `-x`= x degrees to the left)
|
|
||||||
number_of_roads | Read | Integer | Number of ways at the intersection of the turn
|
|
||||||
is_u_turn | Read | Boolean | Is the turn a u-turn?
|
|
||||||
has_traffic_light | Read | Boolean | Is a traffic light present at this turn?
|
|
||||||
is_left_hand_driving | Read | Boolean | Is left-hand traffic?
|
|
||||||
source_restricted | Read | Boolean | Is it from a restricted access road? (See definition in `process_way`)
|
|
||||||
source_mode | Read | Enum | Travel mode before the turn. Defined in `include/extractor/travel_mode.hpp`
|
|
||||||
source_is_motorway | Read | Boolean | Is the source road a motorway?
|
|
||||||
source_is_link | Read | Boolean | Is the source road a link?
|
|
||||||
source_number_of_lanes | Read | Integer | How many lanes does the source road have? (default when not tagged: 0)
|
|
||||||
source_highway_turn_classification | Read | Integer | Classification based on highway tag defined by user during setup. (default when not set: 0, allowed classification values are: 0-15))
|
|
||||||
source_access_turn_classification | Read | Integer | Classification based on access tag defined by user during setup. (default when not set: 0, allowed classification values are: 0-15))
|
|
||||||
source_speed | Read | Integer | Speed on this source road in km/h
|
|
||||||
source_priority_class | Read | Enum | The type of road priority class of the source. Defined in `include/extractor/road_classification.hpp`
|
|
||||||
target_restricted | Read | Boolean | Is the target a restricted access road? (See definition in `process_way`)
|
|
||||||
target_mode | Read | Enum | Travel mode after the turn. Defined in `include/extractor/travel_mode.hpp`
|
|
||||||
target_is_motorway | Read | Boolean | Is the target road a motorway?
|
|
||||||
target_is_link | Read | Boolean | Is the target road a link?
|
|
||||||
target_number_of_lanes | Read | Integer | How many lanes does the target road have? (default when not tagged: 0)
|
|
||||||
target_highway_turn_classification | Read | Integer | Classification based on highway tag defined by user during setup. (default when not set: 0, allowed classification values are: 0-15))
|
|
||||||
target_access_turn_classification | Read | Integer | Classification based on access tag defined by user during setup. (default when not set: 0, allowed classification values are: 0-15))
|
|
||||||
target_speed | Read | Integer | Speed on this target road in km/h
|
|
||||||
target_priority_class | Read | Enum | The type of road priority class of the target. Defined in `include/extractor/road_classification.hpp`
|
|
||||||
roads_on_the_right | Read | Vector<ExtractionTurnLeg> | Vector with information about other roads on the right of the turn that are also connected at the intersection
|
|
||||||
roads_on_the_left | Read | Vector<ExtractionTurnLeg> | Vector with information about other roads on the left of the turn that are also connected at the intersection. If turn is a u turn, this is empty.
|
|
||||||
weight | Read/write | Float | Penalty to be applied for this turn (routing weight)
|
|
||||||
duration | Read/write | Float | Penalty to be applied for this turn (duration in deciseconds)
|
|
||||||
|
|
||||||
#### `roads_on_the_right` and `roads_on_the_left`
|
|
||||||
|
|
||||||
The information of `roads_on_the_right` and `roads_on_the_left` that can be read are as follows:
|
|
||||||
|
|
||||||
Attribute | Read/write? | Type | Notes
|
|
||||||
--------------------- | ------------- | --------- | ------------------------------------------------------
|
|
||||||
is_restricted | Read | Boolean | Is it a restricted access road? (See definition in `process_way`)
|
|
||||||
mode | Read | Enum | Travel mode before the turn. Defined in `include/extractor/travel_mode.hpp`
|
|
||||||
is_motorway | Read | Boolean | Is the road a motorway?
|
|
||||||
is_link | Read | Boolean | Is the road a link?
|
|
||||||
number_of_lanes | Read | Integer | How many lanes does the road have? (default when not tagged: 0)
|
|
||||||
highway_turn_classification | Read | Integer | Classification based on highway tag defined by user during setup. (default when not set: 0, allowed classification values are: 0-15)
|
|
||||||
access_turn_classification | Read | Integer | Classification based on access tag defined by user during setup. (default when not set: 0, allowed classification values are: 0-15)
|
|
||||||
speed | Read | Integer | Speed on this road in km/h
|
|
||||||
priority_class | Read | Enum | The type of road priority class of the leg. Defined in `include/extractor/road_classification.hpp`
|
|
||||||
is_incoming | Read | Boolean | Is the road an incoming road of the intersection
|
|
||||||
is_outgoing | Read | Boolean | Is the road an outgoing road of the intersection
|
|
||||||
|
|
||||||
The order of the roads in `roads_on_the_right` and `roads_on_the_left` are *counter clockwise*. If the turn is a u turn, all other connected roads will be in `roads_on_the_right`.
|
|
||||||
|
|
||||||
**Example**
|
|
||||||
|
|
||||||
```
|
|
||||||
c e
|
|
||||||
| /
|
|
||||||
| /
|
|
||||||
a ---- x ---- b
|
|
||||||
/|
|
|
||||||
/ |
|
|
||||||
f d
|
|
||||||
|
|
||||||
|
|
||||||
```
|
|
||||||
When turning from `a` to `b` via `x`,
|
|
||||||
* `roads_on_the_right[1]` is the road `xf`
|
|
||||||
* `roads_on_the_right[2]` is the road `xd`
|
|
||||||
* `roads_on_the_left[1]` is the road `xe`
|
|
||||||
* `roads_on_the_left[2]` is the road `xc`
|
|
||||||
|
|
||||||
Note that indices of arrays in lua are 1-based.
|
|
||||||
|
|
||||||
#### `highway_turn_classification` and `access_turn_classification`
|
|
||||||
When setting appropriate turn weights and duration, information about the highway and access tags of roads that are involved in the turn are necessary. The lua turn function `process_turn` does not have access to the original osrm tags anymore. However, `highway_turn_classification` and `access_turn_classification` can be set during setup. The classification set during setup can be later used in `process_turn`.
|
|
||||||
|
|
||||||
**Example**
|
|
||||||
|
|
||||||
In the following example we use `highway_turn_classification` to set the turn weight to `10` if the turn is on a highway and to `5` if the turn is on a primary.
|
|
||||||
|
|
||||||
```
|
|
||||||
function setup()
|
|
||||||
return {
|
|
||||||
highway_turn_classification = {
|
|
||||||
['motorway'] = 2,
|
|
||||||
['primary'] = 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
function process_turn(profile, turn) {
|
|
||||||
if turn.source_highway_turn_classification == 2 and turn.target_highway_turn_classification == 2 then
|
|
||||||
turn.weight = 10
|
|
||||||
end
|
|
||||||
if turn.source_highway_turn_classification == 1 and turn.target_highway_turn_classification == 1 then
|
|
||||||
turn.weight = 5
|
|
||||||
end
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Guidance
|
|
||||||
The guidance parameters in profiles are currently a work in progress. They can and will change.
|
|
||||||
Please be aware of this when using guidance configuration possibilities.
|
|
||||||
|
|
||||||
Guidance uses road classes to decide on when/if to emit specific instructions and to discover which road is obvious when following a route.
|
|
||||||
Classification uses three flags and a priority-category.
|
|
||||||
The flags indicate whether a road is a motorway (required for on/off ramps), a link type (the ramps itself, if also a motorway) and whether a road may be omitted in considerations (is considered purely for connectivity).
|
|
||||||
The priority-category influences the decision which road is considered the obvious choice and which roads can be seen as fork.
|
|
||||||
Forks can be emitted between roads of similar priority category only. Obvious choices follow a major priority road, if the priority difference is large.
|
|
||||||
|
|
||||||
### Using raster data
|
|
||||||
OSRM has built-in support for loading an interpolating raster data in ASCII format. This can be used e.g. for factoring in elevation when computing routes.
|
|
||||||
|
|
||||||
Use `raster:load()` in your `setup` function to load data and store the source in your configuration hash:
|
|
||||||
|
|
||||||
```lua
|
|
||||||
function setup()
|
|
||||||
return {
|
|
||||||
raster_source = raster:load(
|
|
||||||
"rastersource.asc", -- file to load
|
|
||||||
0, -- longitude min
|
|
||||||
0.1, -- longitude max
|
|
||||||
0, -- latitude min
|
|
||||||
0.1, -- latitude max
|
|
||||||
5, -- number of rows
|
|
||||||
4 -- number of columns
|
|
||||||
)
|
|
||||||
}
|
|
||||||
end
|
|
||||||
```
|
|
||||||
|
|
||||||
The input data must an ASCII file with rows of integers. e.g.:
|
|
||||||
|
|
||||||
```
|
|
||||||
0 0 0 0
|
|
||||||
0 0 0 250
|
|
||||||
0 0 250 500
|
|
||||||
0 0 0 250
|
|
||||||
0 0 0 0
|
|
||||||
```
|
|
||||||
|
|
||||||
In your `segment_function` you can then access the raster source and use `raster:query()` to query to find the nearest data point, or `raster:interpolate()` to interpolate a value based on nearby data points.
|
|
||||||
|
|
||||||
You must check whether the result is valid before using it.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
```lua
|
|
||||||
function process_segment (profile, segment)
|
|
||||||
local sourceData = raster:query(profile.raster_source, segment.source.lon, segment.source.lat)
|
|
||||||
local targetData = raster:query(profile.raster_source, segment.target.lon, segment.target.lat)
|
|
||||||
|
|
||||||
local invalid = sourceData.invalid_data()
|
|
||||||
if sourceData.datum ~= invalid and targetData.datum ~= invalid then
|
|
||||||
-- use values to adjust weight and duration
|
|
||||||
[...]
|
|
||||||
end
|
|
||||||
```
|
|
||||||
|
|
||||||
See [rasterbot.lua](../profiles/rasterbot.lua) and [rasterbotinterp.lua](../profiles/rasterbotinterp.lua) for examples.
|
|
||||||
|
|
||||||
### Helper functions
|
|
||||||
There are a few helper functions defined in the global scope that profiles can use:
|
|
||||||
|
|
||||||
- `durationIsValid`
|
|
||||||
- `parseDuration`
|
|
||||||
- `trimLaneString`
|
|
||||||
- `applyAccessTokens`
|
|
||||||
- `canonicalizeStringList`
|
|