From 9716e262a555f564981b274a34477e0987525026 Mon Sep 17 00:00:00 2001 From: Robert Marianski Date: Fri, 2 Oct 2015 21:53:29 -0400 Subject: [PATCH 1/2] Only include labels with name or sport tags --- TileStache/Goodies/VecTiles/transform.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/TileStache/Goodies/VecTiles/transform.py b/TileStache/Goodies/VecTiles/transform.py index 7fd2b9d7..2bd8900c 100644 --- a/TileStache/Goodies/VecTiles/transform.py +++ b/TileStache/Goodies/VecTiles/transform.py @@ -1483,6 +1483,14 @@ def generate_label_features( if shape.geom_type not in ('Polygon', 'MultiPolygon'): continue + # 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 + # shapely also has a function `representative_point` which we # might want to consider using here label_centroid = shape.centroid From 51025350a084d55d62e09698527c527d68ddaf7b Mon Sep 17 00:00:00 2001 From: Robert Marianski Date: Fri, 2 Oct 2015 21:59:28 -0400 Subject: [PATCH 2/2] Use representative_point instead of centroid --- TileStache/Goodies/VecTiles/transform.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/TileStache/Goodies/VecTiles/transform.py b/TileStache/Goodies/VecTiles/transform.py index 2bd8900c..384329a9 100644 --- a/TileStache/Goodies/VecTiles/transform.py +++ b/TileStache/Goodies/VecTiles/transform.py @@ -1491,13 +1491,13 @@ def generate_label_features( if not sport: continue - # shapely also has a function `representative_point` which we - # might want to consider using here - label_centroid = shape.centroid + 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