Commit 99b23456 authored by Kris Vanneste's avatar Kris Vanneste
Browse files

Added _get_values_at_indexes, _get_labels_at_indexes and...

Added _get_values_at_indexes, _get_labels_at_indexes and _get_style_params_at_indexes methods to MultiData.

git-svn-id: https://svn.seismo.oma.be/svn/seismo/mapping/layeredbasemap/trunk@7564 40b490c5-b4d9-47cb-8714-9bef99b524d5
parent 4457b1ae
......@@ -344,6 +344,32 @@ class MultiData(BasemapData):
value = None
return value
def _get_values_at_indexes(self, idxs):
"""
Fetch values corresponding to given indexes
:param idxs:
list or array of ints
:return:
dict or list
"""
if isinstance(self.values, dict):
values = {}
for key in self.values.keys():
values[key] = []
for index in idxs:
value = self._get_value_at_index(index)
for key in value.keys():
values[key].append(value[key])
else:
values = []
for index in idxs:
value = self._get_value_at_index(index)
values.append(value)
return values
def _get_label_at_index(self, index):
"""
Fetch label corresponding to given index.
......@@ -360,6 +386,19 @@ class MultiData(BasemapData):
label = ""
return label
def _get_labels_at_indexes(self, idxs):
"""
Fetch labels corresponding to given indexes
:param idxs:
list or array of ints
:return:
list of str
"""
labels = [self._get_label_at_index(index) for index in idxs]
return labels
def _get_style_params_at_index(self, index):
"""
Fetch style params corresponding to given index.
......@@ -380,6 +419,26 @@ class MultiData(BasemapData):
style_params[key] = value
return style_params
def _get_style_params_at_indexes(self, idxs):
"""
Fetch style params corresponding to given indexes
:param idxs:
list or array of ints
:return:
dict
"""
style_params = {}
for key in self.style_params.keys():
style_params[key] = []
for index in idxs:
sp = self._get_style_params_at_index(index)
for key in sp.keys():
style_params[key].append(sp[key])
return style_params
def get_overriding_style(self, default_style, index):
"""
Override given style with information in :prop:`style_params`
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment