Ejemplo n.º 1
0
const char *roadmap_plugin_street_full_name (const PluginLine *line) {

   if (line->plugin_id == ROADMAP_PLUGIN_ID) {

      RoadMapStreetProperties properties;
      roadmap_square_set_current (line->square);
      roadmap_street_get_properties (line->line_id, &properties);

      return roadmap_street_get_full_name (&properties);

   } else {
      RoadMapPluginHooks *hooks = get_hooks (line->plugin_id);

      if (hooks == NULL) {
         roadmap_log (ROADMAP_ERROR, "plugin id:%d is missing.",
               line->plugin_id);

         return "";
      }

      if (hooks->get_street_full_name != NULL) {
         return (*hooks->get_street_full_name) (line);
      }

      return "";
   }
}
Ejemplo n.º 2
0
void roadmap_plugin_get_street (const PluginLine *line, PluginStreet *street) {

   if (line->plugin_id == ROADMAP_PLUGIN_ID) {

      RoadMapStreetProperties properties;

		roadmap_square_set_current (line->square);
      roadmap_street_get_properties (line->line_id, &properties);
      street->plugin_id = ROADMAP_PLUGIN_ID;
      street->street_id = properties.street;
      street->square = line->square;

   } else {
      RoadMapPluginHooks *hooks = get_hooks (line->plugin_id);
      street->plugin_id = line->plugin_id;
      street->square = line->square;

      if (hooks == NULL) {
         roadmap_log (ROADMAP_ERROR, "plugin id:%d is missing.",
               line->plugin_id);

         street->street_id = -1;
         return;
      }

      if (hooks->get_street != NULL) {
         (*hooks->get_street) (line, street);

      } else {
         street->street_id = -1;
      }

      return;
   }
}
Ejemplo n.º 3
0
static void get_street_from_line (int square, int line, const char **street_name, const char **city_name) {

    RoadMapStreetProperties properties;
    roadmap_square_set_current(square);
    roadmap_street_get_properties (roadmap_line_get_street (line), &properties);
    *street_name = roadmap_street_get_street_name (&properties);
    *city_name = roadmap_street_get_city_name (&properties);
}
Ejemplo n.º 4
0
void roadmap_plugin_get_street_properties (const PluginLine *line,
                                           PluginStreetProperties *props,
                                           int type) {
   
   if (line->plugin_id == ROADMAP_PLUGIN_ID) {

      RoadMapStreetProperties rm_properties;

	   roadmap_square_set_current (line->square);

      if (type == PLUGIN_STREET_ONLY) {
         roadmap_street_get_street (line->line_id, &rm_properties);
         props->street = roadmap_street_get_street_name (&rm_properties);
         props->shield_text = roadmap_street_get_street_shield_text (&rm_properties);
         props->shield_type = roadmap_street_get_street_shield_type (&rm_properties);
         props->plugin_street.plugin_id = ROADMAP_PLUGIN_ID;
         props->plugin_street.street_id = rm_properties.street;
         return;
      }

      roadmap_street_get_properties (line->line_id, &rm_properties);

      props->address = roadmap_street_get_street_address (&rm_properties);
      props->street = roadmap_street_get_street_name (&rm_properties);
      props->street_t2s = roadmap_street_get_street_t2s (&rm_properties);
      props->city = roadmap_street_get_city_name (&rm_properties);
      props->shield_text = roadmap_street_get_street_shield_text (&rm_properties);
      props->shield_type = roadmap_street_get_street_shield_type (&rm_properties);
      props->plugin_street.plugin_id = ROADMAP_PLUGIN_ID;
      props->plugin_street.street_id = rm_properties.street;
      return;

   } else {
      RoadMapPluginHooks *hooks = get_hooks (line->plugin_id);

      props->address = "";
      props->street = "";
      props->street_t2s = "";
      props->city = "";
      props->shield_text = "";
      props->shield_type = "";

      if (hooks == NULL) {
         roadmap_log (ROADMAP_ERROR, "plugin id:%d is missing.",
               line->plugin_id);

         return;
      }

      if (hooks->get_street_properties != NULL) {
         (*hooks->get_street_properties) (line, props, type);
      }

      return;
   }
}
Ejemplo n.º 5
0
static int fill_dialog(PluginLine *line, RoadMapPosition *pos,
                       int direction) {

   const char *street_name = NULL;
   const char *city_name = NULL;
   int fraddl;
   int toaddl;
   int fraddr;
   int toaddr;
   int left;
   int right;
   char str[100];

   if (line->plugin_id == EditorPluginID) {
#if 0
      EditorStreetProperties properties;

      if (editor_db_activate (line->fips) == -1) return -1;

      editor_street_get_properties (line->line_id, &properties);

      street_name = editor_street_get_street_name (&properties);

      city_name = editor_street_get_street_city
                        (&properties, ED_STREET_LEFT_SIDE);

      editor_street_get_street_range
         (&properties, ED_STREET_LEFT_SIDE, &fraddl, &toaddl);
      editor_street_get_street_range
         (&properties, ED_STREET_RIGHT_SIDE, &fraddr, &toaddr);
#endif
   } else {
      RoadMapStreetProperties properties;

      if (roadmap_locator_activate (line->fips) < 0) return -1;

      roadmap_street_get_properties (line->line_id, &properties);

      street_name = roadmap_street_get_street_name (&properties);

      city_name = roadmap_street_get_street_city
                        (&properties, ROADMAP_STREET_LEFT_SIDE);

      roadmap_street_get_street_range
         (&properties, ROADMAP_STREET_LEFT_SIDE, &fraddl, &toaddl);
      roadmap_street_get_street_range
         (&properties, ROADMAP_STREET_RIGHT_SIDE, &fraddr, &toaddr);
   }

   if (!city_name) city_name = "";

   get_estimated_range
         (line, pos, direction, fraddl, toaddl, fraddr, toaddr, &left, &right);
#ifndef SSD
   roadmap_dialog_set_data ("Update", STREET_PREFIX, street_name);

   roadmap_dialog_set_data ("Update", CITY_PREFIX, city_name);

   snprintf(str, sizeof(str), "%s:%d  %s:%d",
         roadmap_lang_get ("Left"), left,
         roadmap_lang_get ("Right"), right);

   roadmap_dialog_set_data ("Update", "Estimated", str);

   roadmap_dialog_set_data ("Update", UPDATE_LEFT, "");
   roadmap_dialog_set_data ("Update", UPDATE_RIGHT, "");
#else
   ssd_dialog_set_value (STREET_PREFIX, street_name);
   ssd_dialog_set_value (CITY_PREFIX, city_name);
   sprintf(str, "%d", left);
   ssd_dialog_set_value ("estimated_left", str);
   sprintf(str, "%d", right);
   ssd_dialog_set_value ("estimated_right", str);
   ssd_dialog_set_value (UPDATE_LEFT, "");
   ssd_dialog_set_value (UPDATE_RIGHT, "");
   ssd_dialog_draw ();
#endif
   return 0;
}
/**
 * Finds a line ID given 2 GPS points
 * @param pTrafficInfo - pointer to traffic info
 * @param start - first node point
 * @param end - second node point
 * @param Line - point to line to return the found line
 * @param allowedDeviation - allowed deviation when searching the nodes
 * @return TRUE - If a line is found
 */
