Feature Avoidance¶
Customize routes by avoiding specific road features like tunnels, ferries, toll roads, and more to meet operational requirements, safety policies, or cost constraints.
🎯 What is Feature Avoidance?¶
Feature avoidance allows you to exclude specific types of roads or features from your routes. This is essential for:
- Safety compliance (hazardous materials)
- Cost control (avoiding tolls)
- Operational policies (no ferries)
- Driver preferences (avoiding tunnels)
- Seasonal considerations (avoiding seasonal closures)
📋 Available Features to Avoid¶
Supported Features¶
| Feature | Description | Common Use Case |
|---|---|---|
tunnel |
Underground passages | Hazardous materials, claustrophobia |
ferry |
Water crossings by boat | Time constraints, cost |
toll_road |
Roads requiring payment | Budget constraints |
seasonal_closure |
Roads closed seasonally | Winter/summer routing |
controlled_access_highway |
Limited access highways | Local deliveries, safety |
💡 Basic Usage¶
Avoiding Single Features¶
{
"mode": "car",
"origin": [41.0082, 28.9784],
"destination": [41.0150, 28.9850],
"avoid_features": ["toll_road"],
"minimize": "distance"
}
Avoiding Multiple Features¶
{
"mode": "truck",
"origin": [41.0082, 28.9784],
"destination": [41.0150, 28.9850],
"avoid_features": ["tunnel", "ferry", "toll_road"],
"minimize": "duration"
}
🎯 Use Cases¶
1. Hazardous Materials Transport¶
Safety-critical routing for dangerous goods:
{
"mode": "truck",
"origin": [41.0082, 28.9784],
"destination": [41.0150, 28.9850],
"vehicle": {
"length": 1200,
"hazardous_goods": ["flammable", "explosive"]
},
"avoid_features": ["tunnel", "controlled_access_highway"],
"minimize": "distance"
}
Why? - Tunnels pose explosion risks - Highways may have restrictions on hazmat vehicles
2. Budget-Conscious Routing¶
Minimize costs by avoiding toll roads:
{
"mode": "car",
"origin": [41.0082, 28.9784],
"destination": [41.0150, 28.9850],
"avoid_features": ["toll_road"],
"minimize": "distance"
}
Benefits: - Zero toll costs - Predictable route expenses - May discover efficient alternative routes
3. Time-Reliable Routing¶
Avoid ferries for predictable scheduling:
{
"mode": "truck",
"origin": [41.0082, 28.9784],
"destination": [41.0150, 28.9850],
"avoid_features": ["ferry"],
"minimize": "duration"
}
Why? - Ferry schedules can cause delays - Weather may cancel ferry service - Loading times add unpredictability
4. Local Delivery Routing¶
Stay on local roads for neighborhood deliveries:
{
"mode": "car",
"origin": [41.0082, 28.9784],
"waypoints": [
[41.0090, 28.9790],
[41.0095, 28.9795]
],
"destination": [41.0100, 28.9800],
"avoid_features": ["controlled_access_highway"],
"minimize": "distance"
}
Benefits: - Easier access to residential areas - More exit points for multiple stops - Lower speeds safer for frequent stops
5. Winter Routing¶
Avoid seasonally closed mountain passes:
{
"mode": "truck",
"origin": [41.0082, 28.9784],
"destination": [41.0150, 28.9850],
"avoid_features": ["seasonal_closure"],
"alternatives": 1,
"minimize": "duration"
}
🔧 Best Practices¶
1. Match Avoidance to Requirements¶
Only avoid features that are actually problematic:
// Good - Specific safety requirement
{
"vehicle": {
"hazardous_goods": ["explosive"]
},
"avoid_features": ["tunnel"]
}
// Avoid - Unnecessary restrictions
{
"avoid_features": ["tunnel", "ferry", "toll_road", "controlled_access_highway"]
}
2. Consider Trade-offs¶
Avoiding features often increases: - Total distance - Travel time - Route complexity
// Compare with alternatives
{
"avoid_features": ["toll_road"],
"alternatives": 1, // See toll route for comparison
"tolls": true,
"currency": "EUR"
}
3. Combine with Vehicle Specs¶
For comprehensive truck routing:
{
"mode": "truck",
"vehicle": {
"length": 1200,
"height": 350,
"hazardous_goods": ["corrosive"]
},
"avoid_features": ["tunnel", "ferry"],
"minimize": "distance"
}
4. Regional Considerations¶
Some features are more relevant in certain areas:
// Coastal/island areas
{
"avoid_features": ["ferry"]
}
// Mountainous regions
{
"avoid_features": ["tunnel", "seasonal_closure"]
}
// Urban toll zones
{
"avoid_features": ["toll_road"]
}
📊 Impact Comparison¶
Example: Toll Road Avoidance¶
With Tolls:
Without Tolls:
Analysis: - +7 km (+15% distance) - +13 min (+37% time) - -€5.50 savings
Example: Tunnel Avoidance (Hazmat)¶
Allowing Tunnels:
Avoiding Tunnels:
Analysis: - +10 km (+26% distance) - +9 min (+28% time) - Enhanced safety for hazardous materials
⚠️ Important Considerations¶
Route Availability¶
Avoiding too many features may result in: - No available route - Very long detours - Impractical routing
// May be too restrictive
{
"avoid_features": [
"tunnel",
"ferry",
"toll_road",
"controlled_access_highway",
"seasonal_closure"
]
}
Regional Variations¶
Feature availability varies by region: - Urban areas: Many toll roads - Islands: Ferries may be unavoidable - Mountains: Tunnels provide shortest routes - Rural areas: Fewer feature options
Legal Requirements¶
Some avoidances are legal requirements: - Hazmat vehicles must avoid certain tunnels - Oversized loads may be prohibited on some highways - Local regulations may mandate specific routes
Performance¶
More avoidance = more constraints = longer calculation time
🎯 Decision Framework¶
Should I Avoid This Feature?¶
Tunnels¶
✅ Avoid if: - Transporting hazardous materials - Driver has claustrophobia - Company safety policy
❌ Don't avoid if: - Adds significant distance - No safety concerns - Time is critical
Ferries¶
✅ Avoid if: - Tight schedule requirements - Avoid schedule uncertainty - Vehicle not ferry-compatible
❌ Don't avoid if: - Significant detour required - Ferry is fastest option - Schedule is reliable
Toll Roads¶
✅ Avoid if: - Budget constraints - Many free alternatives available - Short route distance
❌ Don't avoid if: - Time savings significant - Few alternatives exist - Toll cost is justified
Controlled Access Highways¶
✅ Avoid if: - Multiple local stops - Residential delivery area - Vehicle restrictions apply
❌ Don't avoid if: - Long-distance travel - Time is priority - Highway is most direct
📈 Cost-Benefit Analysis¶
Example: Toll Avoidance¶
import requests
# Calculate both routes
routes = [
{"avoid_features": [], "tolls": True},
{"avoid_features": ["toll_road"], "tolls": False}
]
for config in routes:
payload = {
"tasks": [{
"origin": [41.0082, 28.9784],
"destination": [41.0150, 28.9850],
"currency": "EUR",
**config
}]
}
response = requests.post(url, json=payload)
data = response.json()
# Compare costs
route = data["tasks"][0]["routes"][0]
# ... calculate and compare
🚀 Complete Example¶
Multi-Feature Avoidance¶
import requests
API_BASE_URL = "https://api.flio.ai"
ROUTE_ENDPOINT = "/solver/route"
API_KEY = "YOUR-API-KEY"
payload = {
"tasks": [
{
"mode": "truck",
"origin": [41.0082, 28.9784],
"destination": [41.0150, 28.9850],
"vehicle": {
"length": 1200,
"height": 350,
"hazardous_goods": ["flammable"]
},
"avoid_features": ["tunnel", "ferry"],
"alternatives": 1, # Get route with features for comparison
"minimize": "distance",
"tolls": True,
"currency": "EUR"
}
]
}
url = f"{API_BASE_URL}{ROUTE_ENDPOINT}?api_key={API_KEY}"
response = requests.post(url, json=payload)
if response.status_code == 200:
data = response.json()
print("Route calculated avoiding tunnels and ferries")
print("Safe for flammable materials transport")
📚 See Also¶
Feature avoidance enables safe, compliant, and cost-effective routing. Choose avoidance features based on specific requirements, not general preferences.