Skip to content

Instantly share code, notes, and snippets.

@kpwebb
Created November 30, 2019 19:42
Show Gist options
  • Save kpwebb/af7d2caa36c324dbe64e8dcc855b80f5 to your computer and use it in GitHub Desktop.
Save kpwebb/af7d2caa36c324dbe64e8dcc855b80f5 to your computer and use it in GitHub Desktop.
const filterCurblrData = (data:CurbFeatureCollection, day:string, time:string, filterType:string):FeatureCollection<LineString> => {
var fitleredData = featureCollection<LineString>([]);
for(var curbFeature of data.features) {
var filteredFeature = feature<LineString>(curbFeature.geometry);
filteredFeature.properties = {};
if(!filterTimeAndDay(curbFeature, day, time))
continue;
for(var regulation of curbFeature.properties.regulations) {
if(regulation.priority) {
var baseOffset = 6 ;
if(curbFeature.properties.location.sideOfStreet === 'left')
baseOffset = -6;
filteredFeature.properties['offset'] = scaledOffet(baseOffset * (regulation.priority - 1));
if(filterType === "time") {
if(regulation.rule.activity === "parking" && regulation.rule.maxStay) {
var maxStay = regulation.rule.maxStay + "";
if(MAXSTAY_COLOR_MAP[maxStay]) {
filteredFeature.properties['color'] = MAXSTAY_COLOR_MAP[maxStay]
fitleredData.features.push(filteredFeature);
}
}
}
else {
filteredFeature.properties['color'] = ACTIVITY_COLOR_MAP[regulation.rule.activity];
fitleredData.features.push(filteredFeature);
}
}
}
}
return fitleredData;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment