Compare commits
10 Commits
935309a640
...
548afee7d6
Author | SHA1 | Date |
---|---|---|
Starbeamrainbowlabs | 548afee7d6 | |
Starbeamrainbowlabs | 833a1eee52 | |
Starbeamrainbowlabs | 1cba6dc8cd | |
Starbeamrainbowlabs | 1d8b1b4016 | |
Starbeamrainbowlabs | 4c1c0fbb6a | |
Starbeamrainbowlabs | 5eb2b66404 | |
Starbeamrainbowlabs | 5611cb2f90 | |
Starbeamrainbowlabs | b91691b99a | |
Starbeamrainbowlabs | e613e3a90c | |
Starbeamrainbowlabs | 330e0daa73 |
|
@ -1,3 +1,4 @@
|
|||
*.asc
|
||||
|
||||
# Created by https://www.gitignore.io/api/node
|
||||
# Edit at https://www.gitignore.io/?templates=node
|
||||
|
|
10
Changelog.md
10
Changelog.md
|
@ -14,6 +14,16 @@ npm install --save terrain50-cli
|
|||
-----
|
||||
|
||||
|
||||
## v1.10.1 (unreleased)
|
||||
- `json`: Support `--tolerant`
|
||||
- `json`: Fix crash when `--output` is specified
|
||||
|
||||
|
||||
## v1.10 (6th December 2022)
|
||||
- Update dependencies, including `applause-cli` (now `--help` will work on a per-subcommand basis if you do `terrain50 <subcommand> --help`)
|
||||
- Add `json` subcommand for serialising to JSON[(L)](https://jsonlines.org/)
|
||||
|
||||
|
||||
## v1.9
|
||||
- `identify`: Add value range to output
|
||||
- `clamp`: add new subcommand
|
||||
|
|
|
@ -61,13 +61,14 @@ Each bin is assigned a colour. Then, for each value in the input, it draws the c
|
|||
|
||||
|
||||
## Read-world use
|
||||
- I'm using it for the main Node.js application for my PhD in Computer Science!
|
||||
- I'm using it for for my PhD in Computer Science!
|
||||
- _(Are you using this project? Get in touch by [opening an issue](https://github.com/sbrl/terrain50/issues/new))_
|
||||
|
||||
|
||||
## Contributing
|
||||
Contributions are welcome as PRs! Don't forget to say that you donate your contribution under the _Mozilla Public License 2.0_ in your PR comment.
|
||||
|
||||
TODO: Use `gunzip-maybe` to transparently support reading from gzipped `.gz` input files
|
||||
|
||||
## Licence
|
||||
This project is licensed under the _Mozilla Public License 2.0_. See the `LICENSE` file in this repository for the full text.
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
{
|
||||
"name": "terrain50-cli",
|
||||
"version": "1.9.0",
|
||||
"version": "1.10.1",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "terrain50-cli",
|
||||
"version": "1.9.0",
|
||||
"version": "1.10.1",
|
||||
"license": "MPL-2.0",
|
||||
"dependencies": {
|
||||
"@iarna/toml": "^2.2.5",
|
||||
"applause-cli": "^1.8.0",
|
||||
"applause-cli": "^1.8.2",
|
||||
"chroma-js": "^2.4.2",
|
||||
"image-encode": "^1.3.1",
|
||||
"nexline": "^1.2.2",
|
||||
"terrain50": "^1.10.1"
|
||||
"terrain50": "^1.11.0"
|
||||
},
|
||||
"bin": {
|
||||
"terrain50": "src/index.mjs"
|
||||
|
@ -26,9 +26,9 @@
|
|||
"integrity": "sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg=="
|
||||
},
|
||||
"node_modules/applause-cli": {
|
||||
"version": "1.8.0",
|
||||
"resolved": "https://registry.npmjs.org/applause-cli/-/applause-cli-1.8.0.tgz",
|
||||
"integrity": "sha512-MyDPPI0z1CLH4TeLUap4VWie+kx3wL4IemJZoh1387o+4HqzADPGCjYCTIOogXGIqRqpbNisg2/4rdcUX/++lA=="
|
||||
"version": "1.8.2",
|
||||
"resolved": "https://registry.npmjs.org/applause-cli/-/applause-cli-1.8.2.tgz",
|
||||
"integrity": "sha512-ZNA/p8e+O6ToDb7nQtArAEpYtawua8HFCP3DVm24xusaXRHiJhpGLI07h+LgBq5PO0bflheUFS5+j+mZKG/t0Q=="
|
||||
},
|
||||
"node_modules/arr-flatten": {
|
||||
"version": "1.1.0",
|
||||
|
@ -352,9 +352,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/terrain50": {
|
||||
"version": "1.10.1",
|
||||
"resolved": "https://registry.npmjs.org/terrain50/-/terrain50-1.10.1.tgz",
|
||||
"integrity": "sha512-zOOTRAAPvFKlbfII5fG0YiWHy/12x8Ms9kyG8RMs64rTy1tLzIhe3OwPeveONY6hP9LupG5DtCr9McP3n4wwww==",
|
||||
"version": "1.11.0",
|
||||
"resolved": "https://registry.npmjs.org/terrain50/-/terrain50-1.11.0.tgz",
|
||||
"integrity": "sha512-doVNajTfix3DoeEqTF/b6AHwn0i7ahY0DtQA4v530n8fTx7hYroHL6U6ywoE4xUeDTjY4KVI/1WV361dgBV/Ew==",
|
||||
"dependencies": {
|
||||
"nexline": "^1.2.2",
|
||||
"nnng": "^1.0.0"
|
||||
|
@ -535,9 +535,9 @@
|
|||
"integrity": "sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg=="
|
||||
},
|
||||
"applause-cli": {
|
||||
"version": "1.8.0",
|
||||
"resolved": "https://registry.npmjs.org/applause-cli/-/applause-cli-1.8.0.tgz",
|
||||
"integrity": "sha512-MyDPPI0z1CLH4TeLUap4VWie+kx3wL4IemJZoh1387o+4HqzADPGCjYCTIOogXGIqRqpbNisg2/4rdcUX/++lA=="
|
||||
"version": "1.8.2",
|
||||
"resolved": "https://registry.npmjs.org/applause-cli/-/applause-cli-1.8.2.tgz",
|
||||
"integrity": "sha512-ZNA/p8e+O6ToDb7nQtArAEpYtawua8HFCP3DVm24xusaXRHiJhpGLI07h+LgBq5PO0bflheUFS5+j+mZKG/t0Q=="
|
||||
},
|
||||
"arr-flatten": {
|
||||
"version": "1.1.0",
|
||||
|
@ -819,9 +819,9 @@
|
|||
}
|
||||
},
|
||||
"terrain50": {
|
||||
"version": "1.10.1",
|
||||
"resolved": "https://registry.npmjs.org/terrain50/-/terrain50-1.10.1.tgz",
|
||||
"integrity": "sha512-zOOTRAAPvFKlbfII5fG0YiWHy/12x8Ms9kyG8RMs64rTy1tLzIhe3OwPeveONY6hP9LupG5DtCr9McP3n4wwww==",
|
||||
"version": "1.11.0",
|
||||
"resolved": "https://registry.npmjs.org/terrain50/-/terrain50-1.11.0.tgz",
|
||||
"integrity": "sha512-doVNajTfix3DoeEqTF/b6AHwn0i7ahY0DtQA4v530n8fTx7hYroHL6U6ywoE4xUeDTjY4KVI/1WV361dgBV/Ew==",
|
||||
"requires": {
|
||||
"nexline": "^1.2.2",
|
||||
"nnng": "^1.0.0"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "terrain50-cli",
|
||||
"version": "1.9.0",
|
||||
"version": "1.10.1",
|
||||
"description": "CLI for parsing Ordnance Survey Digital Elevation Model files",
|
||||
"main": "src/index.mjs",
|
||||
"scripts": {
|
||||
|
@ -34,11 +34,11 @@
|
|||
"homepage": "https://github.com/sbrl/terrain50-cli#readme",
|
||||
"dependencies": {
|
||||
"@iarna/toml": "^2.2.5",
|
||||
"applause-cli": "^1.8.0",
|
||||
"applause-cli": "^1.8.2",
|
||||
"chroma-js": "^2.4.2",
|
||||
"image-encode": "^1.3.1",
|
||||
"nexline": "^1.2.2",
|
||||
"terrain50": "^1.10.1"
|
||||
"terrain50": "^1.11.0"
|
||||
},
|
||||
"bin": {
|
||||
"terrain50": "src/index.mjs"
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
"use strict";
|
||||
|
||||
import fs from 'fs';
|
||||
|
||||
import nexline from 'nexline';
|
||||
|
||||
import a from '../../Helpers/Ansi.mjs';
|
||||
import l from '../../Helpers/Log.mjs';
|
||||
import Terrain50 from 'terrain50';
|
||||
import { write_safe, end_safe } from '../../Helpers/StreamHelpers.mjs';
|
||||
import settings from '../../Bootstrap/settings.mjs';
|
||||
|
||||
async function process_filename(filepath, stream_out) {
|
||||
const stream_in = fs.createReadStream(filepath);
|
||||
let i = 0;
|
||||
for await(const frame of Terrain50.ParseStream(stream_in, settings.cli.tolerant ? /\s+/ : " ")) {
|
||||
const obj = frame.to_json();
|
||||
await write_safe(stream_out, JSON.stringify(obj) + "\n");
|
||||
i++;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
export default async function(settings) {
|
||||
let stream_out = process.stdout;
|
||||
if(settings.cli.output !== "-")
|
||||
stream_out = fs.createWriteStream(settings.cli.output);
|
||||
|
||||
if(!(settings.cli.input instanceof Array))
|
||||
settings.cli.input = [ settings.cli.input ];
|
||||
|
||||
let frames = 0;
|
||||
for(let filepath of settings.cli.input) {
|
||||
l.log(`Processing ${a.hicol}${filepath}${a.reset} from CLI argument`);
|
||||
frames += await process_filename(filepath, stream_out);
|
||||
}
|
||||
|
||||
l.log(`${a.hicol}${a.fgreen}Done${a.reset}, serialised ${a.hicol}${a.fgreen}${frames}${a.reset} frames in total`);
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
description = "Convert 1 or more Terrain50 files to JSON (or JSONL if there are multiple frames in the input). Any logging messages are sent to stderr."
|
||||
|
||||
[[arguments]]
|
||||
name = "input"
|
||||
description = "The input Terrain50 file(s) to operate on. May be specified multiple times. Default: stdin (can be specified explicitly with single dash '-' (without quotes)."
|
||||
# default_value = ""
|
||||
type = "string_multi"
|
||||
|
||||
[[arguments]]
|
||||
name = "output"
|
||||
description = "The output to write the Terrain50 instance(s) to. Defaults to stdout (represented by a single dash '-' without quotes)."
|
||||
default_value = "-"
|
||||
type = "string"
|
Loading…
Reference in New Issue