navit
0.5.3-trunk
|
The TraFF plugin for Android. More...
#include <string.h>
#include <time.h>
#include "glib_slice.h"
#include "config.h"
#include "item.h"
#include "attr.h"
#include "coord.h"
#include "map.h"
#include "route_protected.h"
#include "route.h"
#include "transform.h"
#include "xmlconfig.h"
#include "android.h"
#include "traffic.h"
#include "plugin.h"
#include "callback.h"
#include "vehicle.h"
#include "debug.h"
#include "navit.h"
#include "util.h"
Data Structures | |
struct | traffic_priv |
Stores information about the plugin instance. More... | |
Macros | |
#define | POSITION_RECT_SIZE 100000 |
Minimum area around the current position for which to retrieve traffic updates. More... | |
Functions | |
void | traffic_traff_android_destroy (struct traffic_priv *this_) |
Destructor. More... | |
struct traffic_message ** | traffic_traff_android_get_messages (struct traffic_priv *this_) |
Returns an empty traffic report. More... | |
static void | traffic_traff_android_on_feed_received (struct traffic_priv *this_, char *feed) |
Called when a new TraFF feed is received. More... | |
static void | traffic_traff_android_set_selection (struct traffic_priv *this_) |
Sets the route map selection. More... | |
static void | traffic_traff_android_destination_callback (struct traffic_priv *this_) |
Callback for destination changes. More... | |
static void | traffic_traff_android_status_callback (struct traffic_priv *this_, int status) |
Callback for navigation status changes. More... | |
static void | traffic_traff_android_position_callback (struct traffic_priv *this_, struct navit *navit, struct vehicle *vehicle) |
Callback for position changes. More... | |
static int | traffic_traff_android_init (struct traffic_priv *this_) |
Initializes a traff_android plugin. More... | |
static struct traffic_priv * | traffic_traff_android_new (struct navit *nav, struct traffic_methods *meth, struct attr **attrs, struct callback_list *cbl) |
Registers a new traff_android traffic plugin. More... | |
void | plugin_init (void) |
Initializes the traffic plugin. More... | |
Variables | |
static struct traffic_methods | traffic_traff_android_meth |
The methods implemented by this plugin. More... | |
The TraFF plugin for Android.
Navit, a modular navigation system. Copyright (C) 2005-2018 Navit Team
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
This plugin receives TraFF feeds via Android broadcasts and content providers.
#define POSITION_RECT_SIZE 100000 |
Minimum area around the current position for which to retrieve traffic updates.
100000 is equivalent to around 50 km on each side of the current position. The actual subscription area can be larger, allowing for a subscription area to be kept over multiple position updates.
The actual subscription area around the current location is stored in traffic_priv::position_rect and updated in traffic_traff_android_position_callback(struct traffic_priv *, struct navit *, struct vehicle *).
void plugin_init | ( | void | ) |
Initializes the traffic plugin.
The plugin entry point.
This function is called once on startup.
References dbg, lvl_debug, and traffic_traff_android_new().
|
static |
Callback for destination changes.
this_ | The instance which will handle the destination update |
References traffic_traff_android_set_selection().
Referenced by traffic_traff_android_init().
void traffic_traff_android_destroy | ( | struct traffic_priv * | this_ | ) |
Destructor.
References dbg, jnienv, lvl_error, traffic_priv::NavitTraff, traffic_priv::NavitTraffClass, traffic_priv::position_rect, route_free_selection(), and traffic_priv::route_map_sel.
struct traffic_message ** traffic_traff_android_get_messages | ( | struct traffic_priv * | this_ | ) |
Returns an empty traffic report.
NULL
|
static |
Initializes a traff_android plugin.
References android_activity, android_find_class_global(), callback_cast, callback_new_attr_1, traffic_priv::cbid, dbg, jnienv, lvl_debug, lvl_error, traffic_priv::nav, navigation_register_callback(), navit_add_callback(), navit_get_navigation(), traffic_priv::NavitTraff, traffic_priv::NavitTraffClass, traffic_traff_android_destination_callback(), traffic_traff_android_position_callback(), and traffic_traff_android_status_callback().
Referenced by traffic_traff_android_new().
|
static |
Registers a new traff_android traffic plugin.
nav | The navit instance |
meth | Receives the traffic methods |
attrs | The attributes for the map |
cbl |
traffic_priv
structure for the plugin instance References callback_cast, callback_new_1, traffic_priv::cbid, dbg, lvl_debug, traffic_priv::nav, traffic_priv::position_rect, traffic_priv::position_valid, traffic_priv::route_map_sel, traffic_traff_android_init(), traffic_traff_android_meth, and traffic_traff_android_on_feed_received().
Referenced by plugin_init().
|
static |
Called when a new TraFF feed is received.
this_ | Private data for the module instance |
feed | Feed data in string form |
References dbg, lvl_debug, lvl_error, traffic_priv::nav, navit_attr_iter_destroy(), navit_attr_iter_new(), navit_get_attr(), attr::navit_object, traffic_get_messages_from_xml_string(), traffic_process_messages(), and attr::u.
Referenced by traffic_traff_android_new().
|
static |
Callback for position changes.
This updates traffic_priv::position_rect if the vehicle has moved far enough from its center to be within POSITION_RECT_SIZE of one of its boundaries. The new rectangle is created with twice that amount of padding, allowing the vehicle to move for at least that distance before the subscription needs to be updated again.
this_ | The instance which will handle the position update |
navit | The Navit instance |
vehicle | The vehicle which delivered the position update and from which the position can be queried |
References c, attr::coord_geo, coord_rect_contains(), coord_rect::lu, traffic_priv::position_rect, POSITION_RECT_SIZE, projection_mg, coord_rect::rl, traffic_traff_android_set_selection(), transform_from_geo(), attr::u, vehicle_get_attr(), coord::x, and coord::y.
Referenced by traffic_traff_android_init().
|
static |
Sets the route map selection.
this_ | The instance which will handle the selection update |
References g_strconcat_printf(), jnienv, coord_geo::lat, coord_geo::lng, coord_rect::lu, traffic_priv::nav, navit_get_destination_count(), navit_get_route(), traffic_priv::NavitTraff, traffic_priv::NavitTraffClass, map_selection::next, order_to_min_road_class, traffic_priv::position_rect, projection_mg, coord_rect::rl, route_free_selection(), route_get_selection(), traffic_priv::route_map_sel, and transform_to_geo().
Referenced by traffic_traff_android_destination_callback(), traffic_traff_android_position_callback(), and traffic_traff_android_status_callback().
|
static |
Callback for navigation status changes.
This callback is necessary to force an update of existing subscriptions when Navit acquires a new position (after not having had valid position information), as the map selection will change when the current position becomes known for the first time.
this_ | The instance which will handle the navigation status update |
status | The status of the navigation engine (the value of the attribute) |
References traffic_priv::position_valid, and traffic_traff_android_set_selection().
Referenced by traffic_traff_android_init().
|
static |
The methods implemented by this plugin.
Referenced by traffic_traff_android_new().