예제 #1
0
void roadmap_reminder_add_at_position(RoadMapPosition *position,  BOOL isReminder, BOOL default_reminder){
   int number;
   int layers[128];
   int layers_count;
   PluginStreetProperties properties;
   RoadMapNeighbour neighbours[2];
   RoadMapPosition context_save_pos;
   int context_save_zoom;

   if (!position)
      return;

   roadmap_math_get_context(&context_save_pos, &context_save_zoom);
   layers_count = roadmap_layer_all_roads(layers, 128);
   roadmap_math_set_context(position, 20);
   number = roadmap_street_get_closest(position, 0, layers, layers_count,
                                       1, &neighbours[0], 1);
   roadmap_math_set_context(&context_save_pos, context_save_zoom);
   if (number > 0){
      roadmap_plugin_get_street_properties (&neighbours[0].line, &properties, 0);
      reminder_add_dlg(&properties, position, isReminder, default_reminder);
   }
   else{
      reminder_add_dlg(NULL, position, isReminder,default_reminder);
   }
}
예제 #2
0
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;
}