Beispiel #1
0
static BOOL allowed_turn (const RoadMapNeighbour *from_street, int from_direction,
                          const RoadMapNeighbour *to_street, int to_direction) {
   // -1 = shared node; 0 = not shared; 1 = shared node and turn allowed
   
   int from_id1, to_id1, from_id2, to_id2;
   int shared_node = -1;
   
   if (from_street->line.square != to_street->line.square)
      return 0; //TODO: same line on different squares?
   
   roadmap_square_set_current(from_street->line.square);
   roadmap_line_point_ids (from_street->line.line_id, &from_id1, &to_id1);
   roadmap_line_point_ids (to_street->line.line_id, &from_id2, &to_id2);
   
   if (from_direction == ROUTE_DIRECTION_WITH_LINE &&
       to_direction == ROUTE_DIRECTION_WITH_LINE &&
       to_id1 == from_id2)
      shared_node = to_id1;
   else if (from_direction == ROUTE_DIRECTION_WITH_LINE &&
            to_direction == ROUTE_DIRECTION_AGAINST_LINE &&
            to_id1 == to_id2)
      shared_node = to_id1;
   else if (from_direction == ROUTE_DIRECTION_AGAINST_LINE &&
            to_direction == ROUTE_DIRECTION_WITH_LINE &&
            from_id1 == from_id2)
      shared_node = from_id1;
   else if (from_direction == ROUTE_DIRECTION_AGAINST_LINE &&
            to_direction == ROUTE_DIRECTION_AGAINST_LINE &&
            from_id1 == to_id2)
      shared_node = from_id1;
   
   
   if (shared_node != -1) {
      if (!roadmap_turns_find_restriction(shared_node, from_street->line.line_id, to_street->line.line_id))
         return 1;
      else
         return -1;
   }
   
   return 0;
}
int editor_line_copy (PluginLine *line, int street) {

	editor_line_copy_points		copy_points;
	RoadMapPosition				from_pos;
	RoadMapPosition				to_pos;
	int								trkseg;
	int								from_point;
	int								to_point;
	int								line_id;
	int								direction;
	int								id_from;
	int								id_to;
		
	// collect shape points for trkseg
	roadmap_plugin_line_from (line, &copy_points.last_position);
	copy_points.first_shape = -1;
	copy_points.last_shape = -1; 
	
	// we assume that in case of a line broken because of tiles,
	// we begin with the original "from" segment
	handle_segment (line, &copy_points, FLAG_EXTEND_TO);
	roadmap_street_extend_line_ends (line, &from_pos, &to_pos, FLAG_EXTEND_TO, 
												  handle_segment, &copy_points);
												  
	if (line->plugin_id == EditorPluginID) {

		editor_line_get_points (line->line_id, &from_point, &to_point); 
	} else {
	
		roadmap_square_set_current (line->square);
		roadmap_line_point_ids (line->line_id, &id_from, &id_to);
		
		from_point = editor_point_add (&from_pos, id_from);
		to_point = editor_point_add (&to_pos, id_to);
	}
	
	trkseg = editor_trkseg_add (-1, -1, from_point, 
										 copy_points.first_shape, copy_points.last_shape,
										 -1, -1, ED_TRKSEG_FAKE);
										 
	direction = roadmap_plugin_get_direction (line, ROUTE_DIRECTION_ANY);									 
	line_id = editor_line_add (from_point, to_point, trkseg, line->cfcc, direction, street, ED_LINE_DIRTY);	
		
	return line_id;	
}