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_length (int line) {

   RoadMapPosition p1;
   RoadMapPosition p2;
   editor_db_line *line_db;
   int length = 0;
   int trk_from;
   int first_shape;
   int last_shape;
   int i;

   line_db = (editor_db_line *) editor_db_get_item
                           (ActiveLinesDB, line, 0, NULL);

   editor_trkseg_get (line_db->trkseg,
                      &trk_from, &first_shape, &last_shape, NULL);

   editor_point_position (line_db->point_from, &p1);

   if (first_shape > -1) {
      editor_point_position (trk_from, &p2);

      for (i=first_shape; i<=last_shape; i++) {

         editor_shape_position (i, &p2);
         length += roadmap_math_distance (&p1, &p2);
         p1 = p2;
      }
   }

   editor_point_position (line_db->point_to, &p2);
   length += roadmap_math_distance (&p1, &p2);

   return length;
}
Esempio n. 3
0
void editor_marker_update(int marker, unsigned char flags,
                          const char *note) {

    editor_db_marker *marker_st =
        editor_db_get_item (ActiveMarkersDB, marker, 0, 0);

    int dirty = 0;
    assert(marker_st != NULL);

    if (note == NULL) {
        if (marker_st->note != ROADMAP_INVALID_STRING) {
            dirty++;
            marker_st->note = ROADMAP_INVALID_STRING;
        }
    } else if ((marker_st->note == ROADMAP_INVALID_STRING) ||
               strcmp(editor_dictionary_get(marker_st->note),
                      note)) {

        dirty++;
        marker_st->note = editor_dictionary_add(note);
    }

    if ((marker_st->flags & ~ED_MARKER_DIRTY) !=
            (flags & ~ED_MARKER_DIRTY)) {
        dirty++;
    }

    marker_st->flags = flags;

    if (dirty) editor_db_update_item(ActiveMarkersDB, marker);
}
Esempio n. 4
0
time_t editor_marker_time(int marker) {

    editor_db_marker *marker_st =
        editor_db_get_item (ActiveMarkersDB, marker, 0, 0);
    assert(marker_st != NULL);

    return marker_st->time;
}
Esempio n. 5
0
unsigned char editor_marker_flags(int marker) {

    editor_db_marker *marker_st =
        editor_db_get_item (ActiveMarkersDB, marker, 0, 0);
    assert(marker_st != NULL);

    return marker_st->flags;
}
Esempio n. 6
0
const char *editor_marker_type(int marker) {

    editor_db_marker *marker_st =
        editor_db_get_item (ActiveMarkersDB, marker, 0, 0);
    assert(marker_st != NULL);

    return MarkerTypes[marker_st->type]->name;
}
Esempio n. 7
0
int editor_marker_verify(int marker, unsigned char *flags, const char **note) {

    editor_db_marker *marker_st =
        editor_db_get_item (ActiveMarkersDB, marker, 0, 0);

    assert(marker_st != NULL);

    return MarkerTypes[marker_st->type]->update_marker (marker, flags, note);
}
Esempio n. 8
0
int editor_line_get_timestamp (int line_id) {
	
   editor_db_line *line_db;

   line_db =
      (editor_db_line *) editor_db_get_item
         (ActiveLinesDB, line_id, 0, NULL);

   if (line_db == NULL) return -1;

   return line_db->update_timestamp;
}
Esempio n. 9
0
void editor_marker_position(int marker,
                            RoadMapPosition *position, int *steering) {

    editor_db_marker *marker_st =
        editor_db_get_item (ActiveMarkersDB, marker, 0, 0);
    assert(marker_st != NULL);

    position->longitude = marker_st->longitude;
    position->latitude = marker_st->latitude;

    if (steering) *steering = marker_st->steering;
}
Esempio n. 10
0
int editor_line_is_valid (int line_id) {
	
   editor_db_line *line_db;

   line_db =
      (editor_db_line *) editor_db_get_item
         (ActiveLinesDB, line_id, 0, NULL);

   if (line_db == NULL) return 0;

   return !(line_db->flags & ED_LINE_DELETED);
}
Esempio n. 11
0
int editor_line_get_update_time (int line_id) {

   RoadMapPosition pos;
   RoadMapPosition last_pos;
   int shape;
   int last_tile = -1;
   int tile;
   editor_db_line *line_db;
   int min_update = 0x7fffffff;
   int tile_update;
   int first_shape;
   int last_shape;
   int from_point;

   line_db =
      (editor_db_line *) editor_db_get_item
         (ActiveLinesDB, line_id, 0, NULL);

   if (line_db == NULL) return min_update;
	
	editor_trkseg_get (line_db->trkseg, &from_point, &first_shape, &last_shape, NULL);
	if (first_shape == -1) {
		last_shape = -1;
	}
	for (shape = first_shape - 1; shape <= last_shape; shape++) {
		if (shape == -2) {
			editor_point_position (line_db->point_from, &pos);
		} else if (shape < first_shape) {
			editor_point_position (from_point, &pos);
		} else if (shape >= 0) {
			editor_shape_position (shape, &pos);
		} else {
			editor_point_position (line_db->point_to, &pos);
		}
		
		tile = roadmap_tile_get_id_from_position (0, &pos);
		if (tile != last_tile) {
			roadmap_tile_request (tile, 0, 1, NULL);
			tile_update = (int)roadmap_square_timestamp (tile);
			if (tile_update < min_update) {
				min_update = tile_update;
			}
			if (last_tile != -1) {
				min_update = editor_line_interpolate_request_tiles (last_tile, tile, &last_pos, &pos, min_update);
			}
			last_tile = tile;
		}
		last_pos = pos;
	}
	
	return min_update;
}
Esempio n. 12
0
void editor_line_get_points (int line, int *from, int *to) {

   editor_db_line *line_db;

   line_db = (editor_db_line *) editor_db_get_item
                           (ActiveLinesDB, line, 0, NULL);

	assert (line_db);
	if (!line_db) return;

   if (from) *from = line_db->point_from;
   if (to) *to = line_db->point_to;
}
Esempio n. 13
0
const char *editor_marker_note(int marker) {

    editor_db_marker *marker_st =
        editor_db_get_item (ActiveMarkersDB, marker, 0, 0);
    assert(marker_st != NULL);

    if (marker_st->note == ROADMAP_INVALID_STRING) {
        return "";
    } else {

        return editor_dictionary_get(marker_st->note);
    }
}
Esempio n. 14
0
int editor_line_get_direction (int line, int *direction) {

   editor_db_line *line_db;

   line_db =
      (editor_db_line *) editor_db_get_item
         (ActiveLinesDB, line, 0, NULL);

   if (line_db == NULL) return -1;

   if (direction != NULL) *direction = line_db->direction;

   return 0;
}
Esempio n. 15
0
int editor_line_mark_dirty (int line_id) {
   
   editor_db_line *line_db;
   
   line_db = (editor_db_line *) editor_db_get_item
                           (ActiveLinesDB, line_id, 0, NULL);

   if (line_db == NULL) return -1;

   line_db->flags |= ED_LINE_DIRTY;

	editor_line_set_modification_time (line_db);
   return editor_db_update_item (ActiveLinesDB, line_id);
}
Esempio n. 16
0
int editor_line_get_street (int line,
                            int *street) {

   editor_db_line *line_db;

   line_db =
      (editor_db_line *) editor_db_get_item
         (ActiveLinesDB, line, 0, NULL);

   if (line_db == NULL) return -1;

   if (street != NULL) *street = line_db->street;

   return 0;
}
Esempio n. 17
0
void editor_line_reset_flag (int line, int flag) {
	
   editor_db_line *line_db;

   line_db = (editor_db_line *) editor_db_get_item
                           (ActiveLinesDB, line, 0, NULL);

   assert (line_db != NULL);

   if (line_db == NULL) return;

	line_db->flags = line_db->flags & ~flag;
	editor_line_set_modification_time (line_db);
   editor_db_update_item (ActiveLinesDB, line);
}
Esempio n. 18
0
int editor_line_set_direction (int line, int direction) {

   editor_db_line *line_db;

   line_db =
      (editor_db_line *) editor_db_get_item
         (ActiveLinesDB, line, 0, NULL);

   if (line_db == NULL) return -1;

   line_db->direction = direction;

	editor_line_set_modification_time (line_db);
   return editor_db_update_item (ActiveLinesDB, line);
}
Esempio n. 19
0
int editor_line_get_cross_time (int line, int direction) {

   editor_db_line *line_db;
   time_t start_time;
   time_t end_time;

   line_db = (editor_db_line *) editor_db_get_item
                           (ActiveLinesDB, line, 0, NULL);

   editor_trkseg_get_time
      (line_db->trkseg, &start_time, &end_time);

   if (start_time == end_time) return -1;

   return  (int) (end_time - start_time);
}
Esempio n. 20
0
int editor_line_set_street (int line,
                            int street) {

   editor_db_line *line_db;

   line_db =
      (editor_db_line *) editor_db_get_item
         (ActiveLinesDB, line, 0, NULL);

   if (line_db == NULL) return -1;

   line_db->street = street;

	editor_line_set_modification_time (line_db);
   return editor_db_update_item (ActiveLinesDB, line);
}
Esempio n. 21
0
int editor_marker_export(int marker, const char **name, const char **description,
                         const char *keys[ED_MARKER_MAX_ATTRS],
                         char       *values[ED_MARKER_MAX_ATTRS],
                         int *count) {

    editor_db_marker *marker_st =
        editor_db_get_item (ActiveMarkersDB, marker, 0, 0);

    assert(marker_st != NULL);

    return MarkerTypes[marker_st->type]->export_marker (marker,
            name,
            description,
            keys,
            values,
            count);
}
Esempio n. 22
0
const char *editor_street_get_street_t2s
               (int street_id) {

   editor_db_street *street;
   
   if (street_id < 0) return "";
   
   street =
      (editor_db_street *) editor_db_get_item
                              (ActiveStreetDB, street_id, 0, NULL);
   assert (street != NULL);

   if (street->t2s < 0) {
      return "";
   }

   return editor_dictionary_get (street->t2s);
}
Esempio n. 23
0
void editor_line_modify_properties (int line,
                                    int cfcc,
                                    int flags) {
   
   editor_db_line *line_db;

   line_db = (editor_db_line *) editor_db_get_item
                           (ActiveLinesDB, line, 0, NULL);

   assert (line_db != NULL);

   if (line_db == NULL) return;

   line_db->cfcc = cfcc;
   line_db->flags = flags;
   
	editor_line_set_modification_time (line_db);
   editor_db_update_item (ActiveLinesDB, line);
}
Esempio n. 24
0
void editor_line_get (int line,
                      RoadMapPosition *from,
                      RoadMapPosition *to,
                      int *trkseg,
                      int *cfcc,
                      int *flags) {
   
   editor_db_line *line_db;

   line_db = (editor_db_line *) editor_db_get_item
                           (ActiveLinesDB, line, 0, NULL);

	assert (line_db);
	if (!line_db) return;
	
   if (from) editor_point_position (line_db->point_from, from);
   if (to) editor_point_position (line_db->point_to, to);

   if (trkseg) *trkseg = line_db->trkseg;
   if (cfcc) *cfcc = line_db->cfcc;
   if (flags) *flags = line_db->flags;
}
Esempio n. 25
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);
}