Diff of /trunk/src/osm-gps-map.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 89 by harbaum, Tue Sep 1 11:16:30 2009 UTC revision 91 by harbaum, Tue Sep 1 19:55:49 2009 UTC
# Line 1664  osm_gps_map_init (OsmGpsMap *object) Line 1664  osm_gps_map_init (OsmGpsMap *object)
1664  #endif  #endif
1665  }  }
1666    
1667  static GObject *  static void
1668  osm_gps_map_constructor (GType gtype, guint n_properties, GObjectConstructParam *properties)  osm_gps_map_setup(OsmGpsMapPrivate *priv) {
 {  
     GObject *object;  
     OsmGpsMapPrivate *priv;  
     OsmGpsMap *map;  
1669      const char *uri;      const char *uri;
1670    
     //Always chain up to the parent constructor  
     object = G_OBJECT_CLASS(osm_gps_map_parent_class)->constructor(gtype, n_properties, properties);  
     map = OSM_GPS_MAP(object);  
     priv = OSM_GPS_MAP_PRIVATE(object);  
   
1671      //user can specify a map source ID, or a repo URI as the map source      //user can specify a map source ID, or a repo URI as the map source
1672      uri = osm_gps_map_source_get_repo_uri(OSM_GPS_MAP_SOURCE_NULL);      uri = osm_gps_map_source_get_repo_uri(OSM_GPS_MAP_SOURCE_NULL);
1673      if ( (priv->map_source == 0) || (strcmp(priv->repo_uri, uri) == 0) ) {      if ( (priv->map_source == 0) || (strcmp(priv->repo_uri, uri) == 0) ) {
# Line 1709  osm_gps_map_constructor (GType gtype, gu Line 1700  osm_gps_map_constructor (GType gtype, gu
1700          priv->cache_dir = g_strdup_printf("%s%c%s", priv->tile_dir, G_DIR_SEPARATOR, fname);          priv->cache_dir = g_strdup_printf("%s%c%s", priv->tile_dir, G_DIR_SEPARATOR, fname);
1701          g_debug("Adjusting cache dir %s -> %s", priv->tile_dir, priv->cache_dir);          g_debug("Adjusting cache dir %s -> %s", priv->tile_dir, priv->cache_dir);
1702      }      }
1703    }
1704    
1705    static GObject *
1706    osm_gps_map_constructor (GType gtype, guint n_properties, GObjectConstructParam *properties)
1707    {
1708        //Always chain up to the parent constructor
1709        GObject *object =
1710            G_OBJECT_CLASS(osm_gps_map_parent_class)->constructor(gtype, n_properties, properties);
1711    
1712      inspect_map_uri(map);      osm_gps_map_setup(OSM_GPS_MAP_PRIVATE(object));
1713    
1714        inspect_map_uri(OSM_GPS_MAP(object));
1715    
1716      return object;      return object;
1717  }  }
# Line 1875  osm_gps_map_set_property (GObject *objec Line 1876  osm_gps_map_set_property (GObject *objec
1876                  /* flush the ram cache */                  /* flush the ram cache */
1877                  g_hash_table_remove_all(priv->tile_cache);                  g_hash_table_remove_all(priv->tile_cache);
1878    
1879                  //check if the source given is valid                  osm_gps_map_setup(priv);
1880                  const char *uri = osm_gps_map_source_get_repo_uri(priv->map_source);  
1881                  if (uri) {                  inspect_map_uri(map);
                     g_debug("Setting map source from ID");  
                     g_free(priv->repo_uri);  
   
                     priv->repo_uri = g_strdup(uri);  
                     priv->image_format = g_strdup(  
                            osm_gps_map_source_get_image_format(priv->map_source));  
                     priv->max_zoom = osm_gps_map_source_get_max_zoom(priv->map_source);  
                     priv->min_zoom = osm_gps_map_source_get_min_zoom(priv->map_source);  
                 }  
   
                 /* create a new disk cache path */  
                 const char *fname = osm_gps_map_source_get_friendly_name(priv->map_source);  
                 if(!fname) fname = "_unknown_";  
   
                 if (priv->tile_dir) {  
                     //the new cachedir is the given cache dir + the friendly name of the repo_uri  
                     priv->cache_dir =  
                         g_strdup_printf("%s%c%s", priv->tile_dir, G_DIR_SEPARATOR, fname);  
                     g_debug("Adjusting cache dir %s -> %s", priv->tile_dir, priv->cache_dir);  
                 }  
1882    
1883                  /* adjust zoom if necessary */                  /* adjust zoom if necessary */
1884                  if(priv->map_zoom > priv->max_zoom)                  if(priv->map_zoom > priv->max_zoom)
# Line 1906  osm_gps_map_set_property (GObject *objec Line 1887  osm_gps_map_set_property (GObject *objec
1887                  if(priv->map_zoom < priv->min_zoom)                  if(priv->map_zoom < priv->min_zoom)
1888                      osm_gps_map_set_zoom(map, priv->min_zoom);                      osm_gps_map_set_zoom(map, priv->min_zoom);
1889    
                 inspect_map_uri(map);  
   
1890              } } break;              } } break;
1891          case PROP_IMAGE_FORMAT:          case PROP_IMAGE_FORMAT:
1892              priv->image_format = g_value_dup_string (value);              priv->image_format = g_value_dup_string (value);
# Line 2531  osm_gps_map_source_get_friendly_name(Osm Line 2510  osm_gps_map_source_get_friendly_name(Osm
2510          case OSM_GPS_MAP_SOURCE_NULL:          case OSM_GPS_MAP_SOURCE_NULL:
2511              return "None";              return "None";
2512          case OSM_GPS_MAP_SOURCE_OPENSTREETMAP:          case OSM_GPS_MAP_SOURCE_OPENSTREETMAP:
2513              return "OpenStreetMap";              return "OpenStreetMap I";
2514          case OSM_GPS_MAP_SOURCE_OPENSTREETMAP_RENDERER:          case OSM_GPS_MAP_SOURCE_OPENSTREETMAP_RENDERER:
2515              return "OpenStreetMap Tiles@Home";              return "OpenStreetMap II";
2516          case OSM_GPS_MAP_SOURCE_OPENCYCLEMAP:          case OSM_GPS_MAP_SOURCE_OPENCYCLEMAP:
2517              return "OpenCycleMap";              return "OpenCycleMap";
2518          case OSM_GPS_MAP_SOURCE_MAPS_FOR_FREE:          case OSM_GPS_MAP_SOURCE_MAPS_FOR_FREE:

Legend:
Removed from v.89  
changed lines
  Added in v.91