示例#1
0
static int editor_street_get_distance_with_shape
              (const RoadMapPosition *position,
               int line,
               int square,
               int fips,
               RoadMapNeighbour *neighbours,
               int max) {

   RoadMapPosition from;
   RoadMapPosition to;
   int first_shape;
   int last_shape;
   int cfcc;
   int trkseg;
   int i;
   RoadMapNeighbour current;
   int found = 0;

   editor_line_get (line, &from, &to, &trkseg, &cfcc, NULL);

   roadmap_plugin_set_line (&current.line, EditorPluginID, line, cfcc, square, fips);
   current.from = from;

   editor_trkseg_get (trkseg, &i, &first_shape, &last_shape, NULL);
   editor_point_position (i, &current.to);

   if (first_shape == -1) {
      /* skip the for loop */
      last_shape = -2;
   }
      
   for (i = first_shape; i <= last_shape; i++) {

      editor_shape_position (i, &current.to);

      if (roadmap_math_line_is_visible (&current.from, &current.to)) {

         current.distance =
            roadmap_math_get_distance_from_segment
               (position, &current.from,
                &current.to, &current.intersection, NULL);

			found = roadmap_street_replace (neighbours, found, max, &current);
      }

      current.from = current.to;
   }

   current.to = to;

   if (roadmap_math_line_is_visible (&current.from, &current.to)) {
      current.distance =
         roadmap_math_get_distance_from_segment
            (position, &current.to, &current.from, &current.intersection, NULL);

		found = roadmap_street_replace (neighbours, found, max, &current);
   }

   return found;
}
示例#2
0
static int point_distance_from_expected_position(int   range_begin,
                                             	 int   range_end,
                                             	 int   point)
{
	RoadMapPosition pos1;
	RoadMapPosition pos2;
	if (track_point_time (range_begin) + 1 >= track_point_time (range_end)) {
		pos1 = *track_point_pos (range_begin);
		pos2 = *track_point_pos (range_end);
	} else {
	   double            factor;
	   factor      = time_relative_part_factor_from_absolute_value(
                                                                  track_point_time (range_begin), 
                                                                  track_point_time (range_end), 
                                                                  track_point_time (point) - 0.5);
	   pos1 = RoadMapPosition_from_relative_part_factor(  
                                                       track_point_pos (range_begin),
                                                       track_point_pos (range_end),
                                                       factor);
	   factor      = time_relative_part_factor_from_absolute_value(
                                                                  track_point_time (range_begin), 
                                                                  track_point_time (range_end), 
                                                                  track_point_time (point) + 0.5);
	   pos2 = RoadMapPosition_from_relative_part_factor(  
                                                       track_point_pos (range_begin),
                                                       track_point_pos (range_end),
                                                       factor);
	}

	return roadmap_math_get_distance_from_segment (track_point_pos (point),
																  &pos1, &pos2,
																  NULL, NULL);
}
int editor_track_draw_current_new_direction_road(){
  	RoadMapPen layer_pens[LAYER_PROJ_AREAS];
 	NavigateSegment segment;
 	RoadMapPosition intersection;
 	int distance;
 	int i;
 	
  	if (points_count < 1) return 0;
  		
  	roadmap_square_set_current(TrackConfirmedLine.line.square);
  	if (!roadmap_line_route_is_low_weight (TrackConfirmedLine.line.line_id)) {
  	   return 0;
	}

	segment.square = TrackConfirmedLine.line.square;
	segment.line = TrackConfirmedLine.line.line_id;
	roadmap_line_from(TrackConfirmedLine.line.line_id, &segment.from_pos);
	roadmap_line_to(TrackConfirmedLine.line.line_id, &segment.to_pos);

	roadmap_line_shapes (TrackConfirmedLine.line.line_id, &segment.first_shape, &segment.last_shape);
	segment.shape_initial_pos = segment.from_pos;
   
   	for (i = 0; i < LAYER_PROJ_AREAS; i++) {
      			layer_pens[i] = roadmap_layer_get_pen (roadmap_line_cfcc(TrackConfirmedLine.line.line_id),1, i);
	}
	
	navigate_instr_fix_line_end(track_point_pos(points_count - 1), &segment,
							TrackConfirmedStreet.line_direction == ROUTE_DIRECTION_WITH_LINE ? LINE_END : LINE_START);
	
   	if (!editor_override_exists(TrackConfirmedLine.line.line_id, TrackConfirmedLine.line.square)){
   		distance =
            roadmap_math_get_distance_from_segment
            (track_point_pos(points_count - 1), &segment.from_pos, &segment.to_pos, &intersection, NULL);
	
						
		if (TrackConfirmedStreet.line_direction == ROUTE_DIRECTION_WITH_LINE)
   			distance = roadmap_math_distance (&intersection, &segment.from_pos);
   		else
   			distance = roadmap_math_distance (&intersection, &segment.to_pos);
	    roadmap_ticker_set_last_event(road_munching_event);
   		editor_points_display(distance);
   	}
   roadmap_screen_draw_one_line
               (&segment.from_pos, &segment.to_pos, 0, &segment.shape_initial_pos, segment.first_shape, segment.last_shape,
                NULL, layer_pens, LAYER_PROJ_AREAS, -1, 0, 0, 0);
                
	return 0;              
}
示例#4
0
/* Find if the current point matches a point on the current new line.
 * (Detect loops)
 */
static int match_distance_from_current
                    (const RoadMapGpsPosition *gps_point,
                     int last_point,
                     RoadMapPosition *best_intersection,
                     int *match_point) {

   int i;
   int distance;
   int smallest_distance;
   int azymuth = 0;
   RoadMapPosition intersection;

   smallest_distance = 0x7fffffff;

   for (i = 0; i < (last_point-1); i++) {

      distance =
         roadmap_math_get_distance_from_segment
            ((RoadMapPosition *)gps_point,
             track_point_pos (i),
             track_point_pos (i+1),
             &intersection, NULL);

      if (distance < smallest_distance) {
         smallest_distance = distance;
         *best_intersection = intersection;
         *match_point = i;
         azymuth = roadmap_math_azymuth
             (track_point_pos (i),
             track_point_pos (i+1));
      }
   }

   return (smallest_distance < editor_track_point_distance ()) &&
            (roadmap_math_delta_direction (azymuth, gps_point->steering) < 10);
}