summaryrefslogtreecommitdiff
path: root/navit
diff options
context:
space:
mode:
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2011-01-20 21:05:32 +0000
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2011-01-20 21:05:32 +0000
commit79b7efe2bcbf0ef1a5f74f59dfdf53d4b38698ae (patch)
treed22d4597a60e6f86118eb3c8f93eb4d4ae620aaa /navit
parent190312b00cb275a4059c6f657bc8753bdc032080 (diff)
downloadnavit-79b7efe2bcbf0ef1a5f74f59dfdf53d4b38698ae.tar.gz
Add:Core:Support for specifying vocabulary
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@3942 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit')
-rw-r--r--navit/navigation.c62
-rw-r--r--navit/navigation.h1
-rw-r--r--navit/navit.c12
3 files changed, 54 insertions, 21 deletions
diff --git a/navit/navigation.c b/navit/navigation.c
index 6b92665e5..beed50a1d 100644
--- a/navit/navigation.c
+++ b/navit/navigation.c
@@ -35,6 +35,7 @@
#include "map.h"
#include "navit.h"
#include "callback.h"
+#include "speech.h"
#include "plugin.h"
#include "navit_nls.h"
@@ -65,6 +66,7 @@ struct navigation {
struct callback_list *callback_speech;
struct callback_list *callback;
struct navit *navit;
+ struct speech *speech;
int level_last;
struct item item_last;
int turn_around;
@@ -159,6 +161,18 @@ navigation_get_attr(struct navigation *this_, enum attr_type type, struct attr *
return 1;
}
+int
+navigation_set_attr(struct navigation *this_, struct attr *attr)
+{
+ switch (attr->type) {
+ case attr_speech:
+ this_->speech=attr->u.speech;
+ return 1;
+ default:
+ return 0;
+ }
+}
+
struct navigation *
navigation_new(struct attr *parent, struct attr **attrs)
@@ -1286,13 +1300,28 @@ replace_suffix(char *name, char *search, char *replace)
}
static char *
-navigation_item_destination(struct navigation_itm *itm, struct navigation_itm *next, char *prefix)
+navigation_item_destination(struct navigation *nav, struct navigation_itm *itm, struct navigation_itm *next, char *prefix)
{
char *ret=NULL,*name1,*sep,*name2;
+ char *n1,*n2;
int i,sex;
+ int vocabulary1=65535;
+ int vocabulary2=65535;
+ struct attr attr;
+
if (! prefix)
prefix="";
- if(!itm->name1 && !itm->name2 && itm->item.type == type_ramp) {
+ if (nav->speech && speech_get_attr(nav->speech, attr_vocabulary_name, &attr, NULL))
+ vocabulary1=attr.u.num;
+ if (nav->speech && speech_get_attr(nav->speech, attr_vocabulary_name_systematic, &attr, NULL))
+ vocabulary2=attr.u.num;
+ n1=itm->name1;
+ n2=itm->name2;
+ if (!vocabulary1)
+ n1=NULL;
+ if (!vocabulary2)
+ n2=NULL;
+ if(!n1 && !n2 && itm->item.type == type_ramp && vocabulary2) {
dbg(1,">> Next is ramp %lx current is %lx \n", itm->item.type, next->item.type);
if(next->item.type == type_ramp)
@@ -1303,25 +1332,25 @@ navigation_item_destination(struct navigation_itm *itm, struct navigation_itm *n
return g_strdup_printf("%s%s",prefix,_("into the ramp"));
}
- if (!itm->name1 && !itm->name2)
+ if (!n1 && !n2)
return NULL;
- if (itm->name1) {
+ if (n1) {
sex=-1;
name1=NULL;
for (i = 0 ; i < sizeof(suffixes)/sizeof(suffixes[0]) ; i++) {
- if (contains_suffix(itm->name1,suffixes[i].fullname)) {
+ if (contains_suffix(n1,suffixes[i].fullname)) {
sex=suffixes[i].sex;
- name1=g_strdup(itm->name1);
+ name1=g_strdup(n1);
break;
}
- if (contains_suffix(itm->name1,suffixes[i].abbrev)) {
+ if (contains_suffix(n1,suffixes[i].abbrev)) {
sex=suffixes[i].sex;
- name1=replace_suffix(itm->name1, suffixes[i].abbrev, suffixes[i].fullname);
+ name1=replace_suffix(n1, suffixes[i].abbrev, suffixes[i].fullname);
break;
}
}
- if (itm->name2) {
- name2=itm->name2;
+ if (n2) {
+ name2=n2;
sep=" ";
} else {
name2="";
@@ -1330,7 +1359,7 @@ navigation_item_destination(struct navigation_itm *itm, struct navigation_itm *n
switch (sex) {
case -1:
/* TRANSLATORS: Arguments: 1: Prefix (Space if required) 2: Street Name 3: Separator (Space if required), 4: Systematic Street Name */
- ret=g_strdup_printf(_("%sinto the street %s%s%s"),prefix,itm->name1, sep, name2);
+ ret=g_strdup_printf(_("%sinto the street %s%s%s"),prefix,n1, sep, name2);
break;
case 1:
/* TRANSLATORS: Arguments: 1: Prefix (Space if required) 2: Street Name 3: Separator (Space if required), 4: Systematic Street Name. Male form. The stuff after | doesn't have to be included */
@@ -1349,7 +1378,7 @@ navigation_item_destination(struct navigation_itm *itm, struct navigation_itm *n
} else
/* TRANSLATORS: gives the name of the next road to turn into (into the E17) */
- ret=g_strdup_printf(_("%sinto the %s"),prefix,itm->name2);
+ ret=g_strdup_printf(_("%sinto the %s"),prefix,n2);
name1=ret;
while (name1 && *name1) {
switch (*name1) {
@@ -1536,7 +1565,7 @@ show_maneuver(struct navigation *nav, struct navigation_itm *itm, struct navigat
tellstreetname = 1;
if(nav->tell_street_name && tellstreetname)
- destination=navigation_item_destination(cmd->itm, itm, " ");
+ destination=navigation_item_destination(nav, cmd->itm, itm, " ");
if (level != -2) {
/* TRANSLATORS: The first argument is strength, the second direction, the third distance and the fourth destination Example: 'Turn 'slightly' 'left' in '100 m' 'onto baker street' */
@@ -1602,7 +1631,10 @@ show_next_maneuvers(struct navigation *nav, struct navigation_itm *itm, struct n
}
next = show_maneuver(nav,prev->itm, cur, type, 0);
- speech_time = navit_speech_estimate(nav->navit,next);
+ if (nav->speech)
+ speech_time = speech_estimate_duration(nav->speech,next);
+ else
+ speech_time = -1;
g_free(next);
if (speech_time == -1) { // user didn't set cps
@@ -1620,7 +1652,7 @@ show_next_maneuvers(struct navigation *nav, struct navigation_itm *itm, struct n
buf = show_maneuver(nav, prev->itm, cur, type, 1);
ret = g_strdup_printf("%s, %s", old, buf);
g_free(buf);
- if (navit_speech_estimate(nav->navit,ret) > time2nav) {
+ if (nav->speech && speech_estimate_duration(nav->speech,ret) > time2nav) {
g_free(ret);
ret = old;
i = 2; // This will terminate the loop
diff --git a/navit/navigation.h b/navit/navigation.h
index 820c87f5a..3d5fd69d7 100644
--- a/navit/navigation.h
+++ b/navit/navigation.h
@@ -33,6 +33,7 @@ struct map;
struct navigation;
struct route;
int navigation_get_attr(struct navigation *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter);
+int navigation_set_attr(struct navigation *this_, struct attr *attr);
struct navigation *navigation_new(struct attr *parent, struct attr **attrs);
int navigation_set_announce(struct navigation *this_, enum item_type type, int *level);
void navigation_destroy(struct navigation *this_);
diff --git a/navit/navit.c b/navit/navit.c
index 25d70a081..5889fdbd9 100644
--- a/navit/navit.c
+++ b/navit/navit.c
@@ -1208,12 +1208,6 @@ navit_textfile_debug_log(struct navit *this_, const char *fmt, ...)
va_end(ap);
}
-int
-navit_speech_estimate(struct navit *this_, char *str)
-{
- return speech_estimate_duration(this_->speech, str);
-}
-
void
navit_say(struct navit *this_, char *text)
{
@@ -1425,6 +1419,12 @@ navit_init(struct navit *this_)
navit_destroy(this_);
return;
}
+ if (this_->speech && this_->navigation) {
+ struct attr speech;
+ speech.type=attr_speech;
+ speech.u.speech=this_->speech;
+ navigation_set_attr(this_->navigation, &speech);
+ }
dbg(2,"Initializing graphics\n");
dbg(2,"Setting Vehicle\n");
navit_set_vehicle(this_, this_->vehicle);