-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
911 additions
and
107 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const d3 = window.d3 || require('d3'); | ||
|
||
export const EARTH_CIRCUMFERENCE_KM = 40075.16; | ||
export const LUMINANCE_RED_WEIGHT = 0.2126; | ||
export const LUMINANCE_GREEN_WEIGHT = 0.7152; | ||
export const LUMINANCE_BLUE_WEIGHT = 0.0722; | ||
export const MILES_PER_KM = 1.60934; | ||
export const DEFAULT_LONGITUDE = -122.405293; | ||
export const DEFAULT_LATITUDE = 37.772123; | ||
export const DEFAULT_ZOOM = 11; | ||
|
||
export function kmToPixels(kilometers, latitude, zoomLevel) { | ||
// Algorithm from: http://wiki.openstreetmap.org/wiki/Zoom_levels | ||
const latitudeRad = latitude * (Math.PI / 180); | ||
// Seems like the zoomLevel is off by one | ||
const kmPerPixel = EARTH_CIRCUMFERENCE_KM * Math.cos(latitudeRad) / Math.pow(2, zoomLevel + 9); | ||
return d3.round(kilometers / kmPerPixel, 2); | ||
} | ||
|
||
export function isNumeric(num) { | ||
return !isNaN(parseFloat(num)) && isFinite(num); | ||
} | ||
|
||
export function rgbLuminance(r, g, b) { | ||
// Formula: https://en.wikipedia.org/wiki/Relative_luminance | ||
return LUMINANCE_RED_WEIGHT*r + LUMINANCE_GREEN_WEIGHT*g + LUMINANCE_BLUE_WEIGHT*b; | ||
} |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
div.widget .slice_container { | ||
cursor: grab; | ||
cursor: -moz-grab; | ||
cursor: -webkit-grab; | ||
overflow: hidden; | ||
} | ||
|
||
div.widget .slice_container:active { | ||
cursor: grabbing; | ||
cursor: -moz-grabbing; | ||
cursor: -webkit-grabbing; | ||
} | ||
|
||
.slice_container div { | ||
padding-top: 0px; | ||
} |
Oops, something went wrong.