diff options
author | martin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2008-01-01 22:13:02 +0000 |
---|---|---|
committer | martin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2008-01-01 22:13:02 +0000 |
commit | 06f573ac24e0c55c9963080499cce16a8a93bdb9 (patch) | |
tree | 54b5108dacbb3d5e0e10050a05e4039d1e34c7de | |
parent | e8a726e017a65042bca1cebe3aa400540e65863d (diff) | |
download | navit-svn-06f573ac24e0c55c9963080499cce16a8a93bdb9.tar.gz |
Fix:Core:Improved some internal stuff
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit/src@683 ffa7fe5e-494d-0410-b361-a75ebd5db220
-rw-r--r-- | attr.c | 13 | ||||
-rw-r--r-- | attr_def.h | 4 | ||||
-rw-r--r-- | callback.c | 2 | ||||
-rw-r--r-- | main.c | 1 | ||||
-rw-r--r-- | navit.c | 44 | ||||
-rw-r--r-- | route.c | 27 | ||||
-rw-r--r-- | route.h | 1 | ||||
-rw-r--r-- | vehicle/demo/vehicle_demo.c | 10 |
8 files changed, 61 insertions, 41 deletions
@@ -63,12 +63,6 @@ attr_new_from_text(const char *name, const char *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; @@ -99,6 +93,13 @@ attr_new_from_text(const char *name, const char *value) } break; } + if (attr >= attr_type_coord_geo_start && attr <= attr_type_coord_geo_end) { + 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; + } dbg(1,"default\n"); g_free(ret); ret=NULL; @@ -10,7 +10,7 @@ ATTR(street_name_item) ATTR(street_name_numbers_item) ATTR(street_item) ATTR(street_number_item) -ATTR(item_type) +ATTR(item_type) /* fixme */ ATTR2(0x0001ffff,type_item_end) ATTR2(0x00020000,type_int_begin) @@ -64,7 +64,6 @@ ATTR(entry_fee) ATTR(open_hours) ATTR(skin) ATTR(fullscreen) -ATTR(center) ATTR(view_mode) ATTR(tilt) ATTR(media_window_title) @@ -89,6 +88,7 @@ ATTR(position_direction) ATTR2(0x0005ffff,type_double_end) ATTR2(0x00060000,type_coord_geo_start) ATTR(position_coord_geo) +ATTR(center) ATTR2(0x0006ffff,type_coord_geo_end) ATTR2(0x00070000,type_color_begin) ATTR(color) @@ -144,7 +144,7 @@ callback_list_call_attr(struct callback_list *l, enum attr_type type, int pcount cbi=l->list; while (cbi) { cb=cbi->data; - if (type == attr_any || cb->type == type) + if (type == attr_any || cb->type == attr_any || cb->type == type) callback_call(cb, pcount, p); cbi=g_list_next(cbi); } @@ -2,6 +2,7 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> +#include <signal.h> #include <glib.h> #include <sys/types.h> #include <sys/wait.h> @@ -71,8 +71,6 @@ struct navit { struct statusbar *statusbar; struct menu *menubar; struct route *route; - struct map *route_map; - struct map *route_graph_map; struct navigation *navigation; struct speech *speech; struct tracking *tracking; @@ -316,9 +314,12 @@ navit_new(struct attr **attrs) struct navit *this_=g_new0(struct navit, 1); struct pcoord center; struct coord co; + struct coord_geo g; enum projection pro=projection_mg; int zoom = 256; FILE *f; + g.lat=53.13; + g.lng=11.70; main_add_navit(this_); this_->self.type=attr_navit; @@ -336,25 +337,23 @@ navit_new(struct attr **attrs) this_->bookmarks_hash=g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); - center.x=1300000; - center.y=7000000; - center.pro = pro; for (;*attrs; attrs++) { switch((*attrs)->type) { case attr_zoom: zoom = (*attrs)->u.num; break; case attr_center: - if (coord_parse((*attrs)->u.str, center.pro, &co)) { - center.x=co.x; - center.y=co.y; - } + g=*((*attrs)->u.coord_geo); break; default: dbg(0, "Unexpected attribute %x\n",(*attrs)->type); break; } } + transform_from_geo(pro, &g, &co); + center.x=co.x; + center.y=co.y; + center.pro = pro; dbg(0,"zoom=%d, coords x=%d, y=%d\n",zoom, center.x, center.y); this_->cursor_flag=1; @@ -1013,6 +1012,7 @@ navit_init(struct navit *this_) { struct menu *men; struct mapset *ms; + struct map *map; GList *l; struct navit_vehicle *nv; @@ -1048,12 +1048,15 @@ navit_init(struct navit *this_) } if (this_->mapsets) { ms=this_->mapsets->data; - if (this_->route_map) - mapset_add(ms, this_->route_map); - if (this_->route_graph_map) - mapset_add(ms, this_->route_graph_map); - if (this_->route) + if (this_->route) { + if ((map=route_get_map(this_->route))) + mapset_add(ms, map); + if ((map=route_get_graph_map(this_->route))) { + mapset_add(ms, map); + map_set_active(map, 0); + } route_set_mapset(this_->route, ms); + } if (this_->tracking) tracking_set_mapset(this_->tracking, ms); if (this_->navigation) @@ -1370,20 +1373,7 @@ navit_tracking_add(struct navit *this_, struct tracking *tracking) void navit_route_add(struct navit *this_, struct route *route) { - struct attr route_attr={.type=attr_route,.u.route=route}; - struct attr data_attr={.type=attr_data,.u.str=""}; - struct attr *attrs_route[]={&route_attr, &data_attr, NULL}; - struct attr *attrs_route_graph[]={&route_attr, &data_attr, NULL}; this_->route=route; - this_->route_map=map_new("route",attrs_route); - this_->route_graph_map=map_new("route_graph",attrs_route_graph); - map_set_active(this_->route_graph_map, 0); -} - -struct map * -navit_get_route_map(struct navit *this_) -{ - return this_->route_map; } void @@ -99,6 +99,8 @@ struct route { struct route_graph *graph; struct route_path *path2; + struct map *map; + struct map *graph_map; int speedlist[route_item_last-route_item_first+1]; }; @@ -1650,6 +1652,31 @@ route_graph_map_new(struct map_methods *meth, struct attr **attrs) return route_map_new_helper(meth, attrs, 1); } +static struct map * +route_get_map_helper(struct route *this_, struct map **map, char *type) +{ + struct attr route_attr={.type=attr_route,.u.route=this_}; + struct attr data_attr={.type=attr_data,.u.str=""}; + struct attr *attrs_route[]={&route_attr, &data_attr, NULL}; + + if (! *map) + *map=map_new(type,attrs_route); + return *map; +} + +struct map * +route_get_map(struct route *this_) +{ + return route_get_map_helper(this_, &this_->map, "route"); +} + + +struct map * +route_get_graph_map(struct route *this_) +{ + return route_get_map_helper(this_, &this_->graph_map, "route_graph"); +} + void @@ -74,6 +74,7 @@ struct coord *route_info_get(struct route_info_handle *h); void route_info_close(struct route_info_handle *h); void route_draw(struct route *this, struct transformation *t, struct displaylist *dsp); struct map *route_get_map(struct route *route); +struct map *route_get_graph_map(struct route *route); void route_toggle_routegraph_display(struct route *route); void route_init(void); /* end of prototypes */ diff --git a/vehicle/demo/vehicle_demo.c b/vehicle/demo/vehicle_demo.c index c5dd4c44..b53b06a3 100644 --- a/vehicle/demo/vehicle_demo.c +++ b/vehicle/demo/vehicle_demo.c @@ -71,17 +71,17 @@ vehicle_demo_timer(struct vehicle_priv *priv) { struct coord c, c2, pos, ci; int slen, len, dx, dy; + struct route *route=NULL; struct map *route_map=NULL; struct map_rect *mr=NULL; struct item *item=NULL; len = (priv->config_speed * priv->interval / 1000)/ 3.6; dbg(1, "###### Entering simulation loop\n"); - if (!priv->navit) { - dbg(1, "vehicle->navit is not set. Can't simulate\n"); - return 1; - } - route_map=navit_get_route_map(priv->navit); + if (priv->navit) + route=navit_get_route(priv->navit); + if (route) + route_map=route_get_map(route); if (route_map) mr=map_rect_new(route_map, NULL); if (mr) |