Esempio n. 1
0
void editor_main_shutdown (void) {
   //editor_gps_data_shutdown ();
   // temporary hack - lose extra trkseg data
   //editor_track_report_begin_export ();
   //editor_track_report_conclude_export (1);
   editor_db_close (roadmap_locator_active ());
}
Esempio n. 2
0
int editor_street_get_closest (const RoadMapPosition *position,
                               int *categories,
                               int categories_count,
                               int max_shapes,
                               RoadMapNeighbour *neighbours,
                               int count,
                               int max) {
   
   int i;
   int min_category = 256;
   int lines_count;
   int found = 0;
   int fips = roadmap_locator_active ();
   int line;
   RoadMapNeighbour this[3];
   int max_possible_shapes = (int)(sizeof(this) / sizeof(this[0]));
   
   if (max_shapes > max_possible_shapes) {
   	max_shapes = max_possible_shapes;
   }


	if (!editor_plugin_get_override ()) return count;
	
   for (i = 0; i < categories_count; ++i) {
        if (min_category > categories[i]) min_category = categories[i];
   }

	lines_count = editor_line_get_count ();

   if (! (-1 < min_category)) {
      return count;
   }

   for (line = 0; line < lines_count; line++) {

      RoadMapPosition from;
      RoadMapPosition to;
      int cfcc;
      int flag;

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

      if (flag & ED_LINE_DELETED) continue;
      if (cfcc < min_category) continue;

      found = editor_street_get_distance_with_shape
                           (position, line, -1, fips, this, max_shapes);

      for (i = 0; i < found; i++) {
         count = roadmap_street_replace (neighbours, count, max, this + i);
      }
    }

   return count;
}
Esempio n. 3
0
int editor_street_get_connected_lines (const RoadMapPosition *crossing,
                                       PluginLine *plugin_lines,
                                       int size) {

   int lines_count;
   int count = 0;
   int line;

   /* FIXME - this is wrong */
   int fips = roadmap_locator_active ();
   
   if (editor_db_activate (fips) == -1) return 0;

   //FIXME:
#if 0
   if (! (square_cfccs && (-1 << ROADMAP_ROAD_FIRST))) {
      return count;
   }
#endif
   lines_count = editor_line_get_count ();
   
   for (line=0; line<lines_count; line++) {

      RoadMapPosition line_from;
      RoadMapPosition line_to;
      int cfcc;
      int flag;

      editor_line_get
         (line, &line_from, &line_to, NULL, &cfcc, &flag);

      if (flag & ED_LINE_DELETED) continue;
      //if (cfcc < ROADMAP_ROAD_FIRST) continue;

      if ((line_from.latitude != crossing->latitude) ||
          (line_from.longitude != crossing->longitude)) {

          if ((line_to.latitude != crossing->latitude) ||
              (line_to.longitude != crossing->longitude)) {

              continue;
          }
      }

      roadmap_plugin_set_line
         (&plugin_lines[count++], EditorPluginID, line, cfcc, -1, fips);

      if (count >= size) return count;
   }

   return count;
}
Esempio n. 4
0
void editor_main_check_map (void) {

   int fips;

   fips = roadmap_locator_active ();

   if (fips < 0) {
      fips = 77001;
   }

   if (roadmap_locator_activate (fips) != ROADMAP_US_OK) {
      roadmap_messagebox ("Error.", "Can't load map data.");
      //return;
   }
   
   editor_db_activate (fips);
}
Esempio n. 5
0
int export_sync (void) {

    int i;
    int res;
    char *messages[MAX_MSGS];
    int num_msgs = 0;
    int fips;

    if (!editor_is_enabled ()) {
        return 0;
    }

    res = roadmap_file_free_space (roadmap_path_user());

#if !defined(__SYMBIAN32__) || defined(QTMOBILITY)
    if ((res >= 0) && (res < MIN_FREE_SPACE)) {
        roadmap_messagebox ("Error",
                            "Please free at least 5MB of space before synchronizing.");
        return -1;
    }
#endif

    roadmap_download_progress (0);

    snprintf (SyncProgressLabel, sizeof(SyncProgressLabel), "%s",
              roadmap_lang_get ("Preparing export data..."));

    roadmap_warning_register (download_warning_fn, "edtsync");

    roadmap_main_flush ();
    roadmap_download_progress (0);

    snprintf (SyncProgressLabel, sizeof(SyncProgressLabel), "%s",
              roadmap_lang_get ("Uploading data..."));

    roadmap_main_flush ();

    Realtime_OfflineClose ();
#ifndef J2ME
    res = sync_do_upload ();
#endif
    Realtime_OfflineOpen (editor_sync_get_export_path (),
                          editor_sync_get_export_name ());


    fips = roadmap_locator_active ();

    if (fips < 0) {
        fips = 77001;
    }

#if 0
    if (roadmap_locator_activate (fips) == ROADMAP_US_OK) {
        now_t = time (NULL);
        map_time_t = atoi(roadmap_metadata_get_attribute ("Version", "UnixTime"));

        if ((map_time_t + 3600*24) > now_t) {
            /* Map is less than 24 hours old.
             * A new version may still be available.
             */

            now_tm = *gmtime(&now_t);
            map_time_tm = *gmtime(&map_time_t);

            if (now_tm.tm_mday == map_time_tm.tm_mday) {

                goto end_sync;
            } else {
                /* new day - only download if new maps were already generated. */
                if (now_tm.tm_hour < 2) goto end_sync;
            }
        }
    }
#endif //0

    SyncProgressItems = 1;
    SyncProgressCurrentItem = 0;
    roadmap_download_progress (0);

    snprintf (SyncProgressLabel, sizeof(SyncProgressLabel), "%s",
              roadmap_lang_get ("Downloading new maps..."));

    roadmap_label_clear (-1);
    navigate_graph_clear (-1);

    roadmap_main_flush ();
#ifndef J2ME
    res = editor_download_update_map (&SyncDownloadCallbackFunctions);

    if (res == -1) {
        roadmap_messagebox ("Download Error", roadmap_lang_get("Error downloading map update"));
    }
#endif

    for (i=0; i<num_msgs; i++) {
        roadmap_messagebox ("Info", messages[i]);
        free (messages[i]);
    }

    roadmap_warning_unregister (download_warning_fn);

    return 0;
}
Esempio n. 6
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;
}