Technical articles

Creating a consistent user experience

Usability of our complex features is decisively enhanced by wording and good translations, and as much consistency as possible. It is worth thinking about many expressions or sentences for a little while :-)

Please try to adhere to the following points and conventions:

(1) Consistent Wording:

Use only _one_ expression for a certain feature, do not mix two possible expressions. Examples:

(2) Authoring Text:

(3) A note about rendering: The appearance our default renderer creates has been tested at a multitude of map locations, with many devices, and under very different light conditions. "Spontaneous improvements" to the renderer are almost always questionable, may at least require more investigation and testing than you may think ... :-)

Back to top

How to translate OsmAnd - we need your assistance!

We very much appreciate your help providing translations for OsmAnd! Provideing translations is not very complicated, the preferred way to provide string transaltions is described here: translate.osmand.net.

Additional Information

Please use these described methods rather than publishing changes to strings.xml as issues or e-mailing them to the OsmAnd group.

Thank you for your help !

Q&A

Q: Which strings should I translate?*

A: In the strings.xml the strings look like:

Save as GPX track
Translate only the 'Save route as GPX track' part. In the swing_messages.properties the strings looks like:
IndexCreator.INDEX_CITIES=Indexing cities...
Translate only the right part 'Indexing cities...'


Q: I don't want to create github or googlecode account, can I still post you the file?*

A: Yes, you can email the file, but still for us is the best way to use the github, it is easy.


Q: How should I check what has changed in the _english strings.xml_ ?*

A: New strings are added always on the top of the file. You can download the english file, your file and use some utility like pspad, or vim, or whatever you like to compare them for the new keys. You can also *blame* the english file to see the last line modifications

Back to top

Documentation of OsmAnd Settings Development

Hardy's documentation on OsmAnd UI/Settings development

2011-12
2012-09

Back to top

How to install the development environment
Introduction

The installation is not very difficult, here are the things you are required :

Details

Java 1.6 is required. Download jdk to get source code of base java classes

Android SDK is required. You will need two versions 1.6 and 2.2

(Optional) Android NDK is required if you want to change and compile native code.

You can download Eclipse here. Note: run the eclipse with more memory, 32 bit around 512MB, 64 bit around 1GB. Android tools take lot of memory to compile the project!

You will need Android Development Tools (ADT) plugin for Eclipse.

(Optional) You can install EGit, Git plug-in for eclipse. Alternatively you can stick to some other Git tool.

To see results how you are working you also need map data :

Install repo utility:

 $ curl http://commondatastorage.​googleapis.com/git-repo-downloads/repo > ~/bin/repo
 $ chmod a+x ~/bin/repo

Check out the project from repository:

 
   $ repo init -u git://github.com/osmandapp/OsmAnd-manifest.git
   $ repo sync

You can make your fork on github and work with it and do pull-requests to publish your work in OsmAnd's repository.

Import OsmAnd (from /platforms/android) and OsmAndMapCreator (from /tools/) and OsmAnd-java (from /core/) projects from into eclipse (do not copy them to workspace). See plugins directory, where can be some plugin projects you can contribute to.

Make sure that Eclipse Android plugin refers to android sdk path (Preferences -> Android -> SDK)

(Optional, should work out of the box) Check external folder in OsmAnd project : specify that *use* refers to OsmAnd-java/src (use path variable to have common version in reposititory).

Try to compile all projects to get rid of the errors or try to run Ant script alternatively.

Configure local.properties (look at sample file) in OsmAnd project in order to run OsmAnd\build.xml. Run Ant file OsmAnd\build.xml and get OsmAnd-debug.apk ready.

Config Application

You can run OsmExtractionUI.class and it is OsmAndMapCreator

If you want to enable logging - do not forget to put Java VM arg

 -Djava.util.logging.config.file=​logging.properties

After that you can try to run Swing (standalone) application to see whatever result.

After that you should have installed the development environment on your machine.

Terminal based compilation on Linux or Mac OS X

This might work as well on windows with slightly different commands. It does not use Eclipse or any other IDE. Download and install the Android SDK and NDK. The commands between () are only needed on the initial setup/compilation.

