Skip to content

Commit

Permalink
jshint cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmyangel committed Jul 16, 2016
1 parent 55eba6f commit 2fde8c2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
1 change: 0 additions & 1 deletion js/forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,6 @@ var tmForms = (function () {
fReader.onload = function() {
// We try to parse using omnivore to make sure a GPX file can be viewed later
var layer;
var i;
try {
layer = omnivore.gpx.parse(fReader.result);
} catch (e) {
Expand Down
8 changes: 3 additions & 5 deletions js/mapper.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';
/* exported tmMap */
/* globals L, omnivore, tmForms, tmData, tmUtils, tmConfig, tmConstants, tmMessages, FB, lightbox, Cesium, isMobile, isWebGlSupported, API_BASE_URL, tmBaseMapLayers, StateMachine */
/* globals L, omnivore, tmForms, tmData, tmUtils, tmConfig, tmConstants, tmMessages, lightbox, Cesium, isMobile, isWebGlSupported, API_BASE_URL, tmBaseMapLayers, StateMachine */

var tmMap = (function () {
var map; // For leaflet
Expand Down Expand Up @@ -310,8 +310,6 @@ var tmMap = (function () {
var trackMarkersLayerGroup = setUpMarkersForAllTracks(tracks, track.trackId);
layerControl.addOverlay(trackMarkersLayerGroup, 'Show markers for all tracks');

var trackMetrics = [0, 0, 0, 0];

// If region is US, we use imperial units
var imperial = (track.trackRegionTags.indexOf('US') === -1) ? false : true;

Expand Down Expand Up @@ -371,7 +369,7 @@ var tmMap = (function () {
// map.setZoom(map.getBoundsZoom(tl.getBounds())-1); // For some reason this has a glitch on iPad

// Go ahead and draw the inside line (thinner and bright color like yellow)
var insideT = {type: "FeatureCollection", features: []}; // Here we will put the inside line of the track in a different color
var insideT = {type: 'FeatureCollection', features: []}; // Here we will put the inside line of the track in a different color
insideT.features.push(tmUtils.extractSingleLineString(tl.toGeoJSON()));
L.geoJson(insideT, {
style: function () {
Expand Down Expand Up @@ -699,7 +697,7 @@ var tmMap = (function () {
savedTrackMarkerEntity = viewer.entities.getById(track.trackId);
var lGPX = omnivore.gpx(API_BASE_URL + '/v1/tracks/' + track.trackId + '/GPX', null).on('ready', function() {
// First grab the GeoJSON data from omnivore
var trackGeoJSON = {type: "FeatureCollection", features: []};
var trackGeoJSON = {type: 'FeatureCollection', features: []};
trackGeoJSON.features.push(tmUtils.extractSingleLineString(this.toGeoJSON()));

viewer.dataSources.add(Cesium.CzmlDataSource.load(tmUtils.buildCZMLForTrack(trackGeoJSON, lGPX, track.trackType))).then(function(ds) {
Expand Down
17 changes: 9 additions & 8 deletions js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ var tmUtils = (function () {
trackGeoJSON.features.splice(i, 1);
} else {
// Also remove feature if the LineString has no elevation data
if (!Array.isArray(trackGeoJSON.features[i].geometry.coordinates) || !(trackGeoJSON.features[i].geometry.coordinates[0].length === 3)) {
if (!Array.isArray(trackGeoJSON.features[i].geometry.coordinates) || (trackGeoJSON.features[i].geometry.coordinates[0].length < 3)) {
trackGeoJSON.features.splice(i, 1);
}
}
Expand Down Expand Up @@ -210,10 +210,11 @@ var tmUtils = (function () {
}

// Iterate over Linestring Features
var lastIndex = 0;
for (j=0; j<trackGeoJSON.features.length; j++) {

// Simplify track segment by dropping samples closer than tmConstants.MIN_SAMPLE_DISTANCE meters
var lastIndex = 0;
lastIndex = 0;
for (i=0; i<trackGeoJSON.features[j].geometry.coordinates.length; i++) {
if (i === 0) {
keepSample(j, i);
Expand Down Expand Up @@ -332,40 +333,40 @@ var tmUtils = (function () {
var sLS = {
geometry: {
coordinates: [],
type: "LineString"
type: 'LineString'
},
properties: {
coordTimes: []
},
type: "Feature"
type: 'Feature'
};
for (var i=0; i<t.features.length; i++) {
// Grab the first time found
if (t.features[i].properties.time && !sLS.properties.time) {
sLS.properties.time = t.features[i].properties.time;
}
if (t.features[i].geometry.type == 'LineString') {
if (t.features[i].geometry.type === 'LineString') {
if (t.features[i].geometry.coordinates[0].length >= 3) {
sLS.geometry.coordinates.push.apply(sLS.geometry.coordinates, t.features[i].geometry.coordinates);
if (t.features[i].properties.coordTimes) {
sLS.properties.coordTimes.push.apply(sLS.properties.coordTimes, t.features[i].properties.coordTimes);
}
}
} else {
if (t.features[i].geometry.type == 'MultiLineString') {
if (t.features[i].geometry.type === 'MultiLineString') {
for (var j=0; j<t.features[i].geometry.coordinates.length; j++) {
if (t.features[i].geometry.coordinates[j][0].length >= 3) {
sLS.geometry.coordinates.push.apply(sLS.geometry.coordinates, t.features[i].geometry.coordinates[j]);
}
if (t.features[i].properties.coordTimes[j]) {
sLS.properties.coordTimes.push.apply(sLS.properties.coordTimes, t.features[i].properties.coordTimes[j]);
}
};
}
}
}
}
return sLS;
}
};

return {
calculateTrackMetrics: calculateTrackMetrics,
Expand Down

0 comments on commit 2fde8c2

Please sign in to comment.