Ejemplo n.º 1
0
def estimate_project_tiles(coverage, wmts_source, levels):
    if wmts_source.download_coverage:
        wmts_source_coverage = coverage_from_geojson(
            wmts_source.download_coverage)
    else:
        wmts_source_coverage = make_coverage(
            shapely.geometry.Polygon([(-20037508.34, -20037508.34),
                                      (-20037508.34, 20037508.34),
                                      (20037508.34, 20037508.34),
                                      (20037508.34, -20037508.34)]), SRS(3857))
    coverage_intersection = wmts_source_coverage.geom.intersection(
        coverage.geom)
    if not coverage_intersection:
        return 0
    intersection = make_coverage(coverage_intersection, SRS(3857))

    tiles = estimate_tiles(tile_grid(3857), levels, intersection)
    return tiles
Ejemplo n.º 2
0
def estimate_project_tiles(coverage, wmts_source, levels):
    if wmts_source.download_coverage:
        wmts_source_coverage = coverage_from_geojson(wmts_source.download_coverage)
    else:
        wmts_source_coverage = make_coverage(
            shapely.geometry.Polygon([
                (-20037508.34, -20037508.34),
                (-20037508.34, 20037508.34),
                (20037508.34, 20037508.34),
                (20037508.34, -20037508.34)
            ]), SRS(3857))
    coverage_intersection = wmts_source_coverage.geom.intersection(coverage.geom)
    if not coverage_intersection:
        return 0
    intersection = make_coverage(coverage_intersection, SRS(3857))

    tiles = estimate_tiles(tile_grid(3857), levels, intersection)
    return tiles
Ejemplo n.º 3
0
def data_volume():

    project_coverage = coverage_from_feature_collection(
        json.loads(request.form['coverage']))

    total_tiles = 0
    volume = 0
    if project_coverage:
        for raster_source in json.loads(request.form['raster_data']):
            wmts_source = None
            if request.args.get('export', 'false').lower() == 'true':
                local_source = g.db.query(model.LocalWMTSSource).get(
                    raster_source['source_id'])
                if local_source:
                    wmts_source = local_source.wmts_source
            else:
                wmts_source = g.db.query(model.ExternalWMTSSource).get(
                    raster_source['source_id'])

            if wmts_source.download_coverage:
                wmts_source_coverage = coverage_from_geojson(
                    wmts_source.download_coverage)
            else:
                wmts_source_coverage = make_coverage(
                    shapely.geometry.Polygon([(-20037508.34, -20037508.34),
                                              (-20037508.34, 20037508.34),
                                              (20037508.34, 20037508.34),
                                              (20037508.34, -20037508.34)]),
                    SRS(3857))
            coverage_intersection = wmts_source_coverage.geom.intersection(
                project_coverage.geom)
            if not coverage_intersection:
                continue
            intersection = make_coverage(coverage_intersection, SRS(3857))

            levels = range(raster_source['start_level'],
                           raster_source['end_level'] + 1)
            source_tiles = estimate_tiles(tile_grid(3857), levels,
                                          intersection)
            volume += source_tiles * 15
            total_tiles += source_tiles

    return jsonify(total_tiles=total_tiles, volume_mb=volume / 1024.0)
Ejemplo n.º 4
0
def data_volume():

    project_coverage = coverage_from_feature_collection(json.loads(request.form["coverage"]))

    total_tiles = 0
    volume = 0
    if project_coverage:
        for raster_source in json.loads(request.form["raster_data"]):
            wmts_source = None
            if request.args.get("export", "false").lower() == "true":
                local_source = g.db.query(model.LocalWMTSSource).get(raster_source["source_id"])
                if local_source:
                    wmts_source = local_source.wmts_source
            else:
                wmts_source = g.db.query(model.ExternalWMTSSource).get(raster_source["source_id"])

            if wmts_source.download_coverage:
                wmts_source_coverage = coverage_from_geojson(wmts_source.download_coverage)
            else:
                wmts_source_coverage = make_coverage(
                    shapely.geometry.Polygon(
                        [
                            (-20037508.34, -20037508.34),
                            (-20037508.34, 20037508.34),
                            (20037508.34, 20037508.34),
                            (20037508.34, -20037508.34),
                        ]
                    ),
                    SRS(3857),
                )
            coverage_intersection = wmts_source_coverage.geom.intersection(project_coverage.geom)
            if not coverage_intersection:
                continue
            intersection = make_coverage(coverage_intersection, SRS(3857))

            levels = range(raster_source["start_level"], raster_source["end_level"] + 1)
            source_tiles = estimate_tiles(tile_grid(3857), levels, intersection)
            volume += source_tiles * 15
            total_tiles += source_tiles

    return jsonify(total_tiles=total_tiles, volume_mb=volume / 1024.0)