}
static int
-coord_is_segment(void *priv_data)
+coord_is_node(void *priv_data)
{
struct gobject *g = priv_data;
struct map_rect_priv *mr = g->priv_data;
if (mr->last_coord == 0)
- return 0;
- return gar_is_object_dcoord_node(mr->gmap, g, mr->last_coord - 1);
+ return 1;
+ return gar_is_object_dcoord_node(mr->gmap, g, mr->last_coord);
}
static int
attr->type = attr_town_name;
return garmin_object_label(g, attr);
case attr_street_name:
- attr->type = attr_street_name;
+ attr->type = attr_type;
return garmin_object_label(g, attr);
case attr_flags:
attr->type = attr_flags;
poly_coord_get,
attr_rewind, // point_attr_rewind,
point_attr_get, // poly_attr_get,
- coord_is_segment,
+ coord_is_node,
};
static int
int (*item_coord_get)(void *priv_data, struct coord *c, int count);
void (*item_attr_rewind)(void *priv_data);
int (*item_attr_get)(void *priv_data, enum attr_type attr_type, struct attr *attr);
- int (*item_coord_is_segment)(void *priv_data);
+ int (*item_coord_is_node)(void *priv_data);
};
struct item {
int id_hi;
int id_lo;
struct map *map;
- struct item_methods *meth;
+ struct item_methods *meth;
void *priv_data;
};
void item_coord_rewind(struct item *it);
int item_coord_get(struct item *it, struct coord *c, int count);
int item_coord_get_pro(struct item *it, struct coord *c, int count, enum projection pro);
-/* does the next returned coordinate mark a segment */
-int item_coord_is_segment(struct item *it);
+/* does the next returned coordinate mark a node */
+int item_coord_is_node(struct item *it);
void item_attr_rewind(struct item *it);
int item_attr_get(struct item *it, enum attr_type attr_type, struct attr *attr);
struct item *item_new(char *type, int zoom);
int
route_destination_reached(struct route *this)
{
- struct street_data *sd = NULL;
+ struct street_data *sd = NULL;
- if(! this->pos)
- return 0;
-
- sd = this->pos->street;
+ if (!this->pos)
+ return 0;
+
+ sd = this->pos->street;
if (!this->path2) {
return 0;
}
- if (! item_is_equal(this->pos->street->item, this->dst->street->item)) {
+ if (!item_is_equal(this->pos->street->item, this->dst->street->item)) {
return 0;
}
return 0;
}
- if (transform_distance(projection_mg, &this->pos->c, &this->dst->lp) > this->destination_distance) {
+ if (transform_distance(route_projection(this), &this->pos->c, &this->dst->lp) > this->destination_distance) {
return 0;
}
int flags, int offset)
{
struct route_graph_segment *s;
+/*
+ FIXME: commented out becouse
+ it is possible to have one item with two different
+ offsets as segments
s=start->start;
while (s) {
if (item_is_equal(*item, s->item))
return;
s=s->start_next;
- }
+ }
+*/
s = g_new0(struct route_graph_segment, 1);
if (!s) {
printf("%s:Out of memory\n", __FUNCTION__);
int isseg,rc;
int sc = 0;
do {
- isseg = item_coord_is_segment(item);
+ isseg = item_coord_is_node(item);
rc = item_coord_get(item, &c, 1);
if (rc) {
len+=transform_distance(map_projection(item->map), &l, &c);
else
return 0;
return 1;
+ case attr_label:
+ mr->attr_next=attr_none;
+ return 0;
default:
+ mr->attr_next=attr_none;
attr->type=attr_none;
return 0;
}
struct map_rect_priv *mr = priv_data;
struct route_path_segment *seg = mr->seg;
int i,rc=0;
+ struct route *r = mr->mpriv->route;
+ enum projection pro = route_projection(r);
+
if (! seg)
return 0;
for (i=0; i < count; i++) {
break;
if (i >= seg->ncoords)
break;
- c[i] = seg->c[mr->last_coord++];
+ if (pro != projection_mg)
+ transform_from_to(&seg->c[mr->last_coord++], pro,
+ &c[i],projection_mg);
+ else
+ c[i] = seg->c[mr->last_coord++];
rc++;
}
dbg(1,"return %d\n",rc);
switch (attr_type) {
case attr_any:
while (mr->attr_next != attr_none) {
- if (rm_attr_get(priv_data, mr->attr_next, attr))
+ if (rp_attr_get(priv_data, mr->attr_next, attr))
return 1;
}
+ return 0;
case attr_label:
attr->type = attr_label;
if (mr->str)
mr->attr_next=attr_none;
return 1;
default:
+ mr->attr_next=attr_none;
+ attr->type=attr_none;
return 0;
}
}
struct route_graph_point *p = mr->point;
struct route_graph_segment *seg = mr->rseg;
int rc = 0,i,dir;
+ struct route *r = mr->mpriv->route;
+ enum projection pro = route_projection(r);
+
for (i=0; i < count; i++) {
if (mr->item.type == type_rg_point) {
if (mr->last_coord >= 1)
break;
- c[i] = p->c;
+ if (pro != projection_mg)
+ transform_from_to(&p->c, pro,
+ &c[i],projection_mg);
+ else
+ c[i] = p->c;
} else {
if (mr->last_coord >= 2)
break;
dir=1;
if (mr->last_coord)
dir=1-dir;
- if (dir)
- c[i] = seg->end->c;
- else
- c[i] = seg->start->c;
+ if (dir) {
+ if (pro != projection_mg)
+ transform_from_to(&seg->end->c, pro,
+ &c[i],projection_mg);
+ else
+ c[i] = seg->end->c;
+ } else {
+ if (pro != projection_mg)
+ transform_from_to(&seg->start->c, pro,
+ &c[i],projection_mg);
+ else
+ c[i] = seg->start->c;
+ }
}
mr->last_coord++;
rc++;
static struct map_methods route_meth = {
projection_mg,
- NULL,
+ "utf-8",
rm_destroy,
rm_rect_new,
rm_rect_destroy,
static struct map_methods route_graph_meth = {
projection_mg,
- NULL,
+ "utf-8",
rm_destroy,
rp_rect_new,
rm_rect_destroy,