#include <glib.h>
#include "debug.h"
#include "item.h"
+#include "coord.h"
+#include "transform.h"
#include "color.h"
#include "attr.h"
{
enum attr_type attr;
struct attr *ret;
+ struct coord_geo *g;
+ struct coord c;
ret=g_new0(struct attr, 1);
dbg(1,"enter name='%s' value='%s'\n", name, value);
case attr_item_type:
ret->u.item_type=item_from_name(value);
break;
+ case attr_position_coord_geo:
+ g=g_new(struct coord_geo, 1);
+ ret->u.coord_geo=g;
+ coord_parse(value, projection_mg, &c);
+ transform_to_geo(projection_mg, &c, g);
+ break;
default:
if (attr >= attr_type_string_begin && attr <= attr_type_string_end) {
ret->u.str=(char *)value;
void
attr_free(struct attr *attr)
{
+ if (attr->type == attr_position_coord_geo)
+ g_free(attr->u.coord_geo);
if (attr->type >= attr_type_color_begin && attr->type <= attr_type_color_end)
g_free(attr->u.color);
g_free(attr);
struct log *ret=g_new0(struct log, 1);
struct attr *data,*overwrite,*flush_size,*flush_time;
- dbg(0,"enter\n");
+ dbg(1,"enter\n");
data=attr_search(attrs, NULL, attr_data);
if (! data)
return NULL;
maneuver_required2(struct navigation_itm *old, struct navigation_itm *new, int *delta)
{
dbg(1,"enter %p %p %p\n",old, new, delta);
- if (new->item.type == type_ramp && old && (old->item.type == type_highway_land || old->item.type == type_highway_city)) {
- dbg(1, "maneuver_required: new is ramp from highway: yes\n");
+ if (new->item.type != old->item.type && (new->item.type == type_ramp || old->item.type == type_ramp)) {
+ dbg(1, "maneuver_required: old or new is ramp\n");
return 1;
}
if (is_same_street2(old, new)) {
}
static void
-popup_show_attr_val(void *menu, struct attr *attr)
+popup_show_attr_val(struct map *map, void *menu, struct attr *attr)
{
char *attr_name=attr_to_name(attr->type);
+ char *str;
if (attr->type >= attr_type_int_begin && attr->type <= attr_type_int_end)
popup_printf(menu, menu_type_menu, "%s: %d", attr_name, attr->u.num);
- else
- popup_printf(menu, menu_type_menu, "%s: %s", attr_name, attr->u.str);
+ else {
+ str=map_convert_string(map, attr->u.str);
+ popup_printf(menu, menu_type_menu, "%s: %s", attr_name, str);
+ map_convert_free(str);
+ }
}
#if 0
#endif
static void
-popup_show_attrs(void *menu, struct item *item)
+popup_show_attrs(struct map *map, void *menu, struct item *item)
{
#if 0
popup_show_attr(menu, item, attr_debug);
for (;;) {
memset(&attr, 0, sizeof(attr));
if (item_attr_get(item, attr_any, &attr))
- popup_show_attr_val(menu, &attr);
+ popup_show_attr_val(map, menu, &attr);
else
break;
}
item=map_rect_get_item_byid(mr, item->id_hi, item->id_lo);
dbg(1,"item=%p\n", item);
if (item) {
- popup_show_attrs(menu_item, item);
+ popup_show_attrs(item->map, menu_item, item);
}
map_rect_destroy(mr);
menu_map=popup_printf(menu, menu_type_submenu, "Map");
h->pos=0;
h->rp=route_path_open(h->route);
case 0:
- if (! h->street_data) {
+ if (! h->street_data && h->rp) {
seg=route_path_get_segment(h->rp);
if (seg) {
item=route_path_segment_get_item(seg);
struct vehicle_priv {
int interval;
+ int position_set;
struct callback_list *cbl;
struct navit *navit;
struct coord_geo geo;
attr->u.numd = &priv->direction;
break;
case attr_position_coord_geo:
- dbg(1, "coord %f,%f\n", priv->geo.lat, priv->geo.lng);
attr->u.coord_geo = &priv->geo;
break;
default:
static int
vehicle_demo_timer(struct vehicle_priv *priv)
{
- struct route_path_coord_handle *h;
- struct coord *c, *pos, ci;
+ struct route_path_coord_handle *h=NULL;
+ struct coord *c, *pos=NULL, ci;
int slen, len, dx, dy;
len = (priv->speed * priv->interval / 1000)/ 3.6;
return 1;
}
struct route *vehicle_route = navit_get_route(priv->navit);
- if (!vehicle_route) {
- dbg(1, "navit_get_route NOK\n");
- return 1;
- }
-
- h = route_path_coord_open(vehicle_route);
- if (!h) {
- dbg(1, "navit_path_coord_open NOK\n");
- return 1;
- }
- pos = route_path_coord_get(h);
+ if (vehicle_route)
+ h = route_path_coord_open(vehicle_route);
+ if (h)
+ pos = route_path_coord_get(h);
dbg(1, "current pos=%p\n", pos);
if (pos) {
+ priv->position_set=0;
dbg(1, "current pos=0x%x,0x%x\n", pos->x, pos->y);
dbg(1, "last pos=0x%x,0x%x\n", priv->last.x, priv->last.y);
if (priv->last.x == pos->x && priv->last.y == pos->y) {
break;
}
}
+ } else {
+ if (priv->position_set)
+ callback_list_call_0(priv->cbl);
}
return 1;
}
*cbl, struct attr **attrs)
{
struct vehicle_priv *ret;
- struct attr *interval,*speed;
+ struct attr *interval,*speed,*position_coord_geo;
dbg(1, "enter\n");
ret = g_new0(struct vehicle_priv, 1);
ret->speed=speed->u.num;
if ((interval=attr_search(attrs, NULL, attr_interval)))
ret->interval=speed->u.num;
+ if ((position_coord_geo=attr_search(attrs, NULL, attr_position_coord_geo))) {
+ ret->geo=*(position_coord_geo->u.coord_geo);
+ ret->position_set=1;
+ dbg(0,"position_set %f %f\n", ret->geo.lat, ret->geo.lng);
+ }
*meth = vehicle_demo_methods;
g_timeout_add(ret->interval, (GSourceFunc) vehicle_demo_timer, ret);
return ret;