Weird behaviour of Vehicle with very limited possible ways

Hello. I need to add RelationTagParser which would parse all relations with tag “piste” and modify access for all ways inside this relation.
I tried to duplicate code from OSMFootNetworkTagParser. My relation parser looks like this:

class PisteRelationParser(private val pisteNordicEnc: BooleanEncodedValue, relConfig: EncodedValue.InitializerConfig) : RelationTagParser {
    val transformerPisteEnc = SimpleBooleanEncodedValue(getKey("piste", "piste_relation"))

    init {
        transformerPisteEnc.init(relConfig)
    }

    override fun handleRelationTags(relFlags: IntsRef, relation: ReaderRelation) {
        val relIntAccess = IntsRefEdgeIntAccess(relFlags)
        val type = relation.tags.get("piste:type") as? String
        if (type == "nordic") {
            transformerPisteEnc.setBool(false, -1, relIntAccess, true)
        }
    }

    override fun handleWayTags(edgeId: Int, edgeIntAccess: EdgeIntAccess, way: ReaderWay, relationFlags: IntsRef) {
        val relIntAccess = IntsRefEdgeIntAccess(relationFlags)
        val isNordicPiste = transformerPisteEnc.getBool(false, -1, relIntAccess)
        pisteNordicEnc.setBool(false, edgeId, edgeIntAccess, isNordicPiste)
    }
}

All I do in other TagParsers is checking this boolean value and treat it as correct way:
Speed:

  val isNordicRelation = nordicRelation.getBool(false, edgeId, edgeIntAccess)
        if (isNordicRelation) { setSpeed(false, edgeId, edgeIntAccess, 5.0) }

Access:

  val isNordicRelation = nordicRelation.getBool(false, edgeId, edgeIntAccess)
        if (isNordicRelation) {
            accessEnc.setBool(false, edgeId, edgeIntAccess, true)
            accessEnc.setBool(true, edgeId, edgeIntAccess, true)
        }

Priority:

val isNordicRelation = nordicRelation.getBool(false, edgeId, edgeIntAccess)
        if (isNordicRelation) {
            priorityWayEncoder.setDecimal(false, edgeId, edgeIntAccess, PriorityCode.getValue(PriorityCode.BEST.value))
        }

I made prints and I am sure that correct ways are marked as “isNordicRelation”, but routing doesn’t always work. If I limit reading relation to only one (for example this) then it will work:

   val relIntAccess = IntsRefEdgeIntAccess(relFlags)
        val type = relation.tags.get("piste:type") as? String
        if (type == "nordic" && (relation.id == 8269871L)) {
            transformerPisteEnc.setBool(false, -1, relIntAccess, true)
        }

But if I allow to read one more relation (like this):

  val relIntAccess = IntsRefEdgeIntAccess(relFlags)
        val type = relation.tags.get("piste:type") as? String
        if (type == "nordic" && (relation.id == 8269871L || relation.id == 3900859L)) {
            transformerPisteEnc.setBool(false, -1, relIntAccess, true)
        }

Then only one of those relations will work. What is suprising that if I print “isNordicRelation” in TagParsers then ways from both relations will have correct value!!! I think that reading relation and passing its data to Ways works correctly, but something is wrong when graph is limited to small number of possible ways?

Everything is tested on Graphhoper 8.0

To simplify issue I tried to just allow Vehicle to move on two unrelated ways (one way from one piste:type = nordic relation).

Ways are:

If I allow Vehicle to use both, only one of them will be used. If I allow Vehicle to use just one of them, then it always works. By allowing to use I mean averageSpeed = 5, access = true, priority = BEST

I don’t know if this is related, by if I print ways in TagParsers then one of those routes is parsed once and second twice, with different edge_distances:

115065516 [(trail_visibility, excellent), (mtb:scale, 0), (access, yes), (smoothness, very_bad), (surface, unpaved), (incline, down), (tracktype, grade3), (highway, track), (key_values, []), (node_tags, [{}, {}, {}]), (edge_distance, 51.271298670622826), (point_list, (49.5816782,20.009467,840.0), (49.5818727,20.0088344,831.0)), (country, POL), (country_state, -), (custom_areas, [com.graphhopper.routing.util.CustomArea@501dd1d2])]

162698139 [(highway, track), (surface, compacted), (tracktype, grade1), (key_values, []), (node_tags, [{}, {}, {}, {}, {}, {}, {}, {}, {}, {}]), (edge_distance, 176.68171474418656), (point_list, (49.6348068,20.3085229,832.0), (49.634599,20.3078907,837.0), (49.6344341,20.307089,840.0), (49.6344564,20.3067554,840.0), (49.6344989,20.306569,832.0), (49.6345773,20.3063448,832.0), (49.634618,20.3062922,832.0)), (country, POL), (country_state, -), (custom_areas, [com.graphhopper.routing.util.CustomArea@501dd1d2])]

162698139 [(highway, track), (surface, compacted), (tracktype, grade1), (key_values, []), (node_tags, [{}, {}]), (edge_distance, 36.53459662572716), (point_list, (49.634618,20.3062922,832.0), (49.6349017,20.3060363,832.0)), (country_state, -), (country, POL), (custom_areas, [com.graphhopper.routing.util.CustomArea@501dd1d2])]

Error is MultiplePointsNotFoundException

Can this be related to “minNetworkSize”? Is this possible to change minNetworkSize depending on vehicle (or profile)? I guess it is not safe for whole Graph to set it for 1 or 0 to disable it? Network size is measured in number of edges?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.