Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid adding holes if there are none #249

Merged
merged 1 commit into from
Oct 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions geoviews/operation/projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,13 @@ def _process_element(self, element):
projected = gpd.GeoDataFrame(projected, columns=element.data.columns)
elif element.interface is MultiInterface:
x, y = element.kdims
item = element.data[0]
if isinstance(item, dict) and 'geometry' in item:
item = element.data[0] if element.data else None
if item is None or (isinstance(item, dict) and 'geometry' in item):
return element.clone(projected, crs=self.p.projection)
projected = [geom_dict_to_array_dict(p, [x.name, y.name]) for p in projected]
if pd and isinstance(item, pd.DataFrame):
if any('holes' in p for p in projected):
pass
elif pd and isinstance(item, pd.DataFrame):
projected = [pd.DataFrame(p, columns=item.columns) for p in projected]
elif isinstance(item, np.ndarray):
projected = [np.column_stack([p[d.name] for d in element.dimensions()])
Expand Down
6 changes: 4 additions & 2 deletions geoviews/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,17 @@ def geom_dict_to_array_dict(geom_dict, coord_names=['Longitude', 'Latitude']):
holes = []
for interior in geom.interiors:
holes.append(geom_to_array(interior))
new_dict['holes'] = [holes]
if holes:
new_dict['holes'] = [holes]
elif geom.geom_type == 'MultiPolygon':
outer_holes = []
for g in geom:
holes = []
for interior in g.interiors:
holes.append(geom_to_array(interior))
outer_holes.append(holes)
new_dict['holes'] = outer_holes
if any(hs for hs in outer_holes):
new_dict['holes'] = outer_holes
return new_dict


Expand Down