Commit 33d21034 authored by Kris Vanneste's avatar Kris Vanneste
Browse files

Allowed 'selection_dict' property of GisData to be a string (attribute filter...

Allowed 'selection_dict' property of GisData to be a string (attribute filter passed to read_gis_file function), and modified get_data method accordingly.

git-svn-id: 40b490c5-b4d9-47cb-8714-9bef99b524d5
parent c46fb80b
......@@ -47,6 +47,9 @@ class GisData(BasemapData):
dict, mapping column names to values; only matching records will be selected
Note: multiple values mapped to a column name will act as logical OR,
multiple keys will act as logical AND operator.
Alternatively: str, attribute_filter that will be directly passed to
(default: None)
:param joined_attributes:
dict, mapping additional attribute names (not present in the GIS table)
to dictionaries containing two entries:
......@@ -57,7 +60,7 @@ class GisData(BasemapData):
(default: True)
:param invert_selection:
bool, whether or not to invert the selection criteria in
:param:`selection_dict`. Ignored if :param:`selection_dict` is a string
(default: False)
:param region:
(west, east, south, north) tuple in geographic coordinates,
......@@ -170,7 +173,7 @@ class GisData(BasemapData):
for colname in polygon_value_colnames:
polygon_data.values[colname] = []
if not self.invert_selection:
if not self.invert_selection or isinstance(self.selection_dict, basestring):
## Delegate selection to read_gis_file
attribute_filter = self.selection_dict
......@@ -179,6 +182,7 @@ class GisData(BasemapData):
region=self.region, out_srs=out_srs,
if isinstance(self.selection_dict, dict):
selected = np.zeros(len(self.selection_dict.keys()))
for i, (selection_colname, selection_value) in enumerate(self.selection_dict.items()):
if rec[selection_colname] == selection_value:
......@@ -189,6 +193,8 @@ class GisData(BasemapData):
selected[i] = 0
if self.invert_selection:
selected = np.abs(selected - 1)
selected = np.array([True])
if selected.all():
label = rec.get(self.label_colname)
if label is None and self.label_colname in self.joined_attributes:
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