Skip to content

Commit

Permalink
feat: add coordinate parsing and validation (#88)
Browse files Browse the repository at this point in the history
issue #70
  • Loading branch information
kalisjoshua authored Dec 2, 2024
1 parent 4ceec7e commit 6c23f31
Show file tree
Hide file tree
Showing 48 changed files with 2,783 additions and 983 deletions.
7 changes: 7 additions & 0 deletions .changeset/blue-teachers-share.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@accelint/geo": minor
---

Add coordinate parsing capability; parse string into object with conversion
options: MGRS, UTM, and lat/lon DD, DDM, DMS. Some error messaging is included
to be helpful for users and debuggers.
2 changes: 2 additions & 0 deletions packages/geo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
"dependencies": {
"@accelint/math": "workspace:0.1.3",
"@accelint/predicates": "workspace:0.1.3",
"@ngageoint/mgrs-js": "^1.0.0",
"@ngageoint/grid-js": "^2.1.0",
"typescript": "^5.6.3"
},
"$schema": "https://json.schemastore.org/package",
Expand Down
39 changes: 39 additions & 0 deletions packages/geo/src/cartesian.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// __private-exports
/*
* Copyright 2024 Hypergiant Galactic Systems Inc. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/

/**
* Computes the Cartesian product of multiple arrays.
*
* @template T
* the type of elements in the input arrays.
* @param {...T[][]} all
* a variadic number of arrays to compute the Cartesian product of.
* @returns {T[][]}
* An array containing all possible combinations of elements from the input
* arrays, where each combination is represented as an array.
*
* @pure
*
* @example
* const result = cartesian([1, 2], ['a', 'b']);
* // result: [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']]
*/
export function cartesian<T>(...all: T[][]): T[][] {
return all.reduce<T[][]>(
(results, entries) =>
results
.map((result) => entries.map((entry) => result.concat([entry])))
.reduce((sub, res) => sub.concat(res), []),
[[]],
);
}
6 changes: 0 additions & 6 deletions packages/geo/src/coordinates/README.md

This file was deleted.

55 changes: 0 additions & 55 deletions packages/geo/src/coordinates/__fixtures__/index.ts

This file was deleted.

Loading

0 comments on commit 6c23f31

Please sign in to comment.