示例#1
0
def map_info(request):
    geo_utils = GeoUtils()
    hex_bin_bounds = geo_utils.get_bounds_from_geojson(settings.DEFAULT_BOUNDS)
    default_center = geo_utils.get_centroid(settings.DEFAULT_BOUNDS)
    return {
        'map_info': {
            'x':
            default_center['coordinates'][0],
            'y':
            default_center['coordinates'][1],
            'zoom':
            settings.DEFAULT_MAP_ZOOM,
            'map_min_zoom':
            settings.MAP_MIN_ZOOM,
            'map_max_zoom':
            settings.MAP_MAX_ZOOM,
            'mapbox_api_key':
            settings.MAPBOX_API_KEY,
            'mapzen_api_key':
            settings.MAPZEN_API_KEY,
            'hex_bin_size':
            settings.HEX_BIN_SIZE if settings.HEX_BIN_SIZE != None else 100,
            'mapbox_sprites':
            settings.MAPBOX_SPRITES,
            'mapbox_glyphs':
            settings.MAPBOX_GLYPHS,
            'hex_bin_bounds':
            json.dumps(hex_bin_bounds),
            'geocoder_default':
            settings.DEFAULT_GEOCODER,
            'preferred_coordinate_systems':
            JSONSerializer().serialize(settings.PREFERRED_COORDINATE_SYSTEMS)
        }
    }
示例#2
0
def map_info(request):
    geo_utils = GeoUtils()
    if settings.DEFAULT_BOUNDS is not None:
        hex_bin_bounds = geo_utils.get_bounds_from_geojson(settings.DEFAULT_BOUNDS)
        default_center = geo_utils.get_centroid(settings.DEFAULT_BOUNDS)
    else:
        hex_bin_bounds = (0, 0, 1, 1)
        default_center = {"coordinates": [6.602384, 0.245926]}  # an island off the coast of Africa
    query = GroupMapSettings.objects.filter(group=request.user.groups.all()[0])
    if query.exists():
        group_map_settings = query.first()
        min_zoom = group_map_settings.min_zoom
        max_zoom = group_map_settings.max_zoom
        default_zoom = group_map_settings.default_zoom
    else:
        min_zoom = settings.MAP_MIN_ZOOM
        max_zoom = settings.MAP_MAX_ZOOM
        default_zoom = settings.DEFAULT_MAP_ZOOM
    return {
        "map_info": {
            "x": default_center["coordinates"][0],
            "y": default_center["coordinates"][1],
            "zoom": default_zoom,
            "map_min_zoom": min_zoom,
            "map_max_zoom": max_zoom,
            "mapbox_api_key": settings.MAPBOX_API_KEY,
            "hex_bin_size": settings.HEX_BIN_SIZE if settings.HEX_BIN_SIZE is not None else 100,
            "mapbox_sprites": settings.MAPBOX_SPRITES,
            "mapbox_glyphs": settings.MAPBOX_GLYPHS,
            "hex_bin_bounds": json.dumps(hex_bin_bounds),
            "geocoder_default": settings.DEFAULT_GEOCODER,
            "preferred_coordinate_systems": JSONSerializer().serialize(settings.PREFERRED_COORDINATE_SYSTEMS),
        }
    }
示例#3
0
def map_info(request):
    geo_utils = GeoUtils()
    hex_bin_bounds = geo_utils.get_bounds_from_geojson(settings.DEFAULT_BOUNDS)
    default_center = geo_utils.get_centroid(settings.DEFAULT_BOUNDS)
    return {
        'map_info': {
            'x': default_center['coordinates'][0],
            'y': default_center['coordinates'][1],
            'zoom': settings.DEFAULT_MAP_ZOOM,
            'map_min_zoom': settings.MAP_MIN_ZOOM,
            'map_max_zoom': settings.MAP_MAX_ZOOM,
            'mapbox_api_key': settings.MAPBOX_API_KEY,
            'hex_bin_size': settings.HEX_BIN_SIZE if settings.HEX_BIN_SIZE != None else 100,
            'mapbox_sprites': settings.MAPBOX_SPRITES,
            'mapbox_glyphs': settings.MAPBOX_GLYPHS,
            'hex_bin_bounds': json.dumps(hex_bin_bounds),
            'geocoder_default': settings.DEFAULT_GEOCODER,
            'preferred_coordinate_systems': JSONSerializer().serialize(settings.PREFERRED_COORDINATE_SYSTEMS)
        }
    }