@accelint/geo 0.2.4 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cartesian.js +0 -1
- package/dist/cartesian.js.map +1 -1
- package/dist/coordinates/coordinate.js +2 -3
- package/dist/coordinates/coordinate.js.map +1 -1
- package/dist/coordinates/latlon/decimal-degrees/parser.js +4 -5
- package/dist/coordinates/latlon/decimal-degrees/parser.js.map +1 -1
- package/dist/coordinates/latlon/decimal-degrees/system.js +1 -2
- package/dist/coordinates/latlon/decimal-degrees/system.js.map +1 -1
- package/dist/coordinates/latlon/degrees-decimal-minutes/parser.js +4 -5
- package/dist/coordinates/latlon/degrees-decimal-minutes/parser.js.map +1 -1
- package/dist/coordinates/latlon/degrees-decimal-minutes/system.js +1 -2
- package/dist/coordinates/latlon/degrees-decimal-minutes/system.js.map +1 -1
- package/dist/coordinates/latlon/degrees-minutes-seconds/parser.js +4 -5
- package/dist/coordinates/latlon/degrees-minutes-seconds/parser.js.map +1 -1
- package/dist/coordinates/latlon/degrees-minutes-seconds/system.js +1 -2
- package/dist/coordinates/latlon/degrees-minutes-seconds/system.js.map +1 -1
- package/dist/coordinates/latlon/internal/create-cache.js +2 -3
- package/dist/coordinates/latlon/internal/create-cache.js.map +1 -1
- package/dist/coordinates/latlon/internal/exhaustive-errors.js +4 -5
- package/dist/coordinates/latlon/internal/exhaustive-errors.js.map +1 -1
- package/dist/coordinates/latlon/internal/in-range.js +1 -2
- package/dist/coordinates/latlon/internal/in-range.js.map +1 -1
- package/dist/coordinates/latlon/internal/index.js +9 -10
- package/dist/coordinates/latlon/internal/index.js.map +1 -1
- package/dist/coordinates/latlon/internal/lexer.js +8 -9
- package/dist/coordinates/latlon/internal/lexer.js.map +1 -1
- package/dist/coordinates/latlon/internal/parse-format.js +3 -4
- package/dist/coordinates/latlon/internal/parse-format.js.map +1 -1
- package/dist/coordinates/latlon/internal/parse.js +0 -1
- package/dist/coordinates/latlon/internal/parse.js.map +1 -1
- package/dist/coordinates/latlon/internal/pipes/check-ambiguous.js +0 -1
- package/dist/coordinates/latlon/internal/pipes/check-ambiguous.js.map +1 -1
- package/dist/coordinates/latlon/internal/pipes/check-numbers.js +0 -1
- package/dist/coordinates/latlon/internal/pipes/check-numbers.js.map +1 -1
- package/dist/coordinates/latlon/internal/pipes/fix-bearings.js +4 -5
- package/dist/coordinates/latlon/internal/pipes/fix-bearings.js.map +1 -1
- package/dist/coordinates/latlon/internal/pipes/fix-dividers.js +2 -3
- package/dist/coordinates/latlon/internal/pipes/fix-dividers.js.map +1 -1
- package/dist/coordinates/latlon/internal/pipes/genome.js +1 -2
- package/dist/coordinates/latlon/internal/pipes/genome.js.map +1 -1
- package/dist/coordinates/latlon/internal/pipes/index.js +4 -5
- package/dist/coordinates/latlon/internal/pipes/index.js.map +1 -1
- package/dist/coordinates/latlon/internal/pipes/simpler.js +1 -2
- package/dist/coordinates/latlon/internal/pipes/simpler.js.map +1 -1
- package/dist/coordinates/latlon/internal/violation.js +1 -2
- package/dist/coordinates/latlon/internal/violation.js.map +1 -1
- package/dist/coordinates/mgrs/parser.js +2 -3
- package/dist/coordinates/mgrs/parser.js.map +1 -1
- package/dist/coordinates/mgrs/system.js +1 -2
- package/dist/coordinates/mgrs/system.js.map +1 -1
- package/dist/coordinates/utm/parser.js +2 -3
- package/dist/coordinates/utm/parser.js.map +1 -1
- package/dist/coordinates/utm/system.js +1 -2
- package/dist/coordinates/utm/system.js.map +1 -1
- package/dist/metafile-esm.json +1 -0
- package/dist/patterning.js +5 -6
- package/dist/patterning.js.map +1 -1
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/coordinates/latlon/internal/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/coordinates/latlon/internal/index.ts"],"names":[],"mappings":";;AA8BO,MAAM,QAAA,GAAW;AAAA,EACtB,GAAA,EAAK,CAAC,GAAA,EAAK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AAA;AAAA,MACA;AAAA;AAAA,KACF;AAAA,IACA,UAAA,CAAW,QAAA,CAAS,eAAA,CAAgB,OAAO;AAAA,GAC7C;AAAA,EACA,QAAQ,UAAA,CAAW,KAAA;AAAA,IACjB,UAAA,CAAW,OAAA;AAAA,MACT,UAAA;AAAA;AAAA,MACA,GAAA;AAAA,MACA;AAAA;AAAA,KACF;AAAA,IACA,UAAA,CAAW,QAAA,CAAS,eAAA,CAAgB,OAAO;AAAA,GAC7C;AAAA,EACA,QAAQ,UAAA,CAAW,KAAA;AAAA,IACjB,UAAA,CAAW,OAAA;AAAA,MACT,SAAA;AAAA;AAAA,MACA,GAAA;AAAA,MACA;AAAA;AAAA,KACF;AAAA,IACA,UAAA,CAAW,QAAA,CAAS,eAAA,CAAgB,OAAO;AAAA,GAC7C;AAAA,EACA,KAAK,UAAA,CAAW,KAAA;AAAA,IACd,UAAA,CAAW,QAAA;AAAA,MACT,UAAA,CAAW,OAAA;AAAA,QACT;AAAA;AAAA,OACF;AAAA,MACA,UAAA,CAAW,QAAA,CAAS,eAAA,CAAgB,OAAO;AAAA;AAC7C,GACF;AAAA,EACA,MAAA,EAAQ,gBAAA,CAAiB,eAAA,CAAgB,OAAO,CAAA;AAAA,EAChD,MAAA,EAAQ,gBAAA,CAAiB,eAAA,CAAgB,OAAO;AAClD","file":"index.js","sourcesContent":["// __private-exports\n/*\n * Copyright 2024 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport * as Patterning from '@/patterning';\n\nexport type Axes = 'LAT' | 'LON';\nexport type Compass = 'N' | 'S' | 'E' | 'W';\nexport type Errors = string[];\nexport type Format = (typeof FORMATS)[number];\n\n/**\n * Bearings are the consistent/explicit identifiers of directionality of a\n * coordinate component; this library has opted for these over implicit\n * indication by number sign not because there is an inherent superiority\n * but because something had to be chosen.\n *\n * NOTE: these arrays are position-important; negative values are [1] and\n * positive values are [0] so that they can be consistently indexed using\n * an `isNegative` boolean to reference the negative bearing of each axis\n */\nexport const BEARINGS = {\n LAT: ['N', 'S'],\n LON: ['E', 'W'],\n LATLON: [\n ['N', 'S'],\n ['E', 'W'],\n ],\n LONLAT: [\n ['E', 'W'],\n ['N', 'S'],\n ],\n} as const;\n\nexport const FORMATS = ['LATLON', 'LONLAT'] as const;\nexport const FORMATS_DEFAULT = FORMATS[0];\n\nexport const LIMITS = { LATLON: [90, 180], LONLAT: [180, 90] } as const;\n\nexport const SYMBOLS = {\n DEGREES: '°',\n MINUTES: \"'\",\n SECONDS: '\"',\n DIVIDER: '/',\n};\n\nexport const SYMBOL_PATTERNS = {\n LAT: new RegExp(`[${BEARINGS.LAT.join('')}]`),\n LON: new RegExp(`[${BEARINGS.LON.join('')}]`),\n NSEW: new RegExp(`[${[...BEARINGS.LAT, ...BEARINGS.LON].join('')}]`),\n NEGATIVE_BEARINGS: /[SW]/i,\n NEGATIVE_SIGN: /-/,\n\n DEGREES: new RegExp(SYMBOLS.DEGREES),\n MINUTES: new RegExp(SYMBOLS.MINUTES),\n SECONDS: new RegExp(SYMBOLS.SECONDS),\n\n DIVIDER: new RegExp(SYMBOLS.DIVIDER),\n\n DMS: new RegExp(\n `[${[SYMBOLS.DEGREES, SYMBOLS.MINUTES, SYMBOLS.SECONDS].join('')}]`,\n ),\n\n // divider: {\n // first: /(?<NAMED_SEPARATOR>:?)/,\n // follow: new RegExp(`\\\\s?\\\\k<${'NAMED_SEPARATOR'}>\\\\s?`),\n // },\n} as const;\n\nconst decimalSecAndMin = (symbol: RegExp) =>\n Patterning.optional(\n // Negative lookbehind\n // to ensure that the match is not preceded by a digit,\n // avoiding partial matches within larger numbers.\n /(?<!\\d)/,\n\n // 0-59 including 9 decimal places and leading zeros or no number before\n // acceptable values: 0, 0.123456789, .987654321, 001, 59.999999999\n /([-+]?0*(?:[0-5]?\\d|\\.\\d{1,9})(?:\\.\\d{1,9})?)/,\n\n Patterning.optional(symbol),\n\n // Negative lookahead\n // to ensure that the match is not followed by a digit,\n // avoiding partial matches within larger numbers.\n /(?!\\d)/,\n );\n\nexport const PARTIAL_PATTERNS = {\n ' ': /\\s*/,\n '/': Patterning.capture(SYMBOL_PATTERNS.DIVIDER),\n NS: Patterning.optional(Patterning.capture(SYMBOL_PATTERNS.LAT)),\n EW: Patterning.optional(Patterning.capture(SYMBOL_PATTERNS.LON)),\n\n degLatDec: Patterning.merge(\n Patterning.capture(\n /0*(?:90(?:\\.0{1,9})?)/, // 90[.0]\n /|/,\n /(?:0?[0-8]?\\d(?:\\.\\d{1,9})?)/, // [0]0[.0]-89[.9]\n ),\n Patterning.optional(SYMBOL_PATTERNS.DEGREES),\n ),\n degLonDec: Patterning.merge(\n Patterning.capture(\n /(?:180(?:\\.0{1,9})?)/, // 180[.0]\n /|/,\n /(?:0*(?:\\d{1,2}|1[0-7]\\d)(?:\\.\\d{1,9})?)/, // [00]0[.0]-179[.9]\n ),\n Patterning.optional(SYMBOL_PATTERNS.DEGREES),\n ),\n degLat: Patterning.merge(\n Patterning.capture(\n /(?:0?90)/, // 90\n /|/,\n /(?:0?[0-8]?\\d)/, // [0]0-89\n ),\n Patterning.optional(SYMBOL_PATTERNS.DEGREES),\n ),\n degLon: Patterning.merge(\n Patterning.capture(\n /(?:180)/, // 180\n /|/,\n /(?:0*(?:\\d{1,2}|1[0-7]\\d))/, // [00]0-179\n ),\n Patterning.optional(SYMBOL_PATTERNS.DEGREES),\n ),\n min: Patterning.merge(\n Patterning.optional(\n Patterning.capture(\n /(?:0?[0-5]?\\d)?/, // [0]0-59\n ),\n Patterning.optional(SYMBOL_PATTERNS.MINUTES),\n ),\n ),\n minDec: decimalSecAndMin(SYMBOL_PATTERNS.MINUTES),\n secDec: decimalSecAndMin(SYMBOL_PATTERNS.SECONDS),\n} as const;\n"]}
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import * as Patterning from '
|
|
2
|
-
import { SYMBOL_PATTERNS, SYMBOLS } from '
|
|
1
|
+
import * as Patterning from './../../../patterning.js';
|
|
2
|
+
import { SYMBOL_PATTERNS, SYMBOLS } from '.';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var POSITIONAL = new RegExp(
|
|
4
|
+
const DIVIDERS = /[,/]/g;
|
|
5
|
+
const FLOATS = /^(-?)([\d\.]+)([^.\d]?)$/;
|
|
6
|
+
const POSITIONAL = new RegExp(
|
|
8
7
|
Patterning.merge(/\s*/, Patterning.capture(SYMBOL_PATTERNS.DMS), /\s*/),
|
|
9
8
|
"g"
|
|
10
9
|
);
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
const POSITIVE = /\+/g;
|
|
11
|
+
const SIGNS = /([-+])\s*/g;
|
|
12
|
+
const TOKENS = new RegExp(
|
|
14
13
|
Patterning.merge(
|
|
15
14
|
DIVIDERS,
|
|
16
15
|
/|/,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/coordinates/latlon/internal/lexer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/coordinates/latlon/internal/lexer.ts"],"names":[],"mappings":";;;AA0BA,MAAM,QAAA,GAAW,OAAA;AACjB,MAAM,MAAA,GAAS,0BAAA;AAEf,MAAM,aAAa,IAAI,MAAA;AAAA,EACrB,UAAA,CAAW,MAAM,KAAA,EAAO,UAAA,CAAW,QAAQ,eAAA,CAAgB,GAAG,GAAG,KAAK,CAAA;AAAA,EACtE;AACF,CAAA;AACA,MAAM,QAAA,GAAW,KAAA;AACjB,MAAM,KAAA,GAAQ,YAAA;AASd,MAAM,SAAS,IAAI,MAAA;AAAA,EACjB,UAAA,CAAW,KAAA;AAAA,IACT,QAAA;AAAA,IACA,GAAA;AAAA,IACA,eAAA,CAAgB,IAAA;AAAA,IAChB,GAAA;AAAA,IACA,UAAA,CAAW,KAAA;AAAA,MACT,OAAA;AAAA,MACA,UAAA,CAAW,KAAA;AAAA;AAAA,QAET,oBAAA;AAAA;AAAA,QAEA;AAAA,OACF;AAAA,MACA,UAAA,CAAW,QAAA,CAAS,eAAA,CAAgB,GAAG;AAAA;AACzC,GACF;AAAA,EACA;AACF,CAAA;AAGA,SAAS,sBAAsB,CAAA,EAAW;AACxC,EAAA,MAAM,CAAC,IAAA,EAAM,GAAA,EAAK,GAAG,CAAA,GAAA,CAAK,MAAA,CAAO,IAAA,CAAK,CAAC,CAAA,IAAK,EAAC,EAAG,KAAA,CAAM,CAAC,CAAA;AAEvD,EAAA,IAAI,GAAA,EAAK;AACP,IAAA,OAAO,CAAA,EAAG,IAAI,CAAA,EAAG,MAAA,CAAO,WAAW,GAAG,CAAC,GAAG,GAAG,CAAA,CAAA;AAAA,EAC/C;AAEA,EAAA,OAAO,CAAA;AACT;AAkBO,SAAS,MAAM,KAAA,EAAe;AACnC,EAAA,MAAM,MAAA,GACJ,KAAA,CACG,IAAA,EAAK,CACL,WAAA,EAAY,CACZ,OAAA,CAAQ,QAAA,EAAU,EAAE,CAAA,CACpB,OAAA,CAAQ,UAAA,EAAY,KAAK,CAAA,CACzB,OAAA,CAAQ,KAAA,EAAO,IAAI,CAAA,CACnB,OAAA,CAAQ,QAAA,EAAU,OAAA,CAAQ,OAAO,CAAA,CACjC,KAAA,CAAM,MAAM,CAAA,EACX,GAAA,CAAI,qBAAqB,CAAA,EACzB,KAAA,MAAW,EAAC;AAElB,EAAA,OAAO,MAAA;AACT","file":"lexer.js","sourcesContent":["// __private-exports\n/*\n * Copyright 2024 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport * as Patterning from '@/patterning';\n\nimport { SYMBOLS, SYMBOL_PATTERNS } from '.';\n\nexport type Tokens = ReturnType<typeof lexer>;\n\n/**\n * Separating latitude from longitude portions of a coordinate. At this level\n * of pattern matching this list can not include the \"space\" character since\n * that is valid between components of either side of a divider; higher level\n * parsers will be able to make up for this shortcoming and be more intelligent\n * about deducing where a divider could be added or would not be valid.\n */\nconst DIVIDERS = /[,/]/g;\nconst FLOATS = /^(-?)([\\d\\.]+)([^.\\d]?)$/;\n/** Positional indicators for: degrees, minutes, and seconds */\nconst POSITIONAL = new RegExp(\n Patterning.merge(/\\s*/, Patterning.capture(SYMBOL_PATTERNS.DMS), /\\s*/),\n 'g',\n);\nconst POSITIVE = /\\+/g;\nconst SIGNS = /([-+])\\s*/g;\n/**\n * Any recognizably significant tokens anywhere (non-positional-y) within a\n * string; because at this level (lexing) actual position is not important.\n *\n * - [Regex Vis](https://regex-vis.com/?r=%2F%5B%2C%2F%5D%7C%5BNSEW%5D%7C%28%3F%3A%5B-%2B%5D%3F%28%3F%3A%28%3F%3A%5Cd%2B%28%3F%3A%5C.%5Cd*%29%3F%29%7C%28%3F%3A%5C.%5Cd%2B%29%29%28%3F%3A%5B%C2%B0%27%22%5D%29%3F%29%2Fgi)\n * - [Nodexr](https://www.nodexr.net/?parse=%2F%5B,%2F%5D%7C%5BNSEW%5D%7C(%3F%3A%5B-%2B%5D%3F(%3F%3A(%3F%3A%5Cd%2B(%3F%3A%5C.%5Cd*)%3F)%7C(%3F%3A%5C.%5Cd%2B))%5B%C2%B0%27%22%5D%3F)%2Fgi)\n */\n// NOTE: the links (above) for \"Regex Vis\" and \"Nodexr\" would need to be updated if/when the pattern is changed.\nconst TOKENS = new RegExp(\n Patterning.merge(\n DIVIDERS,\n /|/,\n SYMBOL_PATTERNS.NSEW,\n /|/,\n Patterning.group(\n /[-+]?/,\n Patterning.group(\n // left of decimal REQUIRED, right of decimal optional\n /(?:\\d+(?:\\.\\d*)?)|/,\n // left of decimal omitted, right of decimal REQUIRED\n /(?:\\.\\d+)/,\n ),\n Patterning.optional(SYMBOL_PATTERNS.DMS),\n ),\n ),\n 'gi',\n);\n\n// remove trailing zeros '?.0' and ensure leading zero '0.?' in numbers\nfunction fixLeadingAndTrailing(t: string) {\n const [sign, num, pos] = (FLOATS.exec(t) ?? []).slice(1);\n\n if (num) {\n return `${sign}${Number.parseFloat(num)}${pos}`;\n }\n\n return t;\n}\n\n/**\n * Take an input string - possibly from user input - and clean it up enough to\n * be something to work with at a higher level of processing (with more\n * information) than is available at this level. Generating a list of \"tokens\"\n * that are potentially valid parts of a coordinate. The values being looked\n * for are: numbers (with positional indicators) and axes (NSEW).\n *\n * NOTE: No validation is done at this level to keep it simple as agnostic.\n *\n * @remarks\n * pure function\n *\n * @example\n * lexer('N 55,E 44') === ['N' '55', '/', 'E', '44']\n * lexer(` + 89 ° 59 59.999 \" N, 179° 59 59.999\" `) === ['89', '59', '59.999', 'N', '/', '179', '59', '59.999', 'E']\n */\nexport function lexer(input: string) {\n const tokens =\n input\n .trim()\n .toUpperCase()\n .replace(POSITIVE, '') // positive signs are redundant\n .replace(POSITIONAL, '$1 ') // group positional indicators with numbers\n .replace(SIGNS, '$1') // group signs with numbers\n .replace(DIVIDERS, SYMBOLS.DIVIDER) // standardize the divider\n .match(TOKENS)\n ?.map(fixLeadingAndTrailing)\n ?.slice() ?? [];\n\n return tokens;\n}\n"]}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { SYMBOL_PATTERNS, SYMBOLS } from '
|
|
1
|
+
import { SYMBOL_PATTERNS, SYMBOLS } from '.';
|
|
2
2
|
import { parse } from './parse.js';
|
|
3
3
|
import { violation } from './violation.js';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var createParser = (config) => (format, input) => parseWithConfig(config, format, input);
|
|
5
|
+
const axisTypeTest = (k, t) => SYMBOL_PATTERNS[k].test(t) && k;
|
|
6
|
+
const createParser = (config) => (format, input) => parseWithConfig(config, format, input);
|
|
8
7
|
function parseWithConfig(config, format, input) {
|
|
9
8
|
const [parseTokens, violations] = parse(input, format);
|
|
10
9
|
const foundFormat = parseTokens.reduce(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/coordinates/latlon/internal/parse-format.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/coordinates/latlon/internal/parse-format.ts"],"names":[],"mappings":";;;;AA4BA,MAAM,YAAA,GAAe,CAAC,CAAA,EAAiC,CAAA,KACrD,gBAAgB,CAAC,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,IAAK,CAAA;AAEzB,MAAM,YAAA,GACX,CAAI,MAAA,KACJ,CAAC,QAAgB,KAAA,KACf,eAAA,CAAgB,MAAA,EAAQ,MAAA,EAAQ,KAAK;AAEzC,SAAS,eAAA,CACP,MAAA,EACA,MAAA,EACA,KAAA,EACc;AACd,EAAA,MAAM,CAAC,WAAA,EAAa,UAAU,CAAA,GAAI,KAAA,CAAM,OAAO,MAAM,CAAA;AAErD,EAAA,MAAM,cAAc,WAAA,CAAY,MAAA;AAAA,IAC9B,CAAC,GAAA,EAAK,CAAA,KAAM,GAAA,IAAO,YAAA,CAAa,KAAA,EAAO,CAAC,CAAA,IAAK,YAAA,CAAa,KAAA,EAAO,CAAC,CAAA,IAAK,EAAA,CAAA;AAAA,IACvE;AAAA,GACF;AAEA,EAAA,IAAI,CAAC,UAAA,CAAW,MAAA,IAAU,WAAA,IAAe,gBAAgB,MAAA,EAAQ;AAC/D,IAAA,OAAO;AAAA,MACL,EAAC;AAAA,MACD;AAAA,QACE,SAAA;AAAA,UACE,CAAA,qBAAA,EAAwB,MAAM,CAAA,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IAAI,CAAC,SAAS,MAAA,EAAQ;AACpB,IAAA,MAAM,IAAI,KAAA;AAAA,MACR;AAAA,QACE,yFAAA;AAAA,QACA,MAAA,CAAO,KAAK,GAAG,CAAA;AAAA,QACf,iCAAA;AAAA,QACA,MAAA,CAAO,QAAQ,MAAM,CAAA;AAAA,QACrB;AAAA,OACF,CAAE,KAAK,EAAE;AAAA,KACX;AAAA,EACF;AAEA,EAAA,OAAO,CAAC,OAAA,EAAS,EAAE,CAAA;AACrB","file":"parse-format.js","sourcesContent":["// __private-exports\n/*\n * Copyright 2024 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { type Format, SYMBOLS, SYMBOL_PATTERNS } from '.';\nimport { type ParseResults, parse } from './parse';\nimport { violation } from './violation';\n\ntype FormatParserConfig<T> = {\n formats: {\n // biome-ignore lint/style/useNamingConvention: <explanation>\n LATLON: RegExp;\n // biome-ignore lint/style/useNamingConvention: <explanation>\n LONLAT: RegExp;\n };\n identifyErrors: (format: Format) => (arg: T, i: number) => ParseResults;\n identifyPieces: (half: string[]) => T;\n};\n\nconst axisTypeTest = (k: keyof typeof SYMBOL_PATTERNS, t: string) =>\n SYMBOL_PATTERNS[k].test(t) && k;\n\nexport const createParser =\n <T>(config: FormatParserConfig<T | undefined>) =>\n (format: Format, input: string) =>\n parseWithConfig(config, format, input);\n\nfunction parseWithConfig<T>(\n config: FormatParserConfig<T>,\n format: Format,\n input: string,\n): ParseResults {\n const [parseTokens, violations] = parse(input, format);\n\n const foundFormat = parseTokens.reduce(\n (acc, t) => acc + (axisTypeTest('LAT', t) || axisTypeTest('LON', t) || ''),\n '',\n );\n\n if (!violations.length && foundFormat && foundFormat !== format) {\n return [\n [],\n [\n violation(\n `Mismatched formats: \"${format}\" expected, \"${foundFormat}\" found.`,\n ),\n ],\n ];\n }\n\n const hasErrors = !parseTokens.length && violations.length;\n\n if (hasErrors) {\n return [[], violations];\n }\n\n const [tokens, errors] = [\n parseTokens.slice(0, parseTokens.indexOf(SYMBOLS.DIVIDER)), // left of divider\n parseTokens.slice(1 + parseTokens.indexOf(SYMBOLS.DIVIDER)), // right of divider\n ]\n .map(config.identifyPieces)\n .map(config.identifyErrors(format))\n .reduce((a, b) => [\n [...a[0], SYMBOLS.DIVIDER, ...b[0]],\n [...a[1], ...b[1]].map(violation),\n ]);\n\n if (errors.length) {\n return [\n [],\n // dedupe errors\n Array.from(new Set(errors)),\n ];\n }\n\n const matches = (config.formats[format].exec(tokens.join(' ')) || []).slice(\n 1,\n );\n\n if (!matches?.length) {\n throw new Error(\n [\n 'A validation check seems to be missing because the cleaned and normalized input value (',\n tokens.join(' '),\n ') is not matching the pattern (',\n config.formats[format],\n ').',\n ].join(''),\n );\n }\n\n return [matches, []];\n}\n"]}
|
|
@@ -2,7 +2,6 @@ import { lexer } from './lexer.js';
|
|
|
2
2
|
import { pipesRunner } from './pipes/index.js';
|
|
3
3
|
import { violation } from './violation.js';
|
|
4
4
|
|
|
5
|
-
// src/coordinates/latlon/internal/parse.ts
|
|
6
5
|
function parse(input, format) {
|
|
7
6
|
if (!input?.length) {
|
|
8
7
|
return [[], [violation("No input.")]];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/coordinates/latlon/internal/parse.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/coordinates/latlon/internal/parse.ts"],"names":[],"mappings":";;;;AAsDO,SAAS,KAAA,CAAM,OAAe,MAAA,EAA+B;AAClE,EAAA,IAAI,CAAC,OAAO,MAAA,EAAQ;AAClB,IAAA,OAAO,CAAC,EAAC,EAAG,CAAC,SAAA,CAAU,WAAW,CAAC,CAAC,CAAA;AAAA,EACtC;AAEA,EAAA,MAAM,CAAC,QAAQ,MAAM,CAAA,GAAI,YAAY,KAAA,CAAM,KAAK,GAAG,MAAM,CAAA;AAEzD,EAAA,OAAO,CAAC,QAAQ,MAAA,EAAQ,MAAA,GAAS,OAAO,GAAA,CAAI,SAAS,CAAA,GAAI,EAAE,CAAA;AAC7D","file":"parse.js","sourcesContent":["// __private-exports\n/*\n * Copyright 2024 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport type { Errors, Format } from '.';\nimport { type Tokens, lexer } from './lexer';\nimport { pipesRunner } from './pipes';\nimport { violation } from './violation';\n\nexport type ParseResults = [Tokens, Errors];\n\n/**\n * Parse a raw input string into a validated and normalized coordinate\n * primitive ready for further refinement/validation by a more specific parser.\n *\n * @param input\n * raw input, from a user or external system, of unknown validity\n *\n * @param format\n * the expected format - LATLON or LONLAT - the coordinate should conform to\n *\n * @returns\n * tuple with two values: tokens, and errors\n *\n * @remarks\n * pure function\n *\n * @example\n * const input = '1 2 3 / 4 5 6'\n * parse(input); // [['1', '2', '3', '/', '4', '5', '6'], []]\n *\n * @description\n * __Assumptions/Specification__\n * 1. Decimals are indicated by a \".\" and not \",\"\n * 2. A degrees indicator is \"°\"\n * 3. A minutes indicator is \"'\"\n * 4. A seconds indicator is '\"'\n * 5. Each indicator is expected to follow the number it is annotating\n * 6. Numeric parts - degrees, minutes, and seconds - are positional and can\n * not be arranged in alternative orders and be considered valid\n * 7. Output will have explicit bearings characters (NSEW) and not rely on\n * positive and negative values; when bearings are available. Negative\n * values will only be replaced with absolute values if bearings are available.\n *\n */\nexport function parse(input: string, format?: Format): ParseResults {\n if (!input?.length) {\n return [[], [violation('No input.')]];\n }\n\n const [tokens, errors] = pipesRunner(lexer(input), format);\n\n return [tokens, errors?.length ? errors.map(violation) : []];\n}\n"]}
|
|
@@ -2,7 +2,6 @@ import { SYMBOLS, SYMBOL_PATTERNS } from '../index.js';
|
|
|
2
2
|
import { pipesResult } from '../pipes/index.js';
|
|
3
3
|
import { simpler } from './simpler.js';
|
|
4
4
|
|
|
5
|
-
// src/coordinates/latlon/internal/pipes/check-ambiguous.ts
|
|
6
5
|
function checkAmbiguousGrouping(tokens, _format) {
|
|
7
6
|
if (tokens.includes(SYMBOLS.DIVIDER)) {
|
|
8
7
|
return pipesResult(tokens, false);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/coordinates/latlon/internal/pipes/check-ambiguous.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../../src/coordinates/latlon/internal/pipes/check-ambiguous.ts"],"names":[],"mappings":";;;;AAuBO,SAAS,sBAAA,CAAuB,QAAgB,OAAA,EAAkB;AACvE,EAAA,IAAI,MAAA,CAAO,QAAA,CAAS,OAAA,CAAQ,OAAO,CAAA,EAAG;AACpC,IAAA,OAAO,WAAA,CAAY,QAAQ,KAAK,CAAA;AAAA,EAClC;AAEA,EAAA,MAAM,MAAA,GAAS,QAAQ,MAAM,CAAA;AAG7B,EAAA,MAAM,SAAA,GAAY,+BAAA,CAAgC,IAAA,CAAK,MAAM,CAAA;AAE7D,EAAA,MAAM,QAAA,GAAW,YAAA,CAAa,IAAA,CAAK,MAAM,CAAA;AAMzC,EAAA,MAAM,OAAA,GAAU,OAGb,KAAA,CAAM,CAAA,EAAG,EAAE,CAAA,CACX,MAAA,CAAO,CAAC,GAAA,EAAK,CAAA,KAAM;AAClB,IAAA,MAAM,KAAA,GACJ,CAAA,CAAE,QAAA,CAAS,OAAA,CAAQ,OAAO,CAAA,IAC1B,CAAA,CAAE,QAAA,CAAS,OAAA,CAAQ,OAAO,CAAA,IAC1B,eAAA,CAAgB,IAAA,CAAK,KAAK,CAAC,CAAA;AAE7B,IAAA,OAAO,CAAA,EAAG,GAAG,CAAA,EAAG,KAAA,GAAQ,MAAM,GAAG,CAAA,CAAA;AAAA,EACnC,CAAA,EAAG,EAAE,CAAA,CACJ,QAAA,CAAS,GAAG,CAAA;AAEf,EAAA,MAAM,QAAA,GAAW,UAAA,CAAW,IAAA,CAAK,MAAM,KAAK,CAAC,OAAA;AAE7C,EAAA,OAAO,WAAA,CAAY,MAAA,EAAQ,SAAA,IAAa,QAAA,IAAY,QAAQ,CAAA;AAC9D","file":"check-ambiguous.js","sourcesContent":["// __private-exports\n/*\n * Copyright 2024 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { type Format, SYMBOLS, SYMBOL_PATTERNS } from '..';\nimport type { Tokens } from '../lexer';\nimport { pipesResult } from '../pipes';\n\nimport { simpler } from './simpler';\n\n/**\n * Look for groupings of numbers that are ambiguous; no indicators, or no\n * dividers and not possibility of deducing where a divider should be inserted.\n */\nexport function checkAmbiguousGrouping(tokens: Tokens, _format?: Format) {\n if (tokens.includes(SYMBOLS.DIVIDER)) {\n return pipesResult(tokens, false);\n }\n\n const simple = simpler(tokens);\n\n // 3-5 numbers after or before a single bearing indicator BNNN, NNNB\n const ambiguous = /^(?:(?:BN{3,5})|(?:N{3,5}B))$/.test(simple);\n // 3-5 numbers between 2 bearings indicators BNNNB\n const bookends = /^BN{3,5}B$/.test(simple);\n // \"helpful\" indicators:\n // 1. degrees number in the right-of-divider position e.g. # #°\n // 2. seconds number in the left-of-divider position e.g. # #\" #\n // 3. trailing bearings in the left-of-divider position e.g. # N #\n // 4. leading bearings in the right-of-divider position e.g. N # E #\n const helpful = tokens\n // helpful tokens are only helpful in the middle of the token list\n // not the beginning or end of the list\n .slice(1, -1)\n .reduce((acc, t) => {\n const helps =\n t.includes(SYMBOLS.DEGREES) ||\n t.includes(SYMBOLS.SECONDS) ||\n SYMBOL_PATTERNS.NSEW.test(t);\n\n return `${acc}${helps ? 'H' : '_'}`;\n }, '')\n .includes('H');\n // 3-5 numbers with no bearings indicators, and no helpful indicators\n const hopeless = /^N{3,5}$/.test(simple) && !helpful;\n\n return pipesResult(tokens, ambiguous || bookends || hopeless);\n}\n"]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { pipesResult } from '../pipes/index.js';
|
|
2
2
|
import { simpler } from './simpler.js';
|
|
3
3
|
|
|
4
|
-
// src/coordinates/latlon/internal/pipes/check-numbers.ts
|
|
5
4
|
function checkNumberValues(tokens) {
|
|
6
5
|
const simple = simpler(tokens);
|
|
7
6
|
if ((simple.match(/N/g) ?? []).length < 2) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/coordinates/latlon/internal/pipes/check-numbers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../../src/coordinates/latlon/internal/pipes/check-numbers.ts"],"names":[],"mappings":";;;AAqBO,SAAS,kBAAkB,MAAA,EAAgB;AAChD,EAAA,MAAM,MAAA,GAAS,QAAQ,MAAM,CAAA;AAE7B,EAAA,IAAA,CAAK,OAAO,KAAA,CAAM,IAAI,KAAK,EAAC,EAAG,SAAS,CAAA,EAAG;AACzC,IAAA,OAAO,WAAA,CAAY,QAAQ,kBAAkB,CAAA;AAAA,EAC/C;AAEA,EAAA,MAAM,KAAA;AAAA;AAAA,IAEJ,2BAAA,CAA4B,KAAK,MAAM,CAAA;AAAA,IAAA,CAEtC,OAAO,KAAA,CAAM,IAAI,CAAA,IAAK,IAAI,MAAA,GAAS;AAAA,GAAA;AAEtC,EAAA,IAAI,KAAA,EAAO;AACT,IAAA,OAAO,WAAA,CAAY,QAAQ,mBAAmB,CAAA;AAAA,EAChD;AAEA,EAAA,MAAM,OAAA,GAAU,MAAA,CACb,MAAA,CAAO,CAAC,KAAK,CAAA,KAAM;AAClB,IAAA,IAAI,IAAA,CAAK,IAAA,CAAK,CAAC,CAAA,EAAG;AAChB,MAAA,GAAA,CAAI,KAAK,MAAA,CAAO,UAAA,CAAW,CAAC,CAAA,GAAI,CAAA,GAAI,MAAM,GAAG,CAAA;AAAA,IAC/C,CAAA,MAAO;AACL,MAAA,GAAA,CAAI,KAAK,GAAG,CAAA;AAAA,IACd;AAEA,IAAA,OAAO,GAAA;AAAA,EACT,CAAA,EAAG,EAAc,CAAA,CAChB,KAAK,EAAE,CAAA;AAEV,EAAA,MAAM,OAAA,GAAU,OAAA,CAAQ,KAAA,CAAM,QAAQ,CAAA;AAItC,EAAA,IAAI,CAAC,CAAC,OAAA,IAAW,OAAA,KAAY,MAAA,EAAQ;AACnC,IAAA,OAAO,WAAA,CAAY,QAAQ,6CAA6C,CAAA;AAAA,EAC1E;AAEA,EAAA,OAAO,WAAA,CAAY,QAAQ,KAAK,CAAA;AAClC","file":"check-numbers.js","sourcesContent":["// __private-exports\n/*\n * Copyright 2024 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport type { Tokens } from '../lexer';\nimport { pipesResult } from '../pipes';\n\nimport { simpler } from './simpler';\n\n/**\n * Check for problems in the numeric values.\n */\nexport function checkNumberValues(tokens: Tokens) {\n const simple = simpler(tokens);\n\n if ((simple.match(/N/g) ?? []).length < 2) {\n return pipesResult(tokens, 'Too few numbers.');\n }\n\n const error =\n // 4 consecutive numbers in specific formation is not going to be valid\n /(?:N{4,}BN+)|(?:N+BN{4,})/.test(simple) ||\n // more than 6 numbers total\n (simple.match(/N/g) ?? []).length > 6;\n\n if (error) {\n return pipesResult(tokens, 'Too many numbers.');\n }\n\n const pattern = tokens\n .reduce((acc, t) => {\n if (/\\d/.test(t)) {\n acc.push(Number.parseFloat(t) < 0 ? '-' : '+');\n } else {\n acc.push('_');\n }\n\n return acc;\n }, [] as string[])\n .join('');\n\n const matches = pattern.match(/[^_]-./);\n\n // special case '_--_' when the input is something like 'S -1 -1 W'\n // which is invalid for other reasons and will be caught elsewhere\n if (!!matches && pattern !== '_--_') {\n return pipesResult(tokens, 'Negative value for non-degrees value found.');\n }\n\n return pipesResult(tokens, false);\n}\n"]}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { BEARINGS, SYMBOLS, SYMBOL_PATTERNS } from '../index.js';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
var orthogonal = {
|
|
3
|
+
const orthogonal = {
|
|
5
4
|
N: BEARINGS.LON,
|
|
6
5
|
S: BEARINGS.LON,
|
|
7
6
|
E: BEARINGS.LAT,
|
|
8
7
|
W: BEARINGS.LAT
|
|
9
8
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
const bearingConflictsWithNumber = (tokens) => tokens[0] && tokens[1] && SYMBOL_PATTERNS.NEGATIVE_SIGN.test(tokens[1]) && SYMBOL_PATTERNS.NSEW.test(tokens[0]) && !SYMBOL_PATTERNS.NEGATIVE_BEARINGS.test(tokens[0]);
|
|
10
|
+
const bePositive = (n) => n.replace(SYMBOL_PATTERNS.NEGATIVE_SIGN, "");
|
|
11
|
+
const conflict = ([a, b]) => `Bearing (${a}) conflicts with negative number (${b}).`;
|
|
13
12
|
function fixBearings(tokens, format) {
|
|
14
13
|
const [left, right] = [
|
|
15
14
|
tokens.slice(0, tokens.indexOf(SYMBOLS.DIVIDER)),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/coordinates/latlon/internal/pipes/fix-bearings.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../../src/coordinates/latlon/internal/pipes/fix-bearings.ts"],"names":[],"mappings":";;AAiBA,MAAM,UAAA,GAAa;AAAA,EACjB,GAAG,QAAA,CAAS,GAAA;AAAA,EACZ,GAAG,QAAA,CAAS,GAAA;AAAA,EACZ,GAAG,QAAA,CAAS,GAAA;AAAA,EACZ,GAAG,QAAA,CAAS;AACd,CAAA;AAEA,MAAM,0BAAA,GAA6B,CAAC,MAAA,KAClC,MAAA,CAAO,CAAC,CAAA,IACR,MAAA,CAAO,CAAC,CAAA,IACR,eAAA,CAAgB,aAAA,CAAc,IAAA,CAAK,MAAA,CAAO,CAAC,CAAC,CAAA,IAC5C,eAAA,CAAgB,IAAA,CAAK,IAAA,CAAK,MAAA,CAAO,CAAC,CAAC,CAAA,IACnC,CAAC,eAAA,CAAgB,iBAAA,CAAkB,IAAA,CAAK,MAAA,CAAO,CAAC,CAAC,CAAA;AAEnD,MAAM,aAAa,CAAC,CAAA,KAAc,EAAE,OAAA,CAAQ,eAAA,CAAgB,eAAe,EAAE,CAAA;AAE7E,MAAM,QAAA,GAAW,CAAC,CAAC,CAAA,EAAG,CAAC,CAAA,KACrB,CAAA,SAAA,EAAY,CAAC,CAAA,kCAAA,EAAqC,CAAC,CAAA,EAAA,CAAA;AAO9C,SAAS,WAAA,CAAY,QAAgB,MAAA,EAA6B;AACvE,EAAA,MAAM,CAAC,IAAA,EAAM,KAAK,CAAA,GAAI;AAAA,IACpB,OAAO,KAAA,CAAM,CAAA,EAAG,OAAO,OAAA,CAAQ,OAAA,CAAQ,OAAO,CAAC,CAAA;AAAA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n/*\n * Copyright 2024 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { BEARINGS, type Format, SYMBOLS, SYMBOL_PATTERNS } from '..';\nimport type { Tokens } from '../lexer';\nimport type { PipeResult } from '../pipes';\n\nconst orthogonal = {\n N: BEARINGS.LON,\n S: BEARINGS.LON,\n E: BEARINGS.LAT,\n W: BEARINGS.LAT,\n};\n\nconst bearingConflictsWithNumber = (tokens: Tokens) =>\n tokens[0] &&\n tokens[1] &&\n SYMBOL_PATTERNS.NEGATIVE_SIGN.test(tokens[1]) &&\n SYMBOL_PATTERNS.NSEW.test(tokens[0]) &&\n !SYMBOL_PATTERNS.NEGATIVE_BEARINGS.test(tokens[0]);\n\nconst bePositive = (n: string) => n.replace(SYMBOL_PATTERNS.NEGATIVE_SIGN, '');\n\nconst conflict = ([a, b]: Tokens) =>\n `Bearing (${a}) conflicts with negative number (${b}).`;\n\n/**\n * Normalize bearings - negative and positive numeric values to NSEW - and\n * positioning of bearings - after the numeric values - and fill in any missing\n * bearings if only one is provided.\n */\nexport function fixBearings(tokens: Tokens, format?: Format): PipeResult {\n const [left, right] = [\n tokens.slice(0, tokens.indexOf(SYMBOLS.DIVIDER)),\n tokens.slice(1 + tokens.indexOf(SYMBOLS.DIVIDER)),\n ].map(moveBearingsToHead) as [Tokens, Tokens];\n\n if (bearingConflictsWithNumber(left)) {\n return [[], conflict(left)];\n }\n\n if (bearingConflictsWithNumber(right)) {\n return [[], conflict(right)];\n }\n\n const [leftHasBearing, rightHasBearing] = [left, right].map(\n (list) => !!(list?.[0] && SYMBOL_PATTERNS.NSEW.test(list[0])),\n );\n\n let leftBearing = '';\n let rightBearing = '';\n\n if (leftHasBearing && rightHasBearing) {\n leftBearing = left.shift() ?? '';\n rightBearing = right.shift() ?? '';\n } else if (leftHasBearing) {\n leftBearing = left.shift() ?? '';\n rightBearing =\n orthogonal[leftBearing as keyof typeof orthogonal][\n +SYMBOL_PATTERNS.NEGATIVE_SIGN.test(right[0] ?? '') as 0 | 1\n ];\n } else if (rightHasBearing) {\n rightBearing = right.shift() ?? '';\n leftBearing =\n orthogonal[rightBearing as keyof typeof orthogonal][\n +SYMBOL_PATTERNS.NEGATIVE_SIGN.test(right[0] ?? '') as 0 | 1\n ];\n } else if (format) {\n leftBearing = `${BEARINGS[format][0][+SYMBOL_PATTERNS.NEGATIVE_SIGN.test(`${left[0]}`)]}`;\n rightBearing = `${BEARINGS[format][1][+SYMBOL_PATTERNS.NEGATIVE_SIGN.test(`${right[0]}`)]}`;\n } else {\n // neither exist\n return [[...left, SYMBOLS.DIVIDER, ...right], false];\n }\n\n return [\n [\n ...left.map(bePositive),\n leftBearing,\n SYMBOLS.DIVIDER,\n ...right.map(bePositive),\n rightBearing,\n ],\n false,\n ];\n}\n\n/**\n * Move the bearings indicators to the first element in the list - in this\n * module only - so that it is easier to work with; moving a bearing to the\n * \"head\" allows for `push()` of subsequent number processing will keep the\n * order of the numeric values intact.\n */\nfunction moveBearingsToHead(coord: Tokens) {\n return coord.reduce((acc, t) => {\n if (/\\d/.test(t)) {\n acc.push(t);\n } else {\n acc.unshift(t);\n }\n\n return acc;\n }, [] as Tokens);\n}\n"]}
|
|
@@ -2,14 +2,13 @@ import { SYMBOLS } from '../index.js';
|
|
|
2
2
|
import { getGenomeIndex } from './genome.js';
|
|
3
3
|
import { simpler } from './simpler.js';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
var SIMPLER_PATTERNS = {
|
|
5
|
+
const SIMPLER_PATTERNS = {
|
|
7
6
|
NN: 1,
|
|
8
7
|
NNB: 1,
|
|
9
8
|
BNNB: 2,
|
|
10
9
|
BNN: 2
|
|
11
10
|
};
|
|
12
|
-
|
|
11
|
+
const insertDivider = (tokens, index) => [
|
|
13
12
|
[...tokens.slice(0, index), SYMBOLS.DIVIDER, ...tokens.slice(index)],
|
|
14
13
|
false
|
|
15
14
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/coordinates/latlon/internal/pipes/fix-dividers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../../src/coordinates/latlon/internal/pipes/fix-dividers.ts"],"names":[],"mappings":";;;;AAqBA,MAAM,gBAAA,GAAmB;AAAA,EACvB,EAAA,EAAI,CAAA;AAAA,EACJ,GAAA,EAAK,CAAA;AAAA,EACL,IAAA,EAAM,CAAA;AAAA,EACN,GAAA,EAAK;AACP,CAAA;AAEA,MAAM,aAAA,GAAgB,CAAC,MAAA,EAAgB,KAAA,KAA8B;AAAA,EACnE,CAAC,GAAG,MAAA,CAAO,KAAA,CAAM,CAAA,EAAG,KAAK,CAAA,EAAG,OAAA,CAAQ,OAAA,EAAS,GAAG,MAAA,CAAO,KAAA,CAAM,KAAK,CAAC,CAAA;AAAA,EACnE;AACF,CAAA;AAUO,SAAS,UAAA,CAAW,UAAkB,OAAA,EAA8B;AAEzE,EAAA,IAAI,QAAA,CAAS,QAAA,CAAS,OAAA,CAAQ,OAAO,CAAA,EAAG;AACtC,IAAA,OAAO,CAAC,UAAU,KAAK,CAAA;AAAA,EACzB;AAGA,EAAA,MAAM,MAAA,GAAS,QAAA,CAAS,KAAA,CAAM,CAAC,CAAA;AAE/B,EAAA,MAAM,WAAA,GAAc,eAAe,MAAM,CAAA;AAEzC,EAAA,IAAI,WAAA,EAAa;AACf,IAAA,OAAO,aAAA,CAAc,QAAQ,WAAW,CAAA;AAAA,EAC1C;AAEA,EAAA,MAAM,MAAA,GAAS,QAAQ,MAAM,CAAA;AAE7B,EAAA,IAAI,gBAAA,CAAiB,MAAM,CAAA,EAAG;AAC5B,IAAA,OAAO,aAAA,CAAc,MAAA,EAAQ,gBAAA,CAAiB,MAAM,CAAC,CAAA;AAAA,EACvD;AAIA,EAAA,OAAO,CAAC,EAAC,EAAG,IAAI,CAAA;AAClB","file":"fix-dividers.js","sourcesContent":["// __private-exports\n/*\n * Copyright 2024 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { type Format, SYMBOLS } from '..';\nimport type { Tokens } from '../lexer';\nimport type { PipeResult } from '../pipes';\nimport { getGenomeIndex } from './genome';\nimport { simpler } from './simpler';\n\n// N = number\n// B = bearing\nconst SIMPLER_PATTERNS = {\n NN: 1,\n NNB: 1,\n BNNB: 2,\n BNN: 2,\n};\n\nconst insertDivider = (tokens: Tokens, index: number): PipeResult => [\n [...tokens.slice(0, index), SYMBOLS.DIVIDER, ...tokens.slice(index)],\n false,\n];\n\n/**\n * For tokens lists without a divider, `fixDivider` attempts to determine the\n * __safe__ location to add a divider based on the existing formatting of the\n * coordinate: numbers, number positions, and number indicators.\n *\n * @remarks\n * pure function\n */\nexport function fixDivider(original: Tokens, _format?: Format): PipeResult {\n // if there is already a divider then there is nothing to do\n if (original.includes(SYMBOLS.DIVIDER)) {\n return [original, false];\n }\n\n // disconnect from argument memory space so we aren't working on shared memory\n const tokens = original.slice(0);\n\n const genomeIndex = getGenomeIndex(tokens);\n\n if (genomeIndex) {\n return insertDivider(tokens, genomeIndex);\n }\n\n const simple = simpler(tokens) as keyof typeof SIMPLER_PATTERNS;\n\n if (SIMPLER_PATTERNS[simple]) {\n return insertDivider(tokens, SIMPLER_PATTERNS[simple]);\n }\n\n // no position is found to be a safe location to insert a divider; any placement\n // would be a guess and therefor only has a 50% chance of being wrong or right\n return [[], true];\n}\n"]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { SYMBOLS, SYMBOL_PATTERNS } from '../index.js';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
var GENOME_PATTERN = /^(B?)([DN]?[MN]?[SN]?)(B?)(?:B?)([DN]?[MN]?[SN]?)(?:B?)$/;
|
|
3
|
+
const GENOME_PATTERN = /^(B?)([DN]?[MN]?[SN]?)(B?)(?:B?)([DN]?[MN]?[SN]?)(?:B?)$/;
|
|
5
4
|
function dividerIndexer(_full, ...args) {
|
|
6
5
|
const [bearing1 = "", number1, bearing2 = "", number2] = args;
|
|
7
6
|
if (!(number1?.length && number2?.length)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/coordinates/latlon/internal/pipes/genome.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../../src/coordinates/latlon/internal/pipes/genome.ts"],"names":[],"mappings":";;AAgBA,MAAM,cAAA,GACJ,0DAAA;AAOF,SAAS,cAAA,CAAe,UAAkB,IAAA,EAAgB;AACxD,EAAA,MAAM,CAAC,QAAA,GAAW,EAAA,EAAI,SAAS,QAAA,GAAW,EAAA,EAAI,OAAO,CAAA,GAAI,IAAA;AAGzD,EAAA,IAAI,EAAE,OAAA,EAAS,MAAA,IAAU,OAAA,EAAS,MAAA,CAAA,EAAS;AACzC,IAAA,OAAO,GAAA;AAAA,EACT;AAEA,EAAA,OAAO,GAAG,OAAA,CAAQ,MAAA,IAAU,QAAA,CAAS,MAAA,IAAU,SAAS,MAAA,CAAO,CAAA,CAAA;AACjE;AAYA,SAAS,eAAA,CAAgB,KAAa,CAAA,EAAW;AAC/C,EAAA,IAAI,CAAA,CAAE,QAAA,CAAS,OAAA,CAAQ,OAAO,CAAA,EAAG;AAC/B,IAAA,OAAO,GAAG,GAAG,CAAA,CAAA,CAAA;AAAA,EACf;AAEA,EAAA,IAAI,CAAA,CAAE,QAAA,CAAS,OAAA,CAAQ,OAAO,CAAA,EAAG;AAC/B,IAAA,OAAO,GAAG,GAAG,CAAA,CAAA,CAAA;AAAA,EACf;AAEA,EAAA,IAAI,CAAA,CAAE,QAAA,CAAS,OAAA,CAAQ,OAAO,CAAA,EAAG;AAC/B,IAAA,OAAO,GAAG,GAAG,CAAA,CAAA,CAAA;AAAA,EACf;AAEA,EAAA,IAAI,eAAA,CAAgB,IAAA,CAAK,IAAA,CAAK,CAAC,CAAA,EAAG;AAChC,IAAA,OAAO,GAAG,GAAG,CAAA,CAAA,CAAA;AAAA,EACf;AAEA,EAAA,IAAI,IAAA,CAAK,IAAA,CAAK,CAAC,CAAA,EAAG;AAChB,IAAA,OAAO,GAAG,GAAG,CAAA,CAAA,CAAA;AAAA,EACf;AAEA,EAAA,OAAO,GAAG,GAAG,CAAA,CAAA,CAAA;AACf;AAMO,SAAS,eAAe,MAAA,EAAgB;AAC7C,EAAA,MAAM,GAAA,GAAM,MAAA,CAAO,MAAA,CAAO,eAAA,EAAiB,EAAE,CAAA;AAE7C,EAAA,OAAO,cAAA,CAAe,IAAA,CAAK,GAAG,CAAA,GAC1B,MAAA,CAAO,QAAA,CAAS,GAAA,CAAI,OAAA,CAAQ,cAAA,EAAgB,cAAc,CAAC,CAAA,GAC3D,CAAA;AACN","file":"genome.js","sourcesContent":["// __private-exports\n/*\n * Copyright 2024 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { SYMBOLS, SYMBOL_PATTERNS } from '..';\nimport type { Tokens } from '../lexer';\n\nconst GENOME_PATTERN =\n /^(B?)([DN]?[MN]?[SN]?)(B?)(?:B?)([DN]?[MN]?[SN]?)(?:B?)$/;\n\n/**\n * Get the position (index) of where to insert a divider into the token list;\n * basically, the count of numeric components (left-of-divider position) plus\n * 1 if there is a bearing identifier (left-of-divider).\n */\nfunction dividerIndexer(_full: string, ...args: string[]) {\n const [bearing1 = '', number1, bearing2 = '', number2] = args;\n\n // if no numeric values exist there no way to infer a location to insert a divider\n if (!(number1?.length && number2?.length)) {\n return '0';\n }\n\n return `${number1.length + (bearing1.length || bearing2.length)}`;\n}\n\n/**\n * The genome sequence is a simplification of the tokens list:\n *\n * - B = bearings (NSEW)\n * - D = degrees (number with degree character following)\n * - M = minutes (number with minutes character following)\n * - S = seconds (number with seconds character following)\n * - N = number (no identifying character following)\n * - X = for unmatched token types\n */\nfunction genomeSequencer(acc: string, t: string) {\n if (t.includes(SYMBOLS.DEGREES)) {\n return `${acc}D`;\n }\n\n if (t.includes(SYMBOLS.MINUTES)) {\n return `${acc}M`;\n }\n\n if (t.includes(SYMBOLS.SECONDS)) {\n return `${acc}S`;\n }\n\n if (SYMBOL_PATTERNS.NSEW.test(t)) {\n return `${acc}B`;\n }\n\n if (/\\d/.test(t)) {\n return `${acc}N`;\n }\n\n return `${acc}X`;\n}\n\n/**\n * Use the \"genome\" sequence of the token list to find the index for inserting\n * a missing divider token.\n */\nexport function getGenomeIndex(tokens: Tokens) {\n const seq = tokens.reduce(genomeSequencer, '');\n\n return GENOME_PATTERN.test(seq)\n ? Number.parseInt(seq.replace(GENOME_PATTERN, dividerIndexer))\n : 0;\n}\n"]}
|
|
@@ -4,15 +4,14 @@ import { checkNumberValues } from './check-numbers.js';
|
|
|
4
4
|
import { fixBearings } from './fix-bearings.js';
|
|
5
5
|
import { fixDivider } from './fix-dividers.js';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var pipesResult = (t, e) => [
|
|
7
|
+
const makeGlobal = (k) => new RegExp(SYMBOL_PATTERNS[k], "g");
|
|
8
|
+
const pipesResult = (t, e) => [
|
|
10
9
|
// if there are errors do NOT return the tokens
|
|
11
10
|
e ? [] : t,
|
|
12
11
|
e
|
|
13
12
|
];
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
const tooMany = (p) => (t) => pipesResult(t, (t.join("").match(p) ?? []).length > 2);
|
|
14
|
+
const pipes = [
|
|
16
15
|
// Unrecoverable violations
|
|
17
16
|
["Too many bearings.", tooMany(makeGlobal("NSEW"))],
|
|
18
17
|
["Too many numeric signs.", tooMany(/[-+]/g)],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/coordinates/latlon/internal/pipes/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../../src/coordinates/latlon/internal/pipes/index.ts"],"names":[],"mappings":";;;;;;AA0BA,MAAM,UAAA,GAAa,CAAC,CAAA,KAClB,IAAI,OAAO,eAAA,CAAgB,CAAC,GAAG,GAAG,CAAA;AAW7B,MAAM,WAAA,GAAc,CAAC,CAAA,EAAW,CAAA,KAAoC;AAAA;AAAA,EAEzE,CAAA,GAAI,EAAC,GAAI,CAAA;AAAA,EACT;AACF;AAGA,MAAM,UAAU,CAAC,CAAA,KAAc,CAAC,CAAA,KAC9B,YAAY,CAAA,EAAA,CAAI,CAAA,CAAE,IAAA,CAAK,EAAE,EAAE,KAAA,CAAM,CAAC,KAAK,EAAC,EAAG,SAAS,CAAC,CAAA;AAEvD,MAAM,KAAA,GAA0B;AAAA;AAAA,EAE9B,CAAC,oBAAA,EAAsB,OAAA,CAAQ,UAAA,CAAW,MAAM,CAAC,CAAC,CAAA;AAAA,EAClD,CAAC,yBAAA,EAA2B,OAAA,CAAQ,OAAO,CAAC,CAAA;AAAA,EAC5C,CAAC,8BAAA,EAAgC,OAAA,CAAQ,UAAA,CAAW,SAAS,CAAC,CAAC,CAAA;AAAA,EAC/D,CAAC,8BAAA,EAAgC,OAAA,CAAQ,UAAA,CAAW,SAAS,CAAC,CAAC,CAAA;AAAA,EAC/D,CAAC,8BAAA,EAAgC,OAAA,CAAQ,UAAA,CAAW,SAAS,CAAC,CAAC,CAAA;AAAA,EAC/D,CAAC,yBAAyB,iBAAiB,CAAA;AAAA,EAC3C,CAAC,kDAAkD,sBAAsB,CAAA;AAAA;AAAA,EAGzE,CAAC,+CAA+C,UAAU,CAAA;AAAA,EAC1D,CAAC,gCAAgC,WAAW;AAC9C,CAAA;AAQO,SAAS,WAAA,CACd,QACA,MAAA,EACoB;AACpB,EAAA,IAAI,IAAA,GAAO,MAAA,CAAO,KAAA,CAAM,CAAC,CAAA;AACzB,EAAA,IAAI,KAAA,GAAuB,KAAA;AAC3B,EAAA,MAAM,SAAS,EAAC;AAEhB,EAAA,KAAA,MAAW,CAAC,OAAA,EAAS,EAAE,CAAA,IAAK,KAAA,EAAO;AACjC,IAAA,CAAC,IAAA,EAAM,KAAK,CAAA,GAAI,EAAA,CAAG,MAAM,MAAM,CAAA;AAE/B,IAAA,IAAI,KAAA,EAAO;AAGT,MAAA,MAAA,CAAO,IAAA,CAAK,KAAA,KAAU,IAAA,GAAO,OAAA,GAAU,KAAK,CAAA;AAE5C,MAAA,IAAI,CAAC,KAAK,MAAA,EAAQ;AAChB,QAAA,OAAO,CAAC,IAAA,EAAM,CAAC,UAAU,IAAA,GAAO,OAAA,GAAU,KAAK,CAAC,CAAA;AAAA,MAClD;AAAA,IACF;AAAA,EACF;AAEA,EAAA,OAAO,CAAC,MAAM,MAAM,CAAA;AACtB","file":"index.js","sourcesContent":["// __private-exports\n/*\n * Copyright 2024 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { type Format, SYMBOL_PATTERNS } from '..';\nimport type { Tokens } from '../lexer';\n\nimport { checkAmbiguousGrouping } from './check-ambiguous';\nimport { checkNumberValues } from './check-numbers';\nimport { fixBearings } from './fix-bearings';\nimport { fixDivider } from './fix-dividers';\n\ntype Pipe = (t: Tokens, f?: Format) => [Tokens, boolean | string];\n\nexport type PipeResult = ReturnType<Pipe>;\n\n/** Make a RegExp global. */\nconst makeGlobal = (k: keyof typeof SYMBOL_PATTERNS) =>\n new RegExp(SYMBOL_PATTERNS[k], 'g');\n\n/**\n * Consistently create a PipesResult array to return. Use this instead of\n * casting to PipesResult everywhere.\n *\n * @param e true = has error, false = no error\n *\n * @remarks\n * pure function\n */\nexport const pipesResult = (t: Tokens, e: boolean | string): PipeResult => [\n // if there are errors do NOT return the tokens\n e ? [] : t,\n e,\n];\n\n/** Check if there are more than 2 of something. */\nconst tooMany = (p: RegExp) => (t: Tokens) =>\n pipesResult(t, (t.join('').match(p) ?? []).length > 2);\n\nconst pipes: [string, Pipe][] = [\n // Unrecoverable violations\n ['Too many bearings.', tooMany(makeGlobal('NSEW'))],\n ['Too many numeric signs.', tooMany(/[-+]/g)],\n ['Too many degrees indicators.', tooMany(makeGlobal('DEGREES'))],\n ['Too many minutes indicators.', tooMany(makeGlobal('MINUTES'))],\n ['Too many seconds indicators.', tooMany(makeGlobal('SECONDS'))],\n ['Number values checks.', checkNumberValues],\n ['Ambiguous grouping of numbers with no divider.', checkAmbiguousGrouping],\n\n // fix values and formatting to be consistent\n ['Unable to identify latitude from longitude.', fixDivider],\n ['Unable to identify bearings.', fixBearings],\n];\n\n/**\n * Run the tokens through a preset pipeline of violations checks exiting the\n * process as early as possible when violations are found because violations\n * will make further violations checks less accurate and could return inaccurate\n * violations that could be misleading or hide the most important violation\n */\nexport function pipesRunner(\n tokens: Tokens,\n format?: Format,\n): [Tokens, string[]] {\n let copy = tokens.slice(0);\n let error: PipeResult[1] = false;\n const errors = [] as string[];\n\n for (const [message, op] of pipes) {\n [copy, error] = op(copy, format);\n\n if (error) {\n // accumulate the \"errors\" because if tokens are returned\n // the errors are only warnings and are recoverable\n errors.push(error === true ? message : error);\n\n if (!copy.length) {\n return [copy, [error === true ? message : error]];\n }\n }\n }\n\n return [copy, errors];\n}\n"]}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
var simpler = (tokens) => tokens.map((t) => /\d/.test(t) ? "N" : "B").join("");
|
|
1
|
+
const simpler = (tokens) => tokens.map((t) => /\d/.test(t) ? "N" : "B").join("");
|
|
3
2
|
|
|
4
3
|
export { simpler };
|
|
5
4
|
//# sourceMappingURL=simpler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/coordinates/latlon/internal/pipes/simpler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../../src/coordinates/latlon/internal/pipes/simpler.ts"],"names":[],"mappings":"AAyBO,MAAM,OAAA,GAAU,CAAC,MAAA,KACtB,MAAA,CAAO,IAAI,CAAC,CAAA,KAAO,IAAA,CAAK,IAAA,CAAK,CAAC,CAAA,GAAI,GAAA,GAAM,GAAI,CAAA,CAAE,KAAK,EAAE","file":"simpler.js","sourcesContent":["// __private-exports\n/*\n * Copyright 2024 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport type { Tokens } from '../lexer';\n\n/**\n * Create a simplified pattern string - numbers = 'N', bearings = 'B' - to\n * allow for simpler pattern matching.\n *\n * @remarks\n * pure function\n *\n * @example\n * simplify(tokens); // 'NNNBNNNB' or similar\n */\nexport const simpler = (tokens: Tokens) =>\n tokens.map((t) => (/\\d/.test(t) ? 'N' : 'B')).join('');\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/coordinates/latlon/internal/violation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/coordinates/latlon/internal/violation.ts"],"names":[],"mappings":"AAaO,MAAM,SAAA,GAAY,CAAC,CAAA,KAAc,CAAA,QAAA,EAAW,CAAC,CAAA","file":"violation.js","sourcesContent":["// __private-exports\n/*\n * Copyright 2024 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport const violation = (s: string) => `[ERROR] ${s}`;\n"]}
|
|
@@ -2,9 +2,8 @@ import { MGRS } from '@ngageoint/mgrs-js';
|
|
|
2
2
|
import { parse } from '../latlon/internal/parse.js';
|
|
3
3
|
import { violation } from '../latlon/internal/violation.js';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var error = (message) => [
|
|
5
|
+
const PATTERN_PARTS = /^((?:..?)?)(\w?)\s*((?:\w{2})?)\s*(?:(\d+(?:\.\d*)?)?)\s*(?:(\d+(?:\.\d*)?)?)$/i;
|
|
6
|
+
const error = (message) => [
|
|
8
7
|
[],
|
|
9
8
|
[`${violation(message)}; expected format DDZ AA DDD DDD.`]
|
|
10
9
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/coordinates/mgrs/parser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"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CAAA;AAAA,EAC3E;AAEA,EAAA,OAAO,MAAM,2BAA2B,CAAA;AAC1C;AAIO,SAAS,SAAA,CAAU,SAAc,KAAA,EAAe;AACrD,EAAA,IAAI;AACF,IAAA,MAAM,KAAA,GAAQ,IAAA,CAAK,KAAA,CAAM,KAAK,EAAE,OAAA,EAAQ;AAExC,IAAA,OAAO,KAAA,CAAM,CAAA,EAAG,KAAA,CAAM,WAAA,EAAa,MAAM,KAAA,CAAM,YAAA,EAAc,CAAA,CAAA,EAAI,QAAQ,CAAA;AAAA,EAC3E,SAAS,EAAA,EAAI;AACX,IAAA,OAAO,eAAe,KAAK,CAAA;AAAA,EAC7B;AACF","file":"parser.js","sourcesContent":["/*\n * Copyright 2024 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { MGRS } from '@ngageoint/mgrs-js';\n\nimport { type ParseResults, parse } from '../latlon/internal/parse';\nimport { violation } from '../latlon/internal/violation';\n\ntype Match = [string, string, string, string, string];\n\nconst PATTERN_PARTS =\n /^((?:..?)?)(\\w?)\\s*((?:\\w{2})?)\\s*(?:(\\d+(?:\\.\\d*)?)?)\\s*(?:(\\d+(?:\\.\\d*)?)?)$/i;\n\nconst error = (message: string) =>\n [\n [],\n [`${violation(message)}; expected format DDZ AA DDD DDD.`],\n ] as ParseResults;\n\nfunction detailedErrors(input: string) {\n if (!input) {\n return error('No input provided');\n }\n\n const [utm, bnd, hkm, east, north] = (\n input.trim().replace(/\\s+/g, ' ').match(PATTERN_PARTS) ?? []\n ).slice(1) as Match;\n\n if (!utm || +utm > 60 || +utm < 1) {\n return error(\n `Invalid UTM zone number (${utm}) found in grid zone designation`,\n );\n }\n\n if (!/[C-HJ-NP-X]/i.test(bnd)) {\n return error(\n `Invalid Latitude band letter (${bnd}) found in grid zone designation`,\n );\n }\n\n if (!/^[A-HJ-NP-Z]*$/i.test(hkm)) {\n return error(`Invalid 100K m square identification (${hkm}) found`);\n }\n\n if (!(east && north && +east > 0 && +north > 0)) {\n return error(`Invalid numerical location (${[east, north].join()}) found`);\n }\n\n return error('Uncaught error condition.');\n}\n\n// biome-ignore lint/style/useNamingConvention: <explanation>\n// biome-ignore lint/suspicious/noExplicitAny: <explanation>\nexport function parseMGRS(_format: any, input: string) {\n try {\n const point = MGRS.parse(input).toPoint();\n\n return parse(`${point.getLatitude()} / ${point.getLongitude()}`, 'LATLON');\n } catch (_e) {\n return detailedErrors(input);\n }\n}\n"]}
|
|
@@ -3,8 +3,7 @@ import { MGRS } from '@ngageoint/mgrs-js';
|
|
|
3
3
|
import { SYMBOL_PATTERNS } from '../latlon/internal/index.js';
|
|
4
4
|
import { parseMGRS } from './parser.js';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
var systemMGRS = {
|
|
6
|
+
const systemMGRS = {
|
|
8
7
|
name: "Military Grid Reference System",
|
|
9
8
|
parse: parseMGRS,
|
|
10
9
|
toFloat(arg) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/coordinates/mgrs/system.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/coordinates/mgrs/system.ts"],"names":[],"mappings":";;;;;AAsBO,MAAM,UAAA,GAA+B;AAAA,EAC1C,IAAA,EAAM,gCAAA;AAAA,EAEN,KAAA,EAAO,SAAA;AAAA,EAEP,QAAQ,GAAA,EAAK;AACX,IAAA,MAAM,CAAC,GAAA,EAAK,IAAI,CAAA,GAAI,GAAA;AAEpB,IAAA,OACE,MAAA,CAAO,WAAW,GAAG,CAAA,IACpB,gBAAgB,iBAAA,CAAkB,IAAA,CAAK,IAAI,CAAA,GAAI,EAAA,GAAK,CAAA,CAAA;AAAA,EAEzD,CAAA;AAAA,EAEA,QAAA,CAAS,MAAA,EAAgB,CAAC,IAAA,EAAM,KAAK,CAAA,EAAqB;AACxD,IAAA,MAAM,EAAE,GAAA,EAAK,GAAA,EAAI,GAAI,OAAO,WAAA,CAAY;AAAA,MACtC,CAAC,MAAA,CAAO,KAAA,CAAM,CAAA,EAAG,CAAC,GAAG,IAAI,CAAA;AAAA,MACzB,CAAC,MAAA,CAAO,KAAA,CAAM,CAAC,GAAG,KAAK;AAAA,KACxB,CAAA;AAED,IAAA,OAAO,IAAA,CAAK,KAAK,KAAA,CAAM,KAAA,CAAM,KAAK,GAAG,CAAC,EAAE,QAAA,EAAS;AAAA,EACnD;AACF","file":"system.js","sourcesContent":["// __private-exports\n/*\n * Copyright 2024 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { Point } from '@ngageoint/grid-js';\nimport { MGRS } from '@ngageoint/mgrs-js';\n\nimport { type Compass, type Format, SYMBOL_PATTERNS } from '../latlon/internal';\nimport type { CoordinateSystem } from '../latlon/internal/coordinate-system';\n\nimport { parseMGRS } from './parser';\n\n// biome-ignore lint/style/useNamingConvention: acronym\nexport const systemMGRS: CoordinateSystem = {\n name: 'Military Grid Reference System',\n\n parse: parseMGRS,\n\n toFloat(arg) {\n const [num, bear] = arg as [string, Compass];\n\n return (\n Number.parseFloat(num) *\n (SYMBOL_PATTERNS.NEGATIVE_BEARINGS.test(bear) ? -1 : 1)\n );\n },\n\n toFormat(format: Format, [left, right]: [number, number]) {\n const { LAT, LON } = Object.fromEntries([\n [format.slice(0, 3), left],\n [format.slice(3), right],\n ]) as Record<'LAT' | 'LON', number>;\n\n return MGRS.from(Point.point(LON, LAT)).toString();\n },\n};\n"]}
|
|
@@ -2,9 +2,8 @@ import { UTM } from '@ngageoint/mgrs-js';
|
|
|
2
2
|
import { parse } from '../latlon/internal/parse.js';
|
|
3
3
|
import { violation } from '../latlon/internal/violation.js';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var error = (message) => [
|
|
5
|
+
const PATTERN_PARTS = /^((?:..)?)\s*(\w?)\s*(?:(\d+(?:\.\d*)?)?)\s*(?:(\d+(?:\.\d*)?)?)$/i;
|
|
6
|
+
const error = (message) => [
|
|
8
7
|
[],
|
|
9
8
|
[`${violation(message)}; expected format ZZ N|S DDD DDD.`]
|
|
10
9
|
];
|