Last active
August 30, 2017 17:53
Revisions
-
Mike Atlas revised this gist
Oct 24, 2014 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,3 @@ Array.prototype.splitAtEvery = (callback) -> sections = [] arrayClone = this.slice(0) -
Mike Atlas revised this gist
Oct 24, 2014 . 1 changed file with 0 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,3 @@ Array.prototype.splitAtEvery = (callback) -> sections = [] -
Mike Atlas revised this gist
Oct 24, 2014 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,7 @@   Array.prototype.splitAtEvery = (callback) -> sections = [] arrayClone = this.slice(0) -
Mike Atlas revised this gist
Oct 24, 2014 . 1 changed file with 40 additions and 41 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,44 +1,43 @@ Array.prototype.splitAtEvery = (callback) -> sections = [] arrayClone = this.slice(0) $.each(arrayClone, (idx, item) => sectionsLength = 0 _.each(sections, (section) => sectionsLength += section.length; ) if callback(this, idx, item) == true sections.push(arrayClone.slice(0, idx+1-sectionsLength)) arrayClone = arrayClone.slice(idx+1-sectionsLength, arrayClone.length) return ) sections.push(arrayClone) return sections drawPolylines = (latLons, leafletMap) -> normalizeIndexes = [] $.each(latLons, (i, latLon) => last = latLons[i-1] if last? if Math.abs(latLon.lng - last.lng) > 180 normalizeIndexes.push(i) ) normalizeIndexesRef = normalizeIndexes.slice(0) $.each(normalizeIndexes, (i, normalizeIndex) => flipDirection = if latLons[normalizeIndexesRef[i]].lng < 0 then -1 else 1 latLons.splice(normalizeIndexesRef[i], 0, L.latLng(latLons[normalizeIndexesRef[i]].lat, flipDirection * -179.99999)) latLons.splice(normalizeIndexesRef[i]+1, 0, L.latLng(latLons[normalizeIndexesRef[i]].lat, flipDirection * 179.99999)) normalizeIndexesRef = _.map(normalizeIndexesRef, (idx) => idx+2) ) sections = latLons.splitAtEvery((array, i, val) -> return (Math.abs(val.lng) == 179.99999) && \ (Math.abs(array[i+1].lng) == 179.99999) ) $.each(sections, (i, section) -> polyline = L.polyline(section, {color:'#0099cc'}).addTo(leafletMap); ) return latLons -
Mike Atlas created this gist
Oct 24, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,44 @@ Array.prototype.splitAtEvery = (callback) -> sections = [] arrayClone = this.slice(0) $.each(arrayClone, (idx, item) => sectionsLength = 0 _.each(sections, (section) => sectionsLength += section.length; ) if callback(this, idx, item) == true sections.push(arrayClone.slice(0, idx+1-sectionsLength)) arrayClone = arrayClone.slice(idx+1-sectionsLength, arrayClone.length) return ) sections.push(arrayClone) return sections drawPolylines = (latLons, leafletMap) -> normalizeIndexes = [] $.each(latLons, (i, latLon) => last = latLons[i-1] if last? if Math.abs(latLon.lng - last.lng) > 180 normalizeIndexes.push(i) ) normalizeIndexesRef = normalizeIndexes.slice(0) $.each(normalizeIndexes, (i, normalizeIndex) => flipDirection = if latLons[normalizeIndexesRef[i]].lng < 0 then -1 else 1 latLons.splice(normalizeIndexesRef[i], 0, L.latLng(latLons[normalizeIndexesRef[i]].lat, flipDirection * -179.99999)) latLons.splice(normalizeIndexesRef[i]+1, 0, L.latLng(latLons[normalizeIndexesRef[i]].lat, flipDirection * 179.99999)) normalizeIndexesRef = _.map(normalizeIndexesRef, (idx) => idx+2) ) sections = latLons.splitAtEvery((array, i, val) -> return (Math.abs(val.lng) == 179.99999) && \ (Math.abs(array[i+1].lng) == 179.99999) ) $.each(sections, (i, section) -> polyline = L.polyline(section, {color:'#0099cc'}).addTo(leafletMap); ) return latLons