Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(geo/src/coordinates): add coordinate parsing and validation #88

Merged
merged 1 commit into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading