Repository navigation
Add support for (single) via-way restrictions - #2689
Conversation
|
@aibear-huang if you are looking for via-way restriction handling it would be very helpful if you could help testing this branch. All via-way restrictions with a single via, from- and to-member (which is the vast majority) should be working. Those with multiple via-ways will be ignored so far, but this can probably also be fixed soon after this PR. |
|
Btw here is the list of turn restriction warnings printed with this PR for the current OSM file. I'll update this from time to time: There are about 33000 such warnings and about 25000 of these are due to missing from/via/to members. In many cases these restrictions got broken when the member ways/nodes were edited after the restrictions were created. I opened an issue in iD for this: openstreetmap/iD#9346 |
lukasalexanderweber
left a comment
There was a problem hiding this comment.
Nice work! :) I just marked some stuff I noticed. It's nice to see how someone "deeper" inside Graphhopper implements this and I learn a lot from it.
|
Thanks for including the comments into your code!
Maybe for more real world testing it would be nice to have another gist with all working via way restrictions? It would be helpful for e.g.
or
or having a closer look on multi via way examples.
Should I have a look on that? Or are there other todos I can help with? |
Yes, I think it would be helpful to have some kind of corpus of turn restriction cases that we can test the implementation against (now but also in the future). Like the list of examples you started in one of your comments, and that I continued above with explicit links to some routes with the expected distance (assuming the restriction works correctly), but something that is more organized and that we can run automatically. So far my workflow was something like this: a) Run the OSM import and print some logs to find certain kinds of turn restrictions, This repository already contains a relatively large OSM file for the city of Leipzig: https://github.com/graphhopper/graphhopper/blob/master/map-matching/files/leipzig_germany.osm.pbf An alternative could be searching for interesting turn restrictions and then extracting mini-OSM file using the 'export' functionality on openstreetmap.org for example. Then again, it should be sufficient to simply create artificial restriction situations (maybe resembling some we found in the wild) in RestrictionSetterTest. These will be easier to debug anyway and as long as the 'conversion' code works correctly this is the part that is more interesting to test anyway. Maybe the goal should be to have only a few tests that use real OSM data and include the full OSM import, and in turn more such low level tests. But maybe first of all we should just continue our list of 'interesting' turn restrictions manually and sort it a bit. I'd be interested in 'only' via-way restrictions specifically, because so far I wasn't entirely sure how they should be treated. We could use our import to print a list of these (or the same for some other kind like multi-via way), or figure out a query that does the same on overpass-turbo.eu (I tried this briefly, but didn't have the patience to study the query language).
Yes, of course if you want to push this forward please go ahead. In case I find more time to work on this PR I will rather focus on finishing the single via-way case. Note that there is still an issue for multi-via ways even in step 3). To fix this, maybe we can make the assumption that via-ways always have only two tower nodes (for these this should actually be the case and we can warn/ignore otherwise)?
Right now I think a list of 'interesting' via-way restrictions of type 'only' would be quite useful. Also to make sure there aren't (many) cases where handling the via-way turn restrictions makes the routing worse. For example this could be the case if restrictions were mapped incorrectly (or there is a bug on our side). |
|
Ok, so why not specify requirements on a Via Way Turn Restriction dataset which we can filter for some representative examples: We would need
have you any other requirements?
I don't find the inline comment you mean, could you give me a hint? |
here: 77a939a
No, your list looks like a good start. And maybe keep track of the OSM file with timestamp you used. |
I see the problem, but I don't understand if this is "only" a problem of finding the correct order of the via ways or what this has to do with tower nodes / 1:1 mapping. |
I just thought it could be easier if we can assume a 1:1 mapping, but probably it doesn't really make a difference. However, I think if there are multiple edges for a via way we should stop/warn anyway. I think I fixed this problem here: 8729462 |
|
I checked another ~20 via-way 'only' restrictions (from bottom to top of your list). Looks good. I think this is ready to merge. |
Co-authored-by: Lukas Weber <[email protected]>
|
@lukasalexanderweber I added you to the contributors list, thanks a lot for your help! |
|
Unfortunately, there seems to be some kind of snapping or access issue still: This car wash can neither be used by cars nor is it excluded from the network: http://localhost:8989/maps/?point=52.508133%2C13.2807&point=52.507974%2C13.280731&profile=car&layer=OpenStreetMap Update: This is probably not related to this PR and only happened, because I was using the |
|
... but there is another thing that is still missing: We need to keep the .. or actually not as long as the post-import modifications affect the real and artificial edges in the same way. |
| // Important note: To deal with via-way turn restrictions we introduce artificial edges in OSMReader (#2689). | ||
| // These are simply copies of real edges. Any further modifications of the graph edges must take care of keeping | ||
| // the artificial edges in sync with their real counterparts. So if an edge attribute shall be changed this change | ||
| // must also be applied to the corresponding artificial edge. |
There was a problem hiding this comment.
@karussell Unfortunately, this is a bit sketchy. The problem is that we copy some edges to implement the turn restrictions, but later on the edge attributes might be changed again, namely by the elevation interpolation and (probably not so critical) the urban density calculation. As it stands I think everything should be fine, because these post import steps will affect the real edges just the way they affect the artificial edges.
An alternative could be to either: a) introduce the turn restrictions at the very end of the import (and do not allow any modifications afterwards / freeze the graph directly after, or b) do an extra 'syncing' step at the end where we use the artificialEdgesByEdges map to copy the edge attributes to the artificial edges once more. Or do you have a better idea?
There was a problem hiding this comment.
a) could also allow graph sorting when turn costs are enabled, because the turn cost storage would be written only after the graph was sorted. But I'm not even sure the graph sorting is useful?
There was a problem hiding this comment.
Or would it be feasible to store some kind of 'reference' for one edge that points to the properties of another? This would save some memory (but not a lot), and more importantly the artificial edges would stay in sync with the real ones automatically.
There was a problem hiding this comment.
No idea and no strong opinion on the solution (yet).
We could directly point to the same geometry (incl. elevation) and KV Storage. Then we would need to sync the flags only.
Or would it be feasible to store some kind of 'reference' for one edge that points to the properties of another?
Doing this via the KV storage would be fine as only a few selected edges would use this.
There was a problem hiding this comment.
Doing this via the KV storage would be fine as only a few selected edges would use this.
Yes, but it would only be useful if it could be used transparently, i.e. calling something like edge.get(whateverEnc) should automatically return the referenced edges value.
I'd say we keep this as it is for now.
thanks for this :) and thanks for being a timely and constructive reviewer! |
* force max_slope and average_slope to create SlopeCalculator * remove that motorroad=yes influences speed or is used as highway tag, graphhopper#2329 * CurvatureCalculator: if included in tests that don't set artificial tags * Treat segments tagged as "lcn=yes" the same way as a bicycle route relation with "network=lcn". (graphhopper#2693) See https://wiki.openstreetmap.org/wiki/DE:Tag:lcn%3Dyes * update maps * Fix rare NPE in map matching * Add support for (single) via-way restrictions (graphhopper#2689) * Remove outdated comment and rule * Revert "Remove outdated comment and rule" This reverts commit 03e64da. * value can be no for oneway:bicycle but also for cycleway:right:oneway, fixes graphhopper#2694 * Replace com.wdtinc MVT library with no.ecc (graphhopper#2698) * Upgrade to JTS 1.19.0, fix graphhopper#1803 * minor * Support ";" access delimiter for bikes (graphhopper#2676) One example is vehicle = agricultural;forestry Now we block also such combinations for bikes. * Update maps, geocoding is disabled now * Remove LegacyProfileResolver (graphhopper#2679) * removed legacy parameters * fixed error message * add comment * Update README.md * Copy no.ecc code, remove no.ecc repository, graphhopper#2698 * Create edges even if flags are empty (graphhopper#2700) * Add OSM way ID encoded value (graphhopper#2701) * remove Bike2WeightTagParser again (graphhopper#2668) * fix changelog graphhopper#2703 * Use explicit ignore list for highway values during OSM import (graphhopper#2702) * Revert "Use explicit ignore list for highway values during OSM import (graphhopper#2702)" This reverts commit ef2937f. * split buildEncodingManagerAndOSMParsers method * Revert "Revert "Use explicit ignore list for highway values during OSM import (graphhopper#2702)"" This reverts commit 97579b6 * Revert "Revert "Revert "Use explicit ignore list for highway values during OSM import (graphhopper#2702)""" This reverts commit daccf5f. * Revert "Revert "Revert "Revert "Use explicit ignore list for highway values during OSM import (graphhopper#2702)"""" This reverts commit b9b1ed4. * Allow ignoring vehicle tag parser name * Add tests to demonstrate that moped=yes etc. does not allow driving on a footway * Keep ways tagged as man_made=pier or platform=railway for foot/bike * Footway encoded value (graphhopper#2707) * Add ignored highways to benchmark.sh * do not throw an error if Java config is used without config file * Revert "do not throw an error if Java config is used without config file" This reverts commit c872780. * Revert ignored highways for now * Use GitHub Actions for Maven Central deployment too (graphhopper#2709) * use github actions to deploy to maven central * use private key directly to avoid escaping problems * run only when tagged; renamed * specify key id * use more recent plugin versions * different badge * github actions: ignore tags * include branches required * include (2nd) test build to be sure * ignoring tags is the default if branches is specified * matches really all tags, https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet * force test failure * Revert "force test failure" This reverts commit 85b38fe. * include bus into TransportationMode enum, graphhopper#2710 * log the exception, not just the message * mapmatching: put visited nodes into log event * github packages: set permissions * open a few things up * vehicle -> profile * remove unused non-private abstract method * Implement edge-to-edge routing for unidir AStar * Revert "Revert ignored highways for now" This reverts commit 03978b8. * Fix test * Put back test (?) * Rename publish-github-actions.yml * Enable LM for small benchmark map and A* measurements for small map * Remove name, turnCostEnc and getAccess from VehicleTagParser (graphhopper#2713) * make CustomWeighting.Parameters public, graphhopper#2717 * distance_influence should not get a default value if no value is specified (graphhopper#2716) * distance_influence should only be sent to server when explicitly specified and the default value of 70 makes this impossible * fix changelog * changelog * CustomModel.getDistanceInfluence: allow null values * remove comment * comment * make CustomWeighting.Parameters constructor public too, graphhopper#2717 * pt: push back mapdb * remove hasDistanceInfluence, graphhopper#2716 * i18n: updated, graphhopper#2721 * cleanup of ElevationProvider, fixes graphhopper#2642 * average_speed path detail: avoid infinity value (or max JS floats) near bridges etc, graphhopper#2636 * fixup: pt: push back mapdb * bug fix for graphhopper#2716 * Add GH version to client-hc * Fix * make custom areas available in custom models (graphhopper#2725) * make it possible to use all custom areas in all custom models * minor comment regarding ID * set feature.id from feature.properties.id for our countries.geojson, related to graphhopper#2725 * getResourceAsStream implicitly creates a FileSystem required when the file is in the jar, https://stackoverflow.com/q/25032716/194609 * specially handle "NO_EDGE"; fixes graphhopper#2723 * Extract method * avoid rounding down small speed (graphhopper#2726) * Maxspeed fix (graphhopper#2727) * clean up speed and maxspeed handling * bug fix * for bike we have to pick maximum max_speed * fix yet another bug * Do not check if edge flags are empty before handling node tags * Return void from TagParser#handleWayTags * Remove some explicit edge flag usage * EncodingManager: initializer config is only needed when building * Fix * Use EV factory * Test access and speed instead of just flags.isEmpty() for foot and bike parsers (graphhopper#2728) * i18n: adding no_NO and updating pl_PL while at it (graphhopper#2730) * areas: don't enforce empty properties, use separate check for areaID, related to graphhopper#2725 * increase point_hint limit from 100 to 170, fixes graphhopper#2732 * Moving Bokmål locale to the correct nb_NO (graphhopper#2731) * i18n: moving Bokmål locale to the correct nb_NO * i18n: fix a missing placeholder in translation and add nb_NO to translationmap * i18n: lexicographical order, graphhopper#2731 * support for foot:backward and forward, fixes graphhopper#2565 * minor docs update * move area/EV name check into relevant classes and fix graphhopper#2735 * fix annoying error message if path details are missing * remove comment (hmm-lib is no longer used) see graphhopper@789580c * Split vehicle tag parsers into access, speed and priority (graphhopper#2738) * Use multi-threading for subnetwork preparation (graphhopper#2737) * bike: always use 4km/h for railway=platform, discussion in graphhopper#2728 * use custom_models.directory consistent naming regarding custom_areas.directory * Report rank (by distance to network) of chosen snaps * Graph speed measurement * Remove block area (graphhopper#2741) * Make sure waypoints are not removed during path simplification (graphhopper#2742) * use FeatureCollection instead of String,Feature Map (graphhopper#2734) * use FeatureCollection instead of String,Feature Map for CustomModel.areas * issue * remove comment * adapt json and docs * fix doc * cleanup * use GH maps from custom_area_feature_collection branch * fix tests * fix graphhopper#2339 (graphhopper#2736) * removed unused method (Polygon, graphhopper#2741) * more mapmatching statistics * Remove no-longer existing extraProfiles field from maps config * i18n: updated sv_SE (graphhopper#2748) * Revert "removed unused method (Polygon, graphhopper#2741)" This reverts commit 95565fd. * Revert "Remove block area (graphhopper#2741)" This reverts commit aa71dc2 * Allow small tolerance for waypoint consistency check, graphhopper#2742 * apparently some kind of rounding (?) is going on between the path point list and the snapped waypoint coordinates so the values are only equal with a certain accuracy * without this fix the GH server can respond with an internal server error (500) and our tests did not cover this so far * handle 'permit' like 'private', fixes graphhopper#2712 (graphhopper#2749) * client-hc: add hints to response * PathDetailsBuilderFactory: avoid modifying request * client-hc: return hints as text * move to more recent java versions * Add request transformer hook to RouteResource * i18n: updated tr and fix typo in nb_NO (graphhopper#2750) * minor fix * client-hc: use Helper.toObject * readme: use jar from maven central * Improve error message when using another vehicle than the ones used for the import, fix graphhopper#2758 * CustomModelParser: more explicit verification of method calls, fixes graphhopper#2743 * remove StringEncodedValue support from custom model due to insufficient usage/testing * Extend Heading Documentation (graphhopper#2714) * Minor changes for heading docs, graphhopper#2714 * Make sure LM approximation is never worse than beeline (graphhopper#2756) * remove hike vehicle (graphhopper#2759) * hike removal * use roads vehicle to allow roads with hike_rating * ensure that hike can use higher sac_scale values than foot, i.e. roads vehicle must be used * Remove block_area (again) (graphhopper#2755) * Fix snap issue (graphhopper#2752) * PathDetailsBuilderFactory: avoid modifying request * snap on edge is sometimes too close to tower node leading to inconsistencies due to GHPoint.equals check in QueryOverlayBuilder * correction only necessary for Position.EDGE * fix test setup * fix repeated test * Add test and comment * snapping must be consistent to avoid test failure * consistent * fix comment --------- Co-authored-by: easbar <[email protected]> * Extract createSolver methods * add parsers only once if multiple bike/foot profiles * Extract test method * Allow adding node-based CH for profiles with turn costs * protected * further lower priority for sidewalk=no, especially for highways not in safe and preferred set, graphhopper#847 * fix bug in conditional handling, graphhopper#1326 * fix comment * clean up custom models and documentation, graphhopper#2659 * foot vehicle: important fix regarding barrier nodes, bug introduced in graphhopper#2738 * Revert "Allow adding node-based CH for profiles with turn costs" This reverts commit b2b955d. * fix bike2.json reference in config example * try older maven * improve documentation for windows * make mvn deploy to Github Actions working again with a special option instead of a version downgrade * Use way point indices instead of intervals in ResponsePath, graphhopper#2742 * the intervals are only really needed for the simplification, so create them there * Clarify test: instruction for two-lane (!) u-turn * use custom weighting, since this should be most common now * algorithm should not matter (this is tested elsewhere) * make get+setTags of ReaderElement consistent * fix follow up snap issue (graphhopper#2769) * Update snapped point when changing the closest node * update wayindex and position too * update query distance too --------- Co-authored-by: easbar <[email protected]> * Allow skipping the creation of ReaderNodes/Ways/Relations for pbfs, skip nodes in first pass of OSM import (graphhopper#2770) * Show u-turn instruction for plain u-turns (graphhopper#2767) * 7.0 release - change readme * use 8.0-SNAPSHOT * Add path details for the time, distance and weight of the single legs (graphhopper#2768) * A*: set weight of visited path explicitly * changelog: set release date * Reuse the polygon BBox (graphhopper#2685) Co-authored-by: Thomas Butz <[email protected]> * Make use of node tags like 'highway' or 'crossing' (graphhopper#2705) * Pass all node tags to edge handlers * Remove node tag count (was only used for analysis) * crossing EV (graphhopper#2706) * add tests; fix traffic_signalS; remove zebra as same as uncontrolled; include proposed tags https://wiki.openstreetmap.org/wiki/Proposed_features/Highway_crossing_cleanup * fix * fix tests * minor fix * minor typo * node tag whitelist; use get not put in removeTag * include node tags handling for road_access and fords (road_environment) * mark only node tags of barrier edge as 'split_node' * avoid stream and collect * minor further perf tune * make barrier edge explicit via tag * simplify handleNodeTags * Remove artificial gh:split_node tag and use long hash set instead * minor rename * use EdgeKVStorage for node tags storage * rename EdgeKVStorage to KVStorage as also used to temporarily store node tags for import * log more infos about node tags; no compact necessary due to KVStorage; limit pointer of KVStorage to positive numbers for now * rename method to handleBarrierEdge * fix taggednodecount method * node tags for the barrier edge should be identical, i.e. use the ref instead of a copy --------- Co-authored-by: Peter <[email protected]> * changelog * pt: remove hardcoded use of FastestWeighting to avoid problems with foot-priority-0 links * New "backward_xy" variable notation in custom models (graphhopper#2760) * initial backward_car_access impl * test+fix when used in CustomModel * new test regarding the addition order of (bike) VehicleTagParser and selected other TagParser * New signature for encoded values and tag parsers (graphhopper#2740) * Add static creators for enum encoded values * Rename createIntAccess -> createEdgeIntAccess * bike profile should allow reverse oneway roads and set walking speed (graphhopper#2774) * bike: allow reverse oneways; mark them as 'get off bike' and slow down to 4km/h * fix speed issue * fix test * create bike_oneway that is always true, except for the reverse direction of a oneway road * fix tests * minor cleanup * initial backward_car_access impl * test+fix when used in CustomModel * use modified bike profile * include custom_models/bike.json in integration test * for bike test reverse access of oneways; use jackson allow comments feature * revert changes to jackson parsing with comment * include bike_priority in bike.json * make custom models simpler via setting bike speed and priority unconditionally at the beginning * add get_off_bike parser after bike_access * comment * fixed typo * re-add test * imports * minor revert to master for 2 files * Never treat a highway tagged with cycleway:both as oneway for bicycles (graphhopper#2776) * include permit->private handling in road_access, graphhopper#2712, graphhopper#2749 * add 4 more enc values to config description * avoid get_off_bike problem for path, fixes graphhopper#2777 * fix bug in bike custom model * Improve bicycle handling: Now prioritise cycleways with SLIGHT_PREFER (graphhopper#2785) * Improve bicycle handling: Now prioritise cycleways with SLIGHT_PREFER, fixes graphhopper#2784 * Add priority handling support for "cycleway:both" i "lane" * Add priority handling support for "cycleway=opposite_track" as discussed in graphhopper#2786. * custom_model_files arrays (graphhopper#2787) * replace custom_model_file with custom_model_files array * fix changelog * certain conditional tags allow to ignore max_weight (graphhopper#2788) * add max_weight_except encoded value; use conditional tagging to set hgv and max_weight; add maxweightrating:hgv parsing for max_weight * include maxweightrating:hgv for MaxWeightExceptParser too * Apply suggestions from code review Co-authored-by: otbutz <[email protected]> * Update MaxWeightExceptParser.java * Update OSMMaxWeightParser.java * fix import --------- Co-authored-by: otbutz <[email protected]> * Check cycleway access tags (graphhopper#2786) * Check cycleway access * Test cycleway access * Test with non-preferred highway type * Update contributors * removed parser options block_private and block_fords (graphhopper#2780) * removed block_private and block_fords * fix issue number * exclude private for all models under custom_models * make intendedValues and others read-only * adjust benchmarks for graphhopper#2780 * removed motorcycle vehicle (graphhopper#2781) * removed block_private and block_fords * fix issue number * removed motorcycle vehicle * minor fixes * minor change * move curvature part outside of motorcycle * fix config-example.yml * hike and cargo_bike: exclude private roads * custom models: list priority first for no particular reason * minor tweak * Revert "removed parser options block_private and block_fords (graphhopper#2780)" This reverts commit be7209b. * A*: infinite approximation means the target is unreachable * Make the MiniGraphUI working again. (graphhopper#2793) * Use separate logger for OSM warnings * osm_warning -> osm_warnings * update graphhopper maps to latest * maps: avoid URI too long for bigger custom models * avoid IllegalStateException if duplicate path detail * bike custom model: fix roundabout * Prefer bicycle_road/cycleway (graphhopper#2790) * Prefer bicycle roads and cycle streets * Handle pushing section priority * Add unittests * Simplify check * Move test into dedicated method * Update changelog * i18n: update da_DK (graphhopper#2794) * Improve surface parser (graphhopper#2792) * Move synonyms into Surface * Add support for unhewn_cobblestone * Handle surface subtypes * Treat pebblestone as gravel * Treat grass_paver as grass * Add support for wooden surfaces * Test all synonyms * Check subtypes in dedicated test * Update changelog * avoid config mistakes * Add timeout_ms parameter for routing requests (graphhopper#2795) * Upgrade to dropwizard 2.1.6 (graphhopper#2653) * upgrade to dropwizard 2.1.1 * try 2.1.4 * latest 2.1.6 --------- Co-authored-by: easbar <[email protected]> * resurrect appveyor * appveyor: revert part of the change * upgrade commons-io + junit-bom + osmosis-osm-binary * bike: differentiate between bad highways (graphhopper#2796) * bike: there is a difference between avoid highways like trunk and secondary * add one more test for secondary * avoid creation of values() * reduce calling PriorityCode.getValue, code review in graphhopper#2796 * minor test rename * Update nl and cz translations (graphhopper#2799) * Update nl and cz translations * Fix nl translation * upgrade janino to latest version 3.1.9; remove our workaround for 3.1.6 and below * cleanup of EnumEncodedValue (graphhopper#2800) * remove custom toString in EnumEncodedValue and avoid calling Enum::values() * API JSON response must not change * custom toString necessary for Country and HazmatTunnel * fix imports * always use unix LF, related graphhopper#2791 * Add root editorconfig (graphhopper#2791) * Update CONTRIBUTING.md * Prefer bigger roads for racebike (graphhopper#2802) * Make the MiniGraphUI working again. * Improve priority handling for race bikes as discussed in graphhopper#2796 * Adopt expected Monaco test result for race bike profile * changelog for graphhopper#2796 and graphhopper#2802 * This is a 400 user error, not an ERROR in the logging sense * Simplify WaySegmentParser.Builder * Release some memory earlier after reading OSM * profile name, not vehicle name * Fix * Add check for pillar node overflow * OSMNodeData.nodeKVStorage: add missing create * ferry: hgv=yes allows car even if car tagging is missing * B-tree: Make space for values configurable (graphhopper#2814) * initial working version * make to and from long more clear * make it working for negative keys and values * nextLong(bounds) only for more recent JDKs * fix javadoc * Use long for pillar node id stack variables * use long where it could be a pillar or tower node * simulate large amount of pillar nodes * remove second check for pillar nodes * use 0 as start again * minor * make empty value configurable * changes for review --------- Co-authored-by: easbar <[email protected]> * clarify foot access parser (graphhopper#2801) * De-prioritise steps for bicycles (graphhopper#2804) * De-prioritise steps for bicycles, fixes graphhopper#2803 original discovery Also use MIN_SPEED for highway=steps in the mtb profile * Don't explicitly call setHighwaySpeed for Mountainbike for values which are used in BikeCommonAverageSpeedParser * De-prioritise steps for bicycles to BAD * Also initialize the avoidHighwayTags with BAD just in order to avoid confusion. * Remove steps from the avoidHighwayTags map * i18n: updated tr (@ihsanguldur) and added new translation for Kazakh kz * differentiate travel time betas for access vs egress * Make sure directed edge filter receives real edge * public CustomModelParser.createWeightingParameters * hike model: allow private tags that are for motor vehicles only, adds tests of the model, fixes graphhopper#2820 * Update README.md * Set empty custom model in custom profile constructor (graphhopper#2821) * Update deploy.md * number formatting: use ENGLISH instead of FRENCH as it sometimes causes missing symbols in terminals * Try latest JDK 20 (graphhopper#2789) * try jdk 20 * try again * Process callables GHUtility.runConcurrently in batches to save memory (graphhopper#2828) * Process callables in batches to save memory * changelog * Do not re-use Executorservice * Overhauled Moving Average Elevation Smoothing (graphhopper#2772) * first implementation which is validated with unit tests no focus on performance, code beauty or documentation. used for validation and comparison with some real world test areas * overwrite previous averaging algorithm, added unit tests and made window size configurable * explain unit test * incorporate pr feedback from otbutz * use IntDoubleHashMap to avoid object unboxing * extended contributor list * pr feedback: rename config to be more consistent * pr feedback: code formatting * pr feedback: having a dedicated class for each implementation and tests * avoid incorrect urban_density classification for the USA (graphhopper#2832) * initial workaround for graphhopper#2829 * use enum * Fix QueryGraph#getEdges * previously we got an error when we tried to call getEdgeIteratorState with edge IDs running up to QueryGraph#getEdges() * Country subdivision (state) (graphhopper#2830) * initial version to include subdivision in Country enum * minor fix * use correct PR * GHUtility cleanup * allow country comparison via getAlpha3 method * minor fixes * clarify iso codes with the help of wikipedia * use alpha2 for custom model to make it more consistent * minor fixes * try separate state instead of country extension * minor enhancement * use complete use for getStateCode * fix * use getter instead of create * remove TODO * for now this method is used only once, so avoid overhead * shorter * Use ForkJoinPool for concurrent processing (graphhopper#2833) * residential should not be ignored but treated as tertiary, graphhopper#2832 * Remove BitUtilBig (graphhopper#2811) * Fix interchanged parameter names in bit util * removed BitUtilBig * cleanup --------- Co-authored-by: Peter <[email protected]> * update GH maps to latest * Clean up country/state selection logic, graphhopper#2830 * default speed limits (graphhopper#2810) * initial version * less output * maxspeed tag vs max_speed name * less logging * use urbanDensity in replaceFunction and explicitly set maxspeed only if UNSET_SPEED * added tests * replace CountryRule.getMaxSpeed with LegalDefaultSpeeds lib * tricky. thinking... * lane support * surface support * residential roads have the same limits in Germany * do not forget the reverse speed * use same version as osm-legal-default-speeds-jvm * something is strange with dropwizard tests as they require an explicit dependency on kotlin-stdlib (not kotlin-stdlib-jdk8) * force okhttp and osm-legal-default-speeds-jvm to use both more recent but same kotlin 1.8.0 * use more recent okio with recommended kotlin 1.6.20; seems to work for osm-legal-default-speeds-jvm too * make createWeightingParameters public * separate storage and parser for default max speed and only combine this after import with the maxspeed tag from OSM * separate close * default speed library does not support maxspeed:forward and :backward tags * test regarding living_street is now useless at that level * comment * fix problematic forward/backward case * store osm max_speed and temporarily the default urban+rural from library to improve max_speed afterwards * reduce overhead a bit and force type * grow array on get too * storage: we need a tiny offset * okhttp 4.11.0 has cleaner deps * reduce tag count and cache speeds to reduce overhead, see westnordost/osm-legal-default-speeds#7 * configure preliminary GHDirectory * added maxweight * avoid default-maxspeed library while OSM parsing * Revert "avoid default-maxspeed library while OSM parsing" This reverts commit 8b07594. * fix setup to use the same GHDirectory instance to avoid problems with missing directory etc * consider walk as 6kmh * don't interpret country-dependent speeds in stringToKmh * call computeIfAbsent for cache; convert maxspeed into kmh before import; fix test for stringToKmh * fix comment * added description to config * add max_speed_estimated boolean encoded value * use speedlib v1.3 * use statecode to feed speedlib * updated legal_default_speeds.json * residential should not be ignored but treated as tertiary, graphhopper#2832 * comment * Update maps * typo * bike: remove hazmat handling, fixes graphhopper#2840 * bug fix for UK speed limit * use unlimited speed constant for DEU * Fix compilation * Fix matrix test * Fix tests * Fix compilation * Fix matrix profiles and add tests * Fix merge conflict --------- Co-authored-by: Peter <[email protected]> Co-authored-by: ratrun <[email protected]> Co-authored-by: easbar <[email protected]> Co-authored-by: Michael Zilske <[email protected]> Co-authored-by: OlafFlebbeBosch <[email protected]> Co-authored-by: Lukas Weber <[email protected]> Co-authored-by: otbutz <[email protected]> Co-authored-by: Thomas Butz <[email protected]> Co-authored-by: bt90 <[email protected]> Co-authored-by: Robin <[email protected]> Co-authored-by: Christoph Lingg <[email protected]>
This PR adds support for OSM restriction relations that use a single via-way (compared to the restrictions that use a via-node, that we support so far). There is an open issue for this here:
#446#3155, and @lukasalexanderweber also pushed this forward (see discussion in #2673) . Let me first explain the code in this PR. The restriction handling is done as follows:When we import the OSM file we simply collect all restriction relations in a list. This is feasible as there are only about 1.7mio restriction relations for the planet file currently. We also maintain a mapping between all the OSM way IDs that are used in these restriction relations and the edges these ways are split into. Remember, each OSM way might be split into multiple graph edges during the import. So far we stored the reverse mapping (edge->way), which is easier to store because it is a 1:1 mapping, but storing the way->edge* mapping isn't a big problem either and is handled in the
WayToEdgesMapclass here. The reason I need this mapping is that I am converting each restriction relation from the 'OSM representation' (given in terms of OSM IDs) to the 'graph representation' (given in terms of edge IDs). We'll see why in a moment.When the OSM import is finished we have the complete list of all the restriction relations and can now add the according turn restrictions to the graph. This can be done independently from the OSM reading process and is thus easier to maintain and test.
Next comes the conversion from the OSM to the graph representation. This is done in
RestrictionConverter#convertin two steps:a) We extract the relation members in the
extractMembersfunction where we also print warnings about various OSM tagging mistakes (and ignore the corresponding relations)b) We figure out which of the (possibly many) edges that were created for the from/via/to way members are the ones that are actually part of the turn restriction to be created. This is not entirely trivial, usually OSM ways need to be split at the via members, because otherwise the restriction would be ambiguous. But the ways could still be split into multiple edges at junctions other than the junction the restriction targets. In this step we are thus also able to warn about these kinds of mapping errors and ignore the relation.
The previous steps can all be done independently from the vehicle type, but the following will be done separately for each vehicle type.
First we parse the relation tags using one of the
RelationTagParsersgiven inOSMParsers. This gives us the flexibility to decide which OSM tags should be considered for the turn restrictions and write different turn cost encoded values for example. The result of this parsing is basically just eitherNO(=the turn(s) corresponding to the given relation shall be restricted),ONLY(=all turns except those corresponding to the relation shall be restricted) ornull` (=given relation shall not affect this vehicle type/relation tag parser).Finally the restrictions are passed to the
RestrictionSetterwhich does the actual modification of the routing graph. This can easily be done without any OSM related stuff, so we can write unit tests that just create a bare graph, define some restrictions and check if they work correctly. Basically steps 1)-4) are concerned with all the OSM parsing and step 5) is hardly related to OSM at all. I thought this is important, or at least very nice to have because we can focus on actually implementing the restrictions (which isn't that trivial, see below) without thinking about the OSM parsing in this step.Currently there are the following limitations:
Otherwise, I think this implementation is complete and I tested it visually for some restrictions like the following (I took most of these examples from #2673.
relation restriction-type, example route
2468010 no_u_turn http://localhost:8989/maps/?point=49.37924%2C8.563404&point=49.378762%2C8.562984&profile=car&layer=OpenStreetMap 222m
3567246 no_u_turn http://localhost:8989/maps/?point=49.329264%2C8.537622&point=49.329905%2C8.537087&profile=car&layer=OpenStreetMap 602m
5614305 no_u_turn http://localhost:8989/maps/?point=49.331166%2C8.536742&point=49.330506%2C8.536883&profile=car&layer=OpenStreetMap 899m
5739275 no_u_turn http://localhost:8989/maps/?point=49.298051%2C8.635106&point=49.297951%2C8.635046&profile=car&layer=OpenStreetMap 862m
7636822 only_left_turn http://localhost:8989/maps/?point=48.995991%2C8.343731&point=48.996479%2C8.345591&profile=car&layer=OpenStreetMap 192m
8409418 no_u_turn http://localhost:8989/maps/?point=48.856593%2C8.247488&point=48.856651%2C8.246936&profile=car&layer=OpenStreetMap 438m
11290869 no_u_turn http://localhost:8989/maps/?point=49.416%2C8.758752&point=49.416074%2C8.758813&profile=car&layer=OpenStreetMap 1000m
13335861 no_left_turn http://localhost:8989/maps/?point=49.002511%2C8.425032&point=49.003946%2C8.423683&profile=car&layer=OpenStreetMap 520m
13447603 no_left_turn http://localhost:8989/maps/?point=49.596021%2C8.46136&point=49.596531%2C8.462894&profile=car&layer=OpenStreetMap 355m
2602528 no_u_turn http://localhost:8989/maps/?point=49.556722%2C8.646987&point=49.556858%2C8.646931&profile=car&layer=OpenStreetMap 583m
2602528 no_u_turn http://localhost:8989/maps/?point=49.556722%2C8.646987&point=49.557818%2C8.648691&profile=car&layer=OpenStreetMap 228m
2602529 no_u_turn http://localhost:8989/maps/?point=49.556186%2C8.648994&point=49.556405%2C8.648734&profile=car&layer=OpenStreetMap 474m
2602530 no_u_turn http://localhost:8989/maps/?point=49.557452%2C8.648543&point=49.557373%2C8.648712&profile=car&layer=OpenStreetMap 401m
2602530 no_u_turn http://localhost:8989/maps/?point=49.556805%2C8.647604&point=49.556966%2C8.647838&profile=car&layer=OpenStreetMap 471m
2821562 no_u_turn http://localhost:8989/maps/?point=49.013704%2C8.35326&point=49.013462%2C8.353155&profile=car&layer=OpenStreetMap 345m
2920827 no_u_turn http://localhost:8989/maps/?point=48.995009%2C8.383025&point=48.995142%2C8.382807&profile=car&layer=OpenStreetMap 380m
2920827 no_u_turn http://localhost:8989/maps/?point=48.995474%2C8.384312&point=48.995064%2C8.382721&profile=car&layer=OpenStreetMap 148m
3399136 only_right_turn http://localhost:8989/maps/?point=49.483605%2C8.44781&point=49.482221%2C8.449843&profile=car&layer=OpenStreetMap 592m
1891360 only_left_turn http://localhost:8989/maps/?point=50.760142%2C7.022396&point=50.759247%2C7.023499&profile=car&layer=OpenStreetMap looks like a mapping error? or what does only_left_turn mean here?
10684723 only_straight_on http://localhost:8989/maps/?point=49.486035%2C7.727314&point=49.485682%2C7.726962&profile=car&layer=OpenStreetMap 401m
1300205 only_straight_on http://localhost:8989/maps/?point=53.567212%2C9.847676&point=53.567466%2C9.847521&profile=car&layer=OpenStreetMap 515m
How does the actual restriction handling work?
Via-node restrictions are handled in a similar or almost the same way as before. Maybe the only difference is that we now use a way->edge instead of an edge->way mapping. Also I no longer skip restrictions of turns that are anyway impossible, because of one-ways. I think this should be handled separately, as we might for example allow routing through one-ways in the opposite direction, but still do not like to violate turn restrictions.
Via-way restrictions are handled by adding an artificial copy of the via edge and applying turn restrictions at both ends of the via edge. It is important to:
a) only add a single artificial edge for each real edge, even when there are multiple restrictions or restrictions for different vehicles using the same via-way.
b) restrict turns between artificial from/to edges and the artificial via-edge, because of 'overlapping' turn restrictions (see the code and tests for more details)
c) restrict turns between a real and the corresponding artificial edge
For a recent Germany OSM extract and using the car+bike profile the number of turn cost entries increased from 131291 to 166403 between master and this branch.
todo: