@versatiles/container 1.2.4 → 1.2.5
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 +20 -17
- package/README.md +28 -119
- package/dist/index.d.ts +1 -1
- package/package.json +14 -13
- package/LICENSE.md +0 -24
package/LICENSE
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
This is free and unencumbered software released into the public domain.
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Anyone is free to copy, modify, publish, use, compile, sell, or
|
|
4
|
+
distribute this software, either in source code form or as a compiled
|
|
5
|
+
binary, for any purpose, commercial or non-commercial, and by any
|
|
6
|
+
means.
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
of this software
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
In jurisdictions that recognize copyright laws, the author or authors
|
|
9
|
+
of this software dedicate any and all copyright interest in the
|
|
10
|
+
software to the public domain. We make this dedication for the benefit
|
|
11
|
+
of the public at large and to the detriment of our heirs and
|
|
12
|
+
successors. We intend this dedication to be an overt act of
|
|
13
|
+
relinquishment in perpetuity of all present and future rights to this
|
|
14
|
+
software under copyright law.
|
|
11
15
|
|
|
12
|
-
|
|
13
|
-
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
20
|
+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
21
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
|
14
23
|
|
|
15
|
-
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
24
|
+
For more information, please refer to [unlicense.org](https://unlicense.org/)
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[](https://codecov.io/gh/versatiles-org/node-versatiles)
|
|
1
|
+
[](https://codecov.io/gh/versatiles-org/node-versatiles-container)
|
|
2
2
|
[](https://github.com/versatiles-org/node-versatiles-container/actions/workflows/ci.yml)
|
|
3
3
|
|
|
4
4
|
A client library for [VersaTiles containers](https://github.com/versatiles-org/versatiles-spec).
|
|
@@ -10,135 +10,44 @@ A client library for [VersaTiles containers](https://github.com/versatiles-org/v
|
|
|
10
10
|
# Usage Example
|
|
11
11
|
|
|
12
12
|
```js
|
|
13
|
-
import
|
|
14
|
-
import fs from
|
|
13
|
+
import { Container } from "@versatiles/container";
|
|
14
|
+
import fs from "fs";
|
|
15
15
|
|
|
16
|
-
const container = new
|
|
16
|
+
const container = new Container("https://example.org/planet.versatiles");
|
|
17
17
|
const header = await container.getHeader();
|
|
18
|
-
const tile = await container.getTileUncompressed(z,x,y);
|
|
19
|
-
fs.writeFileSync(
|
|
18
|
+
const tile = await container.getTileUncompressed(z, x, y);
|
|
19
|
+
fs.writeFileSync("tile." + header.tileFormat, tile);
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
# API
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
## Classes
|
|
27
|
-
|
|
28
|
-
### Class: `Container`<a id="class_container"></a>
|
|
29
|
-
|
|
30
|
-
The `VersaTiles` class is a wrapper around a `.versatiles` container file. It provides methods\
|
|
31
|
-
to access tile data, metadata, and other properties within the container. <sup><a href="https://github.com/versatiles-org/node-versatiles-container/blob/e484579058a7333a6228803147bb9314e45f51a4/src/index.ts#L73">\[src]</a></sup>
|
|
32
|
-
|
|
33
|
-
#### Constructor: `new Container(source, options)`
|
|
34
|
-
|
|
35
|
-
Constructs a new instance of the VersaTiles class. <sup><a href="https://github.com/versatiles-org/node-versatiles-container/blob/e484579058a7333a6228803147bb9314e45f51a4/src/index.ts#L94">\[src]</a></sup>
|
|
36
|
-
|
|
37
|
-
**Parameters:**
|
|
38
|
-
|
|
39
|
-
* <code>source: string | [Reader](#type_reader)</code>\
|
|
40
|
-
The data source for the tiles. This can be a URL starting with `http://` or `https://`,
|
|
41
|
-
a path to a local file, or a custom `Reader` function that reads data chunks based on offset and length.
|
|
42
|
-
* <code>options: [OpenOptions](#interface_openoptions)</code> (optional)\
|
|
43
|
-
Optional settings that configure tile handling.
|
|
44
|
-
|
|
45
|
-
#### Method: `getHeader()`
|
|
46
|
-
|
|
47
|
-
Asynchronously retrieves the header information from the `.versatiles` container. <sup><a href="https://github.com/versatiles-org/node-versatiles-container/blob/e484579058a7333a6228803147bb9314e45f51a4/src/index.ts#L116">\[src]</a></sup>
|
|
48
|
-
|
|
49
|
-
**Returns:** <code>Promise<[Header](#interface_header)></code>
|
|
50
|
-
|
|
51
|
-
#### Method: `getMetadata()`
|
|
52
|
-
|
|
53
|
-
Asynchronously retrieves the metadata associated with the `.versatiles` container.\
|
|
54
|
-
Metadata typically includes information about `vector_layers` for vector tiles.
|
|
55
|
-
If the container does not include metadata, this method returns `null`. <sup><a href="https://github.com/versatiles-org/node-versatiles-container/blob/e484579058a7333a6228803147bb9314e45f51a4/src/index.ts#L163">\[src]</a></sup>
|
|
56
|
-
|
|
57
|
-
**Returns:** <code>Promise\<undefined | string></code>
|
|
58
|
-
|
|
59
|
-
#### Method: `getTile(z, x, y)`
|
|
60
|
-
|
|
61
|
-
Asynchronously retrieves a specific tile's data as a Buffer. If the tile data is compressed as\
|
|
62
|
-
defined in the container header, the returned Buffer will contain the compressed data.
|
|
63
|
-
To obtain uncompressed data, use the `getTileUncompressed` method.
|
|
64
|
-
If the specified tile does not exist, the method returns `null`. <sup><a href="https://github.com/versatiles-org/node-versatiles-container/blob/e484579058a7333a6228803147bb9314e45f51a4/src/index.ts#L190">\[src]</a></sup>
|
|
65
|
-
|
|
66
|
-
**Parameters:**
|
|
67
|
-
|
|
68
|
-
* <code>z: number</code>\
|
|
69
|
-
The zoom level of the tile.
|
|
70
|
-
* <code>x: number</code>\
|
|
71
|
-
The x coordinate of the tile within its zoom level.
|
|
72
|
-
* <code>y: number</code>\
|
|
73
|
-
The y coordinate of the tile within its zoom level.
|
|
74
|
-
|
|
75
|
-
**Returns:** <code>Promise\<null | Buffer></code>
|
|
24
|
+
You can find a complete documentation of the API at
|
|
25
|
+
<https://versatiles.org/node-versatiles-container/>
|
|
76
26
|
|
|
77
|
-
|
|
27
|
+
## Dependency Graph
|
|
78
28
|
|
|
79
|
-
|
|
80
|
-
retrieves the compressed tile data using `getTile` and then decompresses it based on the
|
|
81
|
-
compression setting in the container header.
|
|
82
|
-
If the specified tile does not exist, the method returns `null`. <sup><a href="https://github.com/versatiles-org/node-versatiles-container/blob/e484579058a7333a6228803147bb9314e45f51a4/src/index.ts#L238">\[src]</a></sup>
|
|
83
|
-
|
|
84
|
-
**Parameters:**
|
|
85
|
-
|
|
86
|
-
* <code>z: number</code>\
|
|
87
|
-
The zoom level of the tile.
|
|
88
|
-
* <code>x: number</code>\
|
|
89
|
-
The x coordinate of the tile within its zoom level.
|
|
90
|
-
* <code>y: number</code>\
|
|
91
|
-
The y coordinate of the tile within its zoom level.
|
|
92
|
-
|
|
93
|
-
**Returns:** <code>Promise\<null | Buffer></code>
|
|
94
|
-
|
|
95
|
-
## Interfaces
|
|
96
|
-
|
|
97
|
-
### Interface: `Header`<a id="interface_header"></a>
|
|
98
|
-
|
|
99
|
-
```typescript
|
|
100
|
-
interface {
|
|
101
|
-
bbox: [number, number, number, number];
|
|
102
|
-
blockIndexLength: number;
|
|
103
|
-
blockIndexOffset: number;
|
|
104
|
-
magic: string;
|
|
105
|
-
metaLength: number;
|
|
106
|
-
metaOffset: number;
|
|
107
|
-
tileCompression: [Compression](#type_compression);
|
|
108
|
-
tileFormat: [Format](#type_format);
|
|
109
|
-
tileMime: string;
|
|
110
|
-
version: string;
|
|
111
|
-
zoomMax: number;
|
|
112
|
-
zoomMin: number;
|
|
113
|
-
}
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
### Interface: `OpenOptions`<a id="interface_openoptions"></a>
|
|
29
|
+
<!--- This chapter is generated automatically --->
|
|
117
30
|
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
31
|
+
```mermaid
|
|
32
|
+
flowchart TB
|
|
33
|
+
|
|
34
|
+
subgraph 0["src"]
|
|
35
|
+
1["index.ts"]
|
|
36
|
+
subgraph 2["lib"]
|
|
37
|
+
3["decompress.ts"]
|
|
38
|
+
4["reader_file.ts"]
|
|
39
|
+
5["reader_http.ts"]
|
|
40
|
+
6["interfaces.ts"]
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
1-->3
|
|
44
|
+
1-->4
|
|
45
|
+
1-->5
|
|
46
|
+
|
|
47
|
+
style 0 fill-opacity:0.2
|
|
48
|
+
style 2 fill-opacity:0.2
|
|
122
49
|
```
|
|
123
50
|
|
|
124
|
-
## Type Aliases
|
|
125
|
-
|
|
126
|
-
### Type: `Compression`<a id="type_compression"></a>
|
|
127
|
-
|
|
128
|
-
**Type:** <code>"br" | "gzip" | "raw"</code>
|
|
129
|
-
|
|
130
|
-
### Type: `Format`<a id="type_format"></a>
|
|
131
|
-
|
|
132
|
-
**Type:** <code>"avif" | "bin" | "geojson" | "jpg" | "json" | "pbf" | "png" | "svg" | "topojson" | "webp"</code>
|
|
133
|
-
|
|
134
|
-
### Type: `Reader`<a id="type_reader"></a>
|
|
135
|
-
|
|
136
|
-
**Type:** <code>(position: number, length: number) => Promise\<Buffer></code>
|
|
137
|
-
|
|
138
51
|
# License
|
|
139
52
|
|
|
140
53
|
[Unlicense](./LICENSE.md)
|
|
141
|
-
|
|
142
|
-
# Future work
|
|
143
|
-
|
|
144
|
-
This library could be extended to run in a web browser to read VersaTiles containers via `fetch`.
|
package/dist/index.d.ts
CHANGED
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
* ```
|
|
35
35
|
*/
|
|
36
36
|
import type { Block, Header, OpenOptions, Reader, TileIndex } from './lib/interfaces.js';
|
|
37
|
-
export type { Compression, Format, Header, OpenOptions, Reader } from './lib/interfaces.js';
|
|
37
|
+
export type { Block, Compression, Format, Header, OpenOptions, Reader, TileIndex } from './lib/interfaces.js';
|
|
38
38
|
/**
|
|
39
39
|
* The `VersaTiles` class is a wrapper around a `.versatiles` container file. It provides methods
|
|
40
40
|
* to access tile data, metadata, and other properties within the container.
|
package/package.json
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@versatiles/container",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.5",
|
|
4
4
|
"description": "A client library for reading VersaTiles containers",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"build": "rm -rf dist && tsc -p tsconfig.build.json",
|
|
6
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.json && npm run doc-graph",
|
|
7
7
|
"check": "npm run lint && npm run build && npm run test",
|
|
8
|
-
"doc": "
|
|
8
|
+
"doc": "npm run doc-typescript && npm run doc-graph",
|
|
9
|
+
"doc-typescript": "vrt doc-typescript -f html",
|
|
10
|
+
"doc-graph": "vrt deps-graph | vrt doc-insert README.md '## Dependency Graph'",
|
|
9
11
|
"lint": "eslint . --color",
|
|
10
|
-
"prepack": "npm run build
|
|
11
|
-
"release": "
|
|
12
|
+
"prepack": "npm run build",
|
|
13
|
+
"release": "vrt release-npm",
|
|
12
14
|
"test-coverage": "NODE_OPTIONS=--experimental-vm-modules jest --coverage",
|
|
13
15
|
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
|
|
14
|
-
"upgrade": "
|
|
16
|
+
"upgrade": "vrt deps-upgrade"
|
|
15
17
|
},
|
|
16
18
|
"files": [
|
|
17
19
|
"dist/**/*.js",
|
|
@@ -50,17 +52,16 @@
|
|
|
50
52
|
],
|
|
51
53
|
"devDependencies": {
|
|
52
54
|
"@types/jest": "^29.5.14",
|
|
53
|
-
"@types/node": "^22.13.
|
|
55
|
+
"@types/node": "^22.13.8",
|
|
54
56
|
"@typescript-eslint/eslint-plugin": "^8.22.0",
|
|
55
57
|
"@typescript-eslint/parser": "^8.22.0",
|
|
56
|
-
"@versatiles/release-tool": "^
|
|
57
|
-
"eslint": "^9.
|
|
58
|
+
"@versatiles/release-tool": "^2.2.4",
|
|
59
|
+
"eslint": "^9.21.0",
|
|
58
60
|
"jest": "^29.7.0",
|
|
59
|
-
"
|
|
60
|
-
"ts-jest": "^29.2.5",
|
|
61
|
+
"ts-jest": "^29.2.6",
|
|
61
62
|
"ts-node": "^10.9.2",
|
|
62
|
-
"tsx": "^4.19.
|
|
63
|
+
"tsx": "^4.19.3",
|
|
63
64
|
"typescript": "^5.7.3",
|
|
64
|
-
"typescript-eslint": "^8.
|
|
65
|
+
"typescript-eslint": "^8.25.0"
|
|
65
66
|
}
|
|
66
67
|
}
|
package/LICENSE.md
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
This is free and unencumbered software released into the public domain.
|
|
2
|
-
|
|
3
|
-
Anyone is free to copy, modify, publish, use, compile, sell, or
|
|
4
|
-
distribute this software, either in source code form or as a compiled
|
|
5
|
-
binary, for any purpose, commercial or non-commercial, and by any
|
|
6
|
-
means.
|
|
7
|
-
|
|
8
|
-
In jurisdictions that recognize copyright laws, the author or authors
|
|
9
|
-
of this software dedicate any and all copyright interest in the
|
|
10
|
-
software to the public domain. We make this dedication for the benefit
|
|
11
|
-
of the public at large and to the detriment of our heirs and
|
|
12
|
-
successors. We intend this dedication to be an overt act of
|
|
13
|
-
relinquishment in perpetuity of all present and future rights to this
|
|
14
|
-
software under copyright law.
|
|
15
|
-
|
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
-
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
20
|
-
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
21
|
-
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
22
|
-
OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
-
|
|
24
|
-
For more information, please refer to [unlicense.org](https://unlicense.org/)
|