/[zanavi_public1]/navit/navit/route.c
ZANavi

Diff of /navit/navit/route.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 53 Revision 54
5889 int i, rc = 0; 5889 int i, rc = 0;
5890 struct route *r = mr->mpriv->route; 5890 struct route *r = mr->mpriv->route;
5891 enum projection pro = route_projection(r); 5891 enum projection pro = route_projection(r);
5892 5892
5893 if (pro == projection_none) 5893 if (pro == projection_none)
5894 {
5894 return 0; 5895 return 0;
5896 }
5895 5897
5896 if (mr->item.type == type_route_start || mr->item.type == type_route_start_reverse || mr->item.type == type_route_end) 5898 if (mr->item.type == type_route_start || mr->item.type == type_route_start_reverse || mr->item.type == type_route_end)
5897 { 5899 {
5898 if (!count || mr->last_coord) 5900 if (!count || mr->last_coord)
5901 {
5899 return 0; 5902 return 0;
5903 }
5900 5904
5901 mr->last_coord = 1; 5905 mr->last_coord = 1;
5902 5906
5903 if (mr->item.type == type_route_start || mr->item.type == type_route_start_reverse) 5907 if (mr->item.type == type_route_start || mr->item.type == type_route_start_reverse)
5904 { 5908 {
5910 } 5914 }
5911 return 1; 5915 return 1;
5912 } 5916 }
5913 5917
5914 if (!seg) 5918 if (!seg)
5919 {
5915 return 0; 5920 return 0;
5921 }
5916 5922
5917 for (i = 0; i < count; i++) 5923 for (i = 0; i < count; i++)
5918 { 5924 {
5919 if (mr->last_coord >= seg->ncoords) 5925 if (mr->last_coord >= seg->ncoords)
5926 {
5920 break; 5927 break;
5928 }
5921 5929
5922 if (i >= seg->ncoords) 5930 if (i >= seg->ncoords)
5931 {
5923 break; 5932 break;
5933 }
5924 5934
5925 if (pro != projection_mg) 5935 if (pro != projection_mg)
5926 { 5936 {
5927 transform_from_to(&seg->c[mr->last_coord++], pro, &c[i], projection_mg); 5937 transform_from_to(&seg->c[mr->last_coord++], pro, &c[i], projection_mg);
5928 } 5938 }
5962 case attr_any: // works only with rg_points for now 5972 case attr_any: // works only with rg_points for now
5963 while (mr->attr_next != attr_none) 5973 while (mr->attr_next != attr_none)
5964 { 5974 {
5965 //dbg(0, "querying %s\n", attr_to_name(mr->attr_next)); 5975 //dbg(0, "querying %s\n", attr_to_name(mr->attr_next));
5966 if (rp_attr_get(priv_data, mr->attr_next, attr)) 5976 if (rp_attr_get(priv_data, mr->attr_next, attr))
5977 {
5967 return 1; 5978 return 1;
5979 }
5968 } 5980 }
5969 return 0; 5981 return 0;
5970 5982
5971 case attr_maxspeed: 5983 case attr_maxspeed:
5972 mr->attr_next = attr_label; 5984 mr->attr_next = attr_label;
5984 else 5996 else
5985 { 5997 {
5986 return 0; 5998 return 0;
5987 } 5999 }
5988 6000
6001#if 1
6002// jandegr version ----------
6003 case attr_label:
6004 mr->attr_next = attr_street_item;
6005 attr->type = attr_label;
6006
6007 if (mr->str)
6008 {
6009 g_free(mr->str);
6010 }
6011
6012 if (mr->item.type == type_rg_point)
6013 {
6014 int lowest_cost = INT_MAX;
6015
6016 if (p->start && p->start->seg_start_out_cost < lowest_cost)
6017 {
6018 lowest_cost = p->start->seg_start_out_cost;
6019 }
6020 if (p->end && p->end->seg_end_out_cost < lowest_cost)
6021 {
6022 lowest_cost = p->end->seg_end_out_cost;
6023 }
6024
6025 if (lowest_cost < INT_MAX)
6026 {
6027 mr->str = g_strdup_printf("%d", lowest_cost);
6028 }
6029 else
6030 {
6031 mr->str = g_strdup("-");
6032 }
6033 }
6034 else
6035 {
6036 int len = seg->data.len;
6037 int speed = route_seg_speed(route->vehicleprofile, &seg->data, NULL);
6038 int time = route_time_seg(route->vehicleprofile, &seg->data, NULL);
6039
6040 // system_log(0, "rp_attr_get:attr_label:002a:%d %d %d", len, speed, time);
6041
6042 if (speed)
6043 {
6044 mr->str = g_strdup_printf("%dm %dkm/h %d.%ds", len, speed, (time / 10), (time % 10));
6045 }
6046 else if (len)
6047 {
6048 mr->str = g_strdup_printf("%dm",len);
6049 }
6050 else
6051 {
6052 mr->str = NULL;
6053 return 0;
6054 }
6055 }
6056 attr->u.str = mr->str;
6057 return 1;
6058
6059 case attr_street_item:
6060 mr->attr_next = attr_flags;
6061 if (mr->item.type != type_rg_segment)
6062 {
6063 return 0;
6064 }
6065
6066 if (seg && seg->data.item.map)
6067 {
6068 attr->u.item = &seg->data.item;
6069 }
6070 else
6071 {
6072 return 0;
6073 }
6074 return 1;
6075// jandegr version ----------
6076#endif
6077
6078#if 0
6079// zoff version ----------
5989 case attr_label: 6080 case attr_label:
5990 mr->attr_next = attr_street_item; 6081 mr->attr_next = attr_street_item;
5991 if ((mr->item.type != type_rg_point) && (mr->item.type != type_rg_segment)) 6082 if ((mr->item.type != type_rg_point) && (mr->item.type != type_rg_segment))
5992 { 6083 {
5993 return 0; 6084 return 0;
6053 return 1; 6144 return 1;
6054 6145
6055 case attr_street_item: 6146 case attr_street_item:
6056 mr->attr_next = attr_flags; 6147 mr->attr_next = attr_flags;
6057 if (mr->item.type != type_rg_segment) 6148 if (mr->item.type != type_rg_segment)
6149 {
6058 return 0; 6150 return 0;
6151 }
6152
6059 if (seg && seg->data.item.map) 6153 if (seg && seg->data.item.map)
6154 {
6060 attr->u.item = &seg->data.item; 6155 attr->u.item = &seg->data.item;
6156 }
6061 else 6157 else
6158 {
6062 return 0; 6159 return 0;
6160 }
6063 return 1; 6161 return 1;
6064 6162// zoff version ----------
6163#endif
6065 case attr_flags: 6164 case attr_flags:
6066 mr->attr_next = attr_direction; 6165 mr->attr_next = attr_direction;
6067 if (mr->item.type != type_rg_segment) 6166 if (mr->item.type != type_rg_segment)
6167 {
6068 return 0; 6168 return 0;
6169 }
6170
6069 if (seg) 6171 if (seg)
6070 { 6172 {
6071 attr->u.num = seg->data.flags; 6173 attr->u.num = seg->data.flags;
6072 } 6174 }
6073 else 6175 else
6079 case attr_direction: 6181 case attr_direction:
6080 mr->attr_next = attr_debug; 6182 mr->attr_next = attr_debug;
6081 // This only works if the map has been opened at a single point, and in that case indicates if the 6183 // This only works if the map has been opened at a single point, and in that case indicates if the
6082 // segment returned last is connected to this point via its start (1) or its end (-1) 6184 // segment returned last is connected to this point via its start (1) or its end (-1)
6083 if (!mr->coord_sel || (mr->item.type != type_rg_segment)) 6185 if (!mr->coord_sel || (mr->item.type != type_rg_segment))
6186 {
6084 return 0; 6187 return 0;
6188 }
6085 6189
6086 if (seg->start == mr->point) 6190 if (seg->start == mr->point)
6087 { 6191 {
6088 attr->u.num = 1; 6192 attr->u.num = 1;
6089 } 6193 }
6100 6204
6101 case attr_debug: 6205 case attr_debug:
6102 mr->attr_next = attr_none; 6206 mr->attr_next = attr_none;
6103 6207
6104 if (mr->str) 6208 if (mr->str)
6209 {
6105 g_free(mr->str); 6210 g_free(mr->str);
6211 }
6212 mr->str=NULL;
6106 6213
6107 switch (mr->item.type) 6214 switch (mr->item.type)
6108 { 6215 {
6109 case type_rg_point: 6216 case type_rg_point:
6110 {
6111 struct route_graph_segment *tmp;
6112 int start = 0;
6113 int end = 0;
6114 tmp = p->start;
6115 while (tmp)
6116 { 6217 {
6218 struct route_graph_segment *tmp;
6219 int start = 0;
6220 int end = 0;
6221 tmp = p->start;
6222 while (tmp)
6223 {
6117 start++; 6224 start++;
6118 tmp = tmp->start_next; 6225 tmp = tmp->start_next;
6226 }
6227 tmp = p->end;
6228 while (tmp)
6229 {
6230 end++;
6231 tmp = tmp->end_next;
6232 }
6233 mr->str = g_strdup_printf("%d %d %p (0x%x,0x%x)", start, end, p, p->c.x, p->c.y);
6234 attr->u.str = mr->str;
6119 } 6235 }
6120 tmp = p->end;
6121 while (tmp)
6122 {
6123 end++;
6124 tmp = tmp->end_next;
6125 }
6126 mr->str = g_strdup_printf("%d %d %p (0x%x,0x%x)", start, end, p, p->c.x, p->c.y);
6127 attr->u.str = mr->str;
6128 }
6129 return 1; 6236 return 1;
6237
6130 case type_rg_segment: 6238 case type_rg_segment:
6131 if (!seg) 6239 if (!seg)
6240 {
6132 return 0; 6241 return 0;
6242 }
6133 mr->str = g_strdup_printf("len %d time %d start %p end %p", seg->data.len, route_time_seg(route->vehicleprofile, &seg->data, NULL), seg->start, seg->end); 6243 mr->str = g_strdup_printf("len %d time %d start %p end %p", seg->data.len, route_time_seg(route->vehicleprofile, &seg->data, NULL), seg->start, seg->end);
6134 attr->u.str = mr->str; 6244 attr->u.str = mr->str;
6135 return 1; 6245 return 1;
6246
6136 default: 6247 default:
6137 return 0; 6248 return 0;
6138 } 6249 }
6139 default: 6250 default:
6140 mr->attr_next = attr_none; 6251 mr->attr_next = attr_none;
6156 //// dbg(0, "enter\n"); 6267 //// dbg(0, "enter\n");
6157 6268
6158 struct map_rect_priv *mr = priv_data; 6269 struct map_rect_priv *mr = priv_data;
6159 struct route_graph_point *p = mr->point; 6270 struct route_graph_point *p = mr->point;
6160 struct route_graph_segment *seg = mr->rseg; 6271 struct route_graph_segment *seg = mr->rseg;
6161 int rc = 0, i, dir; 6272 int rc = 0;
6273 int i;
6274 int dir;
6162 struct route *r = mr->mpriv->route; 6275 struct route *r = mr->mpriv->route;
6163 enum projection pro = route_projection(r); 6276 enum projection pro = route_projection(r);
6164 6277
6165 if (pro == projection_none) 6278 if (pro == projection_none)
6166 { 6279 {
6170 for (i = 0; i < count; i++) 6283 for (i = 0; i < count; i++)
6171 { 6284 {
6172 if (mr->item.type == type_rg_point) 6285 if (mr->item.type == type_rg_point)
6173 { 6286 {
6174 if (mr->last_coord >= 1) 6287 if (mr->last_coord >= 1)
6288 {
6175 break; 6289 break;
6290 }
6176 6291
6177 if (pro != projection_mg) 6292 if (pro != projection_mg)
6293 {
6178 transform_from_to(&p->c, pro, &c[i], projection_mg); 6294 transform_from_to(&p->c, pro, &c[i], projection_mg);
6295 }
6179 else 6296 else
6297 {
6180 c[i] = p->c; 6298 c[i] = p->c;
6181 } 6299 }
6182 else 6300 }
6301 else // mr->item.type == type_rg_segment
6183 { 6302 {
6184 if (mr->last_coord >= 2) 6303 if (mr->last_coord >= 2)
6304 {
6185 break; 6305 break;
6306 }
6186 6307
6187 dir = 0; 6308 dir = 0;
6188
6189 // FIXME !!
6190
6191 // if (seg->end->seg == seg) 6309 // if (seg->end->seg == seg)
6192 // dir = 1; 6310 // dir=1;
6193 6311
6194 if (mr->last_coord) 6312 if (mr->last_coord)
6313 {
6195 dir = 1 - dir; 6314 dir = ( 1 - dir );
6315 }
6196 6316
6317
6197 // if (dir) 6318 if (dir)
6198 // {
6199 // if (pro != projection_mg)
6200 // transform_from_to(&seg->end->c, pro, &c[i], projection_mg);
6201 // else
6202 // c[i] = seg->end->c;
6203 // }
6204 // else
6205 { 6319 {
6206 if (pro != projection_mg) 6320 if (pro != projection_mg)
6321 {
6322 transform_from_to(&seg->end->c, pro, &c[i], projection_mg);
6323 }
6324 else
6325 {
6326 c[i] = seg->end->c;
6327 }
6328 }
6329 else
6330 {
6331 if (pro != projection_mg)
6332 {
6207 transform_from_to(&seg->start->c, pro, &c[i], projection_mg); 6333 transform_from_to(&seg->start->c, pro, &c[i], projection_mg);
6334 }
6208 else 6335 else
6336 {
6209 c[i] = seg->start->c; 6337 c[i] = seg->start->c;
6210 } 6338 }
6211 } 6339 }
6340 }
6341
6212 mr->last_coord++; 6342 mr->last_coord++;
6213 rc++; 6343 rc++;
6344
6214 } 6345 }
6346
6215 return rc; 6347 return rc;
6216} 6348}
6217 6349
6218static struct item_methods methods_point_item = { rm_coord_rewind, rp_coord_get, rp_attr_rewind, rp_attr_get, }; 6350static struct item_methods methods_point_item = { rm_coord_rewind, rp_coord_get, rp_attr_rewind, rp_attr_get, };
6219 6351

Legend:
Removed from v.53  
changed lines
  Added in v.54

   
Visit the ZANavi Wiki