summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--attr.c6
-rw-r--r--item_def.h1
-rw-r--r--layout.c3
-rw-r--r--layout.h3
-rw-r--r--map.c6
-rw-r--r--map.h1
-rw-r--r--navit.c1
-rw-r--r--navit.xml5
-rw-r--r--route.c157
-rw-r--r--route.h1
-rw-r--r--transform.c8
-rw-r--r--transform.h1
-rw-r--r--xmlconfig.c10
13 files changed, 156 insertions, 47 deletions
diff --git a/attr.c b/attr.c
index 6b87431b..3d65c853 100644
--- a/attr.c
+++ b/attr.c
@@ -114,6 +114,12 @@ attr_to_text(struct attr *attr, struct map *map, int pretty)
char *ret;
enum attr_type type=attr->type;
+ if (type >= attr_type_item_begin && type <= attr_type_item_end) {
+ struct item *item=attr->u.item;
+ if (! item)
+ return g_strdup("(nil)");
+ return g_strdup_printf("type=0x%x id=0x%x,0x%x map=%p (%s:%s)", item->type, item->id_hi, item->id_lo, item->map, item->map ? map_get_type(item->map) : "", item->map ? map_get_filename(item->map) : "");
+ }
if (type >= attr_type_string_begin && type <= attr_type_string_end) {
if (map) {
char *mstr=map_convert_string(map, attr->u.str);
diff --git a/item_def.h b/item_def.h
index 283265ad..c106b171 100644
--- a/item_def.h
+++ b/item_def.h
@@ -242,6 +242,7 @@ ITEM(time_zone)
ITEM(marine_boundary)
ITEM(marine_hazard)
ITEM(roundabout)
+ITEM(rg_segment)
/* Area */
ITEM2(0xc0000000,area)
ITEM2(0xc0000001,area_unspecified)
diff --git a/layout.c b/layout.c
index 249989cc..b47dad4a 100644
--- a/layout.c
+++ b/layout.c
@@ -66,7 +66,7 @@ polygon_new(struct color *color)
}
struct element *
-polyline_new(struct color *color, int width)
+polyline_new(struct color *color, int width, int directed)
{
struct element *e;
@@ -74,6 +74,7 @@ polyline_new(struct color *color, int width)
e->type=element_polyline;
e->color=*color;
e->u.polyline.width=width;
+ e->u.polyline.directed=directed;
return e;
}
diff --git a/layout.h b/layout.h
index 083022c2..ddf90ba8 100644
--- a/layout.h
+++ b/layout.h
@@ -16,6 +16,7 @@ struct element {
} point;
struct element_polyline {
int width;
+ int directed;
} polyline;
struct element_polygon {
} polygon;
@@ -55,7 +56,7 @@ void itemtype_add_type(struct itemtype *this, enum item_type type);
void layer_add_itemtype(struct layer *layer, struct itemtype *itemtype);
void itemtype_add_element(struct itemtype *itemtype, struct element *element);
struct element *polygon_new(struct color *color);
-struct element *polyline_new(struct color *color, int width);
+struct element *polyline_new(struct color *color, int width, int directed);
struct element *circle_new(struct color *color, int radius, int width, int label_size);
struct element *label_new(int label_size);
struct element *icon_new(const char *src);
diff --git a/map.c b/map.c
index c86ad5b7..db9ee2c2 100644
--- a/map.c
+++ b/map.c
@@ -98,6 +98,12 @@ map_projection(struct map *this_)
}
void
+map_set_projection(struct map *this_, enum projection pro)
+{
+ this_->meth.pro=pro;
+}
+
+void
map_destroy(struct map *m)
{
m->meth.map_destroy(m->priv);
diff --git a/map.h b/map.h
index 74da1a35..9d0a1e3a 100644
--- a/map.h
+++ b/map.h
@@ -142,6 +142,7 @@ int map_requires_conversion(struct map *this_);
char *map_convert_string(struct map *this_, char *str);
void map_convert_free(char *str);
enum projection map_projection(struct map *this_);
+void map_set_projection(struct map *this_, enum projection pro);
void map_destroy(struct map *m);
struct map_rect *map_rect_new(struct map *m, struct map_selection *sel);
struct item *map_rect_get_item(struct map_rect *mr);
diff --git a/navit.c b/navit.c
index be6db6d0..79024cc6 100644
--- a/navit.c
+++ b/navit.c
@@ -1447,6 +1447,7 @@ void
navit_route_add(struct navit *this_, struct route *route)
{
this_->route=route;
+ route_set_projection(route, transform_get_projection(this_->trans));
}
void
diff --git a/navit.xml b/navit.xml
index aa6f913f..40d5f285 100644
--- a/navit.xml
+++ b/navit.xml
@@ -816,8 +816,11 @@ Change to your home coordinates.
<polygon color="#a0a0a0" />
<label label_size="5" />
</item>
+ <item type="rg_segment" order="0-">
+ <polyline color="#FF089C" width="1" />
+ </item>
<item type="rg_point" order="0-">
- <circle color="#FF089C" radius="10" />
+ <circle color="#FF089C" radius="10" label_size="7" />
</item>
</layer>
</layout>
diff --git a/route.c b/route.c
index 366975f0..650fe271 100644
--- a/route.c
+++ b/route.c
@@ -1313,6 +1313,7 @@ route_crossings_get(struct route *this, struct coord *c)
struct map_rect_priv {
struct route_info_handle *ri;
+ enum attr_type attr_next;
int pos_next;
int pos;
struct map_priv *mpriv;
@@ -1322,7 +1323,8 @@ struct map_rect_priv {
unsigned int last_coord;
struct route_path_segment *seg;
struct route_graph_point *point;
- char *label;
+ struct route_graph_segment *rseg;
+ char *str;
};
static void
@@ -1335,6 +1337,8 @@ rm_coord_rewind(void *priv_data)
static void
rm_attr_rewind(void *priv_data)
{
+ struct map_rect_priv *mr = priv_data;
+ mr->attr_next = attr_street_item;
}
static int
@@ -1345,23 +1349,32 @@ rm_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr)
struct route *route=mr->mpriv->route;
attr->type=attr_type;
switch (attr_type) {
+ case attr_any:
+ while (mr->attr_next != attr_none) {
+ if (rm_attr_get(priv_data, mr->attr_next, attr))
+ return 1;
+ }
+ return 0;
case attr_street_item:
if (seg)
attr->u.item=&seg->item;
else
attr->u.item=mr->sitem;
+ mr->attr_next=attr_length;
return 1;
case attr_length:
if (seg)
attr->u.num=seg->length;
else
attr->u.num=mr->length;
+ mr->attr_next=attr_time;
return 1;
case attr_time:
if (seg)
attr->u.num=route_time(route->speedlist, &seg->item, seg->length);
else
attr->u.num=route_time(route->speedlist, mr->sitem, mr->length);
+ mr->attr_next=attr_none;
return 1;
default:
attr->type=attr_none;
@@ -1422,22 +1435,44 @@ static struct item_methods methods_route_item = {
rm_attr_get,
};
+static void
+rp_attr_rewind(void *priv_data)
+{
+ struct map_rect_priv *mr = priv_data;
+ mr->attr_next = attr_label;
+}
+
static int
rp_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr)
{
struct map_rect_priv *mr = priv_data;
struct route_graph_point *p = mr->point;
+ if (mr->item.type != type_rg_point)
+ return 0;
switch (attr_type) {
- case attr_any:
- case attr_label:
- attr->type = attr_label;
- if (mr->label)
- g_free(mr->label);
- mr->label=g_strdup_printf("x=%d y=%d", p->c.x, p->c.y);
- attr->u.str = mr->label;
- return 1;
- default:
- return 0;
+ case attr_any:
+ while (mr->attr_next != attr_none) {
+ if (rm_attr_get(priv_data, mr->attr_next, attr))
+ return 1;
+ }
+ case attr_label:
+ attr->type = attr_label;
+ if (mr->str)
+ g_free(mr->str);
+ mr->str=g_strdup_printf("%d", p->value);
+ attr->u.str = mr->str;
+ mr->attr_next=attr_none;
+ return 1;
+ case attr_debug:
+ attr->type = attr_debug;
+ if (mr->str)
+ g_free(mr->str);
+ mr->str=g_strdup_printf("x=%d y=%d", p->c.x, p->c.y);
+ attr->u.str = mr->str;
+ mr->attr_next=attr_none;
+ return 1;
+ default:
+ return 0;
}
}
@@ -1446,11 +1481,21 @@ rp_coord_get(void *priv_data, struct coord *c, int count)
{
struct map_rect_priv *mr = priv_data;
struct route_graph_point *p = mr->point;
+ struct route_graph_segment *seg = mr->rseg;
int rc = 0,i;
for (i=0; i < count; i++) {
- if (mr->last_coord >= 1)
- break;
- c[i] = p->c;
+ if (mr->item.type == type_rg_point) {
+ if (mr->last_coord >= 1)
+ break;
+ c[i] = p->c;
+ } else {
+ if (mr->last_coord >= 2)
+ break;
+ if (mr->last_coord)
+ c[i] = seg->end->c;
+ else
+ c[i] = seg->start->c;
+ }
mr->last_coord++;
rc++;
}
@@ -1460,7 +1505,7 @@ rp_coord_get(void *priv_data, struct coord *c, int count)
static struct item_methods methods_point_item = {
rm_coord_rewind,
rp_coord_get,
- rm_attr_rewind,
+ rp_attr_rewind,
rp_attr_get,
};
@@ -1486,6 +1531,9 @@ rm_rect_new(struct map_priv *priv, struct map_selection *sel)
mr->ri=route_info_open(route_get_pos(priv->route), route_get_dst(priv->route), 0);
mr->pos_next=1;
mr->sitem=&(route_get_pos(priv->route)->street->item);
+ mr->item.priv_data = mr;
+ mr->item.type = type_street_route;
+ mr->item.meth = &methods_route_item;
if (mr->ri) {
mr->length=route_info_length(route_get_pos(priv->route), route_get_dst(priv->route), 0);
} else {
@@ -1505,6 +1553,9 @@ rp_rect_new(struct map_priv *priv, struct map_selection *sel)
return NULL;
mr=g_new0(struct map_rect_priv, 1);
mr->mpriv = priv;
+ mr->item.priv_data = mr;
+ mr->item.type = type_rg_point;
+ mr->item.meth = &methods_point_item;
return mr;
}
@@ -1513,8 +1564,8 @@ rm_rect_destroy(struct map_rect_priv *mr)
{
if (mr->ri)
route_info_close(mr->ri);
- if (mr->label)
- g_free(mr->label);
+ if (mr->str)
+ g_free(mr->str);
g_free(mr);
}
@@ -1523,24 +1574,47 @@ rp_get_item(struct map_rect_priv *mr)
{
struct route *r = mr->mpriv->route;
struct route_graph_point *p = mr->point;
+ struct route_graph_segment *seg = mr->rseg;
- if (!p)
- p = r->graph->route_points;
+ if (mr->item.type == type_rg_point) {
+ if (!p)
+ p = r->graph->route_points;
+ else
+ p = p->next;
+ if (p) {
+ mr->point = p;
+ mr->item.id_lo++;
+ rm_coord_rewind(mr);
+ rp_attr_rewind(mr);
+ return &mr->item;
+ } else
+ mr->item.type = type_rg_segment;
+ }
+ if (!seg)
+ seg=r->graph->route_segments;
else
- p = p->next;
- if (!p)
- return NULL;
- mr->point = p;
- mr->last_coord = 0;
- mr->item.id_hi = 0;
- mr->item.id_lo = 0;
- mr->item.map = NULL;
- mr->item.priv_data = mr;
- mr->item.type = type_rg_point;
- mr->item.meth = &methods_point_item;
- return &mr->item;
+ seg=seg->next;
+ if (seg) {
+ mr->rseg = seg;
+ mr->item.id_lo++;
+ rm_coord_rewind(mr);
+ rp_attr_rewind(mr);
+ return &mr->item;
+ }
+ return NULL;
+
+}
+
+static struct item *
+rp_get_item_byid(struct map_rect_priv *mr, int id_hi, int id_lo)
+{
+ struct item *ret=NULL;
+ while (id_lo-- > 0)
+ ret=rp_get_item(mr);
+ return ret;
}
+
static struct item *
rm_get_item(struct map_rect_priv *mr)
{
@@ -1575,20 +1649,18 @@ rm_get_item(struct map_rect_priv *mr)
}
mr->seg = seg;
mr->last_coord = 0;
- mr->item.id_hi = 0;
- mr->item.id_lo = 0;
- mr->item.map = NULL;
- mr->item.priv_data = mr;
- mr->item.type = type_street_route;
- mr->item.meth = &methods_route_item;
+ mr->item.id_lo++;
+ rm_attr_rewind(mr);
return &mr->item;
}
static struct item *
rm_get_item_byid(struct map_rect_priv *mr, int id_hi, int id_lo)
{
- dbg(0,"called on Route map\n");
- return NULL;
+ struct item *ret=NULL;
+ while (id_lo-- > 0)
+ ret=rm_get_item(mr);
+ return ret;
}
static struct map_methods route_meth = {
@@ -1611,7 +1683,7 @@ static struct map_methods route_graph_meth = {
rp_rect_new,
rm_rect_destroy,
rp_get_item,
- rm_get_item_byid,
+ rp_get_item_byid,
NULL,
NULL,
NULL,
@@ -1683,7 +1755,10 @@ route_get_graph_map(struct route *this_)
return route_get_map_helper(this_, &this_->graph_map, "route_graph");
}
-
+void
+route_set_projection(struct route *this_, enum projection pro)
+{
+}
void
route_init(void)
diff --git a/route.h b/route.h
index a096916b..9473bea7 100644
--- a/route.h
+++ b/route.h
@@ -76,6 +76,7 @@ void route_draw(struct route *this, struct transformation *t, struct displaylist
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_set_projection(struct route *this_, enum projection pro);
void route_init(void);
/* end of prototypes */
diff --git a/transform.c b/transform.c
index 382d7ac6..c82dfc41 100644
--- a/transform.c
+++ b/transform.c
@@ -69,6 +69,14 @@ transform_from_geo(enum projection pro, struct coord_geo *g, struct coord *c)
}
}
+void
+transform_from_to(struct coord *cfrom, enum projection from, struct coord *cto, enum projection to)
+{
+ struct coord_geo g;
+ transform_to_geo(from, cfrom, &g);
+ transform_from_geo(to, &g, cto);
+}
+
int
transform(struct transformation *t, enum projection pro, struct coord *c, struct point *p, int count, int unique)
{
diff --git a/transform.h b/transform.h
index d06075bd..b47a268c 100644
--- a/transform.h
+++ b/transform.h
@@ -15,6 +15,7 @@ struct transformation;
struct transformation *transform_new(void);
void transform_to_geo(enum projection pro, struct coord *c, struct coord_geo *g);
void transform_from_geo(enum projection pro, struct coord_geo *g, struct coord *c);
+void transform_from_to(struct coord *cfrom, enum projection from, struct coord *cto, enum projection to);
int transform(struct transformation *t, enum projection pro, struct coord *c, struct point *p, int count, int flags);
void transform_reverse(struct transformation *t, struct point *p, struct coord *c);
enum projection transform_get_projection(struct transformation *this_);
diff --git a/xmlconfig.c b/xmlconfig.c
index 120fbbb1..00123f54 100644
--- a/xmlconfig.c
+++ b/xmlconfig.c
@@ -499,15 +499,19 @@ static int
xmlconfig_polyline(struct xmlstate *state)
{
struct color color;
- const char *width;
- int w=0;
+ const char *width, *directed;
+ int w=0,d=0;
if (! find_color(state, 1, &color))
return 0;
width=find_attribute(state, "width", 0);
if (width)
w=convert_number(width);
- state->element_object=polyline_new(&color, w);
+ directed=find_attribute(state, "directed", 0);
+ if (directed)
+ d=convert_number(directed);
+
+ state->element_object=polyline_new(&color, w, d);
if (! state->element_object)
return 0;
itemtype_add_element(state->parent->element_object, state->element_object);