@osmix/shared 0.0.7 → 0.0.10
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/CHANGELOG.md +18 -0
- package/dist/content-hasher.d.ts +28 -0
- package/dist/content-hasher.d.ts.map +1 -0
- package/dist/content-hasher.js +62 -0
- package/dist/content-hasher.js.map +1 -0
- package/dist/csv-parse-stream.d.ts +38 -0
- package/dist/csv-parse-stream.d.ts.map +1 -0
- package/dist/csv-parse-stream.js +157 -0
- package/dist/csv-parse-stream.js.map +1 -0
- package/dist/relation-kind.d.ts.map +1 -1
- package/dist/relation-kind.js +5 -3
- package/dist/relation-kind.js.map +1 -1
- package/dist/stream-to-bytes.js +2 -1
- package/dist/stream-to-bytes.js.map +1 -1
- package/dist/utils.d.ts +6 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +21 -0
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/content-hasher.ts +70 -0
- package/src/csv-parse-stream.ts +215 -0
- package/src/relation-kind.ts +5 -3
- package/src/stream-to-bytes.ts +1 -1
- package/src/utils.ts +20 -0
- package/test/csv-parse-stream.test.ts +74 -0
- package/dist/src/assert.d.ts +0 -24
- package/dist/src/assert.d.ts.map +0 -1
- package/dist/src/assert.js +0 -28
- package/dist/src/assert.js.map +0 -1
- package/dist/src/bbox-intersects.d.ts +0 -15
- package/dist/src/bbox-intersects.d.ts.map +0 -1
- package/dist/src/bbox-intersects.js +0 -24
- package/dist/src/bbox-intersects.js.map +0 -1
- package/dist/src/bytes-to-stream.d.ts +0 -18
- package/dist/src/bytes-to-stream.d.ts.map +0 -1
- package/dist/src/bytes-to-stream.js +0 -25
- package/dist/src/bytes-to-stream.js.map +0 -1
- package/dist/src/color.d.ts +0 -4
- package/dist/src/color.d.ts.map +0 -1
- package/dist/src/color.js +0 -33
- package/dist/src/color.js.map +0 -1
- package/dist/src/concat-bytes.d.ts +0 -5
- package/dist/src/concat-bytes.d.ts.map +0 -1
- package/dist/src/concat-bytes.js +0 -14
- package/dist/src/concat-bytes.js.map +0 -1
- package/dist/src/coordinates.d.ts +0 -28
- package/dist/src/coordinates.d.ts.map +0 -1
- package/dist/src/coordinates.js +0 -38
- package/dist/src/coordinates.js.map +0 -1
- package/dist/src/haversine-distance.d.ts +0 -16
- package/dist/src/haversine-distance.d.ts.map +0 -1
- package/dist/src/haversine-distance.js +0 -26
- package/dist/src/haversine-distance.js.map +0 -1
- package/dist/src/lineclip.d.ts +0 -2
- package/dist/src/lineclip.d.ts.map +0 -1
- package/dist/src/lineclip.js +0 -3
- package/dist/src/lineclip.js.map +0 -1
- package/dist/src/progress.d.ts +0 -42
- package/dist/src/progress.d.ts.map +0 -1
- package/dist/src/progress.js +0 -53
- package/dist/src/progress.js.map +0 -1
- package/dist/src/relation-kind.d.ts +0 -69
- package/dist/src/relation-kind.d.ts.map +0 -1
- package/dist/src/relation-kind.js +0 -375
- package/dist/src/relation-kind.js.map +0 -1
- package/dist/src/relation-multipolygon.d.ts +0 -43
- package/dist/src/relation-multipolygon.d.ts.map +0 -1
- package/dist/src/relation-multipolygon.js +0 -195
- package/dist/src/relation-multipolygon.js.map +0 -1
- package/dist/src/stream-to-bytes.d.ts +0 -18
- package/dist/src/stream-to-bytes.d.ts.map +0 -1
- package/dist/src/stream-to-bytes.js +0 -30
- package/dist/src/stream-to-bytes.js.map +0 -1
- package/dist/src/test/fixtures.d.ts +0 -36
- package/dist/src/test/fixtures.d.ts.map +0 -1
- package/dist/src/test/fixtures.js +0 -175
- package/dist/src/test/fixtures.js.map +0 -1
- package/dist/src/throttle.d.ts +0 -25
- package/dist/src/throttle.d.ts.map +0 -1
- package/dist/src/throttle.js +0 -34
- package/dist/src/throttle.js.map +0 -1
- package/dist/src/tile.d.ts +0 -34
- package/dist/src/tile.d.ts.map +0 -1
- package/dist/src/tile.js +0 -72
- package/dist/src/tile.js.map +0 -1
- package/dist/src/transform-bytes.d.ts +0 -24
- package/dist/src/transform-bytes.d.ts.map +0 -1
- package/dist/src/transform-bytes.js +0 -28
- package/dist/src/transform-bytes.js.map +0 -1
- package/dist/src/types.d.ts +0 -99
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/types.js +0 -9
- package/dist/src/types.js.map +0 -1
- package/dist/src/utils.d.ts +0 -30
- package/dist/src/utils.d.ts.map +0 -1
- package/dist/src/utils.js +0 -70
- package/dist/src/utils.js.map +0 -1
- package/dist/src/way-is-area.d.ts +0 -24
- package/dist/src/way-is-area.d.ts.map +0 -1
- package/dist/src/way-is-area.js +0 -104
- package/dist/src/way-is-area.js.map +0 -1
- package/dist/src/zigzag.d.ts +0 -33
- package/dist/src/zigzag.d.ts.map +0 -1
- package/dist/src/zigzag.js +0 -40
- package/dist/src/zigzag.js.map +0 -1
- package/dist/test/haversine-distance.test.d.ts +0 -2
- package/dist/test/haversine-distance.test.d.ts.map +0 -1
- package/dist/test/haversine-distance.test.js +0 -8
- package/dist/test/haversine-distance.test.js.map +0 -1
- package/dist/test/relation-kind.test.d.ts +0 -2
- package/dist/test/relation-kind.test.d.ts.map +0 -1
- package/dist/test/relation-kind.test.js +0 -367
- package/dist/test/relation-kind.test.js.map +0 -1
- package/dist/test/relation-multipolygon.test.d.ts +0 -2
- package/dist/test/relation-multipolygon.test.d.ts.map +0 -1
- package/dist/test/relation-multipolygon.test.js +0 -237
- package/dist/test/relation-multipolygon.test.js.map +0 -1
- package/dist/test/utils.test.d.ts +0 -2
- package/dist/test/utils.test.d.ts.map +0 -1
- package/dist/test/utils.test.js +0 -76
- package/dist/test/utils.test.js.map +0 -1
- package/dist/test/way-is-area.test.d.ts +0 -2
- package/dist/test/way-is-area.test.d.ts.map +0 -1
- package/dist/test/way-is-area.test.js +0 -31
- package/dist/test/way-is-area.test.js.map +0 -1
package/dist/src/tile.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* XYZ tile coordinate utilities.
|
|
3
|
-
*
|
|
4
|
-
* Provides conversions between geographic coordinates (lon/lat) and
|
|
5
|
-
* tile pixel coordinates for XYZ tiled map systems. Supports various
|
|
6
|
-
* tile sizes and zoom levels.
|
|
7
|
-
*
|
|
8
|
-
* @module
|
|
9
|
-
*/
|
|
10
|
-
import { pointToTileFraction } from "@mapbox/tilebelt";
|
|
11
|
-
const RADIANS_TO_DEGREES = 180 / Math.PI;
|
|
12
|
-
function tile2lon(x, z) {
|
|
13
|
-
return (x / 2 ** z) * 360 - 180;
|
|
14
|
-
}
|
|
15
|
-
function tile2lat(y, z) {
|
|
16
|
-
const n = Math.PI - (2 * Math.PI * y) / 2 ** z;
|
|
17
|
-
return RADIANS_TO_DEGREES * Math.atan(0.5 * (Math.exp(n) - Math.exp(-n)));
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Get the geographic bounding box of a tile.
|
|
21
|
-
* Returns [west, south, east, north].
|
|
22
|
-
*/
|
|
23
|
-
export function tileToBbox(tile) {
|
|
24
|
-
const [tx, ty, tz] = tile;
|
|
25
|
-
const n = tile2lat(ty, tz);
|
|
26
|
-
const s = tile2lat(ty + 1, tz);
|
|
27
|
-
const e = tile2lon(tx + 1, tz);
|
|
28
|
-
const w = tile2lon(tx, tz);
|
|
29
|
-
return [w, s, e, n];
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Convert a bounding box from geographic coordinates to tile pixel coordinates.
|
|
33
|
-
*/
|
|
34
|
-
export function bboxToTilePx(bbox, tile, tileSize = 256) {
|
|
35
|
-
const [minX, minY] = llToTilePx([bbox[0], bbox[3]], tile, tileSize);
|
|
36
|
-
const [maxX, maxY] = llToTilePx([bbox[2], bbox[1]], tile, tileSize);
|
|
37
|
-
return [minX, minY, maxX, maxY];
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Convert a geographic coordinate to tile pixel coordinates.
|
|
41
|
-
* Returns [x, y] in pixels relative to the top-left of the tile.
|
|
42
|
-
*/
|
|
43
|
-
export function llToTilePx(ll, tile, tileSize = 256) {
|
|
44
|
-
const [tx, ty, tz] = tile;
|
|
45
|
-
const tf = pointToTileFraction(ll[0], ll[1], tz);
|
|
46
|
-
const x = (tf[0] - tx) * tileSize;
|
|
47
|
-
const y = (tf[1] - ty) * tileSize;
|
|
48
|
-
return [x, y];
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Convert tile pixel coordinates to geographic coordinates.
|
|
52
|
-
*/
|
|
53
|
-
export function tilePxToLonLat(px, tile, tileSize = 256) {
|
|
54
|
-
const [tx, ty, tz] = tile;
|
|
55
|
-
const lon = tile2lon(px[0] / tileSize + tx, tz);
|
|
56
|
-
const lat = tile2lat(px[1] / tileSize + ty, tz);
|
|
57
|
-
return [lon, lat];
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Clamp a pixel coordinate to the tile bounds and round to the nearest integer. Useful for converting a floating point pixel
|
|
61
|
-
* coordinate to a the exact tile pixel it is contained by.
|
|
62
|
-
*/
|
|
63
|
-
export function clampAndRoundPx(px, tileSizeOrBbox) {
|
|
64
|
-
const [minX, minY, maxX, maxY] = typeof tileSizeOrBbox === "number"
|
|
65
|
-
? [0, 0, tileSizeOrBbox, tileSizeOrBbox]
|
|
66
|
-
: tileSizeOrBbox;
|
|
67
|
-
return [
|
|
68
|
-
Math.max(minX, Math.min(maxX, Math.round(px[0]))),
|
|
69
|
-
Math.max(minY, Math.min(maxY, Math.round(px[1]))),
|
|
70
|
-
];
|
|
71
|
-
}
|
|
72
|
-
//# sourceMappingURL=tile.js.map
|
package/dist/src/tile.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tile.js","sourceRoot":"","sources":["../../src/tile.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAGtD,MAAM,kBAAkB,GAAG,GAAG,GAAG,IAAI,CAAC,EAAE,CAAA;AAExC,SAAS,QAAQ,CAAC,CAAS,EAA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AM,EACN,cAAkC;IAElC,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,GAC7B,OAAO,cAAc,KAAK,QAAQ;QACjC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,cAAc,EAAE,cAAc,CAAC;QACxC,CAAC,CAAC,cAAc,CAAA;IAClB,OAAO;QACN,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACjD,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KACjD,CAAA;AACF,CAAC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Transform stream utilities.
|
|
3
|
-
*
|
|
4
|
-
* Helpers for piping byte arrays through TransformStreams (e.g., compression).
|
|
5
|
-
*
|
|
6
|
-
* @module
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Pipe a byte array through a TransformStream and return the result.
|
|
10
|
-
*
|
|
11
|
-
* Useful for applying compression/decompression or other transformations
|
|
12
|
-
* to byte data using the Web Streams API.
|
|
13
|
-
*
|
|
14
|
-
* @param bytes - The input bytes.
|
|
15
|
-
* @param transformStream - The transform to apply (e.g., CompressionStream).
|
|
16
|
-
* @returns A Promise resolving to the transformed bytes.
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```ts
|
|
20
|
-
* const compressed = await transformBytes(data, new CompressionStream('gzip'))
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
export declare function transformBytes(bytes: Uint8Array<ArrayBuffer>, transformStream: TransformStream<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>): Promise<Uint8Array<ArrayBuffer>>;
|
|
24
|
-
//# sourceMappingURL=transform-bytes.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transform-bytes.d.ts","sourceRoot":"","sources":["../../src/transform-bytes.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,cAAc,CACnC,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,EAC9B,eAAe,EAAE,eAAe,CAC/B,UAAU,CAAC,WAAW,CAAC,EACvB,UAAU,CAAC,WAAW,CAAC,CACvB,GACC,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAElC"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Transform stream utilities.
|
|
3
|
-
*
|
|
4
|
-
* Helpers for piping byte arrays through TransformStreams (e.g., compression).
|
|
5
|
-
*
|
|
6
|
-
* @module
|
|
7
|
-
*/
|
|
8
|
-
import { bytesToStream } from "./bytes-to-stream";
|
|
9
|
-
import { streamToBytes } from "./stream-to-bytes";
|
|
10
|
-
/**
|
|
11
|
-
* Pipe a byte array through a TransformStream and return the result.
|
|
12
|
-
*
|
|
13
|
-
* Useful for applying compression/decompression or other transformations
|
|
14
|
-
* to byte data using the Web Streams API.
|
|
15
|
-
*
|
|
16
|
-
* @param bytes - The input bytes.
|
|
17
|
-
* @param transformStream - The transform to apply (e.g., CompressionStream).
|
|
18
|
-
* @returns A Promise resolving to the transformed bytes.
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```ts
|
|
22
|
-
* const compressed = await transformBytes(data, new CompressionStream('gzip'))
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
export async function transformBytes(bytes, transformStream) {
|
|
26
|
-
return streamToBytes(bytesToStream(bytes).pipeThrough(transformStream));
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=transform-bytes.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transform-bytes.js","sourceRoot":"","sources":["../../src/transform-bytes.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAEjD;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CACnC,KAA8B,EAC9B,eAGC;IAED,OAAO,aAAa,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC,CAAA;AACxE,CAAC"}
|
package/dist/src/types.d.ts
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared type definitions used across all Osmix packages.
|
|
3
|
-
*
|
|
4
|
-
* Includes geographic primitives (LonLat, Bbox), tile coordinates,
|
|
5
|
-
* and core OSM entity types (Node, Way, Relation).
|
|
6
|
-
*
|
|
7
|
-
* @module
|
|
8
|
-
*/
|
|
9
|
-
/** Geographic coordinate as [longitude, latitude] tuple. */
|
|
10
|
-
export type LonLat = [lon: number, lat: number];
|
|
11
|
-
/** 2D pixel or cartesian coordinate as [x, y] tuple. */
|
|
12
|
-
export type XY = [x: number, y: number];
|
|
13
|
-
/** Geographic coordinate as object with lon/lat properties. */
|
|
14
|
-
export interface ILonLat {
|
|
15
|
-
lon: number;
|
|
16
|
-
lat: number;
|
|
17
|
-
}
|
|
18
|
-
/** XYZ tile coordinate as [x, y, z] tuple. */
|
|
19
|
-
export type Tile = [x: number, y: number, z: number];
|
|
20
|
-
/**
|
|
21
|
-
* Project LonLat to pixels
|
|
22
|
-
*/
|
|
23
|
-
export type LonLatToPixel = (ll: LonLat, zoom: number) => XY;
|
|
24
|
-
export type LonLatToTilePixel = (ll: LonLat, z: number, extent: number) => XY;
|
|
25
|
-
export type Rgba = [r: number, g: number, b: number, a: number] | Uint8ClampedArray;
|
|
26
|
-
/**
|
|
27
|
-
* A bounding box in the format [minLon, minLat, maxLon, maxLat].
|
|
28
|
-
* GeoJSON.BBox allows for 3D bounding boxes, but we use tools that expect 2D bounding boxes.
|
|
29
|
-
*/
|
|
30
|
-
export type GeoBbox2D = [
|
|
31
|
-
minLon: number,
|
|
32
|
-
minLat: number,
|
|
33
|
-
maxLon: number,
|
|
34
|
-
maxLat: number
|
|
35
|
-
];
|
|
36
|
-
/**
|
|
37
|
-
* A pixel bounding box in the format [minX, minY, maxX, maxY]. Note: minY is north. maxY is south.
|
|
38
|
-
*/
|
|
39
|
-
export type TilePxBbox = [
|
|
40
|
-
minX: number,
|
|
41
|
-
minY: number,
|
|
42
|
-
maxX: number,
|
|
43
|
-
maxY: number
|
|
44
|
-
];
|
|
45
|
-
/**
|
|
46
|
-
* Shared OSM Types
|
|
47
|
-
*/
|
|
48
|
-
export type OsmEntityType = "node" | "way" | "relation";
|
|
49
|
-
export interface OsmInfoParsed {
|
|
50
|
-
version?: number;
|
|
51
|
-
timestamp?: number;
|
|
52
|
-
changeset?: number;
|
|
53
|
-
uid?: number;
|
|
54
|
-
user_sid?: number;
|
|
55
|
-
visible?: boolean;
|
|
56
|
-
user?: string;
|
|
57
|
-
}
|
|
58
|
-
export interface OsmTags {
|
|
59
|
-
[key: string]: string | number;
|
|
60
|
-
}
|
|
61
|
-
interface IOsmEntity {
|
|
62
|
-
id: number;
|
|
63
|
-
info?: OsmInfoParsed;
|
|
64
|
-
tags?: OsmTags;
|
|
65
|
-
}
|
|
66
|
-
export interface OsmNode extends IOsmEntity, ILonLat {
|
|
67
|
-
}
|
|
68
|
-
export interface OsmWay extends IOsmEntity {
|
|
69
|
-
refs: number[];
|
|
70
|
-
}
|
|
71
|
-
export interface OsmRelationMember {
|
|
72
|
-
type: OsmEntityType;
|
|
73
|
-
ref: number;
|
|
74
|
-
role?: string;
|
|
75
|
-
}
|
|
76
|
-
export interface OsmRelation extends IOsmEntity {
|
|
77
|
-
members: OsmRelationMember[];
|
|
78
|
-
}
|
|
79
|
-
export type OsmEntity = OsmNode | OsmWay | OsmRelation;
|
|
80
|
-
export interface OsmEntityTypeMap extends Record<OsmEntityType, IOsmEntity> {
|
|
81
|
-
node: OsmNode;
|
|
82
|
-
way: OsmWay;
|
|
83
|
-
relation: OsmRelation;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Semantic kinds of OSM relations based on their type tag and structure.
|
|
87
|
-
*/
|
|
88
|
-
export type RelationKind = "area" | "line" | "point" | "logic" | "super";
|
|
89
|
-
/**
|
|
90
|
-
* Metadata about a relation kind, including expected roles and whether member order matters.
|
|
91
|
-
*/
|
|
92
|
-
export interface RelationKindMetadata {
|
|
93
|
-
kind: RelationKind;
|
|
94
|
-
expectedRoles?: string[];
|
|
95
|
-
orderMatters: boolean;
|
|
96
|
-
description: string;
|
|
97
|
-
}
|
|
98
|
-
export {};
|
|
99
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/src/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,4DAA4D;AAC5D,MAAM,MAAM,MAAM,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,CAAA;AAC/C,wDAAwD;AACxD,MAAM,MAAM,EAAE,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,CAAA;AAEvC,+DAA+D;AAC/D,MAAM,WAAW,OAAO;IACvB,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;CACX;AACD,8CAA8C;AAC9C,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,CAAA;AAEpD;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE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AAEvD,MAAM,WAAW,MAAO,SAAQ,UAAU;IAEzC,IAAI,EAAE,MAAM,EAAE,CAAA;CACd;AAED,MAAM,WAAW,iBAAiB;IACjC,IAAI,EAAE,aAAa,CAAA;IACnB,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,CAAC,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,WAAY,SAAQ,UAAU;IAC9C,OAAO,EAAE,iBAAiB,EAAE,CAAA;CAC5B;AAED,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,WAAW,CAAA;AAEtD,MAAM,WAAW,gBAAiB,SAAQ,MAAM,CAAC,aAAa,EAAE,UAAU,CAAC;IAC1E,IAAI,EAAE,OAAO,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;IACX,QAAQ,EAAE,WAAW,CAAA;CACrB;AAED;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,CAAA;AAExE;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC,IAAI,EAAE,YAAY,CAAA;IAClB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAA;IACxB,YAAY,EAAE,OAAO,CAAA;IACrB,WAAW,EAAE,MAAM,CAAA;CACnB"}
|
package/dist/src/types.js
DELETED
package/dist/src/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
|
package/dist/src/utils.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* General OSM entity utilities.
|
|
3
|
-
*
|
|
4
|
-
* Provides type guards, equality checks, and type detection for OSM entities.
|
|
5
|
-
* Uses deep equality checking for tags, info, and entity-specific properties.
|
|
6
|
-
*
|
|
7
|
-
* @module
|
|
8
|
-
*/
|
|
9
|
-
import type { OsmEntity, OsmEntityType, OsmNode, OsmRelation, OsmWay } from "./types";
|
|
10
|
-
/** Type guard: check if entity is a Node. */
|
|
11
|
-
export declare function isNode(entity: OsmEntity): entity is OsmNode;
|
|
12
|
-
/** Check if two nodes are equal (position, tags, and info). */
|
|
13
|
-
export declare function isNodeEqual(a: OsmNode, b: OsmNode): boolean;
|
|
14
|
-
/** Type guard: check if entity is a Way. */
|
|
15
|
-
export declare function isWay(entity: OsmEntity): entity is OsmWay;
|
|
16
|
-
/** Type guard: check if entity is a Relation. */
|
|
17
|
-
export declare function isRelation(entity: OsmEntity): entity is OsmRelation;
|
|
18
|
-
/** Check if two ways are equal (refs, tags, and info). */
|
|
19
|
-
export declare function isWayEqual(a: OsmWay, b: OsmWay): boolean;
|
|
20
|
-
/** Check if two relations are equal (members, tags, and info). */
|
|
21
|
-
export declare function isRelationEqual(a: OsmRelation, b: OsmRelation): boolean;
|
|
22
|
-
/** Check if two entities have equal properties (type-aware comparison). */
|
|
23
|
-
export declare function entityPropertiesEqual(a: OsmEntity, b: OsmEntity): boolean;
|
|
24
|
-
/** Get the entity type ("node", "way", or "relation") for an entity. */
|
|
25
|
-
export declare function getEntityType(entity: OsmEntity): OsmEntityType;
|
|
26
|
-
/**
|
|
27
|
-
* Check if a relation is a multipolygon relation.
|
|
28
|
-
*/
|
|
29
|
-
export declare function isMultipolygonRelation(relation: OsmRelation): boolean;
|
|
30
|
-
//# sourceMappingURL=utils.d.ts.map
|
package/dist/src/utils.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EACX,SAAS,EACT,aAAa,EACb,OAAO,EACP,WAAW,EACX,MAAM,EACN,MAAM,SAAS,CAAA;AAShB,6CAA6C;AAC7C,wBAAgB,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,IAAI,OAAO,CAE3D;AAED,+DAA+D;AAC/D,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,WAEjD;AAED,4CAA4C;AAC5C,wBAAgB,KAAK,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,IAAI,MAAM,CAEzD;AAED,iDAAiD;AACjD,wBAAgB,UAAU,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,IAAI,WAAW,CAEnE;AAED,0DAA0D;AAC1D,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,WAE9C;AAED,kEAAkE;AAClE,wBAAgB,eAAe,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,WAE7D;AAED,2EAA2E;AAC3E,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,WAO/D;AAED,wEAAwE;AACxE,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,GAAG,aAAa,CAK9D;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,WAAW,GAAG,OAAO,CAErE"}
|
package/dist/src/utils.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* General OSM entity utilities.
|
|
3
|
-
*
|
|
4
|
-
* Provides type guards, equality checks, and type detection for OSM entities.
|
|
5
|
-
* Uses deep equality checking for tags, info, and entity-specific properties.
|
|
6
|
-
*
|
|
7
|
-
* @module
|
|
8
|
-
*/
|
|
9
|
-
import { dequal } from "dequal/lite";
|
|
10
|
-
/**
|
|
11
|
-
* Check if two entities have equal tags and info.
|
|
12
|
-
*/
|
|
13
|
-
function isTagsAndInfoEqual(a, b) {
|
|
14
|
-
return dequal(a.tags, b.tags) && dequal(a.info, b.info);
|
|
15
|
-
}
|
|
16
|
-
/** Type guard: check if entity is a Node. */
|
|
17
|
-
export function isNode(entity) {
|
|
18
|
-
return "lon" in entity && "lat" in entity;
|
|
19
|
-
}
|
|
20
|
-
/** Check if two nodes are equal (position, tags, and info). */
|
|
21
|
-
export function isNodeEqual(a, b) {
|
|
22
|
-
return a.lat === b.lat && a.lon === b.lon && isTagsAndInfoEqual(a, b);
|
|
23
|
-
}
|
|
24
|
-
/** Type guard: check if entity is a Way. */
|
|
25
|
-
export function isWay(entity) {
|
|
26
|
-
return "refs" in entity;
|
|
27
|
-
}
|
|
28
|
-
/** Type guard: check if entity is a Relation. */
|
|
29
|
-
export function isRelation(entity) {
|
|
30
|
-
return "members" in entity;
|
|
31
|
-
}
|
|
32
|
-
/** Check if two ways are equal (refs, tags, and info). */
|
|
33
|
-
export function isWayEqual(a, b) {
|
|
34
|
-
return dequal(a.refs, b.refs) && isTagsAndInfoEqual(a, b);
|
|
35
|
-
}
|
|
36
|
-
/** Check if two relations are equal (members, tags, and info). */
|
|
37
|
-
export function isRelationEqual(a, b) {
|
|
38
|
-
return dequal(a.members, b.members) && isTagsAndInfoEqual(a, b);
|
|
39
|
-
}
|
|
40
|
-
/** Check if two entities have equal properties (type-aware comparison). */
|
|
41
|
-
export function entityPropertiesEqual(a, b) {
|
|
42
|
-
if (!dequal(a.tags, b.tags))
|
|
43
|
-
return false;
|
|
44
|
-
if (!dequal(a.info, b.info))
|
|
45
|
-
return false;
|
|
46
|
-
if (isNode(a) && isNode(b))
|
|
47
|
-
return isNodeEqual(a, b);
|
|
48
|
-
if (isWay(a) && isWay(b))
|
|
49
|
-
return isWayEqual(a, b);
|
|
50
|
-
if (isRelation(a) && isRelation(b))
|
|
51
|
-
return isRelationEqual(a, b);
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
/** Get the entity type ("node", "way", or "relation") for an entity. */
|
|
55
|
-
export function getEntityType(entity) {
|
|
56
|
-
if (isNode(entity))
|
|
57
|
-
return "node";
|
|
58
|
-
if (isWay(entity))
|
|
59
|
-
return "way";
|
|
60
|
-
if (isRelation(entity))
|
|
61
|
-
return "relation";
|
|
62
|
-
throw Error("Unknown entity type");
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Check if a relation is a multipolygon relation.
|
|
66
|
-
*/
|
|
67
|
-
export function isMultipolygonRelation(relation) {
|
|
68
|
-
return relation.tags?.["type"] === "multipolygon";
|
|
69
|
-
}
|
|
70
|
-
//# sourceMappingURL=utils.js.map
|
package/dist/src/utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AASpC;;GAEG;AACH,SAAS,kBAAkB,CAAC,CAAY,EAAE,CAAY;IACrD,OAAO,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAA;AACxD,CAAC;AAED,6CAA6C;AAC7C,MAAM,UAAU,MAAM,CAAC,MAAiB;IACvC,OAAO,KAAK,IAAI,MAAM,IAAI,KAAK,IAAI,MAAM,CAAA;AAC1C,CAAC;AAED,+DAA+D;AAC/D,MAAM,UAAU,WAAW,CAAC,CAAU,EAAE,CAAU;IACjD,OAAO,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,IAAI,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;AACtE,CAAC;AAED,4CAA4C;AAC5C,MAAM,UAAU,KAAK,CAAC,MAAiB;IACtC,OAAO,MAAM,IAAI,MAAM,CAAA;AACxB,CAAC;AAED,iDAAiD;AACjD,MAAM,UAAU,UAAU,CAAC,MAAiB;IAC3C,OAAO,SAAS,IAAI,MAAM,CAAA;AAC3B,CAAC;AAED,0DAA0D;AAC1D,MAAM,UAAU,UAAU,CAAC,CAAS,EAAE,CAAS;IAC9C,OAAO,MAAM,CAAC,CAAC,CAA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CAAC,CAAA;AACnC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,QAAqB;IAC3D,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,KAAK,cAAc,CAAA;AAClD,CAAC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Area detection for OSM ways.
|
|
3
|
-
*
|
|
4
|
-
* Implements the OSM wiki heuristics for determining whether a closed way
|
|
5
|
-
* should be rendered as an area (polygon) or a closed linear feature.
|
|
6
|
-
*
|
|
7
|
-
* @see https://wiki.openstreetmap.org/wiki/Key:area
|
|
8
|
-
* @see https://wiki.openstreetmap.org/wiki/Overpass_turbo/Polygon_Features
|
|
9
|
-
*
|
|
10
|
-
* @module
|
|
11
|
-
*/
|
|
12
|
-
import type { OsmWay } from "./types";
|
|
13
|
-
/**
|
|
14
|
-
* Determine if a way is an area based on its tags and nodes.
|
|
15
|
-
*
|
|
16
|
-
* This function implements the logic described in the OSM wiki:
|
|
17
|
-
* https://wiki.openstreetmap.org/wiki/Key:area
|
|
18
|
-
* https://wiki.openstreetmap.org/wiki/Overpass_turbo/Polygon_Features
|
|
19
|
-
*
|
|
20
|
-
* @param way - The way to check.
|
|
21
|
-
* @returns `true` if the way is an area, `false` otherwise.
|
|
22
|
-
*/
|
|
23
|
-
export declare function wayIsArea(way?: OsmWay): boolean;
|
|
24
|
-
//# sourceMappingURL=way-is-area.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"way-is-area.d.ts","sourceRoot":"","sources":["../../src/way-is-area.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAqDrC;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CA+B/C"}
|
package/dist/src/way-is-area.js
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Area detection for OSM ways.
|
|
3
|
-
*
|
|
4
|
-
* Implements the OSM wiki heuristics for determining whether a closed way
|
|
5
|
-
* should be rendered as an area (polygon) or a closed linear feature.
|
|
6
|
-
*
|
|
7
|
-
* @see https://wiki.openstreetmap.org/wiki/Key:area
|
|
8
|
-
* @see https://wiki.openstreetmap.org/wiki/Overpass_turbo/Polygon_Features
|
|
9
|
-
*
|
|
10
|
-
* @module
|
|
11
|
-
*/
|
|
12
|
-
/**
|
|
13
|
-
* Tags that imply an area unless their value is exactly "no"
|
|
14
|
-
*/
|
|
15
|
-
const IMPLIED_ANY_VALUE_BUT_NO = new Set([
|
|
16
|
-
"amenity",
|
|
17
|
-
"boundary",
|
|
18
|
-
"building",
|
|
19
|
-
"building:part",
|
|
20
|
-
"craft",
|
|
21
|
-
// "golf", Seeing a lot of golf=cartpath which is not an area
|
|
22
|
-
"historic",
|
|
23
|
-
"indoor",
|
|
24
|
-
"landuse",
|
|
25
|
-
"leisure",
|
|
26
|
-
"military",
|
|
27
|
-
"office",
|
|
28
|
-
"place",
|
|
29
|
-
"public_transport",
|
|
30
|
-
"ruins",
|
|
31
|
-
"shop",
|
|
32
|
-
"tourism",
|
|
33
|
-
]);
|
|
34
|
-
/**
|
|
35
|
-
* Tags that imply an area only for these specific values
|
|
36
|
-
*/
|
|
37
|
-
const INCLUDED_VALUE_TAGS = {
|
|
38
|
-
barrier: new Set([
|
|
39
|
-
"city_wall",
|
|
40
|
-
"ditch",
|
|
41
|
-
"hedge",
|
|
42
|
-
"retaining_wall",
|
|
43
|
-
"wall",
|
|
44
|
-
"spikes",
|
|
45
|
-
]),
|
|
46
|
-
highway: new Set(["services", "rest_area", "escape", "elevator"]),
|
|
47
|
-
power: new Set(["plant", "substation", "generator", "transformer"]),
|
|
48
|
-
railway: new Set(["station", "turntable", "roundhouse", "platform"]),
|
|
49
|
-
waterway: new Set(["riverbank", "dock", "boatyard", "dam"]),
|
|
50
|
-
};
|
|
51
|
-
/**
|
|
52
|
-
* Tags that imply an area unless the value is in this exclusion list
|
|
53
|
-
*/
|
|
54
|
-
const EXCLUDED_VALUE_TAGS = {
|
|
55
|
-
aeroway: new Set(["no", "taxiway"]),
|
|
56
|
-
"area:highway": new Set(["no"]),
|
|
57
|
-
man_made: new Set(["no", "cutline", "embankment", "pipeline"]),
|
|
58
|
-
natural: new Set(["no", "coastline", "cliff", "ridge", "arete", "tree_row"]),
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* Determine if a way is an area based on its tags and nodes.
|
|
62
|
-
*
|
|
63
|
-
* This function implements the logic described in the OSM wiki:
|
|
64
|
-
* https://wiki.openstreetmap.org/wiki/Key:area
|
|
65
|
-
* https://wiki.openstreetmap.org/wiki/Overpass_turbo/Polygon_Features
|
|
66
|
-
*
|
|
67
|
-
* @param way - The way to check.
|
|
68
|
-
* @returns `true` if the way is an area, `false` otherwise.
|
|
69
|
-
*/
|
|
70
|
-
export function wayIsArea(way) {
|
|
71
|
-
if (!way)
|
|
72
|
-
return false;
|
|
73
|
-
const { refs, tags } = way;
|
|
74
|
-
if (refs.length < 3)
|
|
75
|
-
return false;
|
|
76
|
-
if (refs[0] !== refs[refs.length - 1])
|
|
77
|
-
return false;
|
|
78
|
-
// End refs are equal, no tags, assume it is an area.
|
|
79
|
-
if (!tags || Object.keys(tags).length === 0)
|
|
80
|
-
return true;
|
|
81
|
-
// Explicit override
|
|
82
|
-
if ("area" in tags)
|
|
83
|
-
return tags["area"] !== "no";
|
|
84
|
-
// Tags that count if value is NOT "no"
|
|
85
|
-
for (const key of IMPLIED_ANY_VALUE_BUT_NO) {
|
|
86
|
-
const v = tags[key];
|
|
87
|
-
if (v && v !== "no")
|
|
88
|
-
return true;
|
|
89
|
-
}
|
|
90
|
-
// Tags that are area only for INCLUDED values
|
|
91
|
-
for (const [key, included] of Object.entries(INCLUDED_VALUE_TAGS)) {
|
|
92
|
-
const v = tags[key];
|
|
93
|
-
if (v && included.has(`${v}`))
|
|
94
|
-
return true;
|
|
95
|
-
}
|
|
96
|
-
// Tags that are area unless value is excluded
|
|
97
|
-
for (const [key, excluded] of Object.entries(EXCLUDED_VALUE_TAGS)) {
|
|
98
|
-
const v = tags[key];
|
|
99
|
-
if (v && !excluded.has(`${v}`))
|
|
100
|
-
return true;
|
|
101
|
-
}
|
|
102
|
-
return false;
|
|
103
|
-
}
|
|
104
|
-
//# sourceMappingURL=way-is-area.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"way-is-area.js","sourceRoot":"","sources":["../../src/way-is-area.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH;;GAEG;AACH,MAAM,wBAAwB,GAAG,IAAI,GAAG,CAAC;IACxC,SAAS;IACT,UAAU;IACV,UAAU;IACV,eAAe;IACf,OAAO;IACP,8DAA8D;IAC9D,UAAU;IACV,QAAQ;IACR,SAAS;IACT,SAAS;IACT,UAAU;IACV,QAAQ;IACR,OAAO;IACP,kBAAkB;IAClB,OAAO;IACP,MAAM;IACN,SAAS;CACT,CAAC,CAAA;AAEF;;GAEG;AACH,MAAM,mBAAmB,GAAG;IAC3B,OAAO,EAAE,IAAI,GAAG,CAAC;QAChB,WAAW;QACX,OAAO;QACP,OAAO;QACP,gBAAgB;QAChB,MAAM;QACN,QAAQ;KACR,CAAC;IACF,OAAO,EAAE,IAAI,GAAG,CAAC,CAAC,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;IACjE,KAAK,EAAE,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC;IACnE,OAAO,EAAE,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;IACpE,QAAQ,EAAE,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;CAClD,C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,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,mBAAmB,CAAC,EAAE,CAAC;QACnE,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAA;QACnB,IAAI,CAAC,IAAI,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YAAE,OAAO,IAAI,CAAA;IAC3C,CAAC;IAED,8CAA8C;IAC9C,KAAK,MAAM,CAAC,GAAG,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,mBAAmB,CAAC,EAAE,CAAC;QACnE,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAA;QACnB,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YAAE,OAAO,IAAI,CAAA;IAC5C,CAAC;IAED,OAAO,KAAK,CAAA;AACb,CAAC"}
|
package/dist/src/zigzag.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Zigzag encoding/decoding for protobuf-style varints.
|
|
3
|
-
*
|
|
4
|
-
* Zigzag encoding converts signed integers to unsigned by interleaving
|
|
5
|
-
* negative and positive values: 0, -1, 1, -2, 2, ... This allows efficient
|
|
6
|
-
* varint encoding of small negative numbers.
|
|
7
|
-
*
|
|
8
|
-
* @module
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* Zigzag encode a number using arithmetic operations.
|
|
12
|
-
* This supports the full safe integer range (up to Number.MAX_SAFE_INTEGER).
|
|
13
|
-
* Formula: n < 0 ? -2*n - 1 : 2*n
|
|
14
|
-
*
|
|
15
|
-
* Used for encoding IDs in vector tiles to convert negative IDs to positive numbers
|
|
16
|
-
* for unsigned varint encoding.
|
|
17
|
-
*/
|
|
18
|
-
export declare function zigzag(num: number): number;
|
|
19
|
-
/**
|
|
20
|
-
* Zigzag encode using bitwise operations (for geometry deltas only).
|
|
21
|
-
* This is faster but limited to 32-bit signed integers.
|
|
22
|
-
* Used for small coordinate deltas in geometry encoding.
|
|
23
|
-
*/
|
|
24
|
-
export declare function zigzag32(num: number): number;
|
|
25
|
-
/**
|
|
26
|
-
* Decode zigzag-encoded number back to original value.
|
|
27
|
-
* Zigzag encoding is used to convert negative IDs to positive numbers for unsigned varint
|
|
28
|
-
* encoding in vector tiles. Uses arithmetic-based decoding to support the full safe integer range.
|
|
29
|
-
*
|
|
30
|
-
* Formula: (encoded & 1) === 1 ? -(encoded + 1) / 2 : encoded / 2
|
|
31
|
-
*/
|
|
32
|
-
export declare function decodeZigzag(encoded: number): number;
|
|
33
|
-
//# sourceMappingURL=zigzag.d.ts.map
|
package/dist/src/zigzag.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"zigzag.d.ts","sourceRoot":"","sources":["../../src/zigzag.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;GAOG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE1C;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE5C;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAGpD"}
|
package/dist/src/zigzag.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Zigzag encoding/decoding for protobuf-style varints.
|
|
3
|
-
*
|
|
4
|
-
* Zigzag encoding converts signed integers to unsigned by interleaving
|
|
5
|
-
* negative and positive values: 0, -1, 1, -2, 2, ... This allows efficient
|
|
6
|
-
* varint encoding of small negative numbers.
|
|
7
|
-
*
|
|
8
|
-
* @module
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* Zigzag encode a number using arithmetic operations.
|
|
12
|
-
* This supports the full safe integer range (up to Number.MAX_SAFE_INTEGER).
|
|
13
|
-
* Formula: n < 0 ? -2*n - 1 : 2*n
|
|
14
|
-
*
|
|
15
|
-
* Used for encoding IDs in vector tiles to convert negative IDs to positive numbers
|
|
16
|
-
* for unsigned varint encoding.
|
|
17
|
-
*/
|
|
18
|
-
export function zigzag(num) {
|
|
19
|
-
return num < 0 ? -2 * num - 1 : 2 * num;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Zigzag encode using bitwise operations (for geometry deltas only).
|
|
23
|
-
* This is faster but limited to 32-bit signed integers.
|
|
24
|
-
* Used for small coordinate deltas in geometry encoding.
|
|
25
|
-
*/
|
|
26
|
-
export function zigzag32(num) {
|
|
27
|
-
return (num << 1) ^ (num >> 31);
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Decode zigzag-encoded number back to original value.
|
|
31
|
-
* Zigzag encoding is used to convert negative IDs to positive numbers for unsigned varint
|
|
32
|
-
* encoding in vector tiles. Uses arithmetic-based decoding to support the full safe integer range.
|
|
33
|
-
*
|
|
34
|
-
* Formula: (encoded & 1) === 1 ? -(encoded + 1) / 2 : encoded / 2
|
|
35
|
-
*/
|
|
36
|
-
export function decodeZigzag(encoded) {
|
|
37
|
-
// Check if encoded is odd (negative) using bitwise, then use arithmetic
|
|
38
|
-
return (encoded & 1) === 1 ? -(encoded + 1) / 2 : encoded / 2;
|
|
39
|
-
}
|
|
40
|
-
//# sourceMappingURL=zigzag.js.map
|
package/dist/src/zigzag.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"zigzag.js","sourceRoot":"","sources":["../../src/zigzag.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;GAOG;AACH,MAAM,UAAU,MAAM,CAAC,GAAW;IACjC,OAAO,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAA;AACxC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAW;IACnC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,CAAC,CAAA;AAChC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,OAAe;IAC3C,wEAAwE;IACxE,OAAO,CAAC,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,CAAA;AAC9D,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"haversine-distance.test.d.ts","sourceRoot":"","sources":["../../test/haversine-distance.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { expect, test } from "bun:test";
|
|
2
|
-
import { haversineDistance } from "../src/haversine-distance";
|
|
3
|
-
test("haversineDistance", () => {
|
|
4
|
-
const p1 = [-75.343, 39.984];
|
|
5
|
-
const p2 = [-75.534, 39.123];
|
|
6
|
-
expect(haversineDistance(p1, p2)).toBeCloseTo(97129.2211, 3);
|
|
7
|
-
});
|
|
8
|
-
//# sourceMappingURL=haversine-distance.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"haversine-distance.test.js","sourceRoot":"","sources":["../../test/haversine-distance.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAE7D,IAAI,CAAC,mBAAmB,EAAE,GAAG,EAAE;IAC9B,MAAM,EAAE,GAAqB,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC9C,MAAM,EAAE,GAAqB,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC9C,MAAM,CAAC,iBAAiB,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,UAAU,EAAE,CAAC,CAAC,CAAA;AAC7D,CAAC,CAAC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"relation-kind.test.d.ts","sourceRoot":"","sources":["../../test/relation-kind.test.ts"],"names":[],"mappings":""}
|