Esempio n. 1
0
static int editor_override_find (int line, editor_db_override **data, int *create) {

   int id;
   int count;
   int square = roadmap_square_active ();
   editor_db_override *rec;
   
   count = editor_db_get_item_count (ActiveOverridesDB);

	for (id = 0; id < count; id++) {
		
		rec = (editor_db_override *)editor_db_get_item (ActiveOverridesDB, id, 0, NULL);
		if (rec->square == square && rec->line == line) {
			if (create) *create = 0;
			break;
		}
	}
	
	if (id == count) {
		if (!create) return -1;
		
		id = editor_db_add_item (ActiveOverridesDB, NULL, 0); 
		if (id >= 0) {
			rec = (editor_db_override *)editor_db_get_item (ActiveOverridesDB, id, 0, NULL);
			rec->square = square;
			rec->line = line;
			rec->flags = 0;
			rec->direction = roadmap_line_route_get_direction (line, ROUTE_CAR_ALLOWED);
			*create = 1;
		}
	}
	
	if (data) *data = rec;
	return id;
}
Esempio n. 2
0
int editor_line_add
         (int p_from,
          int p_to,
          int trkseg,
          int cfcc,
          int direction,
          int street,
          int flags) {

   editor_db_line line;
   int id;
   time_t update_time = roadmap_navigate_get_time ();

	line.update_timestamp = (int)update_time;
   line.point_from = p_from;
   line.point_to = p_to;

   line.trkseg = trkseg;

   line.cfcc = cfcc;
   line.flags = flags;

   line.street = street;
   line.direction = direction;

   id = editor_db_add_item (ActiveLinesDB, &line, 1);

   if (id == -1) return -1;
   assert (editor_line_length (id) > 0);

   if (editor_line_length (id) == 0) return -1;

   editor_bar_set_temp_length(0);
   editor_bar_set_length(editor_line_length (id));
   
   editor_log
      (ROADMAP_INFO,
       "Adding new line - from:%d, to:%d, trkseg:%d, cfcc:%d, flags:%d",
       p_from, p_to, trkseg, cfcc, flags);

   if (id == -1) {
      editor_log (ROADMAP_ERROR, "Can't add new line.");
   }

   return id;
}
Esempio n. 3
0
int editor_marker_add(int longitude,
                      int latitude,
                      int steering,
                      time_t time,
                      unsigned char type,
                      unsigned char flags,
                      const char *note,
                      const char *icon) {

    editor_db_marker marker;
    int id;

    while (steering < 0) {
        steering += 360;
    }
    while (steering >= 360) {
        steering -= 360;
    }

    marker.longitude = longitude;
    marker.latitude  = latitude;
    marker.steering  = steering;
    marker.time      = time;
    marker.type      = type;
    marker.flags     = flags | ED_MARKER_DIRTY;

    if (note == NULL) {
        marker.note = ROADMAP_INVALID_STRING;
    } else {

        marker.note = editor_dictionary_add(note);
    }

    if (icon == NULL) {
        marker.icon = ROADMAP_INVALID_STRING;
    } else {

        marker.icon = editor_dictionary_add(icon);
    }

    id = editor_db_add_item (ActiveMarkersDB, &marker, 1);

    return id;
}
Esempio n. 4
0
int editor_street_create (const char *_name,
                          const char *_type,
                          const char *_prefix,
                          const char *_suffix,
                          const char *_city,
                          const char *_t2s) {

   editor_db_street street;

   street.fename = editor_dictionary_add (_name);
   street.fetype = editor_dictionary_add (_type);
   street.fedirp = editor_dictionary_add (_prefix);
   street.fedirs = editor_dictionary_add (_suffix);
   street.city = editor_dictionary_add (_city);
   street.t2s = editor_dictionary_add (_t2s);

   //TODO optimize - this is a linear search

   if (street.fename != -1) {
      int i;

      for (i = editor_db_get_item_count (ActiveStreetDB) - 1; i >= 0; i--) {
         editor_db_street *street_ptr =
            (editor_db_street *) editor_db_get_item
                        (ActiveStreetDB, i, 0, NULL);

         assert (street_ptr != NULL);

         if ((street_ptr != NULL) &&
               !memcmp (street_ptr, &street, sizeof (editor_db_street))) {
            return i;
         }
      }
   }
   
   return editor_db_add_item (ActiveStreetDB, &street, 1);
}