static BOOL RTTrafficInfo_Get_LineId(RTTrafficInfo *pTrafficInfo, RoadMapPosition *start, RoadMapPosition *end, char *name, PluginLine *Line, int allowedDeviation){
	RoadMapNeighbour neighbours_start[6], neighbours_end[6];
	int count_start, count_end = 0;
   int layers[128];
   int layers_count;
   RoadMapPosition context_save_pos;
   int context_save_zoom;
	RoadMapPosition from;
	RoadMapPosition to;
	int i;


    roadmap_math_get_context(&context_save_pos, &context_save_zoom);

    layers_count = roadmap_layer_all_roads(layers, 128);

    roadmap_math_set_context(start, 20);
    count_start = roadmap_street_get_closest(start, 0, layers, layers_count,
            1, &neighbours_start[0], 5);

    // first try to find it in the same segment
	for (i=0; i<count_start; i++){
		RoadMapStreetProperties properties;
		const char *street_name;
		roadmap_square_set_current(neighbours_start[i].line.square);
		roadmap_street_get_properties(neighbours_start[i].line.line_id, &properties);
		street_name = roadmap_street_get_street_fename(&properties);
		if (strcmp(street_name, pTrafficInfo->sStreet))
			continue;
	    roadmap_plugin_line_from (&neighbours_start[i].line, &from);
	    roadmap_plugin_line_to (&neighbours_start[i].line, &to);
 		if ( ( samePosition(&from, start,allowedDeviation) && samePosition(&to, end,allowedDeviation)) || (samePosition(&from, end,allowedDeviation) && samePosition(&to, start,allowedDeviation))  ){
		   		if (samePosition(&from, start,allowedDeviation))
		   			pTrafficInfo->iDirection = ROUTE_DIRECTION_WITH_LINE;
		   		else
		   			pTrafficInfo->iDirection = ROUTE_DIRECTION_AGAINST_LINE;
 		 			roadmap_math_set_context(&context_save_pos, context_save_zoom);
		   		    *Line = neighbours_start[i].line;
 					return TRUE;
 		}
	}

	//if not try to extend the line on the starting point
	for (i=0; i<count_start; i++){
		 RoadMapStreetProperties properties;
		 const char *street_name;
		 roadmap_square_set_current(neighbours_start[i].line.square);
		 roadmap_street_get_properties(neighbours_start[i].line.line_id, &properties);
		 street_name = roadmap_street_get_street_fename(&properties);
		 if (strcmp(street_name, pTrafficInfo->sStreet)){
			continue;
		 }

 		 roadmap_street_extend_line_ends (&neighbours_start[i].line, &from, &to, FLAG_EXTEND_BOTH, NULL, NULL);
 		 if ( ( samePosition(&from, start,allowedDeviation) && samePosition(&to, end,allowedDeviation)) || (samePosition(&from, end,allowedDeviation) && samePosition(&to, start,allowedDeviation))  ){
		   		if (samePosition(&from, start,allowedDeviation))
		   			pTrafficInfo->iDirection = ROUTE_DIRECTION_WITH_LINE;
		   		else
		   			pTrafficInfo->iDirection = ROUTE_DIRECTION_AGAINST_LINE;
 		 			roadmap_street_extend_line_ends (&neighbours_start[i].line, &from, &to, FLAG_EXTEND_BOTH, extendCallBack, (void *)pTrafficInfo);
 		 			roadmap_math_set_context(&context_save_pos, context_save_zoom);
		   		    *Line = neighbours_start[i].line;
 					return TRUE;
 		 }
	}

	roadmap_math_set_context(end, 20);
    count_end = roadmap_street_get_closest(end, 0, layers, layers_count,
            1, &neighbours_end[0], 4);

	for (i=0; i<count_end; i++){
		 RoadMapStreetProperties properties;
		 const char *street_name;
		 roadmap_square_set_current(neighbours_end[i].line.square);
		 roadmap_street_get_properties(neighbours_end[i].line.line_id, &properties);
		 street_name = roadmap_street_get_street_fename(&properties);
		 if (strcmp(street_name, pTrafficInfo->sStreet)){
			continue;
		 }

 		 roadmap_street_extend_line_ends (&neighbours_end[i].line, &from, &to, FLAG_EXTEND_BOTH, NULL, NULL);
 		 if ( ( samePosition(&from, start,allowedDeviation) && samePosition(&to, end,allowedDeviation)) || (samePosition(&from, end,allowedDeviation) && samePosition(&to, start,allowedDeviation))  ){
		     		if (samePosition(&to, end,allowedDeviation))
		   			pTrafficInfo->iDirection = ROUTE_DIRECTION_WITH_LINE;
		   		else
		   			pTrafficInfo->iDirection = ROUTE_DIRECTION_AGAINST_LINE;

 		 			roadmap_street_extend_line_ends (&neighbours_end[i].line, &from, &to, FLAG_EXTEND_BOTH, extendCallBack, (void *)pTrafficInfo);
 		 			roadmap_math_set_context(&context_save_pos, context_save_zoom);
		   		    *Line = neighbours_end[i].line;
 					return TRUE;
 		 }
	}

	roadmap_math_set_context(&context_save_pos, context_save_zoom);
	return FALSE;
}
Ejemplo n.º 7
0
int roadmap_geocode_address (RoadMapGeocode **selections,
                             const char *number_image,
                             const char *street_name,
                             const char *city_name,
                             const char *state_name) {

   int i, j;
   int fips;
   int count;
   int number;

   RoadMapBlocks blocks[ROADMAP_MAX_STREETS];

   RoadMapGeocode *results;


   RoadMapGeocodeLastErrorString = "No error";
   RoadMapGeocodeLastErrorCode   = geo_error_none;
   *selections = NULL;

   switch (roadmap_locator_by_city (city_name, state_name)) {

   case ROADMAP_US_OK:

      count = roadmap_street_blocks_by_city
                  (street_name, city_name, blocks, ROADMAP_MAX_STREETS);
      break;

   case ROADMAP_US_NOSTATE:

      RoadMapGeocodeLastErrorString =
         roadmap_lang_get ("No state with that name could be found");
      RoadMapGeocodeLastErrorCode = geo_error_no_state;
      return 0;

   case ROADMAP_US_NOCITY:

      RoadMapGeocodeLastErrorString =
         roadmap_lang_get ("No city with that name could be found");
      RoadMapGeocodeLastErrorCode = geo_error_no_city;
      return 0;

   default:

      RoadMapGeocodeLastErrorString =
         roadmap_lang_get ("No related map could be found");
      RoadMapGeocodeLastErrorCode = geo_error_no_map;
      return 0;
   }

   if (count <= 0) {

      switch (count) {
      case ROADMAP_STREET_NOADDRESS:
         RoadMapGeocodeLastErrorString =
            roadmap_lang_get ("Address could not be found");
         RoadMapGeocodeLastErrorCode = geo_error_no_address;
         break;
      case ROADMAP_STREET_NOCITY:
         RoadMapGeocodeLastErrorString =
            roadmap_lang_get ("No city with that name could be found");
         RoadMapGeocodeLastErrorCode = geo_error_no_city;
         break;
      case ROADMAP_STREET_NOSTREET:
         RoadMapGeocodeLastErrorString =
            roadmap_lang_get ("No street with that name could be found");
         RoadMapGeocodeLastErrorCode = geo_error_no_street;
      default:
         RoadMapGeocodeLastErrorString =
            roadmap_lang_get ("The address could not be found");
         RoadMapGeocodeLastErrorCode = geo_error_no_address;
      }
      return 0;
   }

   if (count > ROADMAP_MAX_STREETS) {
      roadmap_log (ROADMAP_ERROR, "too many blocks");
      RoadMapGeocodeLastErrorCode = geo_error_general;
      count = ROADMAP_MAX_STREETS;
   }

   /* If the street number was not provided, retrieve all street blocks to
    * expand the match list, else decode that street number and update the
    * match list.
    */
    
   if (number_image[0] == 0) {
   	
   	number = -1;
   } else {
   	
      number = roadmap_math_street_address (number_image, strlen(number_image));
   } 

   results = (RoadMapGeocode *)
       calloc (count, sizeof(RoadMapGeocode));

   fips = roadmap_locator_active();

   for (i = 0, j = 0; i< count; ++i) {

      if (roadmap_street_get_position
      			(blocks + i, number, &results[j].position)) {

	      RoadMapStreetProperties properties;
	          
	      roadmap_street_get_properties (blocks[i].line, &properties);
       	results[j].fips = fips;
        	results[j].square = blocks[i].square; // roadmap_square_active ();
        	results[j].line = blocks[i].line;
        	results[j].name = strdup (roadmap_street_get_full_name (&properties));
        	j += 1;
      }
   }

   if (j <= 0) {

      free (results);
      if (number_image[0] != 0) {
         RoadMapGeocodeLastErrorString =
            roadmap_lang_get ("House number was not found in that street. Please enter a valid house number, or erase the house number entry");
         RoadMapGeocodeLastErrorCode = geo_error_no_house_number;
      } else {
         RoadMapGeocodeLastErrorString = roadmap_lang_get ("No valid street was found");
         RoadMapGeocodeLastErrorCode = geo_error_no_street;
      }

   } else {

      *selections = results;
   }

   return j;
}
Ejemplo n.º 8
0
void editor_segments_fill_dialog (SelectedLine *lines, int lines_count) {

   char street_name[512];
   const char *street_type = "";
   const char *t2s = "";
   const char *city = "";
   int cfcc = ROADMAP_ROAD_LAST;
   int same_street = 1;
   int same_city = 1;
   int i;

   strcpy (street_name, "");
   for (i=0; i<lines_count; i++) {
      
      const char *this_name = "";
      const char *this_type = "";
      const char *this_t2s = "";
      const char *this_city = "";

      if (lines[i].line.plugin_id == EditorPluginID) {
         if (editor_db_activate (lines[i].line.fips) != -1) {

            int street_id = -1;
            
            editor_line_get_street (lines[i].line.line_id, &street_id);

            this_name = editor_street_get_street_fename (street_id);
            this_type = editor_street_get_street_fetype (street_id);
            this_t2s = editor_street_get_street_t2s (street_id);
            this_city = editor_street_get_street_city (street_id);
				//editor_line_get_direction (lines[i].line.line_id, &this_direction);
         }
      } else { 

         RoadMapStreetProperties properties;

         if (roadmap_locator_activate (lines[i].line.fips) < 0) {
            continue;
         }

         roadmap_square_set_current (lines[i].line.square);
         roadmap_street_get_properties (lines[i].line.line_id, &properties);
    
         this_name = roadmap_street_get_street_name (&properties);
         this_type = roadmap_street_get_street_fetype (&properties);
         this_t2s = roadmap_street_get_street_t2s (&properties);

         this_city = roadmap_street_get_street_city
               (&properties, ROADMAP_STREET_LEFT_SIDE);
/*
			if (!editor_override_line_get_direction (lines[0].line.line_id, &this_direction)) {

            this_direction =
               roadmap_line_route_get_direction
                  (lines[i].line.line_id, ROUTE_CAR_ALLOWED);
            roadmap_line_route_get_speed_limit
                  (lines[i].line.line_id,
                   &this_speed_limit, &this_speed_limit);
         }
*/         
      }

      if (same_street) {
         if (!strlen(street_type)) {
            street_type = this_type;
         }

         if (!strlen(t2s)) {
            t2s = this_t2s;
         }

         if (!strlen(street_name)) {
            strncpy_safe (street_name, this_name, 512);
         } else {
            if (strlen(this_name) && strcmp(this_name, street_name)) {
               strcpy (street_name, "");
               street_type = "";
               t2s = "";
               same_street = 0;
            }
         }
       }

      if (same_city) {
         if (!strlen(city)) {
            city = this_city;
         } else {
            if (strlen(this_city) && strcmp(this_city, city)) {
               same_city = 0;
               city = "";
            }
         }
      } 
      
      if (lines[i].line.cfcc < cfcc) {
         cfcc = lines[i].line.cfcc;
      }
   }

   if (same_city && !strlen(city)) {
      
      city = editor_segments_find_city
             (lines[0].line.line_id, lines[0].line.plugin_id, lines[0].line.square);
   }

#ifdef SSD
   ssd_dialog_set_data ("Road type", (void *) (long)(cfcc - ROADMAP_ROAD_FIRST));
   ssd_dialog_set_value ("Name", street_name);
   ssd_dialog_set_value ("Text to Speech", t2s);

   ssd_dialog_set_value ("City", city);

   def_values[0] = ssd_dialog_get_value ("City");

#else
   roadmap_dialog_set_data
      ("General", "Road type", (void *) (cfcc - ROADMAP_ROAD_FIRST));
   roadmap_dialog_set_data ("General", "Street type", street_type);
   roadmap_dialog_set_data ("General", "Name", street_name);
   roadmap_dialog_set_data ("General", "Text to Speech", t2s);

   roadmap_dialog_set_data ("General", "City", city);

#endif


}
Ejemplo n.º 9
0
static const char *editor_segments_find_city
         (int line, int plugin_id, int square) {

   int i;
   int count;
   int layers_count;
   int layers[128];
   RoadMapPosition point;
   RoadMapNeighbour neighbours[50];

   if (plugin_id == EditorPluginID) {
      editor_line_get (line, &point, NULL, NULL, NULL, NULL);
   } else {
   	  roadmap_square_set_current (square);
      roadmap_line_from (line, &point);
   }

   layers_count = roadmap_layer_all_roads (layers, 128);

   count = roadmap_street_get_closest
           (&point,
            0,
            layers,
            layers_count,
            1,
            neighbours,
            sizeof(neighbours) / sizeof(RoadMapNeighbour));

   count = roadmap_plugin_get_closest
               (&point, layers, layers_count, 1, neighbours, count,
                sizeof(neighbours) / sizeof(RoadMapNeighbour));

   for (i = 0; i < count; ++i) {

      const char *city;
      
      if (roadmap_plugin_get_id (&neighbours[i].line) == EditorPluginID) {
         int street_id = -1;

			editor_line_get_street 
            (roadmap_plugin_get_line_id (&neighbours[i].line),
             &street_id);

         city =
            editor_street_get_street_city
               (street_id);
         
      } else if (roadmap_plugin_get_id (&neighbours[i].line) ==
            ROADMAP_PLUGIN_ID) {
         RoadMapStreetProperties properties;

			roadmap_square_set_current (roadmap_plugin_get_square (&neighbours[i].line));
         roadmap_street_get_properties
            (roadmap_plugin_get_line_id (&neighbours[i].line),
             &properties);

         city =
            roadmap_street_get_street_city
               (&properties, ROADMAP_STREET_LEFT_SIDE);

      } else {
         city = "";
      }

      if (strlen(city)) {
         return city;
      }
   }

   return "";
}