cd /opt/software
(mkdir osmandapp)
cd osmandapp
(repo init -u https://github.com/osmandapp/OsmAnd-manifest.git)
repo sync -d
export ANDROID_SDK=/opt/software/android-sdk-linux
export ANDROID_NDK=/opt/software/android-ndk-r8e
./android/OsmAnd/old-ndk-build.sh

This will build all the basic stuff, the dependencies and the native library

The above command(s) will build the dependencies for an arm, x86 and mips combined apk, but it will not build the apk itself yet.

Make sure that the last line of your "./android/OsmAnd/old-ndk-build.sh" command compilation run ends with:

Install        : libgnustl_shared.so => libs/armeabi/libgnustl_shared.so
To compile the apk finally do:
cd android/OsmAnd
ant -file build.xml -Dsdk.dir=$ANDROID_SDK -Dndk.dir=$ANDROID_NDK -Dnativeoff=false -Dmanifest="/opt/software/osmandapp/​android/OsmAnd/​AndroidManifest.xml" clean debug

Back to top

Voice routing - current status (by Hardy)

The current feature set is documented in each (new, v1.5-style) tts-config.p file in this comment block in the file header:

% IMPLEMENTED (X) or MISSING ( ) FEATURES:
% (X) new Version 1.5 format
% (X) route calculated prompts, left/right, u-turns, roundabouts, straight/follow
% (X) arrival
% (X) other prompts: attention (without Type implementation), location lost, off_route, exceed speed limit
% (X) special grammar: onto_street / on_street / to_street
% (N/A) special grammar: nominative/dativ for distance measure
% (N/A) special grammar: imperative/infinitive distinction for turns
% (X) distance measure: meters / feet / yard support
% (X) Street name announcement (suppress in prepare_roundabout)
% (X) Name announcement for destination / intermediate / GPX waypoint arrival
% ( ) Time announcement for new and recalculated route (for recalculated suppress in appMode=car)
% ( ) word order checked (hint for translators)

The file's string contents are sorted accordingly, in this fashion we can easily check which file already supports which feature.

Prompts

Let me quickly document here which prompt is played when in our voice router module:

  1. "Route recalculated":*
    1. Is played after the route has been recalculated, but only if the new route "is useful", i.e. now guides you in "forward direction"
    2. Is suppressed entirely for GPX routing (as it makes no sense then)
  2. "GPS signal lost":*

    Is played after GPS signal has been lost for continuous 20 sec and this was not caused by user action (still buggy, see Issue 893)

  3. "Make a U-turn when possible":*

    This prompt is an interim advice for cases where you continuously head in the wrong direction, and does only sound (once) if a new route in forward direction could not be found in x (currently 10) seconds:

    1. When you head down a long dead end road, where the only possible route out is 'backwards'.
    2. Where a new route in forward direction could not yet be re-calculated within the x seconds.
    3. The prompt is only played once, until the situation is resolved, i.e. you have either turned in the right direction, or route has been recalculated in "forward" direction.
  4. Turn instructions:*

    Are suppressed if traveling in a weird directions (account for GPS issues)

  5. Lead distances (lead time)
    1. CAR profile* (DEFAULT_SPEED = 12m/s=43km/h):

      || (a) >3000m out || "Follow the course of the road for..."|| || (b) 3000m-2000m || PREPARE_LONG|| || (c) 1500m-1200m || PREPARE|| || (d) 300m-168m (or <25sec) || TURN_IN|| || (e) <60m (or <5sec) || TURN||

    2. BICYCLE profile* (DEFAULT_SPEED = 5m/s=18 km/h):

      || (b) 500m-300m || PREPARE_LONG|| || (c) ~~500m-350m~~ 200m-120m || PREPARE|| || (d) ~~225m-80m (or <45sec)~~ 80m-60m (or <16sec) || TURN_IN|| || (e) ~~<45m (or <9sec)~~ <30m (or <6sec) || TURN||

    3. PEDESTRIAN profile* (DEFAULT_SPEED = 2 m/s=7.2km/h):

      || (c) ~~200m-150m~~ 100m-70m || PREPARE|| || (d) ~~100m-70m (or <50sec)~~ 50m-30m (or <25sec) || TURN_IN|| || (e) ~~25m or (or <12sec)~~ 15m (or <7.5sec) || TURN||

      ,,(Corrected values for bike and ped from forum feedback June 2013.),,

Back to top

Installation of different builds

Different builds of OsmAnd should install over any other build of the same strain (older or newer) without any issues, and with all Offline data being preserved.

The latest development build (not necessarily stable !) for testing can be found here.

This will update over any more recent existing development build with no problems at all. Should trying to update produce a signing or "not installed" error (like if you currently use the market or a very old dev build), please

All maps/tracks etc. are kept in place unchanged during this procedure.

Back to top

The map generation process
Introduction

Since OsmAnd has its own binary map format it is an OsmAnd initiative to generate/support and distribute these maps. OsmAnd can not update the maps frequently because it takes 2 weeks to process the whole world and only 1 out of 3 generations is successful. Most people are looking for a solution providing local maps.

The tool OsmAndMapCreator helps to create maps in a non-automated way. This is only to process user-defined OSM maps or to use maps for your own purpose.

On this page two methods will be described:

Complete automated workflow with upload possibilities
Prerequisites

Prerequisites : *Jenkins*, *Java*, *Ant*.

Automation is provided by the continuous integration tool called Jenkins. It will allow you to schedule jobs at whatever time you like and to utilize a lot of useful Jenkins plugins.

Please configure Jenkins so that it is allowed to use Java and Ant from your machine. Don't forget to install the GIT plugin for Jenkins and to specify user.name and user.email.

Steps overview

There are 2 main steps : GenerateIndexes and UploadIndexes. You can have a look at continuous integration. GenerateIndexes downloads OSM files from different sources (defined in regions.xml) and generates OsmAnd files. After that, successfully generated files are moved to the indexes directory. UploadIndexes verifies generated files from *indexes* dir, moves them into the *uploaded* dir and uploads them through *ssh* to a specified server.

OsmAnd continuous generation has the same steps except that it uploads to a different *ssh* (production) server. And there is also an additional step to move all uploaded files to a backup and start a completely new index generation. It is used when all indexes are generated.

To monitor the whole process you can use the logs from this site. You can also see what files are currently generated work folder. You can see what files are about to be verified and uploaded dir and which have already been uploaded in the uploaded directory.

Configure GenerateIndexes

Schedule : Depends on you. You can run it every day 0 12 * * * or manually.

SCM (source control) : _git://github.com/osmandapp/Osmand.git_ and Branch Specifier _origin/master_.

Steps :

You can point $INDEXES_FILE to any indexes.xml and leave only regions you want to generate. Please also copy build-scripts/indexes-batch-generate.xml and update it to your local settings and replace _java_ program parameter to your local file.

Configure UploadIndexes

It is highly appreciated if you want to share generated indexes with others. You need to send your public key (id_rsa.pub) generated by ssh-keygen to the community (Google Groups). After that you will be authorized to *ssh jenkins@new.osmand.net* (to a master jenkins continuous generation). I think it would also be good to register at Jenkins through UI.

Schedule : every 15 minutes to monitor indexes folder constantly for changes */15 * * * *.

SCM (source control) : _git://github.com/osmandapp/Osmand.git_ and Branch Specifier _origin/master_.

Steps :

 ant *compile jar*. Advanced DataExtractionOSM/build.xml.
 
 java -cp "DataExtractionOSM​/OsmAndMapCreator.jar​:DataExtractionOSM​/lib/*.jar" net.osmand.data​.index.IndexUploader /home/.../indexes /home/.../indexes/uploaded -ssh --url=ssh://... --user=jenkins --privKey=/home/.../.ssh/id_rsa --path=/var/lib/jenkins/indexes/

The 1st argument is where the indexes to upload are laid, 2nd argument if the upload success where the files will be moved. Specify private key to authorize through ssh --privKey.

Back to top

Create offline maps for yourself

OsmAndMapCreator can also be used to create maps for yourself if you want maps that are more up-to-date then the ones you can download from OsmAnd. We will explain this via a Un*x/Linux/OS X like shell script and we will use the nightly generated maps from Geofabrik, a German company that sells OpenstreetMap based maps and appliances.

Shell script
#!/bin/sh
WORK_FOLDER="/opt/OpenStreetMap"
# First download all the data
cd "$WORK_FOLDER/osm_files"
echo "Now in pwd\n"
rm *
wget -v -O Netherlands_europe.osm.pbf "http://download.geofabrik.de​/europe/netherlands-latest.osm.pbf"
#wget -v -O Luxembourg_europe.osm.pbf "http://download.geofabrik.de​/europe/luxembourg-latest.osm.pbf"
#wget -v -O Belgium_europe.osm.pbf "http://download.geofabrik.de​/europe/belgium-latest.osm.pbf"

cd $WORK_FOLDER
echo date > starttime.txt
echo "Now converting from osm.pbf to osmand obf\n"
cd "$WORK_FOLDER/OsmAndMapCreator"

java -Djava.util.logging.config.file=​logging.properties -Xms256M -Xmx2560M -cp "./OsmAndMapCreator.jar:​./lib/OsmAnd-core.jar:./lib/*.jar" net.osmand.data.​index.IndexBatchCreator ./batch.xml

cd $WORK_FOLDER
echo date > endtime.txt

echo "And finally moving the obf files from the index folder to the osmandmaps folder\n"
mv index_files/*.obf osmandmaps/
Explanation

The line _WORK_FOLDER="/opt/OpenStreetMap"_ is a variable to set our working folder. Inside this folder we have the maps _osm_files_, _OsmAndMapCreator_, _index_files_ and _gen_files_.

We move into our download folder _osm_files_ and we use the command _wget_ to download our map(s). The wget command is used with the parameter _-O <name>_ as we will download the latest nightly map from Geofabrik, but we will save it immediately in the nameformat OsmAnd prefers.

We move into the folder _OsmAndMapCreator_ where we installed/copied the OsmAndMapCreator program. It is best to really use the program from this folder, otherwise you have to set all kind of environment variables. The line:

_java -Djava.util.logging.config.file=​logging.properties -Xms256M -Xmx2560M -cp "./OsmAndMapCreator.jar:​./lib/OsmAnd-core.jar:./lib/*.jar" net.osmand.data.​index.IndexBatchCreator ./batch.xml_
runs OsmAndMapcreator on our downloaded maps. OsmAndMapCreator will process all maps it will find in the download map. this also means that it will process older maps if you still had them there.

We will log the process to file (-Djava.util.logging.config.file=logging.properties), give OsmAndMapCreator a minimum amount of 256MB and a maximum amount of 2560MB (preferably more then 1024MB), and we use the setup as specified in _batch.xml_.
Note: a 32bit Operating system can address up to approximately 1.5GB. This means that your -Xmx value can no larger be then -Xmx1720M. A larger specification is accepted without errors, but not used.

The _batch.xml_ file can be found in the OsmAndMapCreator folder, together with the program, and contains settings for running the program. The line:

 _process directory_for_osm_files=​"/opt/OpenStreetMap/osm_files" directory_for_index_files=​"/opt/OpenStreetMap/index_files" directory_for_generation=​"/opt/OpenStreetMap/gen_files"_
specifies our working folders.

The next line:
_skipExistingIndexesAt="/..." indexPOI="true" indexRouting="true" indexMap="true"        indexTransport="true" indexAddress="true">_ 
gives you options to modify parts of your map. If you don't need routing and/or addresses, you can simply skip these by setting the parameters to "false".

You can also use multiple batch.xml files for different purposes.

The last two lines in the script move the created maps to the osmandmaps folder where we store our maps (in this case).

The lines

_echo date > starttime.txt_ 

and 

_echo date > endtime.txt_ 
are not really neccessary but simply display how long the process takes.

Scheduling

The shell script can be scheduled as well. You have to take notice of the Geofabrik schedule for the maps creations (calculate for your own time zone).

If you want to create a new map every night, you could add a crontab line like:

_01 03 * * 7 /opt/OpenStreetMap/​osm.pbf_to_obf_convert.sh > /dev/null 2>&1_

This will start the creation of the map at 03:01 in the morning which is currently after the Geofabrik netherlands osm.pbf map has been generated (local time zone).

Performance and tuning

Creating maps is a memory hungry and very I/O intensive (disk intensive) process. In other words: It takes long to very long!

What can you do to improve performance:

SSD disks

The modern "solid state" disks are 2-6 times as fast as conventional hard-disks and can improve your map creation performance dramatically.

Multiple disks

Modern operating systems can access multiple disks simultaneously. Note that this really means *multiple disks* and *NOT* multiple partitions on one disk.

If you have your _process directory_for_osm_files_ on one disk and your _directory_for_generation_ on another disk you will see an nice and noticeable performance gain.

In memory processing

You can do a great deal of the map creation not on disk but in memory. In your batch.xml one of the top lines contains:


The osmDbDialect="sqlite" mapDbDialect="sqlite" determines where your map generation process will take place.

The line osmDbDialect="sqlite" mapDbDialect="sqlite" means that it will take place on disk.

If you change this to osmDbDialect="sqlite_in_memory" mapDbDialect="sqlite_in_memory" the process will take place in memory.

This "in memory" processing will speed up the map generation by 10-50% but requires a lot of memory. The 10% to 50% is dependent on the map size. Smaller maps benefit less from in memory processing than larger maps, as still the normal disk access (initial reading and final map writing) plays a major role in smaller maps, where as the processing of all the data (and their relations) in larger maps requires more "calculation".

In normal "on disk" processing a nodes.tmp.odb file is created from your .osm or .osm.pbf file. This nodes.tmp.odb file is a sqlite database file and it is about 15 to 25 times as big as the original .osm.pbf file which you downloaded from geofabrik.de.

So if your original .osm.pbf file is 300MB, your nodes.tmp.odb file will be 5GB to 6GB! Note that smaller maps will be around the 15x factor whereas big maps (>350MB) will end up in the 20x to 25X space increase.

With "in memory" processing this nodes.tmp.odb file will be created in your working memory. It means that the -Xmx parameter, which we discussed in the Explanation sections, needs to be big enough for both the nodes.tmp.odb and the normal processing that takes place in memory.

You will need "the size of the nodes.tmp.odb" + 20-25%.

It means that for a 250MB .osm.pbf, which will generate a ~4.5GB nodes.tmp.odb file, you need about 5GB heapspace which requires an -Xmx value of -Xmx5120M.

Note: a 32bit Operating system can address up to approximately 1.5GB. This means that your -Xmx value can no larger be then -Xmx1720M. A larger specification is accepted without errors, but not used.

So in effect you really need a 64bit Operating system to really benefit from "in memory" processing.

Note also that your -Xmx value should not be that big that your operating system starts swapping to disk. This will even decrease your performance below that of normal "on disk" processing.

Finally: your source .osm.pbf file can be no larger then 600MB as this would require up to 20GB working memory. If your source file exceeds 600MB, OsmAndMapCreator will switch back to normal "on disk" processing. You will be notified early in the process with a warning "Switching SQLITE in memory dialect to SQLITE"

Back to top

Creating a country polygon

This article describes how to create a poly(gon) for a missing country in geofabrik.de and how to add this poly to the map generation server of OsmAnd

Introduction

OsmAnd comes with a lot of maps for a lot of countries. Most maps are created from "raw data" maps downloaded from geofabrik.de. Geofabrik supplies these raw data maps for free to everyone and they deliver (commercial) services and products based on these maps.

Geofabrik.de has the strategy to deliver maps for the countries that are requested by larger numbers of users or by their customers. This means that some maps never make it on geofabrik as there are simply not enough requests for (or none at all), like some exotic countries like the Seychelles or Burundi, etc.

Server process

Because of this strategic decision of geofabrik, OsmAnd has an option to generate maps for these exotic rare countries and the tools OsmAndMapCreator and osmconvert are used for this. For OsmAndMapCreator this is a three step process:

Necessary actions

Depending on the complexity of the (generated) polygon this complete chain of actions can take from 10 minutes to 2 hours in total.

Get the OpenStreetMap relation from Nominatim
Retrieve the poly(gon) from polygons.openstreetmap.fr
Generate the polygon
Simplify the polygon

The number of Node Points (NPoints) needs to be as low as possible for the fastest possible creation of the map by OsmAndMapCreator. As mentioned: In case of more then 350 node points try to reduce them by simplifying the polygon.

Further modification and simplification of the polygon
Adding the poly(gon) to the OsmAnd server

To be able to do this you must register as a user.

To make the map generation possible there are two steps required:

Adding the polygon to the map data section
Add the map creation to the batch list
Creating your own personal maps from a poly

You can create for example polygons from countries, counties/provinces/states, regions and cities.

Say your daughter is going to Paris for a couple of days with a friend. She is not interested in navigation, walking or cycling (unless absolutely necessary), but she wants to know where she is, where to go to and where to find the interesting places (POIs). Next to that she has a small phone (low end CPU, low on memory) and small SD-card (stuffed with music). So the map needs to be as small as possible: both for storage as well as performance. You can of course download the map for france_ile-de-france.obf containing Paris, but you can also generate a "custom made" Paris map.

Back to top

OsmAnd Data Structure
Introduction

Regarding many questions, issues about map data in application that topic unveils technical details of internal data format and data processing. It can be interesting for non-developers but who is familar with OSM data structure.

All the OsmAnd data is containing in 'obf' files. 'obf' files have complex structure and can consists of many part. It is higly not recomended to have files around or more than 2 Gb. Currently obf parts can be many POI parts, many Map parts, Transport parts, Adress parts. That list can be extended in future. To combine or split or delete some parts from obf file use 'binary_inspector' console tool provided with OsmAndMapCreator.

POI, Transport part
Map part
Address part

Q: 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?

A: All places that are visible in OsmAnd as Cities are taken from nodes that has tag place http://wiki.openstreetmap.org/wiki/Place. Currently are used city, town, suburb, village, hamlet.


Q: 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?

A: Simply saying it works by name currently. Mapcreator tries to visit all boundaries and create closed (!) boundary from relation or from separated ways and associate with one of the name. After that it tries to match *place* with *boundary name* by *contains of* algorithm. Also there is additional check that boundary contains the place. If there are many boundaries of different admin_level with the same name (containing each_other like district/town/region has same name) the highest admin_level with exact matching will be chosen. TODO More details should be here (about districts of the city ...) ...


Q: Where is a documentation what admin level is right to build an association to a certain place node? What countries prefer what admin level?

A: Currently admin_level is Currently association between admin_level relation and admin_centre is not used. Because only few relations provides that information.


Q: How does mapcreator know what street belongs to what place? Are there different cases when a boundary polygon is given and when there is none?

A: There are many strategies to check and they are prioritized :

The last part is very inaccurate that's why many streets get attached to a neighboor 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.
    • extract cities (TOWN, CITY)
    • extract vilagges (anything else)
  2. iterate all RELATIONs and WAYs with type=boundary and register all boundaries

    • boundary is called Entity (way or relation) with tag 'boundary=administrative' or with tag 'place=...'
    • boundary should be admin_level > 4 or don't have it
    • boundary is not always associated with a city (or state, ...).
    • boundary can have 'admin_center', 'label' member pointing to a city node
    • boundary exactly matches by name city node and city node is in boundary
    • boundary matches start, end or substring by name city node and city node is in boundary

    Many boundaries can be associated with one city. Here is the order how the most important boundary is taken and associated with the city

    • Boundary is matched by name exactly and has tag place
    • Boundary is matched by name exactly and has admin_level 8 > 7 > 6 > 9 > 10 > 5... or nothing
    • Boundary has admin_id matching
    • All other cases including sorting of admin_level
  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 (Postal_Addresses)

    • relation with "address" tag type, and is "house" or "a6" address_type
    • search for associatedStreet relation and house members
    • try to find the city for the street and city for house address.
    • look up cities (we already must have find it in steps before!!)
    • if we have city and street, register it to database:
      • for streetregistration, see: register street for a city
        • if street is registered, and we are processing street:
        • iterate over all relation members:
          • find street -> write the nodes of the street to db
          • find house -> write the house to to the street
        • if street is registered, and we are processing house:
          • find house number
          • find house border: if found, store: building for the street

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

        Note: we might register street for more cities = this means, the street can be in nested areas, suburb, city, hamlet, etc... For each area, we want to register the street in it.

        • for each city:
          • find existing street registration within the city:
            • if street exists:
              • if city part is unknown -> update the existing street's city part
              • try to find cityPart for our street, and lookup the street again
            • if street does not exists: (might change after the lookup)
              • register the street for city, city part, location, and street name

        findOrRegister street

        • find close cities to the street
        • if the street is in the boundary of the city, add the city for search
        • if no city was find, using boundary, find closest city for the street
        • :register street: for the found cities
  6. iterate all NODES than WAYS than RELATIONS (iterate main entity)
    1. find ways - interpolations:
      • for each interpolation, findOrRegister a street with the location of the interpolation
      • for each two nodes create a building representing the interpolation
    2. for any entity, find addr:housenumber and addr:street tag (can be also the interpolation nodes again!!!)
      • skip if building for this entity already exists!
      • findOrRegister streets for the street
      • find the house number
      • if housenumber contains '-', try to create interpolated house number (missing latlon2?)
      • if housenumber contains '/', try to lookup second street addr:street2 --> seems only for RU osm:

      • there are more variations for this: adr:housenumber2, addr2:street, addr2:housenumber etc....

      • for each street, store the existing house
    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)
      • skip if such street exists already
      • findOrRegister the street for city
      • write the nodes for each found street in each city
    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
    • for each stored postal_code relation
      • for each building member, update the postal_code
  8. write the index:
    • split cities to: citties+towns, suburbs (suburb with is_in tag), villages (not city or town)
    • write cities+towns using suburbs
      • read street from cities+tows + apropriate subburs for each town
        • in here, there might be more streets with same name for one city, in such case we try to find a cityPart for the street (suburb), where the street is in. There should be not more streets with same name within one city part!
      • for each street
        • for each building, register/create/find postcode, register the street
    • write villages
      • same as towns...
    • write extracted postcodes and their streets

    Back to top

How to inspect an obf binary file

If you want inspect the content of obf file, you need to download OsmAndMapCreator. There you can find a console application BinaryInspector (.sh, .bat). This console application has optional parameters [-vmap, -vaddress, -vtransport] and one required parameter (input obf file). By specifying optional parameters you could trace the whole information from obf file (be aware it could be huge!).

Example and step-by-step for Windows users:

Back to top

OBF routing debugging on a PC with OSM map display
How-to
Find the place name to what a street is associated in offline OBF maps

Back to top

OsmAnd Server Configuration
Introduction

This document describes the steps needed to fully setup OsmAnd server for services needed by osmand and relateds stuff to it.

Mail
#Optionally remove the sendmail if present
apt-get purge sendmail-base
apt-get purge sendmail-bin
#Install the postfix and utilities
apt-get install postfix
apt-get install mailutils

Postfix setup: PostfixBasicSetupHowto or dpkg-reconfigure postix and setup the mail

jenkins.osmand.net: Jenkins - builds and indexes
apt-get install jenkins
apt-get install openjdk6

Plugins needed in jenkins: (todo list)

/var/lib/jenkins

In case of existing jenkins site, complete jenkins configuration can be copied: (link on jenkins wiki)

install android sdk - /var/lib/android-sdk-linux (steps)

on 64 bit system install 32 libs: apt-get install ia32-libs

maybe you will need to change jenkins jobs configuration to point the builds to android-sdk-linux location using the sdk.dir variable

Copy debug.keystore to /var/lib/jenkins/.android/debug.keystore take it from git: (link)

add jenkins to group www-data

Apache
 apt-get install libapache2-mod-php5
 apt-get install php5-mysql
 cd /etc/apache2/mods-enabled
 ln -s ../mods-available/rewrite.load
 ln -s ../mods-available/proxy.load
 ln -s ../mods-available/proxy.conf
 ln -s ../mods-available/proxy_balancer.load
 ln -s ../mods-available/proxy_balancer.conf
 ! copy sites (git, todo...)
 cd /etc/apache2/sites-enabled
 ln -s ../sites-available/*
 service apache2 restart

! apache configuration is not yet in git, should be there !

For putting jenkins under ssl:

download.osmand.net

If migrating from existing server:

copy /var/www/www-download completely to the new server (note, this location is used by scripts, do not change!)

Or, create from scratch:

 copy from git config/site to /var/www/www-download
www.osmand.net (joomla)
 copy /var/www/www-joomla completely to the new server
 (todo)

Copying a Joomla website

 tar cvfz joomlabackup.tar.gz /path-to-joomla
 scp joomlaback.tar.gz someuser@remote.machine.etc
 mysqldump -u joomla -p joomla > joomladb.out
 scp joomladb.out someuser@remote.machine.etc

On remote machine:

 apt-get install mysql-server mysql-client //don't forget the password for mysql root user
 mysqladmin -u root -p create joomla
 mysql -u root -p mysql //we are going to create joomla user
 mysql> {{{ GRANT ALL PRIVILEGES ON joomla.* TO joomla@localhost IDENTIFIED BY 'password'; }}} //use the password configured for joomla, configuration.php
 mysql>  flush privileges;
 mysql -u joommla -p joomla < joomladb.out
 cd /var/www-joomla/
 tar xvfz joomlabackup.tar.gz
Awstats
 apt-get install awstats
 copy /etc/awstats/* or get it from git
 copy /var/lib/awstats/* to new server to preserve data
 cd /etc/apache2/conf.d/
 cp /usr/share/doc/awstats/examples/​apache.conf awstats.conf

read also: http://www.debianhelp.co.uk/awstats.htm

!change permissions of apache logs so that awstats can read them!

put a prerotate script to apache2 in /etc/logrotate.d/

       prerotate
       if [ -x /usr/share/awstats/tools/update.sh ]; then
         su - -c /usr/share/awstats/tools/update.sh www-data
       fi
       endscript
 service apache2 restart
Geo::IP instalation for awstats

overview: http://www.maxmind.com/app/installation

 apt-get install geoip-database
 apt-get install libgeo-ip-perl

Now see: http://the.new.site/cgi-bin/awstats.pl

uiman
DNS

if needed, change the dns settings accordingly on the new server provider (currently https://robot.your-server.de/)

translate.osmand.net
Backup

http://duply.net/?title=Main_Page

http://trick77.com/2010/01/01/how-to-ftp-backup-a-linux-server-duply/

 apt-get install duplicity gpg ncftp

read the trick77.com page for setup

/etc/duply/offsite/conf:
{{{ 
GPG_KEY='F61826A6' 
GPG_PW='*******' 
TARGET='ftp://*****:******@****.your-backup.de/dailybackup' 
SOURCE='/' 
MAX_AGE=2M 
MAX_FULLBKP_AGE=1M 
DUPL_PARAMS="$DUPL_PARAMS --full-if-older-than $MAX_FULLBKP_AGE" 
VOLSIZE=100 
DUPL_PARAMS="$DUPL_PARAMS --volsize $VOLSIZE " 
}}} 
/etc/duply/offsite/exclude: 
{{{ 
/bin 
/boot 
/dev 
/lib 
/lib32 
/lib64 
/lost+found 
/media 
/mnt 
/opt 
/proc 
/sbin 
/srv 
/sys 
/tmp 
/usr 
/run 
/selinux 
- /var/lib/jenkins/backup 
- /var/lib/jenkins/backup_old 
- /var/lib/jenkins/indexes 
- /var/lib/jenkins/uploaded 
- /var/lib/jenkins/wiki/work 
- /var/lib/jenkins/srtm-osm 
- /var/lib/jenkins/srtm-proccess 
- /var/lib/jenkins/workspace 
+ /var/lib/jenkins 
+ /var/lib/awstats/ 
- /var/www/www-download/indexes 
- /var/www/www-download/night-builds 
- /var/www/www-download/php_errors.log 
- /var/www/www-download/latest-night-build 
+ /var/www 
- /var
/home/zibrita 
- /root/nobakcup 
}}} 
_do mysql dump before backup_ 
/etc/duply/offsite/pre 
{{{ 
/usr/bin/mysqldump --all-databases -u root -p***** > /home/mysqldump_all.sql 
}}} 
/etc/cron.d/duply 
lftp -u ***,**** ****.your-backup.de 

It is good to backup /etc/duply/offsite/ somewhere, if the machine crashes, there is the info to retrieve encrypted files from the backup!

Restoring

To list the current backup sets on your remote backup path use the following command:

duply offsite status

To restore the whole “offsite” backup to /tmp I’d use this command:

duply offsite restore /tmp/restore

To restore the lastest version of a file from my “offsite” backup to /tmp I’d use this command:

duply offsite fetch etc/myfile /tmp/restore

To restore the version from 4 days ago of a file from my “offsite” backup to /tmp I’d use this command:

duply offsite fetch etc/myfile /tmp/restore 4D

The combination of Duplicity and Duply is a very powerful solution for backups on non-trusted spaces. The setup is a piece of cake compared to other Linux based backup solutions.

Back to top

Using KML Files

In GoogleEarth (GE) you can add you own Placemarks on the map and collect them into a folder. From GE you can save the folder in kml format. When you have a different format you can use QGIS or other opensource software to convert to KML format. Maybe you can convert it directly to osm. You may use any format containing your POIs, if you are able to convert it to osm format.

Converting KML (or Other Formats) into osm Format

To perform this task we need to use gpsbabel. It is very useful to convert waypoints, tracks, and routes between popular GPS receivers and mapping programs. The syntax is very simple, and GPS Babel has an interface to create the syntax for you:

   $ gpsbabel -i kml -f my_places.kml -o osm,tagnd="tourism:museum",​created_by -F my_places.osm

The generated file is like this:

   <?xml version='1.0' encoding='UTF-8'?>
   <osm version='0.5' generator='GPSBabel-1.4.0'>
     <node id='-1' visible='true' lat='41.890121' lon='12.492265'>
       <tag k='name' v='place01'/>
       <tag k='note' v='place01'/>
       <tag k='tourism' v='museum'/>
     </node>
   <node id='-2' visible='true' lat='41.892241' lon='12.489031'>>
       <tag k='name' v='place02'/>
       <tag k='note' v='place02'/>
       <tag k='tourism' v='museum'/>
     </node>
   </osm>

All points inside the kml file are converted into osm points, assigning them some properties like tourism category and museum type. The created_by= option with missing value means that the properties will be ignored. If your poi belongs to different categories, I suggest you create multiple osm files and create OsmAnd odf files and merge them together later with OsmAndMapCreator, or create multiple obf files.

Converting OSM Format into OBF Format

Now you are ready to perform the final step. The conversion will be done using OsmAndMapCreator. Download, unzip and run this program.

If all is right you'll find My_places.obf into your workdir folder. Simply upload this file into your OsmAnd phone folder and you have done.

Good luck!!!

Back to top

How to produce customized vector data

It is possible to create a customized obf file with specific (own) vector data (hiking paths, speed cams, transport routes debug way info), and adjust the rendere to display it.

OsmAndMapCreator can process only OSM files (osm-xml, bz2, pbf). However the set of tags can be custom. To specify what tags/values need to be indexed by Creator please download and change this file. OsmAndMapCreator has an option to use custom rendering_types.xml in the settings. Once file is created you can double check that data is present by utility binaryInspector with '-vmap' argument. This utility is packaged with OsmAndMapCreator.

Once the .obf file is ready you can create custom rendering file to display missing attributes. There is a default rendering style which contains all information about rendering. It is good to have a look at it but it is very hard to open/edit it and understand. More convenient way to create your own rendering style is to create style that depends (inherits) default style. A good example of custom rendering style you can find here.

Currently OsmAndMapCreator doesn't support relation tagging. So you need to manually copy all tags from relations (like route color) to way tags by script.


Custom_Rendering_How-To.htm