From 5bd60a362d6218c5b57dfba87c5247bf874aade4 Mon Sep 17 00:00:00 2001 From: martin-s Date: Thu, 28 Jul 2011 19:06:47 +0000 Subject: [PATCH] Add:Core:Implemented set_center command, extended coordinate format for set_destination git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@4663 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- navit/navit/navit.c | 59 ++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 16 deletions(-) diff --git a/navit/navit/navit.c b/navit/navit/navit.c index 4f6cdf4..857ec96 100644 --- a/navit/navit/navit.c +++ b/navit/navit/navit.c @@ -1118,39 +1118,65 @@ navit_cmd_int_stack_size(struct navit *this, char *function, struct attr **in, s cmd_int_var_stack = g_list_remove_link(cmd_int_var_stack,cmd_int_var_stack); } -static void -navit_cmd_set_destination(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) +static struct attr ** +navit_get_coord(struct navit *this, struct attr **in, struct pcoord *pc) { - struct pcoord pc; - char *description=NULL; if (!in) - return; + return NULL; if (!in[0]) - return; - pc.pro = transform_get_projection(this->trans); - if (ATTR_IS_COORD(in[0]->type)) { - pc.x=in[0]->u.coord->x; - pc.y=in[0]->u.coord->y; + return NULL; + pc->pro = transform_get_projection(this->trans); + if (ATTR_IS_STRING(in[0]->type)) { + struct coord c; + coord_parse(in[0]->u.str, pc->pro, &c); + pc->x=c.x; + pc->y=c.y; + in++; + } else if (ATTR_IS_COORD(in[0]->type)) { + pc->x=in[0]->u.coord->x; + pc->y=in[0]->u.coord->y; in++; } else if (ATTR_IS_PCOORD(in[0]->type)) { - pc=*in[0]->u.pcoord; + *pc=*in[0]->u.pcoord; in++; } else if (in[1] && in[2] && ATTR_IS_INT(in[0]->type) && ATTR_IS_INT(in[1]->type) && ATTR_IS_INT(in[2]->type)) { - pc.pro=in[0]->u.num; - pc.x=in[1]->u.num; - pc.y=in[2]->u.num; + pc->pro=in[0]->u.num; + pc->x=in[1]->u.num; + pc->y=in[2]->u.num; in+=3; } else if (in[1] && ATTR_IS_INT(in[0]->type) && ATTR_IS_INT(in[1]->type)) { - pc.x=in[0]->u.num; - pc.y=in[1]->u.num; + pc->x=in[0]->u.num; + pc->y=in[1]->u.num; in+=2; } else + return NULL; + return in; +} + +static void +navit_cmd_set_destination(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) +{ + struct pcoord pc; + char *description=NULL; + in=navit_get_coord(this, in, &pc); + if (!in) return; if (in[0] && ATTR_IS_STRING(in[0]->type)) description=in[0]->u.str; navit_set_destination(this, &pc, description, 1); } + +static void +navit_cmd_set_center(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) +{ + struct pcoord pc; + in=navit_get_coord(this, in, &pc); + if (!in) + return; + navit_set_center(this, &pc, 0); +} + static void navit_cmd_fmt_coordinates(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) { @@ -1265,6 +1291,7 @@ static struct command_table commands[] = { {"zoom_out",command_cast(navit_cmd_zoom_out)}, {"zoom_to_route",command_cast(navit_cmd_zoom_to_route)}, {"say",command_cast(navit_cmd_say)}, + {"set_center",command_cast(navit_cmd_set_center)}, {"set_center_cursor",command_cast(navit_cmd_set_center_cursor)}, {"set_destination",command_cast(navit_cmd_set_destination)}, {"announcer_toggle",command_cast(navit_cmd_announcer_toggle)}, -- 2.7.4