diff --git a/CHANGELOG.md b/CHANGELOG.md index 6eaec243..83e31be3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -83,7 +83,7 @@ All major and minor version changes will be documented in this file. Details of - 'DNS over HTTPS' operation added [@h345983745] | [#489] ### [8.23.1] - 2019-01-18 -- 'Convert co-ordinate format' operation added [@j433866] | [#476] +- 'Convert coordinate format' operation added [@j433866] | [#476] ### [8.23.0] - 2019-01-18 - 'YARA Rules' operation added [@artemisbot] | [#468] diff --git a/src/core/config/Categories.json b/src/core/config/Categories.json index 94f7fd30..5490d0fb 100755 --- a/src/core/config/Categories.json +++ b/src/core/config/Categories.json @@ -229,7 +229,7 @@ "Convert mass", "Convert speed", "Convert data units", - "Convert co-ordinate format", + "Convert coordinate format", "Show on map", "Parse UNIX file permissions", "Swap endianness", diff --git a/src/core/lib/ConvertCoordinates.mjs b/src/core/lib/ConvertCoordinates.mjs index 4fca357d..68cc84de 100644 --- a/src/core/lib/ConvertCoordinates.mjs +++ b/src/core/lib/ConvertCoordinates.mjs @@ -1,5 +1,5 @@ /** - * Co-ordinate conversion resources. + * Coordinate conversion resources. * * @author j433866 [j433866@gmail.com] * @copyright Crown Copyright 2019 @@ -24,7 +24,7 @@ const LatLonEllipsoidal = geodesy.LatLonEllipsoidal, Utm = geodesy.Utm; /** - * Co-ordinate formats + * Coordinate formats */ export const FORMATS = [ "Degrees Minutes Seconds", @@ -56,7 +56,7 @@ const NO_CHANGE = [ * @param {string} outDelim - The delimiter to separate the output with * @param {string} includeDir - Whether or not to include the compass direction in the output * @param {number} precision - Precision of the result - * @returns {string} A formatted string of the converted co-ordinates + * @returns {string} A formatted string of the converted coordinates */ export function convertCoordinates (input, inFormat, inDelim, outFormat, outDelim, includeDir, precision) { let isPair = false, @@ -112,7 +112,7 @@ export function convertCoordinates (input, inFormat, inDelim, outFormat, outDeli } else { split = input.split(inDelim); } - // Replace any co-ordinate symbols with spaces so we can split on them later + // Replace any coordinate symbols with spaces so we can split on them later for (let i = 0; i < split.length; i++) { split[i] = split[i].replace(/[°˝´'"]/g, " "); } @@ -158,16 +158,16 @@ export function convertCoordinates (input, inFormat, inDelim, outFormat, outDeli lon = convDMSToDD(splitLong[0], splitLong[1], splitLong[2], 10); latlon = new LatLonEllipsoidal(lat.degrees, lon.degrees); } else { - throw new OperationError("Invalid co-ordinate format for Degrees Minutes Seconds"); + throw new OperationError("Invalid coordinate format for Degrees Minutes Seconds"); } } else { - // Not a pair, so only try to convert one set of co-ordinates + // Not a pair, so only try to convert one set of coordinates splitLat = splitInput(split[0]); if (splitLat.length >= 3) { lat = convDMSToDD(splitLat[0], splitLat[1], splitLat[2]); latlon = new LatLonEllipsoidal(lat.degrees, lat.degrees); } else { - throw new OperationError("Invalid co-ordinate format for Degrees Minutes Seconds"); + throw new OperationError("Invalid coordinate format for Degrees Minutes Seconds"); } } break; @@ -176,17 +176,17 @@ export function convertCoordinates (input, inFormat, inDelim, outFormat, outDeli splitLat = splitInput(split[0]); splitLong = splitInput(split[1]); if (splitLat.length !== 2 || splitLong.length !== 2) { - throw new OperationError("Invalid co-ordinate format for Degrees Decimal Minutes."); + throw new OperationError("Invalid coordinate format for Degrees Decimal Minutes."); } // Convert to decimal degrees, and then convert to a geodesy object lat = convDDMToDD(splitLat[0], splitLat[1], 10); lon = convDDMToDD(splitLong[0], splitLong[1], 10); latlon = new LatLonEllipsoidal(lat.degrees, lon.degrees); } else { - // Not a pair, so only try to convert one set of co-ordinates + // Not a pair, so only try to convert one set of coordinates splitLat = splitInput(input); if (splitLat.length !== 2) { - throw new OperationError("Invalid co-ordinate format for Degrees Decimal Minutes."); + throw new OperationError("Invalid coordinate format for Degrees Decimal Minutes."); } lat = convDDMToDD(splitLat[0], splitLat[1], 10); latlon = new LatLonEllipsoidal(lat.degrees, lat.degrees); @@ -197,14 +197,14 @@ export function convertCoordinates (input, inFormat, inDelim, outFormat, outDeli splitLat = splitInput(split[0]); splitLong = splitInput(split[1]); if (splitLat.length !== 1 || splitLong.length !== 1) { - throw new OperationError("Invalid co-ordinate format for Decimal Degrees."); + throw new OperationError("Invalid coordinate format for Decimal Degrees."); } latlon = new LatLonEllipsoidal(splitLat[0], splitLong[0]); } else { - // Not a pair, so only try to convert one set of co-ordinates + // Not a pair, so only try to convert one set of coordinates splitLat = splitInput(split[0]); if (splitLat.length !== 1) { - throw new OperationError("Invalid co-ordinate format for Decimal Degrees."); + throw new OperationError("Invalid coordinate format for Decimal Degrees."); } latlon = new LatLonEllipsoidal(splitLat[0], splitLat[0]); } @@ -275,7 +275,7 @@ export function convertCoordinates (input, inFormat, inDelim, outFormat, outDeli case "Ordnance Survey National Grid": osng = OsGridRef.latLonToOsGrid(latlon); if (osng.toString() === "") { - throw new OperationError("Could not convert co-ordinates to OS National Grid. Are the co-ordinates in range?"); + throw new OperationError("Could not convert coordinates to OS National Grid. Are the coordinates in range?"); } // OSNG wants a precision that's an even number between 2 and 10 if (precision % 2 !== 0) { @@ -293,7 +293,7 @@ export function convertCoordinates (input, inFormat, inDelim, outFormat, outDeli } if (convLat === undefined) { - throw new OperationError("Error converting co-ordinates."); + throw new OperationError("Error converting coordinates."); } if (outFormat.includes("Degrees")) { @@ -357,9 +357,9 @@ function splitInput (input) { /** * Convert Degrees Minutes Seconds to Decimal Degrees * - * @param {number} degrees - The degrees of the input co-ordinates - * @param {number} minutes - The minutes of the input co-ordinates - * @param {number} seconds - The seconds of the input co-ordinates + * @param {number} degrees - The degrees of the input coordinates + * @param {number} minutes - The minutes of the input coordinates + * @param {number} seconds - The seconds of the input coordinates * @param {number} precision - The precision the result should be rounded to * @returns {{string: string, degrees: number}} An object containing the raw converted value (obj.degrees), and a formatted string version (obj.string) */ @@ -467,7 +467,7 @@ function convDDToDDM (decDegrees, precision) { /** * Finds and returns the compass directions in an input string * - * @param {string} input - The input co-ordinates containing the direction + * @param {string} input - The input coordinates containing the direction * @param {string} delim - The delimiter separating latitide and longitude * @returns {string[]} String array containing the latitude and longitude directions */ @@ -526,7 +526,7 @@ export function findDirs(input, delim) { } /** - * Detects the co-ordinate format of the input data + * Detects the coordinate format of the input data * * @param {string} input - The input data whose format we need to detect * @param {string} delim - The delimiter separating the data in input @@ -620,7 +620,7 @@ export function findDelim (input) { if (input.includes(delim)) { const splitInput = input.split(delim); if (splitInput.length <= 3 && splitInput.length > 0) { - // Don't want to try and convert more than 2 co-ordinates + // Don't want to try and convert more than 2 coordinates return delim; } } diff --git a/src/core/operations/ConvertCoordinateFormat.mjs b/src/core/operations/ConvertCoordinateFormat.mjs index f1e1b20f..884de912 100644 --- a/src/core/operations/ConvertCoordinateFormat.mjs +++ b/src/core/operations/ConvertCoordinateFormat.mjs @@ -8,7 +8,7 @@ import Operation from "../Operation.mjs"; import {FORMATS, convertCoordinates} from "../lib/ConvertCoordinates.mjs"; /** - * Convert co-ordinate format operation + * Convert coordinate format operation */ class ConvertCoordinateFormat extends Operation { @@ -18,9 +18,9 @@ class ConvertCoordinateFormat extends Operation { constructor() { super(); - this.name = "Convert co-ordinate format"; + this.name = "Convert coordinate format"; this.module = "Hashing"; - this.description = "Converts geographical coordinates between different formats.

Supported formats:
The operation can try to detect the input co-ordinate format and delimiter automatically, but this may not always work correctly."; + this.description = "Converts geographical coordinates between different formats.

Supported formats:
The operation can try to detect the input coordinate format and delimiter automatically, but this may not always work correctly."; this.infoURL = "https://wikipedia.org/wiki/Geographic_coordinate_conversion"; this.inputType = "string"; this.outputType = "string"; diff --git a/src/core/operations/HaversineDistance.mjs b/src/core/operations/HaversineDistance.mjs index 1d0d25e0..24f3153a 100644 --- a/src/core/operations/HaversineDistance.mjs +++ b/src/core/operations/HaversineDistance.mjs @@ -20,7 +20,7 @@ class HaversineDistance extends Operation { this.name = "Haversine distance"; this.module = "Default"; - this.description = "Returns the distance between two pairs of GPS latitude and longitude co-ordinates in metres.

e.g. 51.487263,-0.124323, 38.9517,-77.1467"; + this.description = "Returns the distance between two pairs of GPS latitude and longitude coordinates in metres.

e.g. 51.487263,-0.124323, 38.9517,-77.1467"; this.infoURL = "https://wikipedia.org/wiki/Haversine_formula"; this.inputType = "string"; this.outputType = "number"; diff --git a/src/core/operations/ShowOnMap.mjs b/src/core/operations/ShowOnMap.mjs index 9c81a27b..08ed26c3 100644 --- a/src/core/operations/ShowOnMap.mjs +++ b/src/core/operations/ShowOnMap.mjs @@ -21,7 +21,7 @@ class ShowOnMap extends Operation { this.name = "Show on map"; this.module = "Hashing"; - this.description = "Displays co-ordinates on a slippy map.

Co-ordinates will be converted to decimal degrees before being shown on the map.

Supported formats:
This operation will not work offline."; + this.description = "Displays coordinates on a slippy map.

Coordinates will be converted to decimal degrees before being shown on the map.

Supported formats:
This operation will not work offline."; this.infoURL = "https://foundation.wikimedia.org/wiki/Maps_Terms_of_Use"; this.inputType = "string"; this.outputType = "string"; diff --git a/tests/operations/tests/ConvertCoordinateFormat.mjs b/tests/operations/tests/ConvertCoordinateFormat.mjs index afe35d87..a7f9d419 100644 --- a/tests/operations/tests/ConvertCoordinateFormat.mjs +++ b/tests/operations/tests/ConvertCoordinateFormat.mjs @@ -1,5 +1,5 @@ /** - * Convert co-ordinate format tests + * Convert coordinate format tests * * @author j433866 * @@ -8,7 +8,7 @@ */ /** - * TEST CO-ORDINATES + * TEST COORDINATES * DD: 51.504°,-0.126°, * DDM: 51° 30.24',-0° 7.56', * DMS: 51° 30' 14.4",-0° 7' 33.6", @@ -22,188 +22,188 @@ import TestRegister from "../../lib/TestRegister.mjs"; TestRegister.addTests([ { - name: "Co-ordinates: From Decimal Degrees to Degrees Minutes Seconds", + name: "Coordinates: From Decimal Degrees to Degrees Minutes Seconds", input: "51.504°,-0.126°,", expectedOutput: "51° 30' 14.4\",-0° 7' 33.6\",", recipeConfig: [ { - op: "Convert co-ordinate format", + op: "Convert coordinate format", args: ["Decimal Degrees", "Comma", "Degrees Minutes Seconds", "Comma", "None", 1] }, ], }, { - name: "Co-ordinates: From Degrees Minutes Seconds to Decimal Degrees", + name: "Coordinates: From Degrees Minutes Seconds to Decimal Degrees", input: "51° 30' 14.4\",-0° 7' 33.6\",", expectedOutput: "51.504°,-0.126°,", recipeConfig: [ { - op: "Convert co-ordinate format", + op: "Convert coordinate format", args: ["Degrees Minutes Seconds", "Comma", "Decimal Degrees", "Comma", "None", 3] }, ], }, { - name: "Co-ordinates: From Decimal Degrees to Degrees Decimal Minutes", + name: "Coordinates: From Decimal Degrees to Degrees Decimal Minutes", input: "51.504°,-0.126°,", expectedOutput: "51° 30.24',-0° 7.56',", recipeConfig: [ { - op: "Convert co-ordinate format", + op: "Convert coordinate format", args: ["Decimal Degrees", "Comma", "Degrees Decimal Minutes", "Comma", "None", 2] } ] }, { - name: "Co-ordinates: From Degrees Decimal Minutes to Decimal Degrees", + name: "Coordinates: From Degrees Decimal Minutes to Decimal Degrees", input: "51° 30.24',-0° 7.56',", expectedOutput: "51.504°,-0.126°,", recipeConfig: [ { - op: "Convert co-ordinate format", + op: "Convert coordinate format", args: ["Degrees Decimal Minutes", "Comma", "Decimal Degrees", "Comma", "None", 3] } ] }, { - name: "Co-ordinates: From Decimal Degrees to Decimal Degrees", + name: "Coordinates: From Decimal Degrees to Decimal Degrees", input: "51.504°,-0.126°,", expectedOutput: "51.504°,-0.126°,", recipeConfig: [ { - op: "Convert co-ordinate format", + op: "Convert coordinate format", args: ["Decimal Degrees", "Comma", "Decimal Degrees", "Comma", "None", 3] } ] }, { - name: "Co-ordinates: From Decimal Degrees to Geohash", + name: "Coordinates: From Decimal Degrees to Geohash", input: "51.504°,-0.126°,", expectedOutput: "gcpvj0h0x,", recipeConfig: [ { - op: "Convert co-ordinate format", + op: "Convert coordinate format", args: ["Decimal Degrees", "Comma", "Geohash", "Comma", "None", 9] }, ], }, { - name: "Co-ordinates: From Geohash to Decimal Degrees", + name: "Coordinates: From Geohash to Decimal Degrees", input: "gcpvj0h0x,", expectedOutput: "51.504°,-0.126°,", recipeConfig: [ { - op: "Convert co-ordinate format", + op: "Convert coordinate format", args: ["Geohash", "Comma", "Decimal Degrees", "Comma", "None", 3] }, ], }, { - name: "Co-ordinates: From Decimal Degrees to MGRS", + name: "Coordinates: From Decimal Degrees to MGRS", input: "51.504°,-0.126°,", expectedOutput: "30U XC 99455 09790,", recipeConfig: [ { - op: "Convert co-ordinate format", + op: "Convert coordinate format", args: ["Decimal Degrees", "Comma", "Military Grid Reference System", "Comma", "None", 10] }, ], }, { - name: "Co-ordinates: From MGRS to Decimal Degrees", + name: "Coordinates: From MGRS to Decimal Degrees", input: "30U XC 99455 09790,", expectedOutput: "51.504°,-0.126°,", recipeConfig: [ { - op: "Convert co-ordinate format", + op: "Convert coordinate format", args: ["Military Grid Reference System", "Comma", "Decimal Degrees", "Comma", "None", 3] } ] }, { - name: "Co-ordinates: From Decimal Degrees to OSNG", + name: "Coordinates: From Decimal Degrees to OSNG", input: "51.504°,-0.126°,", expectedOutput: "TQ 30163 80005,", recipeConfig: [ { - op: "Convert co-ordinate format", + op: "Convert coordinate format", args: ["Decimal Degrees", "Comma", "Ordnance Survey National Grid", "Comma", "None", 10] }, ], }, { - name: "Co-ordinates: From OSNG to Decimal Degrees", + name: "Coordinates: From OSNG to Decimal Degrees", input: "TQ 30163 80005,", expectedOutput: "51.504°,-0.126°,", recipeConfig: [ { - op: "Convert co-ordinate format", + op: "Convert coordinate format", args: ["Ordnance Survey National Grid", "Comma", "Decimal Degrees", "Comma", "None", 3] }, ], }, { - name: "Co-ordinates: From Decimal Degrees to UTM", + name: "Coordinates: From Decimal Degrees to UTM", input: "51.504°,-0.126°,", expectedOutput: "30 N 699456 5709791,", recipeConfig: [ { - op: "Convert co-ordinate format", + op: "Convert coordinate format", args: ["Decimal Degrees", "Comma", "Universal Transverse Mercator", "Comma", "None", 0] }, ], }, { - name: "Co-ordinates: From UTM to Decimal Degrees", + name: "Coordinates: From UTM to Decimal Degrees", input: "30 N 699456 5709791,", expectedOutput: "51.504°,-0.126°,", recipeConfig: [ { - op: "Convert co-ordinate format", + op: "Convert coordinate format", args: ["Universal Transverse Mercator", "Comma", "Decimal Degrees", "Comma", "None", 3] }, ], }, { - name: "Co-ordinates: Directions in input, not output", + name: "Coordinates: Directions in input, not output", input: "N51.504°,W0.126°,", expectedOutput: "51.504°,-0.126°,", recipeConfig: [ { - op: "Convert co-ordinate format", + op: "Convert coordinate format", args: ["Decimal Degrees", "Comma", "Decimal Degrees", "Comma", "None", 3] }, ], }, { - name: "Co-ordinates: Directions in input and output", + name: "Coordinates: Directions in input and output", input: "N51.504°,W0.126°,", expectedOutput: "N 51.504°,W 0.126°,", recipeConfig: [ { - op: "Convert co-ordinate format", + op: "Convert coordinate format", args: ["Decimal Degrees", "Comma", "Decimal Degrees", "Comma", "Before", 3] }, ], }, { - name: "Co-ordinates: Directions not in input, in output", + name: "Coordinates: Directions not in input, in output", input: "51.504°,-0.126°,", expectedOutput: "N 51.504°,W 0.126°,", recipeConfig: [ { - op: "Convert co-ordinate format", + op: "Convert coordinate format", args: ["Decimal Degrees", "Comma", "Decimal Degrees", "Comma", "Before", 3] }, ], }, { - name: "Co-ordinates: Directions not in input, in converted output", + name: "Coordinates: Directions not in input, in converted output", input: "51.504°,-0.126°,", expectedOutput: "N 51° 30' 14.4\",W 0° 7' 33.6\",", recipeConfig: [ { - op: "Convert co-ordinate format", + op: "Convert coordinate format", args: ["Decimal Degrees", "Comma", "Degrees Minutes Seconds", "Comma", "Before", 3] }, ],