Custom POIs

From Navit's Wiki
Revision as of 18:42, 15 December 2012 by Usul (talk | contribs) (cat)
Jump to: navigation, search

Maybe you are interested in making some custom POIs. I was looking for this feature and couldn't find it for days - this is why I am now writing this page. This could be useful in the case you need to show points on a map for your business (clients places, shops, ... ) or for your free time. On the other hand bookmarks are not shown with an icon on the map.

Define your POI

Navit supports text files to be used. This is like bookmarks, but they will be used on the map.

First of all, go to your local .navit folder. Create a new file called my_pois.txt. There you can define your POIs like this:

        mg:8.497582 47.395690 type=poi_custom1   label="andys football field"

This will create a new POI with the type poi_custom1. You can use any type defined in item_def.h [1]

Using a custom icon

To display the new type defined in your my_pois.txt file you also need to define an icon for the new type. This will be done in the navit.xml in your local .navit folder.

Look for the itemgra definitions and add those lines:

     <itemgra item_types="poi_custom1" order="11-">
         <icon src="my_icon1.png"/>

A good place to add this line is after:

 <itemgra item_types="poi_fuel" order="10-">

You also need to make an icon and put it under /usr/share/navit/xpm/

Using the POI file with the map

I am using OSM maps so I added the following line in navit.xml:

               <mapset enabled="yes">
                       <map type="binfile" enabled="yes" data="/home/username/.navit/osm_bbox_eu.bin"/>
                       <map type="textfile" enabled="yes" data="/home/username/.navit/my_pois.txt"/>

Take care to put your correct username in the above path.

Load POIs via CSV

This can be useful to load POIs from a camping guide like Bordatlas or ADAC Camping Caravaning Führer. Most of them provide the camping sites mentioned in their books via CSV. To use this feature you need to compile navit with the parameter --enable-map-csv. Have a look at Navit_csv_format.

But same as above, you can add a custom type to it if you use something like item_type="poi_custom1" (on the line where you add the CSV to your mapset).

Hard way

Read this section only if you don't hesitate to edit some C code, recompile Navit from source, rebuild binfile map from osm data, and finally want your OSM based POI type to be available for others by default.

1. You'll need to use some POI type already defined in item_def.h or add a new type. To make your changes compatible with mainstream navit, always add new POI type right before ITEM2(0x7ffffff0,poi_custom0) line.

2. You have to add mapping from OSM attribute set to Navit item type. That's done in attrmap array of maptool/osm.c. If you want to put POIs only for point OSM objects, begin your line with letter n (for node). If you want lines and areas to be converted to POIs too, use a question mark instead of that letter. Then you should specify OSM attribute-value pairs which define your POI. Keep in mind, Navit will analyse whole attrdef array and use only matching entries which have longest attribute-value chain. As the last element, you should specify Navit POI type name chosen in the first step.

3. Modify navit.xml or navit_shipped.xml to include your POI type in the applicable layouts. This is described in the #Using a custom icon section above.

4. Design your own icon in svg format for the new POI type and put it into the xpm folder of the source tree.

5. Recompile navit and maptool, build new map from raw osm data and test if it works as expected.

6. If you believe your new POI type should be included in mainstream, create a ticket on the and attach your patch made with 'svn diff' command together with suggested POI icon.