|
78 | 78 | _STYLE_TAG = _WMTS_NS + 'Style' |
79 | 79 | _STYLE_LEGEND_URL = _WMTS_NS + 'LegendURL' |
80 | 80 |
|
| 81 | +# Table 9, page 22-23, Parts of Dimensions data structure |
| 82 | +_DIMENSION_TAG = _WMTS_NS + 'Dimension' |
| 83 | +_UOM_TAG = _OWS_NS + 'UOM' |
| 84 | +_DIMENSION_UNIT_SYMBOL_TAG = _WMTS_NS + 'UnitSymbol' |
| 85 | +_DIMENSION_DEFAULT_TAG = _WMTS_NS + 'Default' |
| 86 | +_DIMENSION_CURRENT_TAG = _WMTS_NS + 'Current' |
| 87 | +_DIMENSION_VALUE_TAG = _WMTS_NS + 'Value' |
| 88 | + |
81 | 89 | _THEME_TAG = _WMTS_NS + 'Theme' |
82 | 90 | _THEMES_TAG = _WMTS_NS + 'Themes' |
83 | 91 | _TILE_HEIGHT_TAG = _WMTS_NS + 'TileHeight' |
@@ -793,6 +801,65 @@ def __init__(self, elem, parent=None, index=0, parse_remote_metadata=False): |
793 | 801 | _KEYWORDS_TAG + '/' + _KEYWORD_TAG)] |
794 | 802 | self.infoformats = [f.text for f in elem.findall(_INFO_FORMAT_TAG)] |
795 | 803 |
|
| 804 | + self.dimensions = {} |
| 805 | + for dim in elem.findall(_DIMENSION_TAG): |
| 806 | + dimension = {} |
| 807 | + |
| 808 | + identifier = dim.find(_IDENTIFIER_TAG) |
| 809 | + if identifier is None: |
| 810 | + # mandatory parameter |
| 811 | + raise ValueError('%s missing identifier' % (dim,)) |
| 812 | + if identifier.text in self.dimensions: |
| 813 | + # domain identifier SHALL be unique |
| 814 | + warnings.warn('%s identifier duplicated, taking first occurence' % (dim,)) |
| 815 | + continue |
| 816 | + |
| 817 | + values = [f.text for f in dim.findall(_DIMENSION_VALUE_TAG)] |
| 818 | + if len(values) == 0: |
| 819 | + raise ValueError( |
| 820 | + '%s list of values can not be empty' % (dim,) |
| 821 | + ) |
| 822 | + dimension['values'] = values |
| 823 | + |
| 824 | + title = dim.find(_TITLE_TAG) |
| 825 | + if title is not None: |
| 826 | + dimension['title'] = title.text |
| 827 | + |
| 828 | + abstract = dim.find(_ABSTRACT_TAG) |
| 829 | + if abstract is not None: |
| 830 | + dimension['abstract'] = abstract.text |
| 831 | + |
| 832 | + keywords = [ |
| 833 | + f.text for f in dim.findall(_KEYWORDS_TAG + '/' + _KEYWORD_TAG) |
| 834 | + ] |
| 835 | + if keywords: |
| 836 | + dimension['keywords'] = keywords |
| 837 | + |
| 838 | + uom = dim.find(_UOM_TAG) |
| 839 | + if uom is not None: |
| 840 | + dimension['UOM'] = uom.text |
| 841 | + |
| 842 | + unit_symbol = dim.find(_DIMENSION_UNIT_SYMBOL_TAG) |
| 843 | + if unit_symbol is not None: |
| 844 | + dimension['unit_symbol'] = unit_symbol.text |
| 845 | + |
| 846 | + default_value = dim.find(_DIMENSION_DEFAULT_TAG) |
| 847 | + if default_value in ['default', 'current', '', None]: |
| 848 | + # mandatory parameter |
| 849 | + raise ValueError( |
| 850 | + '%s default value must not be empty or \'default\' or \'current\'' |
| 851 | + % (dim,) |
| 852 | + ) |
| 853 | + dimension['default'] = default_value.text |
| 854 | + |
| 855 | + current = dim.find(_DIMENSION_CURRENT_TAG) |
| 856 | + if current and current.text == 'true': |
| 857 | + dimension['current'] = True |
| 858 | + else: |
| 859 | + dimension['current'] = False |
| 860 | + |
| 861 | + self.dimensions[identifier.text] = dimension |
| 862 | + |
796 | 863 | self.layers = [] |
797 | 864 | for child in elem.findall(_LAYER_TAG): |
798 | 865 | self.layers.append(ContentMetadata(child, self)) |
|
0 commit comments