Introduction

Many questions and issues are about the map data in the application. This article tries to explain some technical details of internal data format and data processing. It can be interesting for developers as well as non-developers, but this article requires knowledge and familiarity with the OSM data structure.
All the OsmAnd data is in 'obf' files. 'obf' files have a complex structure and can consist of multiple parts. The 'obf' file is in essence a "container" format containing multiple data blocks.
Currently obf files can contain (multiple) POI parts, (multiple) Map parts, (multiple) Transport parts and (multiple) Adress parts. This list of "funtional" parts can be extended in the future.
To combine, split off (extract) or delete some parts from the obf file, you can use 'binary_inspector' console tool provided with OsmAndMapCreator. As a side note: It is not recommended at all to have/use 'obf' files of more than 2 Gb.

POI, Transport part

Map part

Address part

1. How does mapcreator generate its list of all places that will appear later in OsmAnd's offline address search? What objects are used in detail for that? What nodes with a place tag are included, and which are excluded?
All places that are visible in OsmAnd as Cities are taken from nodes that have the tag place (wiki.openstreetmap.org/wiki/Place). Currently used are city, town, suburb, village, hamlet.

2. How does mapcreator handle an area polygon that is given via a relation with boundary=administrative? How do you associate a place given as a node with its boundary, when it is present in the OSM data?
Simply saying: it works by name currently.
Mapcreator tries to visit all boundaries and creates a closed (!) boundary from a relation or from separated ways and associate these with one of the name(s). After that it tries to match the place with a boundary name by way of an algorithm. Also there is an additional check that the boundary contains the place.
If there are many boundaries of different admin_level with the same name (containing each other, like district/town/region having the same name) the highest admin_level with exact matching will be chosen.
TODO: More details should be here (about districts of the city ...)

3. Where is the documentation about which admin level is the correct one to build an association to a certain place node? Which countries prefer which admin level(s)?
Currently the admin_level is an association between admin_level relation. The admin_centre is not used. This because only few relations provide that information.

4. How does mapcreator know which street belongs to which place? Are there different cases when a boundary polygon is given and when there is none?
There are many strategies to check and they are prioritized :
The last part is very inaccurate and that's why many streets get attached to a neighbor city. At mapcreator's preferences you have five more settings for street suffixes, zoom, smoothness and rendering ... what are the detailed effects that you can achieve with each of them? Are those settings actually used?

Tools

Address Part - workflow

There are these relations: city -> 0..1 boundary boundary -> 0.. city (used to define suburb of city)

1. iterate all Osm NODEs and register as cities if the tag = PLACE is present.

2. iterate all RELATIONs and WAYs with type=boundary and register all boundaries

2.1 Many boundaries can be associated with one city.

Here is the order how the most important boundary is taken and associated with the city:

3. If the city doesn't have any assigned boundary then all boundaries that doesn't have center cities and contain that city will be checked and the boundary with admin_level >=7 will be assigned.

4. For each boundary, make a list of cities that are in it.

5. iterate all RELATIONS and find addresses

(http://wiki.openstreetmap.org/wiki/Relations/Proposed/Postal_Addresses)

Register street (street, location of street (los), cities):

for each city:

6. iterate all NODES then WAYS then RELATIONS (iterate main entity)

6.1 find ways - interpolations:

6.2 for any entity, find addr:housenumber and addr:street tag (can be also the interpolation nodes again!!!)

6.3 for way with tag - name & tag - highway, but without addr:housenumber and addr:street:

Note: this might be ways for cars, with names (highway, or so)

6.4 Each relation with "postal_code", store for later use.

Note: this does not include the address:type = pc and addr:postalcode !!!

7. process post codes

8. write the index:

TODO

--