Commit 18e3049d authored by Kris Vanneste's avatar Kris Vanneste
Browse files

Quick fix to make to_ogr_feature method of SingleData PY3-compatible.

Quick fix to make construct_ogr_feature_definition method of MultiData PY3-compatible.

git-svn-id: 40b490c5-b4d9-47cb-8714-9bef99b524d5
parent f0d19c83
......@@ -218,12 +218,15 @@ class SingleData(BasemapData):
#elif isinstance(field_value, np.floating):
# field_value = float(field_value)
elif isinstance(field_value, basestring):
if not isinstance(field_value, bytes):
if PY2 and not isinstance(field_value, bytes):
field_value = field_value.encode(encoding,
elif isinstance(field_value, (np.datetime64, datetime.datetime,, datetime.time)):
field_value = bytes(field_value)
if PY2:
field_value = bytes(field_value)
field_value = str(field_value)
elif isinstance(field_value, (list, np.ndarray)):
field_value = ','.join(map(str, field_value))
......@@ -468,7 +471,8 @@ class MultiData(BasemapData):
json = self.to_geojson(as_multi=True)
attributes = json["properties"]
for field_name, field_values in attributes.items():
field_name = field_name.encode(encoding, errors='xmlcharrefreplace')
if PY2:
field_name = field_name.encode(encoding, errors='xmlcharrefreplace')
field_val = field_values[0]
if isinstance(field_val, bool):
fd = ogr.FieldDefn(field_name, ogr.OFTInteger)
Supports Markdown
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