Ejemplo n.º 1
0
def register_rda_graph(conn, rda_graph):
    url = "{}/graph".format(VIRTUAL_RDA_URL)
    res = resolve_if_future(
        conn.post(url,
                  json.dumps(rda_graph, sort_keys=True),
                  headers={'Content-Type': 'application/json'}))
    if res.status_code == 200:
        return res.text
    else:
        raise BadRequest("Problem registering graph: {}".format(res.text))
Ejemplo n.º 2
0
def get_rda_metadata(conn, rda_id, node='toa_reflectance'):
    md_response = conn.get(
        VIRTUAL_RDA_URL +
        "/metadata/{}/{}/metadata.json".format(rda_id, node)).result()
    if md_response.status_code != 200:
        md_json = md_response.json()
        if 'error' in md_json:
            raise BadRequest("RDA error: {}. RDA Graph: {}".format(
                md_json['error'], rda_id))
        raise BadRequest(
            "Problem fetching image metadata: status {} {}, graph_id: {}".
            format(md_response.status_code, md_response.reason, rda_id))
    else:
        md_json = md_response.json()
        return {
            "image": md_json["imageMetadata"],
            "georef": md_json.get("imageGeoreferencing", None),
            "rpcs": md_json.get("rpcSensorModel", None)
        }
Ejemplo n.º 3
0
def get_rda_template_metadata(conn, _id, **kwargs):
    qs = urlencode(kwargs)
    url = VIRTUAL_RDA_URL + "/template/{}/metadata?{}".format(_id, qs)
    md_response = req_with_retries(conn, url)
    if md_response.status_code != 200:
        md_json = md_response.json()
        if 'error' in md_json:
            raise BadRequest("RDA error: {}. RDA Graph: {}".format(
                md_json['error'], _id))
        raise BadRequest(
            "Problem fetching image metadata: status {} {}, graph_id: {}".
            format(md_response.status_code, md_response.reason, _id))
    else:
        md_json = md_response.json()
        return {
            "image": md_json["imageMetadata"],
            "georef": md_json.get("imageGeoreferencing", None),
            "rpcs": md_json.get("rpcSensorModel", None)
        }