Avoiding unlit streets


I’d like to extend ORS to support a preference for avoiding unlit streets. Note that I do not want to avoid them altogether, but I want there to be a big penalty for unlit streets.

From looking at the code, I think I will need to create something like the AvoidHillsWeighting, as this still allows hills to be traversed, but assigns them a significant penalty. The other “avoid” options seem to be much more binary.

Am I correct in my reading of the code here? Or if you have alternative suggestions, I am all ears!



Dear Sam,

first of all, many thanks for your interest in contributing to ORS!

You’re right, you will need to create a dedicated weighting similar to AvoidHillsWeighting. Apart from this routing part, you will also need to encode the value of the OSM key lit in the graph preprocessing phase. The key could be probably simplified to a binary yes/no flag (defaulting to no if unspecified), so I could image defining it in AvoidFeatureFlags and extending WayCategoryGraphStorageBuilder accordingly.

Let me know if you have any further questions, I’m happy to assist you!


Thanks! I’ve already implemented it since my post, and it’s working well! Your suggestion of encoding it as a WayCategory is probably simpler (at the moment I’m generating a whole new storage type), so I might take a look at that before contributing it back.

Thanks again,


1 Like