# Avoiding unlit streets

**URL:** <https://ask.openrouteservice.org/t/avoiding-unlit-streets/195>\
**Category:** openrouteservice\
**Created:** [January 13, 2019, 1:15pm UTC](https://ask.openrouteservice.org/t/avoiding-unlit-streets/195 "2019-01-13T13:15:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![samcrawford](https://ask.openrouteservice.org/user_avatar/ask.openrouteservice.org/samcrawford/32/56_2.png) [@samcrawford](https://ask.openrouteservice.org/u/samcrawford)\
**Post date:** [January 13, 2019, 1:15pm UTC](https://ask.openrouteservice.org/t/avoiding-unlit-streets/195/1 "2019-01-13T13:15:31Z")

</div>

Hello,

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!

Thanks,

Sam

---

<div class="post-metadata">

**Author:** ![andrzej](https://ask.openrouteservice.org/user_avatar/ask.openrouteservice.org/andrzej/32/10_2.png) [@andrzej](https://ask.openrouteservice.org/u/andrzej)\
**Post date:** [January 18, 2019, 3:31pm UTC](https://ask.openrouteservice.org/t/avoiding-unlit-streets/195/2 "2019-01-18T15:31:47Z")

</div>

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](https://taginfo.openstreetmap.org/keys/lit#values) 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!

Cheers,  
Andrzej

---

<div class="post-metadata">

**Author:** ![samcrawford](https://ask.openrouteservice.org/user_avatar/ask.openrouteservice.org/samcrawford/32/56_2.png) [@samcrawford](https://ask.openrouteservice.org/u/samcrawford)\
**Post date:** [January 18, 2019, 4:27pm UTC](https://ask.openrouteservice.org/t/avoiding-unlit-streets/195/3 "2019-01-18T16:27:04Z")

</div>

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,

Sam
