Skip to content

Commit c7e0b68

Browse files
authored
Merge pull request #787 from opendatacube/wcs1_envelope_srs
Fix WCS1 regression
2 parents 88c0148 + 53cbfcb commit c7e0b68

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

datacube_ows/ows_configuration.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,6 +1199,7 @@ def make_gml_name(name):
11991199
self.published_CRSs = {}
12001200
self.internal_CRSs = {}
12011201
CRS_aliases = {}
1202+
geographic_CRSs = []
12021203
for crs_str, crsdef in cfg["published_CRSs"].items():
12031204
if "alias" in crsdef:
12041205
CRS_aliases[crs_str] = crsdef
@@ -1211,6 +1212,8 @@ def make_gml_name(name):
12111212
"gml_name": make_gml_name(crs_str),
12121213
"alias_of": None
12131214
}
1215+
if crsdef["geographic"]:
1216+
geographic_CRSs.append(crs_str)
12141217
self.published_CRSs[crs_str] = self.internal_CRSs[crs_str]
12151218
if self.published_CRSs[crs_str]["geographic"]:
12161219
if self.published_CRSs[crs_str]["horizontal_coord"] != "longitude":
@@ -1219,6 +1222,16 @@ def make_gml_name(name):
12191222
if self.published_CRSs[crs_str]["vertical_coord"] != "latitude":
12201223
raise ConfigException(f"Published CRS {crs_str} is geographic"
12211224
"but has a vertical coordinate that is not 'latitude'")
1225+
# default_geographic_CRS is used by WCS1
1226+
if not self.wcs:
1227+
self.default_geographic_CRS = ""
1228+
elif not geographic_CRSs:
1229+
raise ConfigException(f"At least one geographic CRS must be supplied")
1230+
elif "EPSG:4326" in geographic_CRSs or "WGS-84" in geographic_CRSs:
1231+
self.default_geographic_CRS = "urn:ogc:def:crs:OGC:1.3:CRS84"
1232+
else:
1233+
self.default_geographic_CRS = geographic_CRSs[0]
1234+
12221235
for alias, alias_def in CRS_aliases.items():
12231236
target_crs = alias_def["alias"]
12241237
if target_crs not in self.published_CRSs:

tests/test_cfg_global.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ def test_minimal_global(minimal_global_raw_cfg, minimal_dc):
1616
assert cfg.ready
1717
assert cfg.initialised
1818
assert not cfg.wcs_tiff_statistics
19+
assert cfg.default_geographic_CRS == "" # No WCS
1920

2021

2122
def test_global_no_title(minimal_global_raw_cfg):
@@ -41,6 +42,42 @@ def test_wcs_only(minimal_global_raw_cfg, wcs_global_cfg, minimal_dc):
4142
assert not cfg.wms
4243
assert not cfg.wmts
4344
assert cfg.wcs_tiff_statistics
45+
assert cfg.default_geographic_CRS == "urn:ogc:def:crs:OGC:1.3:CRS84"
46+
47+
def test_geog_crs(minimal_global_raw_cfg, wcs_global_cfg, minimal_dc):
48+
OWSConfig._instance = None
49+
minimal_global_raw_cfg["global"]["services"] = {
50+
"wcs": True,
51+
"wms": False,
52+
"wmts": False,
53+
}
54+
minimal_global_raw_cfg["wcs"] = wcs_global_cfg
55+
minimal_global_raw_cfg["global"]["published_CRSs"] = {
56+
"EPSG:3857": { # Web Mercator
57+
"geographic": False,
58+
"horizontal_coord": "x",
59+
"vertical_coord": "y",
60+
},
61+
}
62+
with pytest.raises(ConfigException) as e:
63+
cfg = OWSConfig(cfg=minimal_global_raw_cfg)
64+
assert "At least one geographic CRS must be supplied" in str(e.value)
65+
OWSConfig._instance = None
66+
minimal_global_raw_cfg["global"]["published_CRSs"] = {
67+
"EPSG:3857": { # Web Mercator
68+
"geographic": False,
69+
"horizontal_coord": "x",
70+
"vertical_coord": "y",
71+
},
72+
"EPSG:99899": { # Made up
73+
"geographic": True,
74+
"horizontal_coord": "longitude",
75+
"vertical_coord": "latitude",
76+
},
77+
}
78+
cfg = OWSConfig(cfg=minimal_global_raw_cfg)
79+
cfg.make_ready(minimal_dc)
80+
assert cfg.default_geographic_CRS == "EPSG:99899"
4481

4582

4683
def test_contact_details_parse(minimal_global_cfg):

0 commit comments

Comments
 (0)