sparc-commons
Advanced tools
Comparing version 0.1.12 to 0.1.13
@@ -6,50 +6,2 @@ /*jshint multistr: true */ | ||
var asCategoryFeatures = es.asCategoryFeatures = function(route, categories){ | ||
function createFeature(mode){ | ||
return { | ||
type: "Feature", | ||
geometry: { | ||
type: "LineString", | ||
coordinates: [] | ||
}, | ||
properties: { | ||
category: _.findKey(categories, {mode: mode}), | ||
mode: mode, | ||
routepoints: [] | ||
} | ||
} | ||
} | ||
return _.reduce(route.events, function(repr, event){ | ||
var feature; | ||
if(_.isEmpty(repr.features)){ | ||
feature = createFeature(event.properties.mode) | ||
} else { | ||
feature = repr.features.pop() | ||
} | ||
//We populate features | ||
var mode = event.properties.mode | ||
if(mode !== feature.properties.mode){ | ||
//The point has a different category than the previous points. We create a new feature | ||
// TODO why? | ||
if(feature.geometry.coordinates.length <= 1){ | ||
feature.geometry.type = "Point" | ||
feature.geometry.coordinates = _.flatten(feature.geometry.coordinates) | ||
} | ||
repr.features.push(feature) | ||
feature = createFeature(event.properties.mode) | ||
} | ||
feature.geometry.coordinates.push(event.geometry.coordinates) | ||
feature.properties.routepoints.push(event.properties) | ||
repr.features.push(feature) | ||
return repr | ||
}, { | ||
type: "FeatureCollection", | ||
features: [], | ||
properties: _.omit(route.getFields(), ['events']) | ||
}) | ||
} | ||
var degToRad = es.degToRad = function degToRad(x) { | ||
@@ -56,0 +8,0 @@ return x * Math.PI / 180.0; |
{ | ||
"name": "sparc-commons", | ||
"version": "0.1.12", | ||
"version": "0.1.13", | ||
"description": "Library with all small time common stuff used across the SPARC echosystem", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
27860
605