Okay, you want to modify OsmAnd's routing for the "Truck" profile in Lithuania to avoid roads with ref tags from A1 to A19. This is done by adding a rule to your custom routing.xml file that applies a penalty to these specific roads when routing with the Truck profile.
Here's how to do it:
1. Locate or Create Your routing.xml File:
- OsmAnd uses
routing_default.xml internally. You should not edit this file directly as it can be overwritten by updates.
- You need to create a custom
routing.xml file in your OsmAnd data directory.
- The location varies by Android version and how OsmAnd was installed, but it's typically within the
files or data folder inside the OsmAnd main folder (e.g., /sdcard/Android/data/net.osmand/files/routing.xml or /sdcard/OsmAnd/data/routing.xml).
- If
routing.xml doesn't exist, copy routing_default.xml to routing.xml in the same directory. You'll need a file explorer app for this. Make a backup of the original routing.xml or routing_default.xml before editing.
2. Edit the routing.xml File:
- Open the
routing.xml file you copied/created with a text editor.
- Find the section for the "truck" profile. It will look something like
<profile name="truck">.
- Inside this
<profile name="truck"> section, but before the closing </profile> tag, add the following rule:
<!-- Rule to avoid A1-A19 roads in Lithuania for trucks -->
<rule>
<!-- Check if the road reference matches A1-A19 -->
<tag name="ref" value_regex="A(1[0-9]|[1-9])"/>
<!-- Apply a significant penalty to strongly discourage this road -->
<!-- Adjust the 'value' if you want stronger or weaker avoidance -->
<penalty value="2000"/>
</rule>
3. Configure OsmAnd to Use Your Custom routing.xml:
- Open the OsmAnd app.
- Go to
Menu (the 3 horizontal lines) -> Settings (the gear icon).
- Select
App profiles.
- Choose your
Truck profile.
- Scroll down to
Navigation settings and tap on it.
- Scroll down to
Routing settings and tap on it.
- Find
Routing configuration and tap on it.
- Select
routing.xml (this tells OsmAnd to use your custom file instead of the default).
4. Test the Routing:
- Plan a route in Lithuania using the Truck profile that you expect would normally use one of the A1-A19 roads.
- OsmAnd should now try to find a route that avoids these roads due to the penalty. If an alternative route exists, it will prefer it. If the destination is only reachable via one of these roads, it might still use a short section, but it will try to minimize its use.
Important Notes:
- Back Up: Always back up your
routing.xml before making changes.
- Syntax: XML is strict about syntax. Make sure your added rule is inside the correct profile tags and all tags are closed correctly. A small error can make the file unreadable by OsmAnd.
- Penalty Value: You can adjust the
penalty value. If OsmAnd is still using A1-A19 roads too often, increase the value (e.g., to 5000 or even 10000). Be careful with extremely high values (like 100000) as they can sometimes lead to very illogical long detours or routing failures if no reasonable alternative exists.
- OsmAnd Updates: Major OsmAnd updates could potentially change the structure of
routing_default.xml. If your custom routing.xml stops working after an update, you might need to copy the new routing_default.xml and re-apply your custom rule to it.
- Complexity: Custom routing can be complex. Test your changes thoroughly.
By following these steps, you will have successfully configured OsmAnd to prioritize avoiding Lithuanian A1-A19 roads for your truck profile.