def get_citywide_bounds_for_size(city_slug, size=LOCATOR_SIZE): """ Returns a 4-tuple extent in degrees decimal longitude and latitude the extent of a rectangle in (size[0], size[1]) pixels that is filled by the city. This is useful in generating locator map bounds because the extent of the city doesn't typically match the aspect ratio of the image. """ extent = city_extent_in_map_srs(city_slug) resolution = extent_resolution(extent, size, settings.MAP_UNITS) new_extent = calculate_bounds(center(extent), resolution, size) # Convert back to lng/lat return transform_extent(new_extent, 4326, src_srs=900913)
def calc_locator_scale(city_slug): return extent_scale(city_extent_in_map_srs(city_slug), size=LOCATOR_SIZE, units=settings.MAP_UNITS)