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
<?php | |
// **************************************** | |
// * Validate waypoint whether it's latlng or postcode | |
// **************************************** | |
function validateWaypoint($waypoint) { | |
if (strpos($waypoint, ",")) { | |
// ? Probably lat lng | |
$latLng = explode(",", $waypoint); | |
if (count($latLng) == 2) { | |
if ($latLng[0] >= -90 && $latLng[0] <= 90) { |
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
<?php | |
// Accepts: 12 34.567N, 1 2.345W | |
// Returns: [12.345, 12.345] | |
function ddmToDDConvert($original) { | |
$coords = []; | |
$original = explode(',', $original); | |
$dirDict = ['S' => -1,'N' => 1,'W' => -1,'E' => 1]; | |
if (count($original) == 2) { | |
$ddmLat = explode(' ', trim(ltrim($original[0]))); |
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
<script> | |
// **************************************** | |
// Check if a point is within a circle. | |
// toFindX, toFindY, circleCentreX, circleCentreY, radius | |
// **************************************** | |
function pointInCircle(x, y, cx, cy, radius) { | |
var distancesquared = (x - cx) * (x - cx) + (y - cy) * (y - cy); | |
return distancesquared <= radius * radius; | |
} | |
// **************************************** |
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
<script> | |
// **************************************** | |
// Checks if a postcode is valid | |
// **************************************** | |
function postcodeValid(postcode) { | |
var result; | |
$.get( "https://api.postcodes.io/postcodes/" + postcode + "/validate", function(data) { | |
result = data['result']; | |
}); | |
return result; |
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
<?php | |
// ? Sort smallest first | |
usort($isochronesArr, function ($item1, $item2) { return $item2['mins'] <=> $item1['mins']; }); | |
// ? Sort largest first | |
usort($isochronesArr, function ($item1, $item2) { return $item1['mins'] <=> $item2['mins']; }); | |
?> |
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
// **************************************** | |
// * Check colour | |
// **************************************** | |
function validateColour($colour) { | |
$COLOR_NAMES = ["AliceBlue","AntiqueWhite","Aqua","Aquamarine","Azure","Beige","Bisque","Black","BlanchedAlmond","Blue","BlueViolet","Brown","BurlyWood","CadetBlue","Chartreuse","Chocolate","Coral","CornflowerBlue","Cornsilk","Crimson","Cyan","DarkBlue","DarkCyan","DarkGoldenRod","DarkGray","DarkGrey","DarkGreen","DarkKhaki","DarkMagenta","DarkOliveGreen","DarkOrange","DarkOrchid","DarkRed","DarkSalmon","DarkSeaGreen","DarkSlateBlue","DarkSlateGray","DarkSlateGrey","DarkTurquoise","DarkViolet","DeepPink","DeepSkyBlue","DimGray","DimGrey","DodgerBlue","FireBrick","FloralWhite","ForestGreen","Fuchsia","Gainsboro","GhostWhite","Gold","GoldenRod","Gray","Grey","Green","GreenYellow","HoneyDew","HotPink","IndianRed","Indigo","Ivory","Khaki","Lavender","LavenderBlush","LawnGreen","LemonChiffon","LightBlue","LightCoral","LightCyan","LightGoldenRodYellow","LightGray","LightGr |