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

Add sort order for peaks #148

Merged
merged 2 commits into from
Apr 28, 2016
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
13 changes: 11 additions & 2 deletions TileStache/Goodies/VecTiles/sort.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,17 @@ def _by_transit_score(feature):
return props.get('mz_transit_score', 0)


def _sort_by_transit_score_then_feature_id(features):
def _by_peak_elevation(feature):
wkb, props, fid = feature
kind = props.get('kind')
if kind != 'peak' and kind != 'volcano':
return 0
return props.get('elevation', 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we coerce to a number here? Or does that already happen elsewhere?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it should already be a float in meters from a previous filter step.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍



def _sort_by_transit_score_then_elevation_then_feature_id(features):
features.sort(key=_by_feature_id)
features.sort(key=_by_peak_elevation, reverse=True)
features.sort(key=_by_transit_score, reverse=True)
return features

Expand Down Expand Up @@ -83,7 +92,7 @@ def places(features, zoom):


def pois(features, zoom):
return _sort_by_transit_score_then_feature_id(features)
return _sort_by_transit_score_then_elevation_then_feature_id(features)


def roads(features, zoom):
Expand Down