drawland 0.0.0-stage → 0.2.0
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/LICENSE +662 -0
- package/README.md +50 -2
- package/cli.js +3 -0
- package/drawland.darwin-arm64.node +0 -0
- package/drawland.darwin-x64.node +0 -0
- package/drawland.linux-arm64-gnu.node +0 -0
- package/drawland.linux-x64-gnu.node +0 -0
- package/drawland.win32-x64-msvc.node +0 -0
- package/index.d.ts +12 -0
- package/index.js +21 -0
- package/native.d.ts +82 -0
- package/native.js +842 -0
- package/package.json +38 -4
package/README.md
CHANGED
|
@@ -1,3 +1,51 @@
|
|
|
1
|
-
#
|
|
1
|
+
# drawland for Node
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
OpenStreetMap drawn as layered pen-plotter SVGs. A short JavaScript
|
|
4
|
+
**profile** says what is drawn and how; `drawland` runs it at a place,
|
|
5
|
+
downloads what it reads (vector tiles, Overpass, elevation, fonts, datasets;
|
|
6
|
+
cached on disk) and returns one SVG in paper millimetres, a group per pen.
|
|
7
|
+
|
|
8
|
+

|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
npm install drawland
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
```js
|
|
15
|
+
const drawland = require('drawland') // or: import drawland from 'drawland'
|
|
16
|
+
|
|
17
|
+
// The built-in postcard, at a place.
|
|
18
|
+
const map = await drawland.draw({ lat: 37.8771, lng: -122.2562 })
|
|
19
|
+
map.save('berkeley.svg')
|
|
20
|
+
|
|
21
|
+
// A profile of your own, or a style saved from https://draw.land
|
|
22
|
+
const bologna = await drawland.draw({ profile: 'city-grain.js', address: 'Piazza Maggiore, Bologna', progress: true })
|
|
23
|
+
console.log(bologna.title, bologna.groups) // [{ id, strokes }]: a group is a pen
|
|
24
|
+
bologna.save('bologna.svg', { perLayer: true }) // and one file per pen
|
|
25
|
+
|
|
26
|
+
// A script's text; what it reads beside it comes from dir.
|
|
27
|
+
await drawland.draw({ script: 'output({ lat: 45.07, lng: 7.69 })\n…', dir: '.' })
|
|
28
|
+
|
|
29
|
+
// The graph only: no download.
|
|
30
|
+
const graph = drawland.graph({ profile: 'city-grain.js', lat: 45.07, lng: 7.69 })
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
The package has the command line too: `npx drawland map city-grain.js
|
|
34
|
+
--lat 37.8771 --lng -122.2562 -o map.svg`.
|
|
35
|
+
|
|
36
|
+
| | |
|
|
37
|
+
|---|---|
|
|
38
|
+
| `draw({ profile, script, dir, lat, lng, address, cache, offline, refresh, progress })` | Draw, off the main thread: a `Promise<Map>` |
|
|
39
|
+
| `graph({ … })` | The graph the profile builds, as an object |
|
|
40
|
+
| `map.svg`, `.title`, `.groups`, `.slices` | The whole SVG; the profile's title; `{ id, strokes }` per pen; `{ suffix, svg }` per sheet |
|
|
41
|
+
| `map.save(path, { perLayer, slices, decimals })` | Write the files; their paths |
|
|
42
|
+
| `map.files({ … })` | The same as `{ suffix, svg }` |
|
|
43
|
+
| `POSTCARD` | The built-in profile's script |
|
|
44
|
+
| `cli(argv)` | The command line; its exit code |
|
|
45
|
+
|
|
46
|
+
Prebuilt for macOS (arm64, x64), Linux (x64, arm64, glibc) and Windows (x64).
|
|
47
|
+
|
|
48
|
+
How to write a profile, every pattern and the full reference:
|
|
49
|
+
[draw.land/docs](https://draw.land/docs). Source:
|
|
50
|
+
[github.com/piLeoni/drawland](https://github.com/piLeoni/drawland).
|
|
51
|
+
AGPL-3.0-only.
|
package/cli.js
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { DrawOptions, ExportFiles, Group, Map, SvgFile } from './native'
|
|
2
|
+
|
|
3
|
+
export type { DrawOptions, ExportFiles, Group, Map, SvgFile }
|
|
4
|
+
|
|
5
|
+
/** Draw a profile at a place: a file (`profile`), a script's text (`script`), or the built-in postcard. */
|
|
6
|
+
export declare function draw(options?: DrawOptions): Promise<Map>
|
|
7
|
+
/** The graph a profile builds, as an object; no map data is downloaded. */
|
|
8
|
+
export declare function graph(options?: DrawOptions): Record<string, unknown>
|
|
9
|
+
/** The command line, `drawland map …`, on `argv` (without the program's name); the exit code. */
|
|
10
|
+
export declare function cli(argv: string[]): number
|
|
11
|
+
/** The built-in postcard's script: the profile drawn when none is given. */
|
|
12
|
+
export declare const POSTCARD: string
|
package/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// draw.land for Node: a profile and a place in, the layered pen-plotter SVG
|
|
2
|
+
// out, downloading and caching what the map reads.
|
|
3
|
+
//
|
|
4
|
+
// const drawland = require('drawland')
|
|
5
|
+
// const map = await drawland.draw({ profile: 'city-grain.js', lat: 37.8771, lng: -122.2562 })
|
|
6
|
+
// map.save('map.svg')
|
|
7
|
+
|
|
8
|
+
const native = require('./native.js')
|
|
9
|
+
|
|
10
|
+
/** The graph a profile builds, as an object; no map data is downloaded. */
|
|
11
|
+
function graph(options) {
|
|
12
|
+
return JSON.parse(native.graph(options))
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
module.exports = {
|
|
16
|
+
draw: native.draw,
|
|
17
|
+
graph,
|
|
18
|
+
cli: native.cli,
|
|
19
|
+
Map: native.Map,
|
|
20
|
+
POSTCARD: native.POSTCARD,
|
|
21
|
+
}
|
package/native.d.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/* auto-generated by NAPI-RS */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Which binding artifact the generated loader actually loaded: `'native'` for
|
|
6
|
+
* a native addon, otherwise the `platformArchABI` of the WASI flavor. Every
|
|
7
|
+
* flavor napi-rs can build is listed, because `NAPI_RS_NATIVE_LIBRARY_PATH`
|
|
8
|
+
* can point the loader at a WASI artifact this package does not build itself.
|
|
9
|
+
*/
|
|
10
|
+
export declare const __napiBindingTarget: 'native' | 'wasm32-wasi' | 'wasm32-wasip1'
|
|
11
|
+
|
|
12
|
+
/** A drawn map. */
|
|
13
|
+
export declare class Map {
|
|
14
|
+
/** The profile's `title(...)`, if it set one. */
|
|
15
|
+
get title(): string | null
|
|
16
|
+
/** The whole map as one layered SVG, in paper millimetres. */
|
|
17
|
+
get svg(): string
|
|
18
|
+
/** The groups in draw order, each a pen, with its stroke count. */
|
|
19
|
+
get groups(): Array<Group>
|
|
20
|
+
/** The sheets when the output is cut (`output.slices`), by name. */
|
|
21
|
+
get slices(): Array<SvgFile>
|
|
22
|
+
/** The files `options` asks for. */
|
|
23
|
+
files(options?: ExportFiles | undefined | null): Array<SvgFile>
|
|
24
|
+
/** Write `path`, and beside it a file per sheet or layer; the paths. */
|
|
25
|
+
save(path: string, options?: ExportFiles | undefined | null): Array<string>
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The command line, `drawland map …`, on `argv` (without the program's
|
|
30
|
+
* name); the exit code.
|
|
31
|
+
*/
|
|
32
|
+
export declare function cli(argv: Array<string>): number
|
|
33
|
+
|
|
34
|
+
/** Draw a profile at a place, off the main thread: a Promise of the map. */
|
|
35
|
+
export declare function draw(options?: DrawOptions | undefined | null): Promise<Map>
|
|
36
|
+
|
|
37
|
+
/** Where and what to draw, and how to download. */
|
|
38
|
+
export interface DrawOptions {
|
|
39
|
+
/** A profile file: a script (`.js`) or a saved graph (`.json`). */
|
|
40
|
+
profile?: string
|
|
41
|
+
/** A script's text, instead of a file. */
|
|
42
|
+
script?: string
|
|
43
|
+
/** Where a `script` reads beside it (datasets, styles its views name). */
|
|
44
|
+
dir?: string
|
|
45
|
+
lat?: number
|
|
46
|
+
lng?: number
|
|
47
|
+
/** Looked up with Nominatim; instead of `lat`/`lng`. */
|
|
48
|
+
address?: string
|
|
49
|
+
/** The response cache (default `cache`). */
|
|
50
|
+
cache?: string
|
|
51
|
+
offline?: boolean
|
|
52
|
+
refresh?: boolean
|
|
53
|
+
/** Paint the progress on stderr, as the command line does. */
|
|
54
|
+
progress?: boolean
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Which files to write. */
|
|
58
|
+
export interface ExportFiles {
|
|
59
|
+
/** One file per top-level layer as well: a file per pen. */
|
|
60
|
+
perLayer?: boolean
|
|
61
|
+
/** `"whole"`, `"slices"` or `"both"` (default), for a cut output. */
|
|
62
|
+
slices?: string
|
|
63
|
+
/** Coordinate decimals, 0 to 6. */
|
|
64
|
+
decimals?: number
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** The graph a profile builds, as JSON text: no map data is downloaded. */
|
|
68
|
+
export declare function graph(options?: DrawOptions | undefined | null): string
|
|
69
|
+
|
|
70
|
+
export interface Group {
|
|
71
|
+
id: string
|
|
72
|
+
strokes: number
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** The built-in postcard's script: the profile drawn when none is given. */
|
|
76
|
+
export declare const POSTCARD: string
|
|
77
|
+
|
|
78
|
+
export interface SvgFile {
|
|
79
|
+
/** `""` the whole map, `"-r1c1"` a sheet, `"-roads"` a layer. */
|
|
80
|
+
suffix: string
|
|
81
|
+
svg: string
|
|
82
|
+
}
|