Dbus
From Navit's Wiki
This Document displays the requirements and implementation details of the navit dbus interface.
Contents |
Navit DBus details:
DBUS Service: "org.navit_project.navit"
DBUS Bus: Session bus
org.navit_project.navit:
DBUS Object Path: /org/navit_project/navit
Methods:
iter
destroy_iter
get_navit
returns an instance of navit
Name: get_navit
Args: Object path returned from the iter() call
Returns: Object path representing an instance of a running navit.
org.navit_project.navit.navit:
DBUS Object Path: /org/navit_project/navit/navit/[]
The way navit use dbus is not really the usual way. If you want to control your navit instance (set_destination, zoom,…), you have first to do the following (examples are in python) :
1) get the navit general object
object = bus.get_object("org.navit_project.navit","/org/navit_project/navit")
2) get the interface of this object :
iface = dbus.Interface(object,dbus_interface="org.navit_project.navit")
3) get an iterator through navit instances :
iter=iface.attr_iter()
4) get the object path of the navit instance in your iterator :
path = object.get_attr_wi("navit",iter)
5) get the navit instance you are interested in :
navit=bus.get_object('org.navit_project.navit', path[1])
6) destroy the iter :
iface.attr_iter_destroy(iter)
The following methods have to be applied on the navit object.
Methods:
Set destination
Sets the destination. coord is a string containing the coordinates in a special format. pro contains the map projection while x and y define the position. descr is a description for the target
coord can be formatted like this:
[Proj:]-0xX [-]0xX - where Proj can be mg/garmin, defaults to mg [Proj:][D][D]Dmm.ss[S][S] N/S [D][D]DMM.ss[S][S]... E/W [Proj:][-][D]D.d[d]... [-][D][D]D.d[d] - where Proj can be geo
Name: set_destination
Args: string coord, string descr
Args: (int pro, string coord), string descr
Args: (int pro, int x, int y), string descr
Returns: (none)
Example that set your destination in Belgium :
navit.set_destination("4.3434 50.688" ,"my destination")
Zoom
Zooms into the map if f is positive, otherwise it zooms out. f is the zoom factor and has to be bigger than 1 or smaller than -1. Values between 1 and -1 have no effect. In addition, x and y can be set to zoom into a special point on the screen.
Name: zoom
Args: int f[, (int x, int y)]
Returns: (none)
Set position
Sets the current position. See Set destination.
Name: set_destination
Args: string coord
Args: (int pro, string coord)
Args: (int pro, int x, int y)
Returns: (none)
Center map (coordinates)
Centers the view to a absolute position on the map. Useful when looking up for some coordinates (e.g. for bookmarks). See Set destination.
Name: set_center
Args: string coord
Args: (int pro, string coord)
Args: (int pro, int x, int y)
Returns: (none)
Center map (pixel)
Centers the map to a specific position on the screen. x and y contain the pixel coordinates on the current map section starting from the upper left.
Name: set_center
Args: (int x, int y)
Returns: (none)
Set layout
Sets the map layout
Name: set_layout
Args: string layout_name
Returns: (none)
Add message
Adds a message to the messages label.
Name: add_message
Args: string message
Returns: (none)
Redraw
Forces a redraw of the current map section
Name: draw
Args: (none)
Return: (none)
Signals:
add bookmark signal:
Setup the callback:
dbus-send --print-reply --session --dest=org.navit_project.navit /org/navit_project/navit org.navit_project.navit.callback_attr_new string:my_signal string:bookmark_map object path "/org/navit_project/navit/callback/0" dbus-send --print-reply --session --dest=org.navit_project.navit /org/navit_project/navit/default_navit org.navit_project.navit.navit.add_attr string:callback variant:objpath:/org/navit_project/navit/callback/0
Replace "my_signal" with a signal name of your choice.
Now add a bookmark and you should see this in dbus-monitor --session:
signal sender=:1.927 -> dest=(null destination) path=/org/navit_project/navit; interface=org.navit_project.navit; member=my_signal

