static void get_map_size (ChamplainView *view, gint *width, gint *height) { gint size, rows, cols; ChamplainMapSource *map_source = champlain_view_get_map_source (view); gint zoom_level = champlain_view_get_zoom_level (view); size = champlain_map_source_get_tile_size (map_source); rows = champlain_map_source_get_row_count (map_source, zoom_level); cols = champlain_map_source_get_column_count (map_source, zoom_level); *width = size * rows; *height = size * cols; }
/** * champlain_map_source_get_meters_per_pixel: * @map_source: a #ChamplainMapSource * @zoom_level: the zoom level * @latitude: a latitude * @longitude: a longitude * * Gets meters per pixel at the position on the map using this map source's projection. * * Returns: the meters per pixel * * Since: 0.4.3 */ gdouble champlain_map_source_get_meters_per_pixel (ChamplainMapSource *map_source, guint zoom_level, gdouble latitude, G_GNUC_UNUSED gdouble longitude) { g_return_val_if_fail (CHAMPLAIN_IS_MAP_SOURCE (map_source), 0.0); /* * Width is in pixels. (1 px) * m/px = radius_at_latitude / width_in_pixels * k = radius of earth = 6 378.1 km * radius_at_latitude = 2pi * k * sin (pi/2-theta) */ gdouble tile_size = champlain_map_source_get_tile_size (map_source); /* FIXME: support other projections */ return 2.0 *M_PI *EARTH_RADIUS *sin (M_PI / 2.0 - M_PI / 180.0 *latitude) / (tile_size * champlain_map_source_get_row_count (map_source, zoom_level)); }