コード例 #1
0
ファイル: aoi_estimators.py プロジェクト: zta6/eventkit-cloud
def get_vector_estimate(provider, bbox, srs="4326"):
    """
    :param provider: The DataProvider to test
    :param bbox: The bounding box of the request
    :param srs: The SRS of the bounding box
    :return: (estimate in mbs, object w/ metadata about how it was generated)
    """
    # TODO tile_grid params should be serialized on all_stats object
    tile_grid = ek_stats.get_default_tile_grid()
    req_bbox = mapproxy_grid.grid_bbox(bbox, mapproxy_srs.SRS(srs),
                                       tile_grid.srs)
    req_area = ek_stats.get_area_bbox(req_bbox)

    # Compute estimate
    size_per_km, method = ek_stats.query(
        provider.slug,
        field=Stats.Fields.SIZE,
        statistic_name=Stats.MEAN,
        bbox=bbox,
        bbox_srs=srs,
        gap_fill_thresh=0.1,
        default_value=0,
    )
    method["size_per_km"] = size_per_km
    return req_area * size_per_km, method
コード例 #2
0
ファイル: aoi_estimators.py プロジェクト: zta6/eventkit-cloud
def get_raster_tile_grid_size_estimate(provider,
                                       bbox,
                                       srs="4326",
                                       with_clipping=True,
                                       min_zoom=None,
                                       max_zoom=None):
    """
    :param provider: The DataProvider to test
    :param bbox: The bounding box of the request
    :param srs: The SRS of the bounding box
    :param with_clipping: see get_total_num_pixels
    :return: (estimate in mbs, object w/ metadata about how it was generated)
    """
    # TODO: Both total_pixels and query intersect the tile grid, can save time if we do it once for both
    tile_grid = ek_stats.get_provider_grid(provider, min_zoom, max_zoom)
    total_pixels = ek_stats.get_total_num_pixels(tile_grid, bbox, srs,
                                                 with_clipping)

    mpp, method = ek_stats.query(
        provider.slug,
        field=Stats.Fields.MPP,
        statistic_name=Stats.MEAN,
        bbox=bbox,
        bbox_srs=srs,
        gap_fill_thresh=0.1,
        default_value=0.00000006,
    )
    method["mpp"] = mpp
    method["with_clipping"] = with_clipping
    # max acceptable is expected maximum number of bytes for the specified amount of pixels
    # pixels * <pixels per byte> / <bytes per MB>
    max_acceptable = total_pixels * 3 / 1e6
    estimate = total_pixels * mpp
    return estimate if estimate < max_acceptable else max_acceptable, method
コード例 #3
0
def get_raster_tile_grid_size_estimate(provider,
                                       bbox,
                                       srs='4326',
                                       with_clipping=True):
    """
    :param provider: The DataProvider to test
    :param bbox: The bounding box of the request
    :param srs: The SRS of the bounding box
    :param with_clipping: see get_total_num_pixels
    :return: (estimate in mbs, object w/ metadata about how it was generated)
    """
    # TODO: Both total_pixels and query intersect the tile grid, can save time if we do it once for both
    tile_grid = ek_stats.get_provider_grid(provider)
    total_pixels = ek_stats.get_total_num_pixels(tile_grid, bbox, srs,
                                                 with_clipping)

    mpp, method = ek_stats.query(provider.name,
                                 'mpp',
                                 'mean',
                                 bbox,
                                 srs,
                                 grouping='provider_name',
                                 gap_fill_thresh=0.1,
                                 default_value=0.00000006)

    method['mpp'] = mpp
    method['with_clipping'] = with_clipping
    return total_pixels * mpp, method
コード例 #4
0
def get_vector_estimate(provider, bbox, srs='4326'):
    """
    :param provider: The DataProvider to test
    :param bbox: The bounding box of the request
    :param srs: The SRS of the bounding box
    :return: (estimate in mbs, object w/ metadata about how it was generated)
    """
    # TODO tile_grid params should be serialized on all_stats object
    tile_grid = ek_stats.get_default_tile_grid()
    req_bbox = mapproxy_grid.grid_bbox(bbox, mapproxy_srs.SRS(srs),
                                       tile_grid.srs)
    req_area = ek_stats.get_area_bbox(req_bbox)

    # Compute estimate
    size_per_km, method = ek_stats.query(
        provider.export_provider_type.type_name,
        'size',
        'mean',
        bbox,
        srs,
        grouping='provider_type',
        gap_fill_thresh=0.1,
        default_value=0)
    method['size_per_km'] = size_per_km
    return req_area * size_per_km, method
コード例 #5
0
def get_vector_estimate(provider, bbox, srs='4326'):
    """
    :param provider: The DataProvider to test
    :param bbox: The bounding box of the request
    :param srs: The SRS of the bounding box
    :return: (estimate in mbs, object w/ metadata about how it was generated)
    """
    # TODO tile_grid params should be serialized on all_stats object
    tile_grid = ek_stats.get_default_tile_grid()
    req_bbox = mapproxy_grid.grid_bbox(bbox, mapproxy_srs.SRS(srs), tile_grid.srs)
    req_area = ek_stats.get_area_bbox(req_bbox)

    # Compute estimate
    size_per_km, method = ek_stats.query(provider.export_provider_type.type_name, 'size', 'mean', bbox, srs,
                                         grouping='provider_type',
                                         gap_fill_thresh=0.1,
                                         default_value=0)
    method['size_per_km'] = size_per_km
    return req_area * size_per_km, method
コード例 #6
0
def get_raster_tile_grid_size_estimate(provider, bbox, srs='4326', with_clipping=True):
    """
    :param provider: The DataProvider to test
    :param bbox: The bounding box of the request
    :param srs: The SRS of the bounding box
    :param with_clipping: see get_total_num_pixels
    :return: (estimate in mbs, object w/ metadata about how it was generated)
    """
    # TODO: Both total_pixels and query intersect the tile grid, can save time if we do it once for both
    tile_grid = ek_stats.get_provider_grid(provider)
    total_pixels = ek_stats.get_total_num_pixels(tile_grid, bbox, srs, with_clipping)

    mpp, method = ek_stats.query(provider.name, 'mpp', 'mean', bbox, srs,
                                 grouping='provider_name',
                                 gap_fill_thresh=0.1,
                                 default_value=0.00000006)

    method['mpp'] = mpp
    method['with_clipping'] = with_clipping
    return total_pixels * mpp, method
コード例 #7
0
ファイル: aoi_estimators.py プロジェクト: zta6/eventkit-cloud
def get_time_estimate(provider, bbox, bbox_srs="4326"):
    """
    :param provider: The DataProvider to test
    :param bbox: The bounding box of the request
    :param bbox_srs: The SRS of the bounding box
    :return: (estimate in seconds, object w/ metadata about how it was generated)
    """
    duration_per_unit_area, method = ek_stats.query(
        provider.slug,
        field=Stats.Fields.DURATION,
        statistic_name=Stats.MEAN,
        bbox=bbox,
        bbox_srs=bbox_srs,
        gap_fill_thresh=0.1,
        default_value=0,
    )

    area = get_area_bbox(bbox)
    estimate = area * duration_per_unit_area

    # If the estimate is more than a day, return a day and one second, we will use this on the front end.
    max_acceptable = 60 * 60 * 24  # Hard capping time estimates to one day (in seconds)
    return estimate if estimate < max_acceptable else max_acceptable + 1, method