Example #1
0
def _build_geojson_select(statement):
    """
    See usages below.
    """
    # this is basically a translation of the postgis ST_AsGeoJSON example into sqlalchemy/geoalchemy2
    return func.json_build_object(
        "type",
        "FeatureCollection",
        "features",
        func.json_agg(func.ST_AsGeoJSON(statement.subquery(), maxdecimaldigits=5).cast(JSON)),
    )
Example #2
0
File: api.py Project: JuKu/pycroft
def json_agg(query):
    return session.session.query(func.json_agg(literal_column("row"))) \
        .select_from(Alias(query.subquery(), "row"))
Example #3
0
File: api.py Project: JuKu/pycroft
def json_agg_core(selectable):
    return select([func.json_agg(literal_column("row"))]) \
        .select_from(selectable.alias("row"))