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
func azimuthBetween(origin: CLLocation, destination: CLLocation) -> Float { | |
var azimuth: Float = 0 | |
let originLatitude = GLKMathDegreesToRadians(Float(origin.coordinate.latitude)) | |
let originLongitude = GLKMathDegreesToRadians(Float(origin.coordinate.longitude)) | |
let destinationLatitude = GLKMathDegreesToRadians(Float(destination.coordinate.latitude)) | |
let destinationLongitude = GLKMathDegreesToRadians(Float(destination.coordinate.longitude)) | |
let dLon = destinationLongitude - originLongitude | |
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
func transformMatrix(originLocation: CLLocation, destinationLocation: CLLocation) -> simd_float4x4 { | |
let azimuth = azimuthBetween(origin: originLocation, destination: destinationLocation) | |
// Place POIs "z" meters away from camera | |
let position = vector_float4(0, 0, -10, 0) | |
let translationMatrix = matrix_identity_float4x4.translationMatrix(position) | |
// Rotate POI based on azimuth | |
let rotationMatrix = matrix_identity_float4x4.rotationAroundY(radians: azimuth) | |
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
internal extension matrix_float4x4 { | |
func rotationAroundY(radians: Float) -> matrix_float4x4 { | |
var matrix: matrix_float4x4 = self | |
matrix.columns.0.x = cos(radians) | |
matrix.columns.0.z = -sin(radians) | |
matrix.columns.2.x = sin(radians) | |
matrix.columns.2.z = cos(radians) | |
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
var locations = turf.featureCollection([ | |
turf.point([latitude, longitude]), | |
turf.point([latitude, longitude]) | |
]); | |
var user = turf.point([latitude, longitude]); |
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
var nearest = turf.nearestPoint(user, locations); | |
var bearing = turf.bearingToAzimuth(turf.bearing(user, nearest)); | |
var distance = turf.distance(user, nearest, { units: meters }); | |
if (distance < 50) { | |
// Unlock Emerald Star | |
} |
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
const map = new mapboxgl.Map({ | |
container: "map", | |
style: "mapbox://styles/mapbox/light-v9", | |
center: [-122.398, 37.788], | |
zoom: 12, | |
pitch: 60 | |
}); | |
map.on("style.load", () => { | |
// Get data for the arc map from SFMTA origin/destination routes |
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
let bearing = ruler.bearing(firstPoint, nextPoint); | |
let p1 = ruler.destination(nextPoint, errorRadius, bearing + 90); | |
let p2 = ruler.destination(firstPoint, acc.prevPoint.errorRadius, bearing + 90); | |
let p3 = ruler.destination(firstPoint, acc.prevPoint.errorRadius, bearing - 90); | |
let p4 = ruler.destination(nextPoint, errorRadius, bearing - 90); | |
const polygon = turf.polygon([[p1, p2, p3, p4, p1]]); |
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
const errorRadiusKm = ruler.distance([item.lon, item.lat], [item.lon + errorRadiusDeg, item.lat]); | |
const circle = turf.circle([item.lon, item.lat], errorRadiusKm, {steps: 32, units: 'kilometers'}); |
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
[ | |
"interpolate", | |
["linear"], | |
["get", "WindSpeed.Kph"], | |
55, | |
"hsl(47, 100%, 90%)", | |
120, | |
"hsl(340, 100%, 82%)", | |
220, | |
"#ff0040" |
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
[ | |
"interpolate", | |
["linear"], | |
["zoom"], | |
2, | |
[ | |
"/", | |
[ | |
"max", | |
[ |
OlderNewer