예제 #1
0
def get_bbox():
    """
    Get bbbox of observations

    .. :quickref: Synthese;
    
    Parameters
    -----------
    id_dataset: int: (query parameter)

    Returns
    -------
        bbox: `geojson`: 
            the bounding box in geojson
    """
    params = request.args

    query = DB.session.query(func.ST_AsGeoJSON(func.ST_Extent(Synthese.the_geom_4326)))
        
    if "id_dataset" in params:
        query = query.filter(Synthese.id_dataset == params["id_dataset"])
    data = query.one()
    if data and data[0]:
        return json.loads(data[0])
    return None
예제 #2
0
파일: data.py 프로젝트: betonr/bdc-stac
def get_collection_extent(collection_id):
    """Retrive the extent as a BBOX for a given collection.

    :param collection_id: collection identifier
    :type collection_id: str
    :return: list of coordinates for the collection extent
    :rtype: list
    """
    extent = (session.query(func.ST_Extent(Item.geom).label("bbox")).filter(
        Collection.id == Item.collection_id,
        Collection.id == collection_id).first())

    bbox = list()
    if extent.bbox:
        bbox = extent.bbox[extent.bbox.find("(") +
                           1:extent.bbox.find(")")].replace(" ", ",")
        bbox = [float(coord) for coord in bbox.split(",")]
    return bbox