📜 ⬆️ ⬇️

How we drew road shields on the map

At the beginning of the 20th century, signs began to appear on the main public roads (further, shield) with numbers. Displaying them on the map is not a mandatory attribute, but is important from the point of view of usability. People who see signs in reality, it is easier to navigate the terrain. It also gives the map a “local flavor”. It should be noted that the same road can have several plates at the same time. This is due to the fact that road routes may overlap each other.


In OsmAnd, we decided to draw a shield as close as possible to reality using the data from OpenStreetMap.



OpenStreetMap and generic notation


OSM does not have a generally accepted and widely used way of describing road shields. Road routes are described using relation (“relations”) such as route = road. But, first, they are well made only for countries with developed infrastructure and / or with a strong local OSM community. Secondly, they usually do not contain information about the color and shape of the shield. Therefore, along with OSM data, we used various open sources, including Wikipedia and the site sites.google.com/site/roadnumberingsystems/home/countries .
')
The basic idea of ​​using the information available in OSM is that we take a road relation and, depending on the network tag, assign a color and shape to the shield, the color of the number (ref). Just in case, we limit the scope to some region or country. But it only works for a limited set of countries. Also, an approach was often used which consisted in parsing ref (road number) and extracting from it a prefix or some sequence inside.


Based on this and the country containing the road, the conclusion is made about the characteristics of the road shield. The third method: some countries have a road numbering system by number range. For example: from 0 to 99 - regional road, blue shield with white text; 100-499 - national road, green shield with yellow text, etc. Sometimes a combined approach was used. Also, when creating an OsmAnd map, information about priorities of shields is recorded there, depending on the road numbering system of specific countries.
In the OSM wiki, there is a ref: color tag that is used around 5,000 times in the world. Most often it is found in Spain - one of the few countries where none of the above methods for determining the shield parameters work. In this case, the background color is taken directly from this tag.

USA


In the US, the situation is as follows. Road relations are mapped very well, but the characteristics of the shields have to be determined differently: there are US Interstate highways, US State highways, secondary highways, territorial highways, state highways, county highways, which mainly differ in the number of separators (colons) in the network tag value.
image

The situation is complicated by the fact that almost every state uses its own shields for state highways. Taking into account the huge number of them, we decided to draw these shields in a simplified way.
imageimageimageimage
Examples of Road shield from different states: North Dakota, Idaho, Minnesota, Florida.

Many roads have modifiers: spur, truck, business, alternate, etc. In OsmAnd, they are displayed above the shield itself in a small rectangle - just like on real-life signs.


Canada


In Canada, each state uses its own road numbering system. The exception is Transcanada Highways, for which the unambiguous tagging method is not accepted in OSM. The problem was solved completely only by adding a verification of the name of the road to the content of the text “transcanada” in different variations.



Europe




European countries for the most part do not use curly shields, such as in the USA. Instead, rectangular tablets are widely used. The exceptions are Hungary, Romania, the Netherlands (stadsroutes, city roads), highways of Germany, Greece and Italy. The type of road is indicated by the background color as well as the text color.
European car routes have the prefix E and from one to three white numbers on a green rectangular background. These routes are to some extent similar to the inter-regional routes of the United States (Interstate Highways). A sign of such a route in OSM is the relation route = road and the network = e-road tag. During data processing, it turned out that the relationship of some of these routes did not contain the network = e-road tag, which was eliminated.
image

Other countries


There are countries (Lebanon, Mongolia) where it turned out to be problematic to establish what kind of colors and forms in reality should be shields. It seems that in these countries road shields are not used at all.
Israel, South Korea, Saudi Arabia and some other countries use shields that are not used anywhere else.


The main map style on openstreetmap.org, mapnik, does not use data from road relations. This fact, together with historical reasons, led to the fact that, as a rule, the ref tag is affixed to all participants in this relationship. At the same time, a significant part of the roads is not included in road relations and the value of the ref tag is the only data source. Consequently, we cannot drop the ref tag and rely only on road relations. Instead, we, in the absence of an appropriate road relation, convert the ref tag to the internal data representation used to store tags derived from road relations. This makes it possible to simplify the card style code.
At the time of publication of the article OsmAnd supports road shields almost worldwide. The exception is part of Africa and part of Central America.

Source: https://habr.com/ru/post/301320/


All Articles