Query param down to edge level

Hi,

How can i pass in a new query parameter and get the value down to the CustomWeighting level, specifically when I’m calculating the weight?

I want to avoid passing the query parameter down through all the functions and would rather upon building the request this could be applied to all edge states or a globally readable value at runtime?

@Override
public double calcEdgeWeight(EdgeIteratorState edgeState, boolean reverse) {
double priority = edgeToPriorityMapping.get(edgeState, reverse);

    if (priority == 0) {
        return Double.POSITIVE_INFINITY;
    }

Thanks,
Brandon

The recommended way is to create a new encoded value (add it to DefaultImportRegistry or extend it) and then you can use the encoded value directly in a custom model to prefer/exclude/avoid it.

1 Like

Thanks for the reply, when i make a request for a route, every i request a route the value in the custom model will be different, will that be fine in a custom model?

Currently i use the basic car.json and this is loaded in once, if i passed in a custom modal, how can i also use the CH?

When i turn off CH and pass in a custom model through the request lets say “time_band: 1” when i get down to the CalcWeight on the edge, the lookup only contains the values from the car.json custom model and I’m unable to see my new “time_band”

Thanks

how can i also use the CH?

For CH you cannot change the request. But without CH you can submit a custom model and it will be merged with the server-side custom model. If you need fast and flexible requests you can try LM.

When i turn off CH and pass in a custom model through the request lets say “time_band: 1”

You need to specify the encoded value e.g. in the condition of the priority statement list. E.g. the following will exclude road segments with time_band==1

"priority": [
  { "if" : "time_band == 1", "multiply_by": "0"
]