MCPcopy
hub / github.com/django/django / metadata

Method metadata

django/contrib/gis/gdal/raster/base.py:11–58  ·  view source on GitHub ↗

Return the metadata for this raster or band. The return value is a nested dictionary, where the first-level key is the metadata domain and the second-level is the metadata item names and values for that domain.

(self)

Source from the content-addressed store, hash-verified

9
10 @property
11 def metadata(self):
12 """
13 Return the metadata for this raster or band. The return value is a
14 nested dictionary, where the first-level key is the metadata domain and
15 the second-level is the metadata item names and values for that domain.
16 """
17 # The initial metadata domain list contains the default domain.
18 # The default is returned if domain name is None.
19 domain_list = ["DEFAULT"]
20
21 # Get additional metadata domains from the raster.
22 meta_list = capi.get_ds_metadata_domain_list(self._ptr)
23 if meta_list:
24 # The number of domains is unknown, so retrieve data until there
25 # are no more values in the ctypes array.
26 counter = 0
27 domain = meta_list[counter]
28 while domain:
29 domain_list.append(domain.decode())
30 counter += 1
31 domain = meta_list[counter]
32
33 # Free domain list array.
34 capi.free_dsl(meta_list)
35
36 # Retrieve metadata values for each domain.
37 result = {}
38 for domain in domain_list:
39 # Get metadata for this domain.
40 data = capi.get_ds_metadata(
41 self._ptr,
42 (None if domain == "DEFAULT" else domain.encode()),
43 )
44 if not data:
45 continue
46 # The number of metadata items is unknown, so retrieve data until
47 # there are no more values in the ctypes array.
48 domain_meta = {}
49 counter = 0
50 item = data[counter]
51 while item:
52 key, val = item.decode().split("=")
53 domain_meta[key] = val
54 counter += 1
55 item = data[counter]
56 # The default domain values are returned if domain is None.
57 result[domain or "DEFAULT"] = domain_meta
58 return result
59
60 @metadata.setter
61 def metadata(self, value):

Callers 1

_metadataMethod · 0.80

Calls 5

appendMethod · 0.45
decodeMethod · 0.45
encodeMethod · 0.45
splitMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected