diff --git a/CONTRIBUTE.md b/CONTRIBUTE.md index 2b98f94581..ac6b90914d 100644 --- a/CONTRIBUTE.md +++ b/CONTRIBUTE.md @@ -10,7 +10,7 @@ -**Firstly, thanks for using the ORS and contributing to making it better for everyone.** +**Firstly, thanks for using openrouteservice and contributing to making it better for everyone.** Openrouteservice has been around for over ten years, and as such it has seen many changes and adoption of new methodologies and techniques, as well as the coming and going of multiple developers. diff --git a/README.md b/README.md index ba2262b9be..71ea909627 100644 --- a/README.md +++ b/README.md @@ -115,4 +115,4 @@ For questions please use our [community forum](https://ask.openrouteservice.org) ## Translations -If you notice anything wrong with translations, or you want to add a new language to the ORS instructions, we have some instructions in our [backend documentation](https://GIScience.github.io/openrouteservice/contributing/contributing-translations) about how you can submit an update. You can also look over at our [maps client GitHub](https://github.com/GIScience/ors-map-client/#add-language) if you want to contribute the language to there as well (adding or editing the language in the openrouteservice GitHub repo only affects the instructions - any new language also needs adding to the client). +If you notice anything wrong with translations, or you want to add a new language to the openrouteservice instructions, we have some instructions in our [backend documentation](https://GIScience.github.io/openrouteservice/contributing/contributing-translations) about how you can submit an update. You can also look over at our [maps client GitHub](https://github.com/GIScience/ors-map-client/#add-language) if you want to contribute the language to there as well (adding or editing the language in the openrouteservice GitHub repo only affects the instructions - any new language also needs adding to the client). diff --git a/docs/.vitepress/config.js b/docs/.vitepress/config.js index bf0909690f..c9ca0ac805 100644 --- a/docs/.vitepress/config.js +++ b/docs/.vitepress/config.js @@ -33,14 +33,14 @@ export default withMermaid(defineVersionedConfig({ }, search: { provider: 'local', - options: { - _render(src, env, md) { - const html = md.render(src, env) - if (env.frontmatter?.search === false) return '' - if (env.relativePath.startsWith('versions')) return '' - return html - } - } + options: { + _render(src, env, md) { + const html = md.render(src, env) + if (env.frontmatter?.search === false) return '' + if (env.relativePath.startsWith('versions')) return '' + return html + } + } }, outline: { level: [2, 4] @@ -62,190 +62,252 @@ export default withMermaid(defineVersionedConfig({ {text: 'Forum', link: 'https://ask.openrouteservice.org'}, {component: 'VersionSwitcher'} ], - // undocumented options for NotFound-Page - notFound: { - title: 'PAGE NOT FOUND', - quote: 'We recently introduced versioning for our documentation. You probably ended up here by changing the version - and this page doesn\'t exist in this version. Click the link below and check "Getting Started" - you will need to change the version again, though.', - linkText: 'Documentation Home - latest Version', - }, + // undocumented options for NotFound-Page + notFound: { + title: 'PAGE NOT FOUND', + quote: 'We recently introduced versioning for our documentation. You probably ended up here by changing the version - and this page doesn\'t exist in this version. Click the link below and check "Getting Started" - you will need to change the version again, though.', + linkText: 'Documentation Home - latest Version', + }, sidebar: { - '/': [ - { - text: 'Home - v9.0.0', link: '/', - items: [ - {text: 'Getting Started', link: '/getting-started'}, - { - text: 'API Reference', collapsed: true, link: '/api-reference/', - items: [ - { - text: 'Endpoints', collapsed: true, link: '/api-reference/endpoints/', - items: [ - { - text: 'Directions', collapsed: true, link: '/api-reference/endpoints/directions/', - items: [ - {text: 'Requests and Return Types', link: '/api-reference/endpoints/directions/requests-and-return-types'}, - {text: 'Routing Options', link: '/api-reference/endpoints/directions/routing-options'}, - { - text: 'Extra info', collapsed: true, link: '/api-reference/endpoints/directions/extra-info/', - items: [ - {text: 'Steepness IDs', link: '/api-reference/endpoints/directions/extra-info/steepness'}, - {text: 'Surface IDs', link: '/api-reference/endpoints/directions/extra-info/surface'}, - {text: 'Category IDs', link: '/api-reference/endpoints/directions/extra-info/waycategory'}, - {text: 'Type IDs', link: '/api-reference/endpoints/directions/extra-info/waytype'}, - {text: 'Difficulty IDs', link: '/api-reference/endpoints/directions/extra-info/trail-difficulty'}, - {text: 'Restriction IDs', link: '/api-reference/endpoints/directions/extra-info/road-access-restrictions'}, - {text: 'Country IDs', link: '/technical-details/country-list'}, - ] - }, - {text: 'Route Attributes', link: '/api-reference/endpoints/directions/route-attributes'}, - {text: 'Geometry Decoding', link: '/api-reference/endpoints/directions/geometry-decoding'}, - {text: 'Instruction Types', link: '/api-reference/endpoints/directions/instruction-types'}, - ] - }, - {text: 'Isochrones', link: '/api-reference/endpoints/isochrones/'}, - {text: 'Matrix', link: '/api-reference/endpoints/matrix/'}, - {text: 'Snapping', link: '/api-reference/endpoints/snapping/'}, - {text: 'Export (not live)', link: '/api-reference/endpoints/export/'}, - {text: 'Health (not live)', link: '/api-reference/endpoints/health/'}, - {text: 'Status (not live)', link: '/api-reference/endpoints/status/'}, - {text: 'POI', link: '/api-reference/endpoints/poi/'}, - {text: 'Elevation', link: '/api-reference/endpoints/elevation/'}, - {text: 'Geocoder', link: '/api-reference/endpoints/geocoder/'}, - {text: 'Optimization', link: '/api-reference/endpoints/optimization/'}, - ] - }, - {text: 'Error Codes', link: '/api-reference/error-codes'}, - ] - }, - { - text: 'Run ORS instance', collapsed: true, link: '/run-instance/', - items: [ - {text: 'System Requirements', link: '/run-instance/system-requirements'}, - {text: 'Data', link: '/run-instance/data'}, - {text: 'Running with Docker', link: '/run-instance/running-with-docker'}, - {text: 'Running JAR', link: '/run-instance/running-jar'}, - {text: 'Running WAR', link: '/run-instance/running-war'}, - {text: 'Building from Source', link: '/run-instance/building-from-source'}, - { - text: 'Configuration', collapsed: true, link: '/run-instance/configuration/', - items: [ - { - text: 'How to configure', - link: '/run-instance/configuration/how-to-configure.md' - }, - { - text: 'What to configure', - link: '/run-instance/configuration/what-to-configure.md' - }, - {text: 'server', link: '/run-instance/configuration/server.md'}, - {text: 'logging', link: '/run-instance/configuration/logging.md'}, - { - text: 'ors.endpoints', - link: '/run-instance/configuration/endpoints/', - collapsed: true, - items: [ - { - text: 'defaults', - link: '/run-instance/configuration/endpoints/defaults.md' - }, - {text: 'routing', link: '/run-instance/configuration/endpoints/routing.md'}, - {text: 'matrix', link: '/run-instance/configuration/endpoints/matrix.md'}, - { - text: 'isochrones', - link: '/run-instance/configuration/endpoints/isochrones.md' - }, - {text: 'snap', link: '/run-instance/configuration/endpoints/snap.md'}, - ] - }, - { - text: 'ors.engine', - link: '/run-instance/configuration/engine/', - collapsed: true, - items: [ - { - text: 'graph_management', - link: '/run-instance/configuration/engine/graph-management.md' - }, - { - text: 'elevation', - link: '/run-instance/configuration/engine/elevation.md' - }, - { - text: 'profiles', - link: '/run-instance/configuration/engine/profiles/', - collapsed: true, - items: [ - { - text: 'build', - link: '/run-instance/configuration/engine/profiles/build.md' - }, - { - text: 'repo', - link: '/run-instance/configuration/engine/profiles/repo.md' - }, - { - text: 'service', - link: '/run-instance/configuration/engine/profiles/service.md' - }, - ] - }, - ] - }, - {text: 'ors.cors', link: '/run-instance/configuration/cors/'}, - {text: 'ors.messages', link: '/run-instance/configuration/messages/'}, - {text: 'JSON config (deprecated)', link:'/run-instance/configuration/json.md'} - ] - }, - { - text: 'Example Setups', collapsed: true, link: '/run-instance/example-setups', - items: [{text: 'Tomcat 10 - Ubuntu 22.04', link: '/run-instance/example-setups/en_tomcat-10-ubuntu_22_04'}] - }, - ] - }, - { - text: 'Contributing', collapsed: true, link: '/contributing/', - items: [ - {text: 'Backend documentation', link: '/contributing/backend-documentation'}, - {text: 'Contribution guidelines', link: 'https://github.com/GIScience/openrouteservice/blob/main/CONTRIBUTE.md'}, - {text: 'Contributing translations', link: '/contributing/contributing-translations'}, - ] - }, - { - text: 'Technical details', collapsed: true, link: '/technical-details/', - items: [ - {text: 'Country List', link: '/technical-details/country-list'}, - {text: 'Travel Speeds', link: '/technical-details/travel-speeds/', - items: [ - {text: 'Country Speeds', link: '/technical-details/travel-speeds/country-speeds.md'}, - {text: 'Tracktype Speeds', link: '/technical-details/travel-speeds/tracktype-speeds.md'}, - {text: 'Waytype Speeds', link: '/technical-details/travel-speeds/waytype-speeds.md'}, - {text: 'Surface Speeds', link: '/technical-details/travel-speeds/surface-speeds.md'}, - ] - }, - {text: 'Tag Filtering', link: '/technical-details/tag-filtering'}, - {text: 'Graph Management', link: '/technical-details/graph-repo-client/'}, - {text: 'Integration Tests', link: '/technical-details/integration-tests'}, - ] - }, - {text: 'FAQ', link: '/frequently-asked-questions'} - ] + '/': [ + { + text: 'Home - v9.0.0', link: '/', + items: [ + {text: 'Getting Started', link: '/getting-started'}, + { + text: 'API Reference', collapsed: true, link: '/api-reference/', + items: [ + { + text: 'Endpoints', collapsed: true, link: '/api-reference/endpoints/', + items: [ + { + text: 'Directions', + collapsed: true, + link: '/api-reference/endpoints/directions/', + items: [ + { + text: 'Requests and Return Types', + link: '/api-reference/endpoints/directions/requests-and-return-types' + }, + { + text: 'Routing Options', + link: '/api-reference/endpoints/directions/routing-options' + }, + { + text: 'Extra info', + collapsed: true, + link: '/api-reference/endpoints/directions/extra-info/', + items: [ + { + text: 'Steepness IDs', + link: '/api-reference/endpoints/directions/extra-info/steepness' + }, + { + text: 'Surface IDs', + link: '/api-reference/endpoints/directions/extra-info/surface' + }, + { + text: 'Category IDs', + link: '/api-reference/endpoints/directions/extra-info/waycategory' + }, + { + text: 'Type IDs', + link: '/api-reference/endpoints/directions/extra-info/waytype' + }, + { + text: 'Difficulty IDs', + link: '/api-reference/endpoints/directions/extra-info/trail-difficulty' + }, + { + text: 'Restriction IDs', + link: '/api-reference/endpoints/directions/extra-info/road-access-restrictions' + }, + {text: 'Country IDs', link: '/technical-details/country-list'}, + ] + }, + { + text: 'Route Attributes', + link: '/api-reference/endpoints/directions/route-attributes' + }, + { + text: 'Geometry Decoding', + link: '/api-reference/endpoints/directions/geometry-decoding' + }, + { + text: 'Instruction Types', + link: '/api-reference/endpoints/directions/instruction-types' + }, + ] + }, + {text: 'Isochrones', link: '/api-reference/endpoints/isochrones/'}, + {text: 'Matrix', link: '/api-reference/endpoints/matrix/'}, + {text: 'Snapping', link: '/api-reference/endpoints/snapping/'}, + {text: 'Export (not live)', link: '/api-reference/endpoints/export/'}, + {text: 'Health (not live)', link: '/api-reference/endpoints/health/'}, + {text: 'Status (not live)', link: '/api-reference/endpoints/status/'}, + {text: 'POI', link: '/api-reference/endpoints/poi/'}, + {text: 'Elevation', link: '/api-reference/endpoints/elevation/'}, + {text: 'Geocoder', link: '/api-reference/endpoints/geocoder/'}, + {text: 'Optimization', link: '/api-reference/endpoints/optimization/'}, + ] + }, + {text: 'Error Codes', link: '/api-reference/error-codes'}, + ] + }, + { + text: 'Run ORS instance', collapsed: true, link: '/run-instance/', + items: [ + {text: 'System Requirements', link: '/run-instance/system-requirements'}, + {text: 'Data', link: '/run-instance/data'}, + {text: 'Running with Docker', link: '/run-instance/running-with-docker'}, + {text: 'Running JAR', link: '/run-instance/running-jar'}, + {text: 'Running WAR', link: '/run-instance/running-war'}, + {text: 'Building from Source', link: '/run-instance/building-from-source'}, + { + text: 'Configuration', collapsed: true, link: '/run-instance/configuration/', + items: [ + { + text: 'How to configure', + link: '/run-instance/configuration/how-to-configure.md' + }, + { + text: 'What to configure', + link: '/run-instance/configuration/what-to-configure.md' + }, + {text: 'server', link: '/run-instance/configuration/server.md'}, + {text: 'logging', link: '/run-instance/configuration/logging.md'}, + { + text: 'ors.endpoints', + link: '/run-instance/configuration/endpoints/', + collapsed: true, + items: [ + { + text: 'defaults', + link: '/run-instance/configuration/endpoints/defaults.md' + }, + { + text: 'routing', + link: '/run-instance/configuration/endpoints/routing.md' + }, + { + text: 'matrix', + link: '/run-instance/configuration/endpoints/matrix.md' + }, + { + text: 'isochrones', + link: '/run-instance/configuration/endpoints/isochrones.md' + }, + {text: 'snap', link: '/run-instance/configuration/endpoints/snap.md'}, + ] + }, + { + text: 'ors.engine', + link: '/run-instance/configuration/engine/', + collapsed: true, + items: [ + { + text: 'graph_management', + link: '/run-instance/configuration/engine/graph-management.md' + }, + { + text: 'elevation', + link: '/run-instance/configuration/engine/elevation.md' + }, + { + text: 'profiles', + link: '/run-instance/configuration/engine/profiles/', + collapsed: true, + items: [ + { + text: 'build', + link: '/run-instance/configuration/engine/profiles/build.md' + }, + { + text: 'repo', + link: '/run-instance/configuration/engine/profiles/repo.md' + }, + { + text: 'service', + link: '/run-instance/configuration/engine/profiles/service.md' + }, + ] + }, + ] + }, + {text: 'ors.cors', link: '/run-instance/configuration/cors/'}, + {text: 'ors.messages', link: '/run-instance/configuration/messages/'}, + {text: 'JSON config (deprecated)', link: '/run-instance/configuration/json.md'} + ] + }, + { + text: 'Example Setups', collapsed: true, link: '/run-instance/example-setups', + items: [{ + text: 'Tomcat 10 - Ubuntu 22.04', + link: '/run-instance/example-setups/en_tomcat-10-ubuntu_22_04' + }] + }, + ] + }, + { + text: 'Contributing', collapsed: true, link: '/contributing/', + items: [ + {text: 'Backend documentation', link: '/contributing/backend-documentation'}, + { + text: 'Contribution guidelines', + link: 'https://github.com/GIScience/openrouteservice/blob/main/CONTRIBUTE.md' + }, + {text: 'Contributing translations', link: '/contributing/contributing-translations'}, + ] + }, + { + text: 'Technical details', collapsed: true, link: '/technical-details/', + items: [ + {text: 'Country List', link: '/technical-details/country-list'}, + { + text: 'Travel Speeds', link: '/technical-details/travel-speeds/', + items: [ + { + text: 'Country Speeds', + link: '/technical-details/travel-speeds/country-speeds.md' + }, + { + text: 'Tracktype Speeds', + link: '/technical-details/travel-speeds/tracktype-speeds.md' + }, + { + text: 'Waytype Speeds', + link: '/technical-details/travel-speeds/waytype-speeds.md' + }, + { + text: 'Surface Speeds', + link: '/technical-details/travel-speeds/surface-speeds.md' + }, + ] + }, + {text: 'Tag Filtering', link: '/technical-details/tag-filtering'}, + {text: 'Graph Management', link: '/technical-details/graph-repo-client/'}, + {text: 'Integration Tests', link: '/technical-details/integration-tests'}, + ] + }, + {text: 'FAQ', link: '/frequently-asked-questions'} + ] + } + ], + socialLinks: [ + {icon: 'github', link: 'https://github.com/GIScience/openrouteservice'} + ], + footer: { + message: 'openrouteservice is part of HeiGIT gGmbH and Universität Heidelberg GIScience research group. | Imprint' } - ], - socialLinks: [ - {icon: 'github', link: 'https://github.com/GIScience/openrouteservice'} - ], - footer: { - message: 'openrouteservice is part of HeiGIT gGmbH and Universität Heidelberg GIScience research group. | Imprint' } - } }, - locales: { - root: { - label: 'English', - lang: 'en' - } - }, + locales: { + root: { + label: 'English', + lang: 'en' + } + }, versioning: { latestVersion: "v9.0.0 (latest)", @@ -256,4 +318,4 @@ export default withMermaid(defineVersionedConfig({ }, }, -}, __dirname )) +}, __dirname)) diff --git a/docs/.vitepress/theme/index.ts b/docs/.vitepress/theme/index.ts index 5941a46dcf..1b08798b7e 100644 --- a/docs/.vitepress/theme/index.ts +++ b/docs/.vitepress/theme/index.ts @@ -1,11 +1,18 @@ import DefaultTheme from 'vitepress/theme-without-fonts' import './custom.css' -import { Theme } from 'vitepress'; +import { Theme, useData, useRoute } from 'vitepress'; import VersionSwitcher from "../components/VersionSwitcher.vue"; +import codeblocksFold from 'vitepress-plugin-codeblocks-fold'; // import method +import 'vitepress-plugin-codeblocks-fold/style/index.css'; // import style export default { extends: DefaultTheme, enhanceApp({ app }) { app.component('VersionSwitcher', VersionSwitcher) + }, + setup() { + const { frontmatter } = useData(); + const route = useRoute(); + codeblocksFold({ route, frontmatter }, false, 200); } } satisfies Theme; \ No newline at end of file diff --git a/docs/api-reference/endpoints/elevation/index.md b/docs/api-reference/endpoints/elevation/index.md index eac522cfef..0adcff2673 100644 --- a/docs/api-reference/endpoints/elevation/index.md +++ b/docs/api-reference/endpoints/elevation/index.md @@ -1,11 +1,11 @@ # Elevation Service :::warning NOTE -This endpoint is not part of the openrouteservice, but of our public API. It is not available when running an own instance of openrouteservice. +This endpoint is not part of openrouteservice, but of our public API. It is not available when running an own instance of openrouteservice. ::: The elevation service is a Flask application which extracts elevation from various elevation datasets for Point or LineString 2D geometries and returns 3D geometries in various formats. -Just like the openrouteservice, the elevation service is also accessible via our public API. +Just like openrouteservice, the elevation service is also accessible via our public API. Details on how to use it can be found in our [API Playground](https://openrouteservice.org/dev/#/api-docs/elevation). diff --git a/docs/api-reference/endpoints/export/index.md b/docs/api-reference/endpoints/export/index.md index 29e6c9186c..f17d012cfe 100644 --- a/docs/api-reference/endpoints/export/index.md +++ b/docs/api-reference/endpoints/export/index.md @@ -1,3 +1,7 @@ +--- +cbf: [2,4,5] +--- + # Export Endpoint :::warning NOTE @@ -8,14 +12,249 @@ You can easily create requests with the [swagger-ui](/api-reference/index.md#swa Export the base graph for different modes of transport. -In the request, the desired routing profile is specified as the last path parameter, -a bounding box for the area of interest has to be defined in the request body. +In the request, the desired routing profile is specified as the penultimate path parameter, and the desired format as +the last path parameter. A bounding box for the area of interest has to be defined in the request body. + +The result can be either obtained as a JSON of nodes and edges, or as +a [TopoJSON](https://github.com/topojson/topojson-specification/tree/master) of edges also capable of representing the +actual geometries of the edges derived from OSM data. + +To make the differences between the two formats more clear, the example responses listed below are based on the same +network extract. + +## JSON Response + +This is an example request for a base graph for the profile `driving-car`: + +```shell +curl -X 'POST' \ + 'http://localhost:8082/ors/v2/export/driving-car/json' \ + -H 'accept: application/json' \ + -H 'Content-Type: application/json' \ + -d '{ + "bbox": [ + [ + 8.681495, + 49.41461 + ], + [ + 8.686507, + 49.41943 + ] + ] +}' +``` + +The json response contains nodes and edges in the bounding box relevant for this routing profile. +The edge entry `weight` contains the fastest car duration in seconds. + +The json response for the above request looks like this: + +```json +{ + "nodes": [ + { + "nodeId": 1168, + "location": [ + 8.686742, + 49.427883 + ] + }, + { + "nodeId": 1169, + "location": [ + 8.687107, + 49.427982 + ] + }, + { + "nodeId": 1378, + "location": [ + 8.685439, + 49.427668 + ] + }, + { + "nodeId": 1381, + "location": [ + 8.687425, + 49.428074 + ] + }, + { + "nodeId": 2134, + "location": [ + 8.685844, + 49.427873 + ] + }, + { + "nodeId": 2135, + "location": [ + 8.686699, + 49.427997 + ] + }, + { + "nodeId": 1162, + "location": [ + 8.68758, + 49.428213 + ] + }, + { + "nodeId": 1165, + "location": [ + 8.685955, + 49.428631 + ] + }, + { + "nodeId": 1166, + "location": [ + 8.685896, + 49.42772 + ] + }, + { + "nodeId": 1167, + "location": [ + 8.686352, + 49.427783 + ] + } + ], + "edges": [ + { + "fromId": 1168, + "toId": 1169, + "weight": "6.872" + }, + { + "fromId": 1169, + "toId": 1168, + "weight": "6.872" + }, + { + "fromId": 2134, + "toId": 2135, + "weight": "15.234" + }, + { + "fromId": 2135, + "toId": 2134, + "weight": "15.234" + }, + { + "fromId": 1166, + "toId": 1167, + "weight": "8.1" + }, + { + "fromId": 1167, + "toId": 1166, + "weight": "8.1" + }, + { + "fromId": 1168, + "toId": 2135, + "weight": "3.15" + }, + { + "fromId": 2135, + "toId": 1168, + "weight": "3.15" + }, + { + "fromId": 1378, + "toId": 1166, + "weight": "8.07" + }, + { + "fromId": 1166, + "toId": 1378, + "weight": "8.07" + }, + { + "fromId": 1381, + "toId": 1162, + "weight": "4.759" + }, + { + "fromId": 1162, + "toId": 1381, + "weight": "4.759" + }, + { + "fromId": 1169, + "toId": 1381, + "weight": "6.042" + }, + { + "fromId": 1381, + "toId": 1169, + "weight": "6.042" + }, + { + "fromId": 2134, + "toId": 1166, + "weight": "4.191" + }, + { + "fromId": 1166, + "toId": 2134, + "weight": "4.191" + }, + { + "fromId": 2135, + "toId": 1165, + "weight": "23.852" + }, + { + "fromId": 1165, + "toId": 2134, + "weight": "22.137" + }, + { + "fromId": 1168, + "toId": 1167, + "weight": "7.259" + }, + { + "fromId": 1167, + "toId": 1168, + "weight": "7.259" + } + ], + "nodes_count": 10, + "edges_count": 20 +} +``` + +Note how edges traversable in both directions are described as two edges with reversed `fromId` and `toId`. The example +network consists of 10 nodes, 18 edges that represent 9 connections between the nodes in both directions, and two edges +representing connections that are only traversable in one direction (one-way street). + +## TopoJSON Response + +The [TopoJSON](https://github.com/topojson/topojson-specification/tree/master) response contains edges in the bounding +box with the geometry of the underlying road network geometry. When requesting a TopoJSON, you can pass an additional +optional parameter `geometry` accepting a boolean value (default is `true`) that controls if the actual geometry of the +edges is returned or a beeline representation omitting all in between nodes. The TopoJSON format can be directly loaded +and visualized with various tools including [QGIS](https://qgis.org) or [geojson.io](http://geojson.io). + +![Development server usage](/public/topojson_qgis.png "Export result in QGIS"){ style="display: block; margin: 0 auto"} + +To fully utilise this feature, your instance of openrouteservice needs to be configured so that the +`OsmId` [external storage feature](/run-instance/configuration/engine/profiles/build#ext-storages) is enabled for the +profile. + +This is an example request for a TopoJSON graph for the profile `driving-car`: -This is an example requests for a base graph for the profile `driving-car`: ```shell curl -X 'POST' \ - 'http://localhost:8082/ors/v2/export/driving-car' \ - -H 'accept: application/geo+json' \ + 'http://localhost:8082/ors/v2/export/driving-car/topojson' \ + -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d '{ "bbox": [ @@ -28,432 +267,817 @@ curl -X 'POST' \ 49.41943 ] ], - "id": "export_request" + "geometry": "true" }' +``` + +### with OSM IDs + +In the TopoJSON response, each arc corresponds to an edge of the routing graph. If the openrouteservice profile that was +queried has stored the OSM IDs of the original map data (i.e. has the `OsmId` storage enabled in configuration), each +object in the `GeometryCollection` represents the set of edges that share the same ID and therefore the same properties: + +- `osm_id` references the OpenStreetMap id of the underlying road geometry. +- `both_directions` is a boolean specifying if the edge can be traversed in both directions. +- `speed` contains the speed the edge can be traversed at travelling in direction of the edge definition. +- `speed_reverse` contains the speed the edge can be reversed at travelling in the opposite direction (only present if + `both_directions` is true). +- `ors_ids` is a list of the ors edge ids. +- `ors_nodes` is a list of the touched ors node ids. +- `distances` contains a list of distances for each edge. + +```json +{ + "type": "Topology", + "objects": { + "network": { + "type": "GeometryCollection", + "geometries": [ + { + "type": "LineString", + "properties": { + "osm_id": 24837547, + "both_directions": true, + "speed": 15.0, + "speed_reverse": 15.0, + "ors_ids": [ + 1498 + ], + "ors_nodes": [ + 2135, + 2134 + ], + "distances": [ + 63.476 + ] + }, + "arcs": [ + 0 + ] + }, + { + "type": "LineString", + "properties": { + "osm_id": 42806217, + "both_directions": true, + "speed": 15.0, + "speed_reverse": 15.0, + "ors_ids": [ + 8017, + 8018, + 8019 + ], + "ors_nodes": [ + 1168, + 1169, + 1381, + 1162 + ], + "distances": [ + 28.632, + 25.173, + 19.828 + ] + }, + "arcs": [ + 1, + 2, + 3 + ] + }, + { + "type": "LineString", + "properties": { + "osm_id": 42806216, + "both_directions": true, + "speed": 15.0, + "speed_reverse": 15.0, + "ors_ids": [ + 8016 + ], + "ors_nodes": [ + 1166, + 1167 + ], + "distances": [ + 33.748 + ] + }, + "arcs": [ + 4 + ] + }, + { + "type": "LineString", + "properties": { + "osm_id": 52956623, + "both_directions": true, + "speed": 15.0, + "speed_reverse": 15.0, + "ors_ids": [ + 8909 + ], + "ors_nodes": [ + 2134, + 1166 + ], + "distances": [ + 17.461 + ] + }, + "arcs": [ + 5 + ] + }, + { + "type": "LineString", + "properties": { + "osm_id": 24000937, + "both_directions": true, + "speed": 15.0, + "speed_reverse": 15.0, + "ors_ids": [ + 719 + ], + "ors_nodes": [ + 2135, + 1168 + ], + "distances": [ + 13.127 + ] + }, + "arcs": [ + 6 + ] + }, + { + "type": "LineString", + "properties": { + "osm_id": 42806218, + "both_directions": true, + "speed": 15.0, + "speed_reverse": 15.0, + "ors_ids": [ + 8020 + ], + "ors_nodes": [ + 1168, + 1167 + ], + "distances": [ + 30.247 + ] + }, + "arcs": [ + 7 + ] + }, + { + "type": "LineString", + "properties": { + "osm_id": 52956625, + "both_directions": false, + "speed": 15.0, + "ors_ids": [ + 8911 + ], + "ors_nodes": [ + 2135, + 1165 + ], + "distances": [ + 99.385 + ] + }, + "arcs": [ + 8 + ] + }, + { + "type": "LineString", + "properties": { + "osm_id": 305482793, + "both_directions": true, + "speed": 15.0, + "speed_reverse": 15.0, + "ors_ids": [ + 18296 + ], + "ors_nodes": [ + 1378, + 1166 + ], + "distances": [ + 33.626 + ] + }, + "arcs": [ + 9 + ] + }, + { + "type": "LineString", + "properties": { + "osm_id": 37831084, + "both_directions": false, + "speed": 15.0, + "ors_ids": [ + 7456 + ], + "ors_nodes": [ + 1165, + 2134 + ], + "distances": [ + 92.239 + ] + }, + "arcs": [ + 10 + ] + } + ] + } + }, + "arcs": [ + [ + [ + 8.686699, + 49.427997 + ], + [ + 8.686342, + 49.427932 + ], + [ + 8.685844, + 49.427873 + ] + ], + [ + [ + 8.686742, + 49.427883 + ], + [ + 8.687107, + 49.427982 + ] + ], + [ + [ + 8.687107, + 49.427982 + ], + [ + 8.687425, + 49.428074 + ] + ], + [ + [ + 8.687425, + 49.428074 + ], + [ + 8.687534, + 49.428133 + ], + [ + 8.68758, + 49.428213 + ] + ], + [ + [ + 8.685896, + 49.42772 + ], + [ + 8.686352, + 49.427783 + ] + ], + [ + [ + 8.685844, + 49.427873 + ], + [ + 8.685896, + 49.42772 + ] + ], + [ + [ + 8.686699, + 49.427997 + ], + [ + 8.686742, + 49.427883 + ] + ], + [ + [ + 8.686742, + 49.427883 + ], + [ + 8.686352, + 49.427783 + ] + ], + [ + [ + 8.686699, + 49.427997 + ], + [ + 8.686558, + 49.428345 + ], + [ + 8.686455, + 49.428512 + ], + [ + 8.686352, + 49.428567 + ], + [ + 8.686085, + 49.428622 + ], + [ + 8.685955, + 49.428631 + ] + ], + [ + [ + 8.685439, + 49.427668 + ], + [ + 8.685646, + 49.427682 + ], + [ + 8.685896, + 49.42772 + ] + ], + [ + [ + 8.685955, + 49.428631 + ], + [ + 8.685879, + 49.428609 + ], + [ + 8.685782, + 49.42854 + ], + [ + 8.685709, + 49.428405 + ], + [ + 8.685766, + 49.428125 + ], + [ + 8.685844, + 49.427873 + ] + ] + ], + "bbox": [ + 8.685439, + 49.427668, + 8.68758, + 49.428631 + ] +} ``` -The response contains nodes and edges in the bounding box relevant for this routing profile. -The edge entry `weight` contains the fastest car duration in seconds: +This dataset is the same network extract as in the JSON example. Note that two `LineString` elements are marked as +`"both_directions": false` and represent the one-way streets with one arc each, the remaining 9 arcs correspond to the 9 +pairs of edges in the JSON response. + +This format reduces information redundancy for edges and their respective geometry. The array `ors_ids` contains the +edge ids within openrouteservice. Note that in openrouteservice edges are always bidirectional, so the `ors_ids` array +contains the ids of the edges in both directions. + +### without OSM IDs + +If requesting the TopoJSON on a profile without `OsmId` storage, the response will contain geometries each consisting of +a +single arc, and have different set of properties: + +- `weight` represents travel duration in seconds. +- `node_from` is the ors node id of the edge start. +- `node_to` is the ors node id of the edge end. ```json { - "nodes": [ - { - "nodeId": 11008, - "location": [ - 8.682782, - 49.417388 - ] - }, - { - "nodeId": 11009, - "location": [ - 8.682461, - 49.417389 - ] - }, - { - "nodeId": 11010, - "location": [ - 8.681794, - 49.417637 - ] - }, - { - "nodeId": 1987, - "location": [ - 8.681674, - 49.416601 - ] - }, - { - "nodeId": 1988, - "location": [ - 8.681532, - 49.418291 - ] - }, - { - "nodeId": 1669, - "location": [ - 8.685746, - 49.415712 - ] - }, - { - "nodeId": 1221, - "location": [ - 8.685382, - 49.417368 - ] - }, - { - "nodeId": 15494, - "location": [ - 8.683159, - 49.419081 - ] - }, - { - "nodeId": 1672, - "location": [ - 8.686424, - 49.417375 - ] - }, - { - "nodeId": 3788, - "location": [ - 8.683666, - 49.414963 - ] - }, - { - "nodeId": 3789, - "location": [ - 8.685888, - 49.415001 - ] - }, - { - "nodeId": 3790, - "location": [ - 8.684803, - 49.414908 - ] - }, - { - "nodeId": 16273, - "location": [ - 8.681976, - 49.418537 - ] - }, - { - "nodeId": 16275, - "location": [ - 8.682777, - 49.417663 - ] - }, - { - "nodeId": 16276, - "location": [ - 8.682465, - 49.417623 - ] - }, - { - "nodeId": 16277, - "location": [ - 8.682592, - 49.417719 - ] - }, - { - "nodeId": 2072, - "location": [ - 8.683596, - 49.417386 - ] - }, - { - "nodeId": 216, - "location": [ - 8.686507, - 49.41943 - ] - }, - { - "nodeId": 219, - "location": [ - 8.681882, - 49.417391 - ] - }, - { - "nodeId": 12891, - "location": [ - 8.683295, - 49.418568 - ] - }, - { - "nodeId": 3360, - "location": [ - 8.68504, - 49.419273 - ] - }, - { - "nodeId": 3506, - "location": [ - 8.682577, - 49.415744 - ] - }, - { - "nodeId": 3507, - "location": [ - 8.683801, - 49.415725 - ] - }, - { - "nodeId": 3508, - "location": [ - 8.683767, - 49.416544 - ] - }, - { - "nodeId": 3510, - "location": [ - 8.68269, - 49.417389 - ] - }, - { - "nodeId": 3511, - "location": [ - 8.682661, - 49.416511 - ] - } - ], - "edges": [ - { - "fromId": 1669, - "toId": 1221, - "weight": 44.655840000000005 - }, - { - "fromId": 3506, - "toId": 3507, - "weight": 21.26352 - }, - { - "fromId": 3507, - "toId": 3506, - "weight": 21.26352 - }, - { - "fromId": 3510, - "toId": 3511, - "weight": 23.4336 - }, - { - "fromId": 3788, - "toId": 3790, - "weight": 19.99776 - }, - { - "fromId": 3790, - "toId": 3789, - "weight": 19.008000000000003 - }, - { - "fromId": 3508, - "toId": 3511, - "weight": 19.22184 - }, - { - "fromId": 3511, - "toId": 3506, - "weight": 20.515680000000003 - }, - { - "fromId": 11010, - "toId": 1988, - "weight": 18.03816 - }, - { - "fromId": 1988, - "toId": 11010, - "weight": 18.03816 - }, - { - "fromId": 3507, - "toId": 3508, - "weight": 21.87696 - }, - { - "fromId": 3508, - "toId": 3507, - "weight": 21.87696 - }, - { - "fromId": 3789, - "toId": 1669, - "weight": 19.117440000000002 - }, - { - "fromId": 1672, - "toId": 1221, - "weight": 18.080640000000002 - }, - { - "fromId": 1221, - "toId": 1672, - "weight": 18.080640000000002 - }, - { - "fromId": 11008, - "toId": 16275, - "weight": 7.34184 - }, - { - "fromId": 16275, - "toId": 11008, - "weight": 7.34184 - }, - { - "fromId": 11009, - "toId": 16276, - "weight": 9.339839999999999 - }, - { - "fromId": 16276, - "toId": 11009, - "weight": 9.339839999999999 - }, - { - "fromId": 11010, - "toId": 16277, - "weight": 14.45232 - }, - { - "fromId": 16277, - "toId": 11010, - "weight": 14.45232 - }, - { - "fromId": 1987, - "toId": 219, - "weight": 21.433200000000003 - }, - { - "fromId": 2072, - "toId": 11008, - "weight": 14.133600000000001 - }, - { - "fromId": 219, - "toId": 1987, - "weight": 21.433200000000003 - }, - { - "fromId": 11008, - "toId": 2072, - "weight": 14.133600000000001 - }, - { - "fromId": 219, - "toId": 11010, - "weight": 6.74016 - }, - { - "fromId": 11010, - "toId": 219, - "weight": 6.74016 - }, - { - "fromId": 219, - "toId": 11009, - "weight": 10.039919999999999 - }, - { - "fromId": 11009, - "toId": 219, - "weight": 10.039919999999999 - }, - { - "fromId": 1221, - "toId": 2072, - "weight": 31.017120000000002 - }, - { - "fromId": 2072, - "toId": 1221, - "weight": 31.017120000000002 - }, - { - "fromId": 12891, - "toId": 1988, - "weight": 18.889488 - }, - { - "fromId": 1988, - "toId": 12891, - "weight": 18.889488 - }, - { - "fromId": 1221, - "toId": 3360, - "weight": 51.17568 - }, - { - "fromId": 15494, - "toId": 3360, - "weight": 33.06288 - }, - { - "fromId": 3508, - "toId": 2072, - "weight": 22.6584 - }, - { - "fromId": 2072, - "toId": 3508, - "weight": 22.6584 - }, - { - "fromId": 3511, - "toId": 1987, - "weight": 17.377920000000003 - }, - { - "fromId": 3507, - "toId": 1669, - "weight": 33.76656 - }, - { - "fromId": 3510, - "toId": 11008, - "weight": 1.59384 - }, - { - "fromId": 11008, - "toId": 3510, - "weight": 1.59384 - }, - { - "fromId": 3510, - "toId": 11009, - "weight": 3.9808799999999995 - }, - { - "fromId": 11009, - "toId": 3510, - "weight": 3.9808799999999995 - }, - { - "fromId": 3360, - "toId": 216, - "weight": 25.802400000000002 - }, - { - "fromId": 3788, - "toId": 3507, - "weight": 20.477040000000002 - }, - { - "fromId": 3507, - "toId": 3788, - "weight": 20.477040000000002 - } - ], - "nodes_count": 26, - "edges_count": 46 + "type": "Topology", + "objects": { + "network": { + "type": "GeometryCollection", + "geometries": [ + { + "type": "LineString", + "properties": { + "weight": "6.872", + "node_from": 1168, + "node_to": 1169 + }, + "arcs": [ + 0 + ] + }, + { + "type": "LineString", + "properties": { + "weight": "6.872", + "node_from": 1169, + "node_to": 1168 + }, + "arcs": [ + -1 + ] + }, + { + "type": "LineString", + "properties": { + "weight": "15.234", + "node_from": 2134, + "node_to": 2135 + }, + "arcs": [ + 1 + ] + }, + { + "type": "LineString", + "properties": { + "weight": "15.234", + "node_from": 2135, + "node_to": 2134 + }, + "arcs": [ + -2 + ] + }, + { + "type": "LineString", + "properties": { + "weight": "8.1", + "node_from": 1166, + "node_to": 1167 + }, + "arcs": [ + 2 + ] + }, + { + "type": "LineString", + "properties": { + "weight": "8.1", + "node_from": 1167, + "node_to": 1166 + }, + "arcs": [ + -3 + ] + }, + { + "type": "LineString", + "properties": { + "weight": "3.15", + "node_from": 1168, + "node_to": 2135 + }, + "arcs": [ + 3 + ] + }, + { + "type": "LineString", + "properties": { + "weight": "3.15", + "node_from": 2135, + "node_to": 1168 + }, + "arcs": [ + -4 + ] + }, + { + "type": "LineString", + "properties": { + "weight": "8.07", + "node_from": 1378, + "node_to": 1166 + }, + "arcs": [ + 4 + ] + }, + { + "type": "LineString", + "properties": { + "weight": "8.07", + "node_from": 1166, + "node_to": 1378 + }, + "arcs": [ + -5 + ] + }, + { + "type": "LineString", + "properties": { + "weight": "4.759", + "node_from": 1381, + "node_to": 1162 + }, + "arcs": [ + 5 + ] + }, + { + "type": "LineString", + "properties": { + "weight": "4.759", + "node_from": 1162, + "node_to": 1381 + }, + "arcs": [ + -6 + ] + }, + { + "type": "LineString", + "properties": { + "weight": "6.042", + "node_from": 1169, + "node_to": 1381 + }, + "arcs": [ + 6 + ] + }, + { + "type": "LineString", + "properties": { + "weight": "6.042", + "node_from": 1381, + "node_to": 1169 + }, + "arcs": [ + -7 + ] + }, + { + "type": "LineString", + "properties": { + "weight": "4.191", + "node_from": 2134, + "node_to": 1166 + }, + "arcs": [ + 7 + ] + }, + { + "type": "LineString", + "properties": { + "weight": "4.191", + "node_from": 1166, + "node_to": 2134 + }, + "arcs": [ + -8 + ] + }, + { + "type": "LineString", + "properties": { + "weight": "23.852", + "node_from": 2135, + "node_to": 1165 + }, + "arcs": [ + 8 + ] + }, + { + "type": "LineString", + "properties": { + "weight": "22.137", + "node_from": 1165, + "node_to": 2134 + }, + "arcs": [ + 9 + ] + }, + { + "type": "LineString", + "properties": { + "weight": "7.259", + "node_from": 1168, + "node_to": 1167 + }, + "arcs": [ + 10 + ] + }, + { + "type": "LineString", + "properties": { + "weight": "7.259", + "node_from": 1167, + "node_to": 1168 + }, + "arcs": [ + -11 + ] + } + ] + } + }, + "arcs": [ + [ + [ + 8.686742, + 49.427883 + ], + [ + 8.687107, + 49.427982 + ] + ], + [ + [ + 8.685844, + 49.427873 + ], + [ + 8.686342, + 49.427932 + ], + [ + 8.686699, + 49.427997 + ] + ], + [ + [ + 8.685896, + 49.42772 + ], + [ + 8.686352, + 49.427783 + ] + ], + [ + [ + 8.686742, + 49.427883 + ], + [ + 8.686699, + 49.427997 + ] + ], + [ + [ + 8.685439, + 49.427668 + ], + [ + 8.685646, + 49.427682 + ], + [ + 8.685896, + 49.42772 + ] + ], + [ + [ + 8.687425, + 49.428074 + ], + [ + 8.687534, + 49.428133 + ], + [ + 8.68758, + 49.428213 + ] + ], + [ + [ + 8.687107, + 49.427982 + ], + [ + 8.687425, + 49.428074 + ] + ], + [ + [ + 8.685844, + 49.427873 + ], + [ + 8.685896, + 49.42772 + ] + ], + [ + [ + 8.686699, + 49.427997 + ], + [ + 8.686558, + 49.428345 + ], + [ + 8.686455, + 49.428512 + ], + [ + 8.686352, + 49.428567 + ], + [ + 8.686085, + 49.428622 + ], + [ + 8.685955, + 49.428631 + ] + ], + [ + [ + 8.685955, + 49.428631 + ], + [ + 8.685879, + 49.428609 + ], + [ + 8.685782, + 49.42854 + ], + [ + 8.685709, + 49.428405 + ], + [ + 8.685766, + 49.428125 + ], + [ + 8.685844, + 49.427873 + ] + ], + [ + [ + 8.686742, + 49.427883 + ], + [ + 8.686352, + 49.427783 + ] + ] + ], + "bbox": [ + 8.685439, + 49.427668, + 8.68758, + 49.428631 + ] } -``` \ No newline at end of file +``` + +Note how the number of arcs is equal to the number of arcs in the response with OSM IDs present, so that the geometries +can be represented without redundancies, and the geometries simply contain pairs of `LineString` elements for each edge +that is traversable in both directions, similar to the JSON response. \ No newline at end of file diff --git a/docs/api-reference/endpoints/geocoder/index.md b/docs/api-reference/endpoints/geocoder/index.md index 0abdb6423f..422d5740c2 100644 --- a/docs/api-reference/endpoints/geocoder/index.md +++ b/docs/api-reference/endpoints/geocoder/index.md @@ -1,7 +1,7 @@ # Geocoder Endpoint :::warning NOTE -This endpoint is not part of the openrouteservice, but of our public API. It is not available when running an own instance of openrouteservice. +This endpoint is not part of openrouteservice, but of our public API. It is not available when running an own instance of openrouteservice. ::: The Geocoder Endpoint of our public API is served by a [Pelias](https://www.pelias.io) instance. diff --git a/docs/api-reference/endpoints/optimization/index.md b/docs/api-reference/endpoints/optimization/index.md index 7ed4f60577..8bed4981de 100644 --- a/docs/api-reference/endpoints/optimization/index.md +++ b/docs/api-reference/endpoints/optimization/index.md @@ -1,7 +1,7 @@ # Optimization Service :::warning NOTE -This endpoint is not part of the openrouteservice, but of our public API. It is not available when running an own instance of openrouteservice. +This endpoint is not part of openrouteservice, but of our public API. It is not available when running an own instance of openrouteservice. ::: Our public API includes an instance of VROOM, an open-source optimization engine written in C++20 that aim at providing diff --git a/docs/api-reference/endpoints/poi/index.md b/docs/api-reference/endpoints/poi/index.md index c4dc05e0c2..496daf885b 100644 --- a/docs/api-reference/endpoints/poi/index.md +++ b/docs/api-reference/endpoints/poi/index.md @@ -1,7 +1,7 @@ # Points-Of-Interest (POI) Service :::warning NOTE -This endpoint is not part of the openrouteservice, but of our public API. It is not available when running an own instance of openrouteservice. +This endpoint is not part of openrouteservice, but of our public API. It is not available when running an own instance of openrouteservice. ::: The [openpoiservice](https://github.com/GIScience/openpoiservice) is a stand-alone service from HeiGIT that returns diff --git a/docs/api-reference/endpoints/status/index.md b/docs/api-reference/endpoints/status/index.md index 6640fa78b8..117809c471 100644 --- a/docs/api-reference/endpoints/status/index.md +++ b/docs/api-reference/endpoints/status/index.md @@ -27,7 +27,7 @@ The GET request http://localhost:8082/ors/v2/status (host and port are dependent * `limits`: configured limits * `services`: Activated services. The endpoints `status` and `health` are not included here. -:::details This is an example response: +This is an example response: ```json { "languages": [ @@ -135,5 +135,3 @@ The GET request http://localhost:8082/ors/v2/status (host and port are dependent ] } ``` -::: - diff --git a/docs/api-reference/error-codes.md b/docs/api-reference/error-codes.md index f553fd016e..0c540c26ff 100644 --- a/docs/api-reference/error-codes.md +++ b/docs/api-reference/error-codes.md @@ -19,7 +19,7 @@ The following table describes the supported HTTP status codes. ## Internal Error Codes -The following sections describes the list of possible internal error codes that might be provided by different ORS +The following sections describes the list of possible internal error codes that might be provided by different openrouteservice Endpoints. ### Routing API diff --git a/docs/api-reference/index.md b/docs/api-reference/index.md index 97afa3de21..220e3c04ac 100644 --- a/docs/api-reference/index.md +++ b/docs/api-reference/index.md @@ -11,7 +11,7 @@ But on the other hand, there is also information about endpoints that are not av but e.g. on instances you run or host yourself like [Export](endpoints/export/index.md), [Health](endpoints/health/index.md) and [Status](endpoints/status/index.md). -If you are developing ORS or running your own instance, you might benefit from the included [Swagger-UI](#swagger-ui). +If you are developing openrouteservice or running your own instance, you might benefit from the included [Swagger-UI](#swagger-ui). ## API Playground @@ -40,7 +40,7 @@ This is a way to get an interactive API doc for your current or an older version (the port may be different on your local environment). :::warning Hint -The swagger-ui is not available on the production ORS instances hosted by HeiGIT. +The swagger-ui is not available on the production openrouteservice instances hosted by HeiGIT. ::: ![Swagger-UI](/public/swagger-ui.png "Swagger UI") diff --git a/docs/contributing/index.md b/docs/contributing/index.md index a11db879e5..bb5f731841 100644 --- a/docs/contributing/index.md +++ b/docs/contributing/index.md @@ -1,6 +1,6 @@ # Contributing -We are glad that you decided to contribute to the openrouteservice. +We are glad that you decided to contribute to openrouteservice. There are plenty of ways to help make it an even better routing service. Whether you are a Java developer who is interested in fixing diff --git a/docs/frequently-asked-questions.md b/docs/frequently-asked-questions.md index 682aba18a7..2103e37bfd 100644 --- a/docs/frequently-asked-questions.md +++ b/docs/frequently-asked-questions.md @@ -4,7 +4,7 @@ title: FAQ # Frequently Asked Questions -## Why is my ors reporting `Could not find point`? +## Why is my openrouteservice instance reporting `Could not find point`? This is a frequently encountered error message: ``` @@ -29,22 +29,22 @@ There are three main reasons for this problem, listed in order of most to least 350m of a routable road. This should only happen with a local installation. Usually, this means that ors is trying to route in an area that graphs have not been built for. - If routes in Heidelberg(Germany) can be found, the ors is still running on the + If routes in Heidelberg(Germany) can be found, openrouteservice is still running on the default dataset. -## When does the OSM data update in the openrouteservice? +## When does the OSM data update in openrouteservice? -The openrouteservice builds its data from the `planet.osm.pbf`-files. According +Openrouteservice builds its data from the `planet.osm.pbf`-files. According to [the osm-wiki](https://wiki.openstreetmap.org/wiki/Planet.osm), these files take two days to build and are updated weekly. Since the `planet`-files are rather large (currently over 60GB), there is a bit of work involved to make sure the download went right and the file is not corrupted in any way and in fact new. Parts of this process are in the hands of -the OSM, parts are done by the openrouteservice. +the OSM, parts are done by openrouteservice. -Once the newest `planet`-file is on the openrouteservice-servers, it needs to -be preprocessed before the openrouteservice can start building the graphs used +Once the newest `planet`-file is on the openrouteservice servers, it needs to +be preprocessed before openrouteservice can start building the graphs used for routing. The build process in itself is [rather @@ -84,10 +84,10 @@ This issue most commonly manifests itself in two ways: In both cases, there might be a node with a `barrier=*`-tag on the roads accessing the ferry port or the residential area. The corresponding barriers are made to disallow unauthorized access. -Thus, if no more information than `barrier=*` is given, the openrouteservice will not route over them. +Thus, if no more information than `barrier=*` is given, openrouteservice will not route over them. This behaviour is often misinterpreted as _wrong_ since in many cases, the barrier is passable by default or a ticket can be purchased. -While often obvious to a human looking at the map, the openrouteservice can not know that. +While often obvious to a human looking at the map, openrouteservice can not know that. Routing over such a barrier would be an assumption that the openrouteservice will not make. [A lot](https://wiki.openstreetmap.org/wiki/Key:access#List_of_possible_values) @@ -100,7 +100,7 @@ Depending on the parameters of your request, the openrouteservice will use different routing algorithms with different preparations to calculate an answer. -For matrix calculations, the ors uses the very fast RPHAST algorithm, which is +For matrix calculations, openrouteservice uses the very fast RPHAST algorithm, which is based on so-called _Contraction Hierarchies_ (CH for short). While the usage of CH speeds up matrix calculation by a lot, preparing them is rather costly. Thus, they are not calculated by default, but have to be turned on manually. diff --git a/docs/getting-started.md b/docs/getting-started.md index d4630a6995..6434c1a559 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -9,7 +9,7 @@ The fastest way to get to the info you are looking for is **the search bar above * [Matrix](api-reference/endpoints/matrix/index.md) endpoint * [Snapping](api-reference/endpoints/snapping/index.md) endpoint * [Export](api-reference/endpoints/export/index.md) endpoint _(not available in our live API)_ -* [Run ORS instance](run-instance/index.md) contains all info about setting up the ors locally. +* [Run openrouteservice instance](run-instance/index.md) contains all info about setting up openrouteservice locally. * [System requirements](run-instance/system-requirements) * [Data](run-instance/data) used by openrouteservice * [Running with Docker](run-instance/running-with-docker.md) artifact @@ -17,8 +17,8 @@ The fastest way to get to the info you are looking for is **the search bar above * [Running WAR](run-instance/running-war.md) artifact * [Building from Source](run-instance/building-from-source.md) * [Configuration](run-instance/configuration/index.md) of openrouteservice instances -* [Contributing](contributing/index.md) contains info about contributing to the openrouteservice, the OpenStreetMap and [translations](contributing/contributing-translations) -* [Technical details](technical-details/index.md) contains all sorts of explanation about the internal workings of the openrouteservice. +* [Contributing](contributing/index.md) contains info about contributing to openrouteservice, the OpenStreetMap and [translations](contributing/contributing-translations) +* [Technical details](technical-details/index.md) contains all sorts of explanation about the internal workings of openrouteservice. * [FAQ](frequently-asked-questions) contains answers to frequently asked questions. For a more general overview, visit our website at [openrouteservice.org](https://openrouteservice.org). diff --git a/docs/index.md b/docs/index.md index a1b415a158..0dac6cf91d 100644 --- a/docs/index.md +++ b/docs/index.md @@ -24,11 +24,11 @@ features: linkText: Instructions link: /run-instance/ - title: Data Sources - details: Find all information on the data used by the openrouteservice here. + details: Find all information on the data used by openrouteservice here. linkText: Data link: /run-instance/data - title: Latest Changes - details: Check out the latest changes to the openrouteservice. + details: Check out the latest changes to openrouteservice. linkText: CHANGELOG.md link: https://github.com/GIScience/openrouteservice/blob/main/CHANGELOG.md --- diff --git a/docs/public/topojson_qgis.png b/docs/public/topojson_qgis.png new file mode 100644 index 0000000000..71c098b4fa Binary files /dev/null and b/docs/public/topojson_qgis.png differ diff --git a/docs/run-instance/configuration/engine/profiles/build.md b/docs/run-instance/configuration/engine/profiles/build.md index f208cbe18b..e81905a730 100644 --- a/docs/run-instance/configuration/engine/profiles/build.md +++ b/docs/run-instance/configuration/engine/profiles/build.md @@ -132,7 +132,7 @@ Properties beneath `ors.engine.profiles.*.ext_storages`: | HillIndex | object | Returns the ascent/descent in the route response, compatible with any profile type | | | TrailDifficulty | object | Returns the trail difficulty in the route response, compatible with walking and cycling profiles | | | Wheelchair | object | Wheelchair-specific attributes compatible only with that profile | [Wheelchair](#wheelchair) | -| OsmId | object | Returns the OsmId of the way, compatible only with wheelchair profile | | +| OsmId | object | Returns the OsmId of the way, compatible with any profile type | | Check [this table](/api-reference/endpoints/directions/extra-info/index.md#extra-info-availability) for extra info availability. diff --git a/docs/run-instance/configuration/how-to-configure.md b/docs/run-instance/configuration/how-to-configure.md index bda369010c..efde60f2d5 100644 --- a/docs/run-instance/configuration/how-to-configure.md +++ b/docs/run-instance/configuration/how-to-configure.md @@ -245,7 +245,7 @@ The commented lines (green) are just included for better readability. ## Docker Scenarios An openrouteservice instance running in a container works in the same way as described in this chapter. -The difference is, that the openrouteservice has a docker container as its environment, +The difference is, that openrouteservice has a docker container as its environment, with a separate file system (different paths) and individual environment variables. The lookup for configuration files is always related to the internal environment, this has to be respected when configuring paths in the YAML config or diff --git a/docs/run-instance/configuration/index.md b/docs/run-instance/configuration/index.md index a3c3db5071..c685416c72 100644 --- a/docs/run-instance/configuration/index.md +++ b/docs/run-instance/configuration/index.md @@ -10,6 +10,6 @@ a [minimal configuration example](what-to-configure.md#minimal-configuration). There are different ways to set configuration properties. This again gives you flexibility in the way you run openrouteservice. But it is crucial to know and understand the different configuration mechanisms -in order to operate the openrouteservice with the desired configuration. +in order to operate openrouteservice with the desired configuration. In Chapter [How to configure](how-to-configure.md) we handle the different dimensions of the configuration topic. diff --git a/docs/run-instance/data.md b/docs/run-instance/data.md index 0f41050cb8..14d93ae176 100644 --- a/docs/run-instance/data.md +++ b/docs/run-instance/data.md @@ -21,7 +21,7 @@ Configuration: [`ors.engine.elevation`](configuration/engine/elevation.md) ### Population When requesting isochrones, you can also request to get population data for the isochrone areas. The data used for this is the [Global Human Settlement Layer (GHSL)](https://ghsl.jrc.ec.europa.eu/ghs_pop2023.php) from the European Commission. -Note, that while the dataset was published in 2023, the most recent data contained is from 2020. This is used by the openrouteservice at a resolution of 100m. +Note, that while the dataset was published in 2023, the most recent data contained is from 2020. This is used by openrouteservice at a resolution of 100m. ### Borders Data relating to the avoid borders features is derived from administrative boundaries features in OpenStreetMap. Information about open borders is obtained from [Wikipedia](https://en.wikipedia.org/wiki/Open_border). diff --git a/docs/run-instance/example-setups/en_tomcat-10-ubuntu_22_04.md b/docs/run-instance/example-setups/en_tomcat-10-ubuntu_22_04.md index 26038da6dd..62c9cd7aaa 100644 --- a/docs/run-instance/example-setups/en_tomcat-10-ubuntu_22_04.md +++ b/docs/run-instance/example-setups/en_tomcat-10-ubuntu_22_04.md @@ -184,7 +184,7 @@ the latest release WAR-File. > sudo systemctl status openrouteservice.service ``` -If you navigate to `http://localhost:8080/ors/v2/health` you should see the health status of the openrouteservice. +If you navigate to `http://localhost:8080/ors/v2/health` you should see the health status of the openrouteservice instance. The output will be as follows: ```json @@ -280,7 +280,7 @@ The following steps are mandatory whenever you change the configuration, folder Now that openrouteservice is set up with correct configurations, check the log files in the `/opt/openrouteservice/logs/ors.log` or the Tomcat log files in the `/opt/tomcat/logs` directory. -Navigate to [http://localhost:8080/ors/v2/health](http://localhost:8080/ors/v2/health) in your browser to see the health status of the openrouteservice or +Navigate to [http://localhost:8080/ors/v2/health](http://localhost:8080/ors/v2/health) in your browser to see the health status of the openrouteservice instance or make a request to the API. ```shell diff --git a/docs/run-instance/running-war.md b/docs/run-instance/running-war.md index 23e066caf2..986efa3c4b 100644 --- a/docs/run-instance/running-war.md +++ b/docs/run-instance/running-war.md @@ -1,6 +1,6 @@ # Running openrouteservice as WAR -Like older versions, ORS version 8 can still be built and run as a Web Application Resource aka Web Archive (WAR). +Like older versions, openrouteservice version 8 can still be built and run as a Web Application Resource aka Web Archive (WAR). A WAR file can be deployed to a Servlet Container like Tomcat, which is running as a service. To run openrouteservice, you also need an OSM data file, e.g. from [Geofabrik](http://download.geofabrik.de). For more details see chapter [Data](data.md). diff --git a/docs/run-instance/running-with-docker.md b/docs/run-instance/running-with-docker.md index 58a22f9e9c..e82c9f8a2c 100644 --- a/docs/run-instance/running-with-docker.md +++ b/docs/run-instance/running-with-docker.md @@ -34,7 +34,7 @@ Now start openrouteservice in the background: docker compose up -d ``` -This will pull the openrouteservice of the selected version and start it up using an example setup +This will pull openrouteservice of the selected version and start it up using an example setup and the provided test OSM file for Heidelberg/Germany and surrounding area. To see the container's logs, run @@ -121,7 +121,7 @@ When you have started the container as described, a directory `ors-docker` with * `example-ors-config.env`: env file template. A customized copy of this file can be used in combination with the `docker-compose.yml`, see [Set properties in an environment file](#set-openrouteservice-properties-in-an-environment-file). Do not edit this file directly since it will be overridden by docker! * `example-ors-config.yml`: YAML file template. A customized copy of this file can be used as `ors-config.yml`, see [Use customized config file](#use-customized-config-file). Do not edit this file directly since it can be overridden by docker: If e.g. a newer docker image tag is used in the `docker-compose.yml`, the `example-ors-config.yml` might be updated if in the newer version of openrouteservice there are changes in the configuration properties or their default values. The updated file can be compared with the customized `ors-config.yml`. -* `ors-config.yml`: The default config used by the openrouteservice inside the container. This file will not be overridden by docker. Initially, the file is identical to `example-ors-config.yml`. See [Use customized config file](#use-customized-config-file) +* `ors-config.yml`: The default config used by the openrouteservice instance inside the container. This file will not be overridden by docker. Initially, the file is identical to `example-ors-config.yml`. See [Use customized config file](#use-customized-config-file) * `elevation_cache`: Directory, where openrouteservice stores downloaded elevation data to avoid repeated downloads. * `example-heidelberg.test.pbf`: The initial sample OSM data used to run the container in its initial setup. Normally, you will remove this file or add another OSM file to the same directory and adapt your config to use your file. diff --git a/docs/run-instance/system-requirements.md b/docs/run-instance/system-requirements.md index b2972b3311..754059d838 100644 --- a/docs/run-instance/system-requirements.md +++ b/docs/run-instance/system-requirements.md @@ -15,7 +15,7 @@ As a guide, you can look at the size of OSM data extracts as a rough guide as to ## JVM configuration -Independent of the configuration of the openrouteservice itself, you might need to adjust settings of the Java Virtual Machine (JVM) running the code. Since the memory requirements of openrouteservice are proportional to the size of the OSM data (and therefore the resulting graph), the setting that needs to be adjusted most often is the heap memory size. +Independent of the configuration of openrouteservice itself, you might need to adjust settings of the Java Virtual Machine (JVM) running the code. Since the memory requirements of openrouteservice are proportional to the size of the OSM data (and therefore the resulting graph), the setting that needs to be adjusted most often is the heap memory size. [//]: # (TODO: elaborate) diff --git a/docs/technical-details/index.md b/docs/technical-details/index.md index 3e794fe889..4f17bb950c 100644 --- a/docs/technical-details/index.md +++ b/docs/technical-details/index.md @@ -3,7 +3,7 @@ [//]: # (Attention: Pages in Technical details are linked from api-playground. When refactoring, adapt the links in the annotations in the java classes) In this section you can find additional information on some important value lists -and explanation about the internal workings of the openrouteservice: +and explanation about the internal workings of openrouteservice: * [Country List](country-list.md) * [Travel Speeds](travel-speeds/index.md) diff --git a/docs/versions/v7.1.1/Frequently-Asked-Questions.md b/docs/versions/v7.1.1/Frequently-Asked-Questions.md index 1081f71834..c319118212 100644 --- a/docs/versions/v7.1.1/Frequently-Asked-Questions.md +++ b/docs/versions/v7.1.1/Frequently-Asked-Questions.md @@ -34,19 +34,19 @@ There are three main reasons for this problem, listed in order of most to least --- -## When does the OSM data update in the openrouteservice? +## When does the OSM data update in openrouteservice? -The openrouteservice builds its data from the `planet.osm.pbf`-files. According +Openrouteservice builds its data from the `planet.osm.pbf`-files. According to [the osm-wiki](https://wiki.openstreetmap.org/wiki/Planet.osm), these files take two days to build and are updated weekly. Since the `planet`-files are rather large (currently over 60GB), there is a bit of work involved to make sure the download went right and the file is not corrupted in any way and in fact new. Parts of this process are in the hands of -the OSM, parts are done by the openrouteservice. +the OSM, parts are done by openrouteservice. -Once the newest `planet`-file is on the openrouteservice-servers, it needs to -be preprocessed before the openrouteservice can start building the graphs used +Once the newest `planet`-file is on the openrouteservice servers, it needs to +be preprocessed before openrouteservice can start building the graphs used for routing. The build process in itself is [rather diff --git a/docs/versions/v7.1.1/getting-started.md b/docs/versions/v7.1.1/getting-started.md index 94df3cfc15..97a970d0a2 100644 --- a/docs/versions/v7.1.1/getting-started.md +++ b/docs/versions/v7.1.1/getting-started.md @@ -13,8 +13,8 @@ If that doesn't work, the sidebar has you covered: [more docker stuff](installation/Advanced-Docker-Setup) * [Data](Data) contains info about the used data sets. * [Contributing](contributing/Contributing) contains info about contributing to - the openrouteservice, the OpenStreetMap and + openrouteservice, the OpenStreetMap and [translations](contributing/Contributing-Translations) * [Documentation](documentation/Documentation) contains all sorts of - explanation about the internal workings of the openrouteservice. + explanation about the internal workings of openrouteservice. * [FAQ](Frequently-Asked-Questions) contains answers to frequently asked questions. diff --git a/docs/versions/v7.1.1/index.md b/docs/versions/v7.1.1/index.md index 69e24d9e7f..85962187bb 100644 --- a/docs/versions/v7.1.1/index.md +++ b/docs/versions/v7.1.1/index.md @@ -24,11 +24,11 @@ features: linkText: Instructions link: ./installation/Installation-and-Usage - title: Data Sources - details: Find all information on the data used by the openrouteservice here. + details: Find all information on the data used by openrouteservice here. linkText: Data link: ./Data - title: Latest Changes - details: Check out the latest changes to the openrouteservice. + details: Check out the latest changes to openrouteservice. linkText: CHANGELOG.md link: https://github.com/GIScience/openrouteservice/blob/master/CHANGELOG.md --- diff --git a/docs/versions/v7.1.1/installation/Building-from-Source.md b/docs/versions/v7.1.1/installation/Building-from-Source.md index 4d5ff0b554..efb69150ab 100644 --- a/docs/versions/v7.1.1/installation/Building-from-Source.md +++ b/docs/versions/v7.1.1/installation/Building-from-Source.md @@ -25,7 +25,7 @@ If you need to install without Docker, on an Ubuntu 20.04 system (also generally [path to folder]` command. An explanation of the file format and parameters can be found [here](Configuration) 7. From within the `openrouteservice` root directory run the command `mvn package`. This will build - the openrouteservice ready for tomcat deployment. + openrouteservice ready for tomcat deployment. 8. For running both the unit and api tests, add `-Papitests` as a parameter to `mvn`. ``` mvn -Papitests verify diff --git a/ors-api/src/main/java/org/heigit/ors/api/controllers/ExportAPI.java b/ors-api/src/main/java/org/heigit/ors/api/controllers/ExportAPI.java index 3be0695b18..5e5b6ef010 100644 --- a/ors-api/src/main/java/org/heigit/ors/api/controllers/ExportAPI.java +++ b/ors-api/src/main/java/org/heigit/ors/api/controllers/ExportAPI.java @@ -150,7 +150,12 @@ public TopoJsonExportResponse getTopoJsonExport( @PostMapping(value = "/{profile}/{responseType}") @Operation(hidden = true) public void getInvalidResponseType(@PathVariable String profile, @PathVariable String responseType) throws StatusCodeException { - throw new StatusCodeException(HttpServletResponse.SC_NOT_ACCEPTABLE, ExportErrorCodes.UNSUPPORTED_EXPORT_FORMAT, "The response format %s is not supported".formatted(responseType)); + if (responseType.equals("topojson")) { + throw new StatusCodeException(HttpServletResponse.SC_NOT_ACCEPTABLE, ExportErrorCodes.UNSUPPORTED_EXPORT_FORMAT, "The response format topojson requires 'application/json' as accept and content-type headers."); + + } else { + throw new StatusCodeException(HttpServletResponse.SC_NOT_ACCEPTABLE, ExportErrorCodes.UNSUPPORTED_EXPORT_FORMAT, "The response format %s is not supported".formatted(responseType)); + } } @ExceptionHandler(MissingServletRequestParameterException.class) diff --git a/ors-api/src/main/java/org/heigit/ors/api/responses/export/json/JsonEdge.java b/ors-api/src/main/java/org/heigit/ors/api/responses/export/json/JsonEdge.java index 5e8a5f0e94..2b22ddf740 100644 --- a/ors-api/src/main/java/org/heigit/ors/api/responses/export/json/JsonEdge.java +++ b/ors-api/src/main/java/org/heigit/ors/api/responses/export/json/JsonEdge.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; import io.swagger.v3.oas.annotations.media.Schema; import org.heigit.ors.common.Pair; @@ -21,7 +22,7 @@ public class JsonEdge { @Schema(description = "Weight of the corresponding edge in the given bounding box", example = "123.45") @JsonProperty(value = "weight") - @JsonFormat(shape = JsonFormat.Shape.NUMBER_FLOAT) + @JsonSerialize(using = WeightSerializer.class) protected Double weight; JsonEdge(Map.Entry, Double> weightedEdge) { diff --git a/ors-api/src/main/java/org/heigit/ors/api/responses/export/json/WeightSerializer.java b/ors-api/src/main/java/org/heigit/ors/api/responses/export/json/WeightSerializer.java new file mode 100644 index 0000000000..e453e2081a --- /dev/null +++ b/ors-api/src/main/java/org/heigit/ors/api/responses/export/json/WeightSerializer.java @@ -0,0 +1,15 @@ +package org.heigit.ors.api.responses.export.json; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; + +import java.io.IOException; +import java.text.DecimalFormat; + +public class WeightSerializer extends JsonSerializer { + @Override + public void serialize(Object o, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException { + jsonGenerator.writeString(new DecimalFormat("#.###").format(o)); + } +} diff --git a/ors-api/src/main/java/org/heigit/ors/api/responses/export/topojson/Properties.java b/ors-api/src/main/java/org/heigit/ors/api/responses/export/topojson/Properties.java index 8b7fb067da..3a0eb7a3ba 100644 --- a/ors-api/src/main/java/org/heigit/ors/api/responses/export/topojson/Properties.java +++ b/ors-api/src/main/java/org/heigit/ors/api/responses/export/topojson/Properties.java @@ -2,8 +2,10 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; import lombok.Builder; import lombok.Getter; +import org.heigit.ors.api.responses.export.json.WeightSerializer; import java.io.Serializable; import java.util.List; @@ -13,7 +15,12 @@ @Builder public class Properties implements Serializable { @JsonProperty("weight") + @JsonSerialize(using = WeightSerializer.class) private Double weight; + @JsonProperty("node_from") + private Long nodeFrom; + @JsonProperty("node_to") + private Long nodeTo; @JsonProperty("osm_id") private Long osmId; @JsonProperty("both_directions") diff --git a/ors-api/src/main/java/org/heigit/ors/api/responses/export/topojson/TopoJsonExportResponse.java b/ors-api/src/main/java/org/heigit/ors/api/responses/export/topojson/TopoJsonExportResponse.java index 74bfd25ed9..94fa06b7c5 100644 --- a/ors-api/src/main/java/org/heigit/ors/api/responses/export/topojson/TopoJsonExportResponse.java +++ b/ors-api/src/main/java/org/heigit/ors/api/responses/export/topojson/TopoJsonExportResponse.java @@ -11,10 +11,7 @@ import org.locationtech.jts.geom.LineString; import java.io.Serializable; -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; +import java.util.*; import static org.heigit.ors.export.ExportResult.TopoGeometry; @@ -59,19 +56,27 @@ public static TopoJsonExportResponse fromExportResult(ExportResult exportResult) private static void buildGeometriesFromEdges(ExportResult exportResult, BBox bbox, LinkedList geometries, LinkedList arcsLocal) { Map, Double> edgeWeights = exportResult.getEdgeWeights(); Map, LineString> edgeGeometries = exportResult.getEdgeGeometries(); - int arcCount = 0; - for (Map.Entry, Double> edgeWeight : edgeWeights.entrySet()) { - arcsLocal.add(Arc.builder().coordinates(makeCoordinateList(edgeGeometries.get(edgeWeight.getKey()), bbox)).build()); - List arcList = List.of(arcCount); - arcCount++; + Map, Integer> edgeArcs = new HashMap<>(); + for (Map.Entry, Double> edgeWeight : edgeWeights.entrySet()) { + Pair key = edgeWeight.getKey(); + Pair reverseKey = Pair.create(key.second, key.first); + int nextArc = edgeArcs.size(); + if (edgeArcs.containsKey(reverseKey)) { + nextArc = - (1 + edgeArcs.get(reverseKey)); + } else { + arcsLocal.add(Arc.builder().coordinates(makeCoordinateList(edgeGeometries.get(key), bbox)).build()); + edgeArcs.put(key, nextArc); + } Properties properties = Properties.builder() .weight(edgeWeight.getValue()) + .nodeFrom((long) key.first) + .nodeTo((long) key.second) .build(); Geometry geometry = Geometry.builder() .type("LineString") .properties(properties) - .arcs(arcList) + .arcs(List.of(nextArc)) .build(); geometries.add(geometry); } diff --git a/ors-api/src/main/java/org/heigit/ors/api/services/ExportService.java b/ors-api/src/main/java/org/heigit/ors/api/services/ExportService.java index e47cfd9fd1..7923a87740 100644 --- a/ors-api/src/main/java/org/heigit/ors/api/services/ExportService.java +++ b/ors-api/src/main/java/org/heigit/ors/api/services/ExportService.java @@ -11,6 +11,7 @@ import org.heigit.ors.exceptions.ParameterValueException; import org.heigit.ors.exceptions.StatusCodeException; import org.heigit.ors.export.ExportErrorCodes; +import org.heigit.ors.export.ExportRequest; import org.heigit.ors.export.ExportResult; import org.heigit.ors.routing.RoutingProfile; import org.heigit.ors.routing.RoutingProfileManager; @@ -29,13 +30,9 @@ public ExportService(EndpointsProperties endpointsProperties, ApiEnginePropertie } public ExportResult generateExportFromRequest(ExportApiRequest exportApiRequest) throws StatusCodeException { - org.heigit.ors.export.ExportRequest exportRequest = this.convertExportRequest(exportApiRequest); - try { - RoutingProfile rp = RoutingProfileManager.getInstance().getRoutingProfile(exportRequest.getProfileName()); - if (rp == null) - throw new InternalServerException(ExportErrorCodes.UNKNOWN, "Unable to find an appropriate routing profile."); - return exportRequest.computeExport(rp); + ExportRequest exportRequest = this.parseExportRequest(exportApiRequest); + return exportRequest.computeExport(); } catch (StatusCodeException e) { throw e; } catch (Exception e) { @@ -43,21 +40,13 @@ public ExportResult generateExportFromRequest(ExportApiRequest exportApiRequest) } } - private org.heigit.ors.export.ExportRequest convertExportRequest(ExportApiRequest exportApiRequest) throws StatusCodeException { - org.heigit.ors.export.ExportRequest exportRequest = new org.heigit.ors.export.ExportRequest(); - exportRequest.setProfileName(exportApiRequest.getProfileName()); + private ExportRequest parseExportRequest(ExportApiRequest exportApiRequest) throws StatusCodeException { + ExportRequest exportRequest = new ExportRequest(); + exportRequest.setProfile(parseRoutingProfile(exportApiRequest.getProfileName())); if (exportApiRequest.hasId()) exportRequest.setId(exportApiRequest.getId()); - int profileType = -1; - - try { - profileType = convertRouteProfileType(exportApiRequest.getProfile()); - exportRequest.setProfileType(profileType); - } catch (Exception e) { - throw new ParameterValueException(ExportErrorCodes.INVALID_PARAMETER_VALUE, ExportApiRequest.PARAM_PROFILE); - } - + exportRequest.setProfileType(parseProfileType(exportApiRequest.getProfile())); exportRequest.setBoundingBox(convertBBox(exportApiRequest.getBbox())); exportRequest.setAdditionalEdgeInfo(exportApiRequest.additionalInfo()); exportRequest.setTopoJson(exportApiRequest.getResponseType().equals(APIEnums.ExportResponseType.TOPOJSON)); @@ -66,6 +55,23 @@ private org.heigit.ors.export.ExportRequest convertExportRequest(ExportApiReques return exportRequest; } + private static RoutingProfile parseRoutingProfile(String profileName) throws InternalServerException { + RoutingProfile rp = RoutingProfileManager.getInstance().getRoutingProfile(profileName); + if (rp == null) + throw new InternalServerException(ExportErrorCodes.UNKNOWN, "Unable to find an appropriate routing profile."); + return rp; + } + + private static int parseProfileType(APIEnums.Profile profile) throws ParameterValueException { + int profileType = -1; + try { + profileType = convertRouteProfileType(profile); + } catch (Exception e) { + throw new ParameterValueException(ExportErrorCodes.INVALID_PARAMETER_VALUE, ExportApiRequest.PARAM_PROFILE); + } + return profileType; + } + BBox convertBBox(List> coordinates) throws ParameterValueException { if (coordinates.size() != 2) { throw new ParameterValueException(ExportErrorCodes.INVALID_PARAMETER_VALUE, ExportApiRequest.PARAM_BBOX); @@ -87,5 +93,4 @@ private double[] convertSingleCoordinate(List coordinate) throws Paramet return new double[]{coordinate.get(0), coordinate.get(1)}; } - } diff --git a/ors-api/src/test/java/org/heigit/ors/apitests/export/ParamsTest.java b/ors-api/src/test/java/org/heigit/ors/apitests/export/ParamsTest.java index eb0c5368e0..7fe573a0ff 100644 --- a/ors-api/src/test/java/org/heigit/ors/apitests/export/ParamsTest.java +++ b/ors-api/src/test/java/org/heigit/ors/apitests/export/ParamsTest.java @@ -242,7 +242,7 @@ void expectTopoJsonFallbackNoOsmIdMode() { .then().log().ifValidationFails() .assertThat() .body("type", is("Topology")) - .body("arcs.size()", is(30)) + .body("arcs.size()", is(28)) .body("objects.network.geometries.size()", is(30)) .body("objects.network.geometries[0].properties.containsKey('weight')", is(true)) .statusCode(200); diff --git a/ors-engine/src/main/java/org/heigit/ors/export/ExportRequest.java b/ors-engine/src/main/java/org/heigit/ors/export/ExportRequest.java index 8f848a1c9c..5b7baa1acd 100644 --- a/ors-engine/src/main/java/org/heigit/ors/export/ExportRequest.java +++ b/ors-engine/src/main/java/org/heigit/ors/export/ExportRequest.java @@ -2,7 +2,6 @@ import com.graphhopper.GraphHopper; import com.graphhopper.routing.util.AccessFilter; -import com.graphhopper.routing.util.FlagEncoder; import com.graphhopper.routing.weighting.Weighting; import com.graphhopper.storage.Graph; import com.graphhopper.storage.NodeAccess; @@ -36,7 +35,11 @@ public class ExportRequest extends ServiceRequest { private static final GeometryFactory geometryFactory = new GeometryFactory(); private BBox boundingBox; - private String profileName; + public void setProfile(RoutingProfile profile) { + this.profile = profile; + } + + private RoutingProfile profile; private int profileType = -1; private boolean additionalEdgeInfo; @@ -48,14 +51,6 @@ public class ExportRequest extends ServiceRequest { private WheelchairAttributesGraphStorage wheelchairAttributesGraphStorage; private Weighting weighting; - public String getProfileName() { - return profileName; - } - - public void setProfileName(String profileName) { - this.profileName = profileName; - } - public void setBoundingBox(BBox bbox) { this.boundingBox = bbox; } @@ -76,11 +71,11 @@ public void setUseRealGeometry(boolean useRealGeometry) { this.useRealGeometry = useRealGeometry; } - public ExportResult computeExport(RoutingProfile routingProfile) { + public ExportResult computeExport() { ExportResult res = new ExportResult(); // Prepare graph data access - GraphHopper gh = routingProfile.getGraphhopper(); + GraphHopper gh = profile.getGraphhopper(); String encoderName = RoutingProfileType.getEncoderName(profileType); Graph graph = gh.getGraphHopperStorage().getBaseGraph(); NodeAccess nodeAccess = graph.getNodeAccess(); diff --git a/package-lock.json b/package-lock.json index 2dea6cc9f3..aeaaeeb4b9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,6 +5,7 @@ "packages": { "": { "dependencies": { + "vitepress-plugin-codeblocks-fold": "^1.2.28", "vitepress-versioning-plugin": "git+https://github.com/GIScience/vitepress-versioning-plugin.git#fix-sidebar-rewrites" }, "devDependencies": { @@ -3377,6 +3378,12 @@ } } }, + "node_modules/vitepress-plugin-codeblocks-fold": { + "version": "1.2.28", + "resolved": "https://registry.npmjs.org/vitepress-plugin-codeblocks-fold/-/vitepress-plugin-codeblocks-fold-1.2.28.tgz", + "integrity": "sha512-ilckzzYmTIv3A9t4xiCSsTcYCfzCFzlsycV9nDtgvRTuk7Fy1lNHMZgPOk6ysB7PLFG/R71HsgQC44AZZKL8cw==", + "license": "MIT" + }, "node_modules/vitepress-plugin-mermaid": { "version": "2.0.17", "resolved": "https://registry.npmjs.org/vitepress-plugin-mermaid/-/vitepress-plugin-mermaid-2.0.17.tgz", diff --git a/package.json b/package.json index 551312126a..cfc8e1a184 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "build-preview": "vitepress build docs && vitepress preview docs" }, "dependencies": { + "vitepress-plugin-codeblocks-fold": "^1.2.28", "vitepress-versioning-plugin": "git+https://github.com/GIScience/vitepress-versioning-plugin.git#fix-sidebar-rewrites" } }