diff --git a/CHANGELOG.md b/CHANGELOG.md index 53bf34240a..1044a37958 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,9 +9,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Added support for ISO 3166-1 Alpha-2 / Alpha-3 codes for routing directions option avoid_countries (Issue #195) - Added support for GH alternative_route algorithm (Issue #377) ### Fixed +- Fixed `geometry_simplify` parameter, which had no effect before. `geometry_simplify` is incompatible with `extra_info` (#381) ### Changed - Updated rural speed limit in France to be 80km/h (Issue #355) - Modified smoothing and buffer distances for small isochrones, aswell as other fixes for smaller isochrones (Issue #382) +- Updated pom to use correct opengeo repo and reordered so this is the last in the list, and use latest ORS-Graphhopper library (Issue #398) +- Added /directions as an endpoint for routing (Issue #384) ### Deprecated ## [4.7.2] - 2018-12-10 @@ -170,11 +173,10 @@ are attached to roads. (Issue #162) - Consider turn restrictions if optimized=false is passed. ### Changed -- +- ### Removed -- +- ### Deprecated -- - +- diff --git a/CONTRIBUTE.md b/CONTRIBUTE.md new file mode 100644 index 0000000000..775ebb11d2 --- /dev/null +++ b/CONTRIBUTE.md @@ -0,0 +1,89 @@ +# Contribution Guidelines + + + +- [Contribution Guidelines](#contribution-guidelines) + - [Issues](#issues) + - [Technical issues](#technical-issues) + - [Routing issues](#routing-issues) + - [Feature requests](#feature-requests) + - [Pull Requests](#pull-requests) + - [Pull request guidelines](#pull-request-guidelines) + - [Contributing code](#contributing-code) + + + +**Firstly, thanks for using the ORS 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. To try and keep the OpenRouteService codebase clean and stable, there are a few guidelines that we try to follow. + +## Issues + +We accept technical issues, routing issues and feature requests. Common questions should be asked at [ask.openrouteservice.org](https://ask.openrouteservice.org). + +Please search for issues before creating [a new one](https://github.com/GIScience/openrouteservice/issues/new). + +### Technical issues + +If you encounter a bug, please make sure to be as descriptive as possible, i.e.: + +- operating system (in case of self-hosting) +- request URL (incl. parameters if POST) +- expected outcome +- actual outcome (e.g. JSON output) +- fenced code around the bug, if known + +### Routing issues + +If you encounter weird or unexpected behavior during routing, please make sure to rule out expected behavior based on road attributes from e.g. [openstreetmap.org](https://openstreetmap.org/query), such as unexpected one-way streets or access restrictions. Find an overview of our tagging filters for all transportation profiles in our [wiki](https://github.com/GIScience/openrouteservice/wiki/Tag-Filtering). + +Information to include: + +- request URL (incl. parameters if POST) +- expected outcome +- actual outcome (e.g. JSON output) +- screenshots where applicable (e.g. from our [maps](https://maps.openrouteservice.org)) + +### Feature requests + +Here you can be creative, but still descriptive. Make sure to describe the current behavior, your desired behavior and **to give actual use cases**. That makes it whole easier for us to prioritize. + +## Pull Requests + +We :heart: pull requests! We also aspire to make our commit history cleaner and more sustainable, benefiting our contributors and us maintainers. + +### Pull request guidelines + +We'd like all pull requests to adhere to the following rules: + +- a PR has to **close an issue**. If there is none yet for yours, please [create one](https://github.com/GIScience/openrouteservice/issues/new) +- branch off [development](https://github.com/GIScience/openrouteservice/tree/development) +- name your branch according to `<[hotfix/bugfix/feat/algo]>/-`, e.g. `[feat]/#381-simplify_geometry` +- if you introduce new functions/classes, write unit or API tests +- **limit the number of commits to a minimum**, i.e. use [`git commit --amend [--no-edit]`](https://www.atlassian.com/git/tutorials/rewriting-history#git-commit--amend) +- use meaningful commit messages, e.g. `commit -m "[feat] include geometry_simplify in API and core code"` +- if your branch needs an update from its base branch, use [`rebase`](https://blog.algolia.com/master-git-rebase/#rebasing-on-the-base-branch), e.g. + +``` +git checkout my-new-feat +git stash +git rebase development +git stash pop +``` + +Be extra careful using `rebase` commands when collaborating on a branch with other people. + +**Don't merge** `development` branch into your feature branch. + +### Contributing code + +For a short explanation on how to setup, deploy and test **openrouteservice** locally for development, see our [wiki entry](https://github.com/GIScience/openrouteservice/wiki/Contributing-Code). + +Though there are no concrete rules for code that is contributed, we have a few general styles that should be adopted: + +- **Descriptive names** for variables, methods and classes +- **Minimal in-line comments**: code should be self-explanatory. **Never** use comments to comment out blocks of code +- **Use JDoc** docstrings to provide context for methods and classes +- **Unit tests!!** +- **API test** when adding API functionality in the corresponding [`openrouteservice-api-tests`](https://github.com/GIScience/openrouteservice/tree/master/openrouteservice-api-tests) subproject +- Keep **methods modular**: rather short and singular functionality than 100s line of code diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md index f3daf54148..0c70047563 100644 --- a/PULL_REQUEST_TEMPLATE.md +++ b/PULL_REQUEST_TEMPLATE.md @@ -1,6 +1,6 @@ ### Pull Request Checklist -- [ ] 1. I have merged the latest version of the development branch into my feature branch and all conflicts have been resolved. +- [ ] 1. I have [**rebased**](https://github.com/GIScience/openrouteservice/blob/master/CONTRIBUTE.md#pull-request-guidelines) the latest version of the development branch into my feature branch and all conflicts have been resolved. - [ ] 2. I have added information about the change/addition to functionality to the CHANGELOG.md file under the [Unreleased] heading. - [ ] 3. I have documented my code using JDocs tags. - [ ] 4. I have removed unnecessary commented out code, imports and System.out.println statements. @@ -17,10 +17,10 @@ Fixes # . ### Information about the changes - Key functionality added: -- Reason for change: +- Reason for change: ### Examples and reasons for differences between live ORS routes and those generated from this pull request -- +- ### Required changes to app.config (if applicable) -- +- diff --git a/README.md b/README.md index 228e413b4a..7ea6b89e44 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Openrouteservice -- [master](https://github.com/GIScience/openrouteservice) [![Build Status](https://travis-ci.org/GIScience/openrouteservice.svg?branch=master)](https://travis-ci.org/GIScience/openrouteservice) -- [development](https://github.com/GIScience/openrouteservice/tree/development) [![Build Status](https://travis-ci.org/GIScience/openrouteservice.svg?branch=development)](https://travis-ci.org/GIScience/openrouteservice) +       [master](https://github.com/GIScience/openrouteservice)        [development](https://github.com/GIScience/openrouteservice/tree/development) +[![Build Status](https://travis-ci.org/GIScience/openrouteservice.svg?branch=master)](https://travis-ci.org/GIScience/openrouteservice) [![Build Status](https://travis-ci.org/GIScience/openrouteservice.svg?branch=development)](https://travis-ci.org/GIScience/openrouteservice) The **openrouteservice API** provides global spatial services by consuming user-generated and collaboratively collected free geographic data directly from [OpenStreetMap](http://www.openstreetmap.org). It is highly customizable, performant and written in Java. @@ -12,11 +12,12 @@ The following services are available via a RESTful interface served by Tomcat. To play around with openrouteservice you may use our [demonstration server](https://maps.openrouteservice.org) which comes with both the backend and a [frontend](https://github.com/GIScience/openrouteservice-app). Or simply sign up for an [API key](https://openrouteservice.org) and fire your requests against the API directly. -Please note that openrouteservice uses a forked and edited version of [graphhopper 0.9](https://github.com/GIScience/graphhopper) which can be found [here](https://github.com/GIScience/graphhopper). +Please note that openrouteservice uses a forked and edited version of [graphhopper 0.10](https://github.com/GIScience/graphhopper) which can be found [here](https://github.com/GIScience/graphhopper). [![ors client accessibility](https://user-images.githubusercontent.com/23240110/30385487-9eac96b8-98a7-11e7-9357-afd4df8fccdf.png)](https://openrouteservice.org/reach) **Note** + - Our geocoding API is a separate service running the stack built around [**Pelias**](https://github.com/pelias/pelias). - Our locations/API is another service which we have coined **openpoiservice** which can be found [here](https://github.com/GIScience/openpoiservice). @@ -29,13 +30,7 @@ Please note that openrouteservice uses a forked and edited version of [graphhopp We appreciate any kind of contribution - bug reports, new feature suggestion or improving our translations are greatly appreciated. Feel free to create an [issue](https://github.com/GIScience/openrouteservice/issues) and label it accordingly. If your issue regards the openrouteservice web-app please use the [corresponding repository](https://github.com/GIScience/openrouteservice-app/issues). -If you want to do contribute your improvements, please follow these steps: - - 1. [Fork the openrouteservice project](https://help.github.com/articles/fork-a-repo) - - 2. Create a branch for the improvement from the development branch on your fork and add your contributions there. - - 3. Create a [pull request](https://help.github.com/articles/using-pull-requests) to our development branch, so we can review your changes before applying them. Please write your pull request description similar to [this](http://api.coala.io/en/latest/Developers/Writing_Good_Commits.html) standard. Also please make sure to reference your pull request to the corresponding issue, for changes regarding multiple issues please create different pullrequests using different branches in your fork. +If you want to contribute your improvements, please follow the steps outlined in [our CONTRIBUTION guidelines](./CONTRIBUTE.md) ## Installation @@ -63,7 +58,7 @@ After you have packaged openrouteservice, there are two options for running it. 1. Install Tomcat 8 using `sudo apt-get install tomcat8`. 2. If you want to use system settings (i.e. Java heap size) other than the default, then you need to add these to the `/usr/share/tomcat8/bin/setenv.sh` file. If the file is not present, then you can create it. The settings generally used on our servers are similar to: - + ```bash JAVA_OPTS="-server -XX:TargetSurvivorRatio=75 -XX:SurvivorRatio=64 -XX:MaxTenuringThreshold=3 -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:ParallelGCThreads=4 -Xms114g -Xmx114g -XX:MaxMetaspaceSize=50m" CATALINA_OPTS="(here we set settings for JMX monitoring)" @@ -96,7 +91,7 @@ After obtaining your key you can try out the different endpoints instantly and s ## Questions -For questions please use our [Google Groups Forum](https://groups.google.com/forum/#!forum/openrouteservice) and we will respond to you shortly or add a GitHub issue if it is of technical nature. +For questions please use our [community forum](https://ask.openrouteservice.org). ## Translations diff --git a/contributing.md b/contributing.md deleted file mode 100644 index 534045986f..0000000000 --- a/contributing.md +++ /dev/null @@ -1,25 +0,0 @@ -#Contribution Guidelines -**Firstly, thanks for using the ORS 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. To try and keep the OpenRouteService codebase clean and stable, there are a few guidelines that we try to follow. -###Creating issues -When creating an issue on GitHub, please complete as many of the following steps as possible to ensure that we can better locate the problem: -* Provide a description of what should happen and what does happen -* If the problem is with an API request, provide the URL that you used (ommitting your API key) -* If the problem is related to geometry, provide a screenshot of the route - -We aim to do a minor update at the end of every month which will add any bug fixes to the live ORS. - -###Creating Pull Requests -When creating pull requests, ensure that you address each item in the checklist before submitting. When an item is not applicable, leave it blank or better yet, use a pait of ~ on each side of the item to show that it is not applicable. -**Only create pull requests against the development branch!** - -###Contributing code -Though there are no concrete rules for code that is contributed, we have a few general styles that should be adopted: -* Always make your code easy to read - methods, variables and classes should all have sensible names that tell you what they are for -* Comments should be used to explain something that needs some background and for JDocs descriptions. They should *NEVER* be used to comment out blocks of code! In general, following the principle of proper naming for variables and methods, your code should be self explanitory and so not need an abundance of comments to explain it. -* Try to make your code extendable with OO techniques (i.e. interfaces) where possible -* Write unit tests -* If your code adds new functionality to the API, make sure to write corresponding API-Tests in the openrouteservice-api-tests subproject. -* Try to keep methods short - it is is almost always better to have multiple short methods that do one thing each rather than one goliath of a method that tries to do everything. -* Keep an eye out for an elusive yet mischievous digital llama hiding in the code - reports say that he appears every now and then and changes a double to a float, just to make things difficult... but then again, maybe a developer created this rumour to cover up their mistakes... no one knows for sure \ No newline at end of file diff --git a/openrouteservice-api-tests/conf/app.config.test b/openrouteservice-api-tests/conf/app.config.test index b38cccd490..86a7f35411 100644 --- a/openrouteservice-api-tests/conf/app.config.test +++ b/openrouteservice-api-tests/conf/app.config.test @@ -408,4 +408,4 @@ stdout: true } } -} \ No newline at end of file +} diff --git a/openrouteservice-api-tests/src/test/java/heigit/ors/services/routing/ParamsTest.java b/openrouteservice-api-tests/src/test/java/heigit/ors/services/routing/ParamsTest.java index 8fcec9ff9b..14a3b305b9 100644 --- a/openrouteservice-api-tests/src/test/java/heigit/ors/services/routing/ParamsTest.java +++ b/openrouteservice-api-tests/src/test/java/heigit/ors/services/routing/ParamsTest.java @@ -754,4 +754,33 @@ public void expectSuppressedWarnings() { .body("routes[0].containsKey('warnings')", is(false)) .statusCode(200); } + + @Test + public void expectSimplifyGeometry() { + given() + .param("coordinates", getParameter("coordinatesShort")) + .param("profile", getParameter("carProfile")) + .param("geometry_simplify", "true") + .when() + .get(getEndPointName()) + .then() + .assertThat() + .body("any { it.key == 'routes' }", is(true)) + .statusCode(200); + }; + + @Test + public void expectIncompatibleParameters() { + given() + .param("coordinates", getParameter("coordinatesShort")) + .param("profile", getParameter("carProfile")) + .param("geometry_simplify", "true") + .param("extra_info", getParameter("extra_info")) + .when() + .get(getEndPointName()) + .then() + .assertThat() + .body("error.code", is(RoutingErrorCodes.INCOMPATIBLE_PARAMETERS)) + .statusCode(400); + }; } diff --git a/openrouteservice-api-tests/src/test/java/heigit/ors/services/routing/ResultTest.java b/openrouteservice-api-tests/src/test/java/heigit/ors/services/routing/ResultTest.java index e3d6222923..e167b4d820 100644 --- a/openrouteservice-api-tests/src/test/java/heigit/ors/services/routing/ResultTest.java +++ b/openrouteservice-api-tests/src/test/java/heigit/ors/services/routing/ResultTest.java @@ -1500,5 +1500,32 @@ public void testAlternativeRoutes() { .body("routes[1].summary.duration", is(1414)) .statusCode(200); } + + @Test + public void testSimplifyHasLessWayPoints() { + + given() + .param("coordinates", getParameter("coordinatesShort")) + .param("profile", "driving-car") + .param("format", "geojson") + .when() + .get(getEndPointName()) + .then() + .assertThat() + .body("features[0].geometry.coordinates.size()", is(75)) + .statusCode(200); + + given() + .param("coordinates", getParameter("coordinatesShort")) + .param("profile", "driving-car") + .param("format", "geojson") + .param("geometry_simplify", "true") + .when() + .get(getEndPointName()) + .then() + .assertThat() + .body("features[0].geometry.coordinates.size()", is(34)) + .statusCode(200); + } } diff --git a/openrouteservice-api-tests/src/test/java/heigit/ors/services/routing/RoutingErrorCodes.java b/openrouteservice-api-tests/src/test/java/heigit/ors/services/routing/RoutingErrorCodes.java index 952ae030d0..c46c6c1e6c 100644 --- a/openrouteservice-api-tests/src/test/java/heigit/ors/services/routing/RoutingErrorCodes.java +++ b/openrouteservice-api-tests/src/test/java/heigit/ors/services/routing/RoutingErrorCodes.java @@ -39,5 +39,6 @@ public class RoutingErrorCodes { public static int EMPTY_ELEMENT = 2008; public static int ROUTE_NOT_FOUND = 2009; public static int POINT_NOT_FOUND = 2010; + public static int INCOMPATIBLE_PARAMETERS = 2011; public static int UNKNOWN = 2099; } diff --git a/openrouteservice/WebContent/WEB-INF/web.xml b/openrouteservice/WebContent/WEB-INF/web.xml index 425c42a6ab..50b8ace288 100644 --- a/openrouteservice/WebContent/WEB-INF/web.xml +++ b/openrouteservice/WebContent/WEB-INF/web.xml @@ -10,6 +10,7 @@ routing /routes + /directions diff --git a/openrouteservice/pom.xml b/openrouteservice/pom.xml index f6db26712d..d6674bb7e8 100644 --- a/openrouteservice/pom.xml +++ b/openrouteservice/pom.xml @@ -171,19 +171,6 @@ Java.net repository http://download.java.net/maven/2 - - osgeo - Open Source Geospatial Foundation Repository - http://download.osgeo.org/webdav/geotools/ - - - - true - - opengeo - OpenGeo Maven Repository - http://repo.opengeo.org - bintray-nitram509-jbrotli bintray @@ -193,6 +180,19 @@ jitpack.io https://jitpack.io + + osgeo + Open Source Geospatial Foundation Repository + http://download.osgeo.org/webdav/geotools/ + + + + true + + opengeo + OpenGeo Maven Repository + http://repo.boundlessgeo.com/main + @@ -273,13 +273,13 @@ com.github.GIScience.graphhopper graphhopper-core - v0.10.1-8 + v0.10.1.12 com.github.GIScience.graphhopper graphhopper-reader-osm - v0.10.1-8 + v0.10.1.12 diff --git a/openrouteservice/src/main/java/heigit/ors/exceptions/IncompatibleParametersException.java b/openrouteservice/src/main/java/heigit/ors/exceptions/IncompatibleParametersException.java new file mode 100644 index 0000000000..fff987dca0 --- /dev/null +++ b/openrouteservice/src/main/java/heigit/ors/exceptions/IncompatibleParametersException.java @@ -0,0 +1,27 @@ +/* This file is part of Openrouteservice. + * + * Openrouteservice is free software; you can redistribute it and/or modify it under the terms of the + * GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 + * of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public License along with this library; + * if not, see . + */ +package heigit.ors.exceptions; + +import heigit.ors.common.StatusCode; + +public class IncompatibleParametersException extends StatusCodeException +{ + private static final long serialVersionUID = 507243355121086541L; + + public IncompatibleParametersException(int errorCode, String param1, String param2) + { + super(StatusCode.BAD_REQUEST, errorCode, "Parameter '" + param1 + "' is incompatible with parameter '" + param2 + "'."); + } +} + diff --git a/openrouteservice/src/main/java/heigit/ors/routing/RouteResultBuilder.java b/openrouteservice/src/main/java/heigit/ors/routing/RouteResultBuilder.java index fb2fd3cfb2..719db5070b 100644 --- a/openrouteservice/src/main/java/heigit/ors/routing/RouteResultBuilder.java +++ b/openrouteservice/src/main/java/heigit/ors/routing/RouteResultBuilder.java @@ -63,7 +63,7 @@ public RouteResult[] createRouteResults(List routes, RoutingRequest return createRouteResultSet(routes.get(0), request, extras); } - public RouteResult createRouteResult(List routes, RoutingRequest request, List extras) throws Exception { + public RouteResult createRouteResult(List routes, RoutingRequest request, List extras) throws Exception { RouteResult result = new RouteResult(request.getExtraInfo()); diff --git a/openrouteservice/src/main/java/heigit/ors/routing/RoutingErrorCodes.java b/openrouteservice/src/main/java/heigit/ors/routing/RoutingErrorCodes.java index 93d85763f5..1a8058e124 100644 --- a/openrouteservice/src/main/java/heigit/ors/routing/RoutingErrorCodes.java +++ b/openrouteservice/src/main/java/heigit/ors/routing/RoutingErrorCodes.java @@ -37,5 +37,6 @@ public class RoutingErrorCodes { public static int EMPTY_ELEMENT = 2008; public static int ROUTE_NOT_FOUND = 2009; public static int POINT_NOT_FOUND = 2010; + public static int INCOMPATIBLE_PARAMETERS = 2011; public static int UNKNOWN = 2099; } diff --git a/openrouteservice/src/main/java/heigit/ors/routing/RoutingProfile.java b/openrouteservice/src/main/java/heigit/ors/routing/RoutingProfile.java index be65dd1629..ae676e3c74 100644 --- a/openrouteservice/src/main/java/heigit/ors/routing/RoutingProfile.java +++ b/openrouteservice/src/main/java/heigit/ors/routing/RoutingProfile.java @@ -804,7 +804,7 @@ public boolean canProcessRequest(double totalDistance, double longestSegmentDist return totalDistance <= maxDistance && wayPoints <= maxWayPoints; } - public GHResponse computeRoute(double lat0, double lon0, double lat1, double lon1, WayPointBearing[] bearings, double[] radiuses, boolean directedSegment, RouteSearchParameters searchParams, EdgeFilter customEdgeFilter, RouteProcessContext routeProcCntx) + public GHResponse computeRoute(double lat0, double lon0, double lat1, double lon1, WayPointBearing[] bearings, double[] radiuses, boolean directedSegment, RouteSearchParameters searchParams, EdgeFilter customEdgeFilter, RouteProcessContext routeProcCntx, Boolean geometrySimplify) throws Exception { GHResponse resp = null; @@ -928,6 +928,8 @@ else if (bearings[1] == null) /*if (directedSegment) resp = mGraphHopper.directRoute(req); NOTE IMPLEMENTED!!! else */ + + mGraphHopper.setSimplifyResponse(geometrySimplify); resp = mGraphHopper.route(req); if (DebugUtility.isDebug()) { diff --git a/openrouteservice/src/main/java/heigit/ors/routing/RoutingProfileManager.java b/openrouteservice/src/main/java/heigit/ors/routing/RoutingProfileManager.java index 7dc4eb5bf7..005139915a 100644 --- a/openrouteservice/src/main/java/heigit/ors/routing/RoutingProfileManager.java +++ b/openrouteservice/src/main/java/heigit/ors/routing/RoutingProfileManager.java @@ -320,9 +320,9 @@ public List computeRoutes(RoutingRequest req, boolean invertFlow, b Coordinate c1 = coords[i]; GHResponse gr = null; if (invertFlow) - gr = rp.computeRoute(c0.y, c0.x, c1.y, c1.x, null, null, false, searchParams, customEdgeFilter, routeProcCntx); + gr = rp.computeRoute(c0.y, c0.x, c1.y, c1.x, null, null, false, searchParams, customEdgeFilter, routeProcCntx, req.getGeometrySimplify()); else - gr = rp.computeRoute(c1.y, c1.x, c0.y, c0.x, null, null, false, searchParams, customEdgeFilter, routeProcCntx); + gr = rp.computeRoute(c1.y, c1.x, c0.y, c0.x, null, null, false, searchParams, customEdgeFilter, routeProcCntx, req.getGeometrySimplify()); //if (gr.hasErrors()) // throw new InternalServerException(RoutingErrorCodes.UNKNOWN, String.format("Unable to find a route between points %d (%s) and %d (%s)", i, FormatUtility.formatCoordinate(c0), i + 1, FormatUtility.formatCoordinate(c1))); @@ -348,7 +348,6 @@ public RouteResult matchTrack(MapMatchingRequest req) throws Exception { public RouteResult[] computeRoute(RoutingRequest req) throws Exception { List routes = new ArrayList(); - //System.out.println("PATCHED!!!!"); //req.setExtraInfo(512); //req.getSearchParameters().setOptions("{\"profile_params\":{\"restrictions\":{\"trail_difficulty\":1}}}"); @@ -397,7 +396,7 @@ public RouteResult[] computeRoute(RoutingRequest req) throws Exception { radiuses[1] = searchParams.getMaximumRadiuses()[i]; } - GHResponse gr = rp.computeRoute(c0.y, c0.x, c1.y, c1.x, bearings, radiuses, c0.z == 1.0, searchParams, customEdgeFilter, routeProcCntx); + GHResponse gr = rp.computeRoute(c0.y, c0.x, c1.y, c1.x, bearings, radiuses, c0.z == 1.0, searchParams, customEdgeFilter, routeProcCntx, req.getGeometrySimplify()); if (gr.hasErrors()) { if (gr.getErrors().size() > 0) { diff --git a/openrouteservice/src/main/java/heigit/ors/routing/RoutingRequest.java b/openrouteservice/src/main/java/heigit/ors/routing/RoutingRequest.java index 5113c072a8..1dc3519d46 100644 --- a/openrouteservice/src/main/java/heigit/ors/routing/RoutingRequest.java +++ b/openrouteservice/src/main/java/heigit/ors/routing/RoutingRequest.java @@ -25,6 +25,7 @@ public class RoutingRequest extends ServiceRequest private DistanceUnit _units = DistanceUnit.Meters; private String _language = "en"; private String _geometryFormat = "encodedpolyline"; + private Boolean _geometrySimplify = false; private RouteInstructionsFormat _instructionsFormat = RouteInstructionsFormat.TEXT; private Boolean _includeInstructions = true; private Boolean _includeElevation = false; @@ -87,6 +88,10 @@ public void setGeometryFormat(String geometryFormat) { _geometryFormat = geometryFormat; } + public boolean getGeometrySimplify() { return _geometrySimplify; } + + public void setGeometrySimplify(boolean geometrySimplify) { _geometrySimplify = geometrySimplify; } + public String getLanguage() { return _language; } diff --git a/openrouteservice/src/main/java/heigit/ors/services/routing/requestprocessors/RoutingRequestParser.java b/openrouteservice/src/main/java/heigit/ors/services/routing/requestprocessors/RoutingRequestParser.java index c248571af4..fbbc5623d8 100644 --- a/openrouteservice/src/main/java/heigit/ors/services/routing/requestprocessors/RoutingRequestParser.java +++ b/openrouteservice/src/main/java/heigit/ors/services/routing/requestprocessors/RoutingRequestParser.java @@ -21,6 +21,7 @@ import heigit.ors.exceptions.ParameterValueException; import heigit.ors.exceptions.StatusCodeException; import heigit.ors.exceptions.UnknownParameterValueException; +import heigit.ors.exceptions.IncompatibleParametersException; import heigit.ors.localization.LocalizationManager; import heigit.ors.routing.RouteExtraInfoFlag; import heigit.ors.routing.RouteInstructionsFormat; @@ -187,6 +188,10 @@ public static RoutingRequest parseFromRequestParams(HttpServletRequest request) req.setGeometryFormat(value); } + value = request.getParameter("geometry_simplify"); + if (!Helper.isEmpty(value)) + req.setGeometrySimplify(Boolean.parseBoolean(value)); + value = request.getParameter("instructions"); if (!Helper.isEmpty(value)) req.setIncludeInstructions(Boolean.parseBoolean(value)); @@ -222,8 +227,12 @@ public static RoutingRequest parseFromRequestParams(HttpServletRequest request) } value = request.getParameter("extra_info"); - if (!Helper.isEmpty(value)) + if (!Helper.isEmpty(value)) { + if (req.getGeometrySimplify()) + throw new IncompatibleParametersException(RoutingErrorCodes.INCOMPATIBLE_PARAMETERS, "extra_info", "geometry_simplify"); + req.setExtraInfo(RouteExtraInfoFlag.getFromString(value)); + } value = request.getParameter("attributes"); if (!Helper.isEmpty(value))