8000 `TraversalPermissionLabeler` errors when tag value is a semicolon `;` · Issue #969 · conveyal/r5 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
TraversalPermissionLabeler errors when tag value is a semicolon ; #969
Open
@tilltnet

Description

@tilltnet

Describe the bug
When using r5r to create a street network from a *.osm.pbf file where one or more cyclepath:right=; (value is just a semicolon, nothing else), r5 throws an ArrayIndexOutOfBoundsException. I experienced this for an OSM file for Florida (US).

To Reproduce
Steps to reproduce the behavior:

  1. Download any *.osm.pbf file where at least one way has the tag/value pair cyclepath:right=;. For example: GeoFarbrik's US Florida file.
  2. Attempt to create network.dat file from the osm file; i.e. in r5r:
options(java.parameters = '-Xmx10G')
library(r5r)
setup_r5("network_bundle/")
  1. Error:
No raster .tif files found. Using elevation = 'NONE'.
21:29:50.080 [main] ERROR com.conveyal.r5.streets.StreetLayer - Continuing to load but ignoring generalized costs due to exception: java.lang.RuntimeException: All ways are expected to have generalized cost tags. Missing: slope_1:forward
java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
	at com.conveyal.r5.labeling.TraversalPermissionLabeler$Label.fromTag(TraversalPermissionLabeler.java:519)
	at com.conveyal.r5.labeling.TraversalPermissionLabeler.applyDirectionalPermissions(TraversalPermissionLabeler.java:206)
	at com.conveyal.r5.labeling.TraversalPermissionLabeler.getPermissions(TraversalPermissionLabeler.java:106)
	at com.conveyal.r5.streets.StreetLayer.makeEdgePair(StreetLayer.java:1180)
	at com.conveyal.r5.streets.StreetLayer.loadFromOsm(StreetLayer.java:338)
	at com.conveyal.r5.streets.StreetLayer.loadFromOsm(StreetLayer.java:232)
	at org.ipea.r5r.Network.NetworkBuilder.createNetwork(NetworkBuilder.java:113)
	at org.ipea.r5r.Network.NetworkBuilder.createR5Network(NetworkBuilder.java:64)
	at org.ipea.r5r.Network.NetworkBuilder.checkAndLoadR5Network(NetworkBuilder.java:39)
	at org.ipea.r5r.R5RCore.<init>(R5RCore.java:237)

Expected behavior
network.dat is created without an error or an error message is produced that calls out the problematic tag/value pair in the osm file.

Possible Fix
The error message calls out TraversalPermissionLabeler.java:519:

    if (tag.contains(";")) {
                tag = tag.split(";")[0];
            }

When testing if a tag value contains a semicolon another thing to test for is if there are any other characters in the value, to make sure that the value can be split on the ; and indexing the result won't lead to an out-of-bounds error.

Desktop:

  • OS: macOS, Ubuntu
  • Version: current

Additional context
This seems to me like an issue that is best fixed on the r5 side of things. Please let me know if you think that this is an issue with r5r and I will post this over there.

Workaround

Remove offending tags from osm file with osmfilter.

osmconvert florida-latest.osm.pbf -o=florida.o5m
osmfilter florida.o5m --drop-tags="*=;" -o=florida-fixed.o5m
osmconvert florida-fixed.o5m -o=florida-fixed.osm.pbf

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0