Пример #1
0
def meta(prefix=None):
    catalog = make_catalog(request.args)

    meta = {
        "bounds": catalog.bounds,
        "center": catalog.center,
        "maxzoom": catalog.maxzoom,
        "minzoom": catalog.minzoom,
        "name": catalog.name,
        "tilejson": "2.1.0",
        "metadata": catalog.src_meta
    }

    with app.app_context():
        meta["tiles"] = [
            "{}{{z}}/{{x}}/{{y}}?{}".format(
                url_for("meta",
                        prefix=make_prefix(),
                        _external=True,
                        _scheme=""),
                urllib.urlencode(request.args),
            )
        ]

    return jsonify(meta)
Пример #2
0
def meta(id, scene_idx, image_id=None, prefix=None):
    # prefix is for URL generation only (API Gateway stages); if it matched the
    # URL, it's part of the id
    if prefix is not None:
        id = "/".join([prefix, id])

    catalog = make_catalog(id, scene_idx, image_id)

    meta = {
        "bounds": catalog.bounds,
        "center": catalog.center,
        "maxzoom": catalog.maxzoom,
        "minzoom": catalog.minzoom,
        "name": catalog.name,
        "tilejson": "2.1.0",
    }

    with app.app_context():
        meta["tiles"] = [
            "{}{{z}}/{{x}}/{{y}}".format(
                url_for(
                    "meta",
                    id=id,
                    scene_idx=scene_idx,
                    image_id=image_id,
                    prefix=make_prefix(),
                    _external=True,
                    _scheme="",
                ))
        ]

    return jsonify(meta)
Пример #3
0
def user_wmts(id, prefix=None):
    catalog = make_remote_catalog("user", id)

    provider = "OpenAerialMap"
    provider_url = "https://openaerialmap.org/"

    if catalog.provider:
        provider = "{} ({})".format(provider, catalog.provider)

    with app.app_context():
        base_url = url_for("user_meta",
                           id=id,
                           prefix=make_prefix(),
                           _external=True)

        return render_template(
            "wmts.xml",
            base_url=base_url,
            bounds=catalog.bounds,
            content_type="image/png",
            ext="png",
            id=catalog.id,
            maxzoom=catalog.maxzoom,
            metadata_url=catalog.metadata_url,
            minzoom=catalog.minzoom,
            provider=provider,
            provider_url=provider_url,
            title=catalog.name,
        ), 200, {
            "Content-Type": "application/xml"
        }
Пример #4
0
def preview(renderer, **kwargs):
    if renderer not in RENDERERS:
        return '', 404

    with app.app_context():
        return render_template(
            "preview.html",
            tilejson_url=url_for(
                "meta",
                _external=True,
                _scheme="",
                prefix=make_prefix(),
                renderer=renderer))
Пример #5
0
def user_preview(id, prefix=None):
    # load the catalog so it will fail if the source doesn't exist
    make_remote_catalog("user", id)

    with app.app_context():
        return render_template(
            "preview.html",
            tilejson_url=url_for("user_meta",
                                 id=id,
                                 prefix=make_prefix(),
                                 _external=True,
                                 _scheme=""),
        ), 200, {
            "Content-Type": "text/html"
        }
Пример #6
0
def preview(prefix=None):
    # initialize the catalog so this route will fail if the source doesn't exist
    make_catalog(request.args)

    with app.app_context():
        return render_template(
            "preview.html",
            tilejson_url=Markup(
                url_for("meta",
                        prefix=make_prefix(),
                        _external=True,
                        _scheme="",
                        **request.args)),
        ), 200, {
            "Content-Type": "text/html"
        }
Пример #7
0
def remote_preview(id, prefix=None):
    # prefix is for URL generation only (API Gateway stages); if it matched the
    # URL, it's part of the id
    if prefix is not None:
        id = "/".join([prefix, id])

    # load the catalog so it will fail if the source doesn't exist
    make_remote_catalog(id)

    with app.app_context():
        return render_template("preview.html",
                               tilejson_url=url_for("remote_meta",
                                                    id=id,
                                                    prefix=make_prefix(),
                                                    _external=True,
                                                    _scheme="")), 200, {
                                                        "Content-Type":
                                                        "text/html"
                                                    }
Пример #8
0
def wmts(id, scene_idx, image_id=None, prefix=None):
    # prefix is for URL generation only (API Gateway stages); if it matched the
    # URL, it's part of the id
    if prefix is not None:
        id = "/".join([prefix, id])

    catalog = make_catalog(id, scene_idx, image_id)

    provider = "OpenAerialMap"
    provider_url = "https://openaerialmap.org/"

    if catalog.provider:
        provider = "{} ({})".format(provider, catalog.provider)

    with app.app_context():
        base_url = url_for(
            "meta",
            id=id,
            scene_idx=scene_idx,
            image_id=image_id,
            prefix=make_prefix(),
            _external=True,
        )

        return render_template(
            "wmts.xml",
            base_url=base_url,
            bounds=catalog.bounds,
            content_type="image/png",
            ext="png",
            id=catalog.id,
            maxzoom=catalog.maxzoom,
            metadata_url=catalog.metadata_url,
            minzoom=catalog.minzoom,
            provider=provider,
            provider_url=provider_url,
            title=catalog.name,
        ), 200, {
            "Content-Type": "application/xml"
        }
Пример #9
0
def meta(renderer, **kwargs):
    if renderer not in RENDERERS:
        return '', 404

    meta = {
        "minzoom": 0,
        "maxzoom": 22,
        "bounds": [-180, -85.05113, 180, 85.05113],
    }

    with app.app_context():
        meta["tiles"] = [
            "{}{{z}}/{{x}}/{{y}}.png".format(
                url_for(
                    "meta",
                    _external=True,
                    _scheme="",
                    prefix=make_prefix(),
                    renderer=renderer))
        ]

    return jsonify(meta)
Пример #10
0
def user_meta(id, prefix=None):
    catalog = make_remote_catalog("user", id)

    meta = {
        "bounds": catalog.bounds,
        "center": catalog.center,
        "maxzoom": catalog.maxzoom,
        "minzoom": catalog.minzoom,
        "name": catalog.name,
        "tilejson": "2.1.0",
    }

    with app.app_context():
        meta["tiles"] = [
            "{}{{z}}/{{x}}/{{y}}".format(
                url_for("user_meta",
                        id=id,
                        prefix=make_prefix(),
                        _external=True,
                        _scheme=""))
        ]

    return jsonify(meta)