void update_range_dialog(void) { RoadMapPosition from; RoadMapPosition to; PluginLine line; RoadMapNeighbour result; int direction; if (roadmap_navigate_get_current (&CurrentGpsPoint, &line, &direction) == -1) { roadmap_messagebox ("Error", "Can't find current street."); return; } roadmap_plugin_line_from (&line, &from); roadmap_plugin_line_to (&line, &to); if (!roadmap_plugin_get_distance ((RoadMapPosition *)&CurrentGpsPoint, &line, &result)) { roadmap_messagebox ("Error", "Can't find a road near point."); return; } CurrentFixedPosition = result.intersection; #ifndef SSD if (roadmap_dialog_activate ("Update house number", NULL, 1)) { roadmap_dialog_new_label ("Update", STREET_PREFIX); roadmap_dialog_new_label ("Update", CITY_PREFIX); roadmap_dialog_new_label ("Update", "Estimated"); roadmap_dialog_new_entry ("Update", UPDATE_LEFT, NULL); roadmap_dialog_new_entry ("Update", UPDATE_RIGHT, NULL); roadmap_dialog_add_button ("Cancel", update_range_cancel); roadmap_dialog_add_button ("OK", update_range_apply); roadmap_dialog_complete (roadmap_preferences_use_keyboard ()); } #else if (!ssd_dialog_activate ("Update house number", NULL)) { create_ssd_dialog(); ssd_dialog_activate ("Update house number", NULL); } #endif fill_dialog (&line, &CurrentFixedPosition, direction); }
int roadmap_display_activate (const char *title, const PluginLine *line, const RoadMapPosition *position, PluginStreet *street) { int street_has_changed; int message_has_changed; const char *format; char text[256]; RoadMapSign *sign; PluginStreetProperties properties; roadmap_log_push ("roadmap_display_activate"); sign = roadmap_display_search_sign (title); if (sign == NULL) { roadmap_log_pop (); return -1; } if (sign->format_descriptor.category == NULL) { return -1; /* This is not a sign: this is a text. */ } format = roadmap_config_get (&sign->format_descriptor); street_has_changed = 0; if (!roadmap_plugin_same_line (&sign->line, line)) { roadmap_plugin_get_street (line, street); if (sign->id != NULL) { free (sign->id); } sign->id = strdup (roadmap_plugin_street_full_name (line)); sign->line = *line; sign->was_visible = 0; if (!roadmap_plugin_same_street (street, &sign->street)) { sign->street = *street; street_has_changed = 1; } } roadmap_message_set ('F', sign->id); roadmap_plugin_get_street_properties (line, &properties, 0); roadmap_message_set ('#', properties.address); roadmap_message_set ('N', properties.street); //roadmap_message_set ('T', properties.street_t2s); roadmap_message_set ('C', properties.city); if (!strcmp(title, "Current Street")){ roadmap_message_set ('Y', properties.street); roadmap_message_set ('Z', properties.city); } if (! roadmap_message_format (text, sizeof(text), roadmap_lang_get(format))) { roadmap_log_pop (); *street = sign->street; return 0; } message_has_changed = (sign->content == NULL || strcmp (sign->content, text) != 0); if (roadmap_config_get_integer (&RoadMapConfigDisplayDuration) == -1) { sign->deadline = -1; } else { sign->deadline = time(NULL) + roadmap_config_get_integer (&RoadMapConfigDisplayDuration); } if (street_has_changed) { roadmap_voice_announce (sign->title); } if (message_has_changed) { if (sign->content != NULL) { free (sign->content); } if (text[0] == 0) { sign->content = strdup("(this street has no name)"); } else { sign->content = strdup (text); } } roadmap_plugin_line_from (line, &sign->endpoint[0]); roadmap_plugin_line_to (line, &sign->endpoint[1]); if (position == NULL) { sign->has_position = 0; } else { sign->has_position = 1; sign->position = *position; } roadmap_log_pop (); *street = sign->street; return 0; }
/** * Finds a line ID given 2 GPS points * @param pTrafficInfo - pointer to traffic info * @param start - first node point * @param end - second node point * @param Line - point to line to return the found line * @param allowedDeviation - allowed deviation when searching the nodes * @return TRUE - If a line is found */ static BOOL RTTrafficInfo_Get_LineId(RTTrafficInfo *pTrafficInfo, RoadMapPosition *start, RoadMapPosition *end, char *name, PluginLine *Line, int allowedDeviation){ RoadMapNeighbour neighbours_start[6], neighbours_end[6]; int count_start, count_end = 0; int layers[128]; int layers_count; RoadMapPosition context_save_pos; int context_save_zoom; RoadMapPosition from; RoadMapPosition to; int i; roadmap_math_get_context(&context_save_pos, &context_save_zoom); layers_count = roadmap_layer_all_roads(layers, 128); roadmap_math_set_context(start, 20); count_start = roadmap_street_get_closest(start, 0, layers, layers_count, 1, &neighbours_start[0], 5); // first try to find it in the same segment for (i=0; i<count_start; i++){ RoadMapStreetProperties properties; const char *street_name; roadmap_square_set_current(neighbours_start[i].line.square); roadmap_street_get_properties(neighbours_start[i].line.line_id, &properties); street_name = roadmap_street_get_street_fename(&properties); if (strcmp(street_name, pTrafficInfo->sStreet)) continue; roadmap_plugin_line_from (&neighbours_start[i].line, &from); roadmap_plugin_line_to (&neighbours_start[i].line, &to); if ( ( samePosition(&from, start,allowedDeviation) && samePosition(&to, end,allowedDeviation)) || (samePosition(&from, end,allowedDeviation) && samePosition(&to, start,allowedDeviation)) ){ if (samePosition(&from, start,allowedDeviation)) pTrafficInfo->iDirection = ROUTE_DIRECTION_WITH_LINE; else pTrafficInfo->iDirection = ROUTE_DIRECTION_AGAINST_LINE; roadmap_math_set_context(&context_save_pos, context_save_zoom); *Line = neighbours_start[i].line; return TRUE; } } //if not try to extend the line on the starting point for (i=0; i<count_start; i++){ RoadMapStreetProperties properties; const char *street_name; roadmap_square_set_current(neighbours_start[i].line.square); roadmap_street_get_properties(neighbours_start[i].line.line_id, &properties); street_name = roadmap_street_get_street_fename(&properties); if (strcmp(street_name, pTrafficInfo->sStreet)){ continue; } roadmap_street_extend_line_ends (&neighbours_start[i].line, &from, &to, FLAG_EXTEND_BOTH, NULL, NULL); if ( ( samePosition(&from, start,allowedDeviation) && samePosition(&to, end,allowedDeviation)) || (samePosition(&from, end,allowedDeviation) && samePosition(&to, start,allowedDeviation)) ){ if (samePosition(&from, start,allowedDeviation)) pTrafficInfo->iDirection = ROUTE_DIRECTION_WITH_LINE; else pTrafficInfo->iDirection = ROUTE_DIRECTION_AGAINST_LINE; roadmap_street_extend_line_ends (&neighbours_start[i].line, &from, &to, FLAG_EXTEND_BOTH, extendCallBack, (void *)pTrafficInfo); roadmap_math_set_context(&context_save_pos, context_save_zoom); *Line = neighbours_start[i].line; return TRUE; } } roadmap_math_set_context(end, 20); count_end = roadmap_street_get_closest(end, 0, layers, layers_count, 1, &neighbours_end[0], 4); for (i=0; i<count_end; i++){ RoadMapStreetProperties properties; const char *street_name; roadmap_square_set_current(neighbours_end[i].line.square); roadmap_street_get_properties(neighbours_end[i].line.line_id, &properties); street_name = roadmap_street_get_street_fename(&properties); if (strcmp(street_name, pTrafficInfo->sStreet)){ continue; } roadmap_street_extend_line_ends (&neighbours_end[i].line, &from, &to, FLAG_EXTEND_BOTH, NULL, NULL); if ( ( samePosition(&from, start,allowedDeviation) && samePosition(&to, end,allowedDeviation)) || (samePosition(&from, end,allowedDeviation) && samePosition(&to, start,allowedDeviation)) ){ if (samePosition(&to, end,allowedDeviation)) pTrafficInfo->iDirection = ROUTE_DIRECTION_WITH_LINE; else pTrafficInfo->iDirection = ROUTE_DIRECTION_AGAINST_LINE; roadmap_street_extend_line_ends (&neighbours_end[i].line, &from, &to, FLAG_EXTEND_BOTH, extendCallBack, (void *)pTrafficInfo); roadmap_math_set_context(&context_save_pos, context_save_zoom); *Line = neighbours_end[i].line; return TRUE; } } roadmap_math_set_context(&context_save_pos, context_save_zoom); return FALSE; }
void roadmap_plugin_get_line_points (const PluginLine *line, RoadMapPosition *from_pos, RoadMapPosition *to_pos, int *first_shape, int *last_shape, RoadMapShapeItr *shape_itr) { roadmap_plugin_line_from (line, from_pos); roadmap_plugin_line_to (line, to_pos); if (line->plugin_id == ROADMAP_PLUGIN_ID) { roadmap_line_shapes (line->line_id, first_shape, last_shape); *shape_itr = NULL; } else { RoadMapPluginHooks *hooks = get_hooks (line->plugin_id); if (hooks == NULL) { roadmap_log (ROADMAP_ERROR, "plugin id:%d is missing.", line->plugin_id); *first_shape = *last_shape = -1; *shape_itr = NULL; return; } //FIXME implement for plugins #if 0 if (hooks->line_shapes != NULL) { (*hooks->line_shapes) (line, first_shape, last_shape, shape_itr); } else { #else { #endif *first_shape = *last_shape = -1; *shape_itr = NULL; } return; } } void roadmap_plugin_line_from (const PluginLine *line, RoadMapPosition *pos) { if (line->plugin_id == ROADMAP_PLUGIN_ID) { roadmap_square_set_current (line->square); roadmap_line_from (line->line_id, pos); } else { RoadMapPluginHooks *hooks = get_hooks (line->plugin_id); if (hooks == NULL) { roadmap_log (ROADMAP_ERROR, "plugin id:%d is missing.", line->plugin_id); pos->longitude = pos->latitude = 0; return; } if (hooks->line_from != NULL) { (*hooks->line_from) (line, pos); } else { pos->longitude = pos->latitude = 0; } return; } } void roadmap_plugin_line_to (const PluginLine *line, RoadMapPosition *pos) { if (line->plugin_id == ROADMAP_PLUGIN_ID) { roadmap_square_set_current (line->square); roadmap_line_to (line->line_id, pos); } else { RoadMapPluginHooks *hooks = get_hooks (line->plugin_id); if (hooks == NULL) { roadmap_log (ROADMAP_ERROR, "plugin id:%d is missing.", line->plugin_id); pos->longitude = pos->latitude = 0; return; } if (hooks->line_to != NULL) { (*hooks->line_to) (line, pos); } else { pos->longitude = pos->latitude = 0; } return; } } int roadmap_plugin_override_line (int line, int cfcc, int fips) { int i; #ifdef __SYMBIAN32__ return 0; #elif defined (J2ME) return 0; #else //return 0; // return hooks[1]->override_line (line, cfcc, fips); #endif //#if 0 for (i=1; i<=PluginCount; i++) { RoadMapPluginHooks *hooks = get_hooks (i); if (hooks == NULL) continue; if (hooks->override_line != NULL) { int res = hooks->override_line (line, cfcc, fips); if (res) return res; } } return 0; //#endif }