Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Apr 8, 2024
1 parent adfe606 commit e913f4e
Show file tree
Hide file tree
Showing 20 changed files with 3,536 additions and 3,200 deletions.
1 change: 0 additions & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ on:
release:
types: [created, edited, published]


env:
ORG: opendatacube
IMAGE: dea-web-tools
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ To run it locally
docker-compose up
```

To use a deployed version access from: http://datacube-ows-tools.dev.dea.ga.gov.au/
To use a deployed version access from: http://datacube-ows-tools.dev.dea.ga.gov.au/
59 changes: 37 additions & 22 deletions datacube-ows-tools/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,20 @@
from flask import render_template, jsonify, json as flask_json
from flask_s3 import FlaskS3
from owslib.wms import WebMapService
from .util import disjoint_bbox, enclosed_bbox, fixed_bbox, v7_catalog_list, wms_endpoint_layers_list, v8_catalog_list
from .util import (
disjoint_bbox,
enclosed_bbox,
fixed_bbox,
v7_catalog_list,
wms_endpoint_layers_list,
v8_catalog_list,
)

app = Flask(__name__, static_url_path=os.getenv("STATIC_PATH", None))
app.config["FLASKS3_BUCKET_NAME"] = "dea-web-webtools-static"
s3 = FlaskS3(app)


# for terria catalog generator
@app.route("/")
def terria_au():
Expand All @@ -35,6 +43,7 @@ def terria_wps():
def comp_legend():
return render_template("legend-comparison.html")


@app.route("/getmap_comp")
def comp_getmap():

Expand All @@ -51,9 +60,9 @@ def comp_getfeatureinfo():
def getmap_url_generator():
getmap_urls = []
paramsJson = request.get_json()
stable_url = paramsJson['stable_url']
bbox = paramsJson['bbox']
crs = paramsJson['crs']
stable_url = paramsJson["stable_url"]
bbox = paramsJson["bbox"]
crs = paramsJson["crs"]

# print(f"request.get_json(): {request.get_json()}")

Expand Down Expand Up @@ -85,13 +94,14 @@ def getmap_url_generator():
layers_url_list = []
for style in layer.styles:
# print(time, file=sys.stdout)

url = f"{stable_url}wms?service=WMS&version=1.3.0&request=GetMap&layers={layer_name}&styles={style}&width=250&height=250&crs={crs}&bbox={bbox}&format=image%2Fpng&transparent=TRUE&bgcolor=0xFFFFFF&exceptions=XML&time={time}"
layers_url_list.append({"style": style, "url": url})
getmap_urls.append({"name": layer_name, "layersList": layers_url_list})

return json.dumps(getmap_urls)


# Utility functions
@app.route("/catalog-match")
def catalog_match_checker():
Expand All @@ -105,35 +115,40 @@ def catalog_match_checker():
terria_catalog_json = urllib.request.urlopen(terria_url)
# TODO: optimise this
# this is to by pass JSONDecodeError: Invalid \escape: line 626 column 79 (char 68035)
a = terria_catalog_json.read().decode(terria_catalog_json.headers.get_content_charset())
a = terria_catalog_json.read().decode(
terria_catalog_json.headers.get_content_charset()
)
b = a.replace("\\n", "iampin").replace("\\\n", "iamnotpin")
terria_data = json.loads(b)


dea_map_url = "https://raw.githubusercontent.com/GeoscienceAustralia/dea-config/master/dev/terria/dea-maps-v8.json"
dea_catalog_json = urllib.request.urlopen(dea_map_url)
dea_map_data = json.loads(dea_catalog_json.read())

terria_prod_catalog_list = v8_catalog_list(terria_data, prod_wms_url)
terria_prod_non_released = list(set(prod_wms_layers)-set(terria_prod_catalog_list))
terria_prod_non_released = list(
set(prod_wms_layers) - set(terria_prod_catalog_list)
)

terria_dev_catalog_list = v8_catalog_list(terria_data, dev_wms_url)
terria_dev_non_released = list(set(dev_wms_layers)-set(terria_dev_catalog_list))

terria_dev_non_released = list(set(dev_wms_layers) - set(terria_dev_catalog_list))

dea_map_catalog_list = v8_catalog_list(dea_map_data, prod_wms_url)
dea_map_non_released = list(set(prod_wms_layers)-set(dea_map_catalog_list))

return render_template("catalog-comparison.html", data={
"dev_non_released": terria_dev_non_released,
"dev_wms_layers": dev_wms_layers,
"dev_catalog_list": terria_dev_catalog_list,
"prod_non_released": terria_prod_non_released,
"prod_wms_layers": prod_wms_layers,
"prod_catalog_list": terria_prod_catalog_list,
"dea_map_non_released": dea_map_non_released,
"dea_map_catalog_list": dea_map_catalog_list,
})
dea_map_non_released = list(set(prod_wms_layers) - set(dea_map_catalog_list))

return render_template(
"catalog-comparison.html",
data={
"dev_non_released": terria_dev_non_released,
"dev_wms_layers": dev_wms_layers,
"dev_catalog_list": terria_dev_catalog_list,
"prod_non_released": terria_prod_non_released,
"prod_wms_layers": prod_wms_layers,
"prod_catalog_list": terria_prod_catalog_list,
"dea_map_non_released": dea_map_non_released,
"dea_map_catalog_list": dea_map_catalog_list,
},
)


@app.route("/jsongenerator", methods=["POST"])
Expand Down
14 changes: 7 additions & 7 deletions datacube-ows-tools/static/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
padding-left: 45px;
}
ul.no-bullets {
list-style-type: none; /* Remove bullets */
padding: 0; /* Remove padding */
margin: 0; /* Remove margins */
list-style-type: none; /* Remove bullets */
padding: 0; /* Remove padding */
margin: 0; /* Remove margins */
}
ul.no-bullets li {
color: green;
color: green;
}

ul.no-bullets li.missing {
color: red;
font-weight: bold;
}
color: red;
font-weight: bold;
}
2 changes: 1 addition & 1 deletion datacube-ows-tools/static/js/wms.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ function createCatalog() {
// }
// );
// end of get
}
},
);
}
81 changes: 59 additions & 22 deletions datacube-ows-tools/static/vendor/bootstrap/css/bootstrap.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e913f4e

Please sign in to comment.