Skip to content
Merged
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
16 changes: 12 additions & 4 deletions TileStache/Goodies/VecTiles/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -1483,13 +1483,21 @@ def generate_label_features(
if shape.geom_type not in ('Polygon', 'MultiPolygon'):
continue

# shapely also has a function `representative_point` which we
# might want to consider using here
label_centroid = shape.centroid
# Additionally, the feature needs to have a name or a sport
# tag, oherwise it's not really useful for labelling purposes
name = properties.get('name')
if not name:
sport = properties.get('sport')
if not sport:
continue

label_point = shape.representative_point()

label_properties = properties.copy()
if label_property_name:
label_properties[label_property_name] = label_property_value
label_feature = label_centroid, label_properties, fid

label_feature = label_point, label_properties, fid

# if we're adding these features to a new layer, don't add the
# original features
Expand Down