@osmix/core 0.1.5 → 0.1.7

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 CHANGED
@@ -1,5 +1,21 @@
1
1
  # @osmix/core
2
2
 
3
+ ## 0.1.7
4
+
5
+ ### Patch Changes
6
+
7
+ - 2a634cb: Fix publishing
8
+ - Updated dependencies [2a634cb]
9
+ - @osmix/shared@0.0.12
10
+
11
+ ## 0.1.6
12
+
13
+ ### Patch Changes
14
+
15
+ - 3c8ee95: Fix and simplify package exports
16
+ - Updated dependencies [3c8ee95]
17
+ - @osmix/shared@0.0.11
18
+
3
19
  ## 0.1.5
4
20
 
5
21
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -21,6 +21,8 @@
21
21
  *
22
22
  * @module @osmix/core
23
23
  */
24
+ export type { IdOrIndex } from "./ids";
25
+ export * from "./mocks";
24
26
  export * from "./nodes";
25
27
  export * from "./osm";
26
28
  export * from "./relations";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAMH,cAAc,SAAS,CAAA;AACvB,cAAc,OAAO,CAAA;AACrB,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,QAAQ,CAAA;AACtB,OAAO,EAAE,iBAAiB,EAAE,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAA;AACnE,cAAc,QAAQ,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAMH,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACtC,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA;AACvB,cAAc,OAAO,CAAA;AACrB,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,QAAQ,CAAA;AACtB,OAAO,EAAE,iBAAiB,EAAE,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAA;AACnE,cAAc,QAAQ,CAAA"}
package/dist/index.js CHANGED
@@ -21,9 +21,7 @@
21
21
  *
22
22
  * @module @osmix/core
23
23
  */
24
- /// <reference path="./types/kdbush.d.ts" />
25
- /// <reference path="./types/geokdbush.d.ts" />
26
- /// <reference path="./types/geoflatbush.d.ts" />
24
+ export * from "./mocks";
27
25
  export * from "./nodes";
28
26
  export * from "./osm";
29
27
  export * from "./relations";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,4CAA4C;AAC5C,+CAA+C;AAC/C,iDAAiD;AAEjD,cAAc,SAAS,CAAA;AACvB,cAAc,OAAO,CAAA;AACrB,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,QAAQ,CAAA;AACtB,OAAO,EAAE,iBAAiB,EAAmB,MAAM,gBAAgB,CAAA;AACnE,cAAc,QAAQ,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAOH,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA;AACvB,cAAc,OAAO,CAAA;AACrB,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,QAAQ,CAAA;AACtB,OAAO,EAAE,iBAAiB,EAAmB,MAAM,gBAAgB,CAAA;AACnE,cAAc,QAAQ,CAAA"}
@@ -0,0 +1,13 @@
1
+ import { Osm } from "./osm";
2
+ /**
3
+ * Create a base OSM with one way and two nodes.
4
+ */
5
+ export declare function createMockBaseOsm(): Osm;
6
+ /**
7
+ * Create a patch OSM with:
8
+ * - The same way as the base OSM, with new tags
9
+ * - A way that has an overlapping node with the first way, but does not share a node and so starts disconnected
10
+ * - A way that crosses over the first way, but does not share a node and so starts disconnected
11
+ */
12
+ export declare function createMockPatchOsm(): Osm;
13
+ //# sourceMappingURL=mocks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mocks.d.ts","sourceRoot":"","sources":["../src/mocks.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAmC3B;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,GAAG,CAOvC;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,IAAI,GAAG,CAqFxC"}
package/dist/mocks.js ADDED
@@ -0,0 +1,122 @@
1
+ import { Osm } from "./osm";
2
+ const YAKIM_LAT = 46.60207;
3
+ const YAKIM_LON = -120.505898;
4
+ const ONE_KM_LON = 0.0131; // approximately
5
+ const ONE_KM_LAT = 0.009;
6
+ const node0 = {
7
+ id: 0,
8
+ lat: YAKIM_LAT,
9
+ lon: YAKIM_LON,
10
+ };
11
+ const node1 = {
12
+ id: 1,
13
+ lat: YAKIM_LAT,
14
+ lon: YAKIM_LON - ONE_KM_LON, // approximately 1km west
15
+ };
16
+ function addBaseNodes(osm) {
17
+ osm.nodes.addNode(node0);
18
+ osm.nodes.addNode(node1);
19
+ }
20
+ function addBaseWays(osm) {
21
+ osm.ways.addWay({
22
+ id: 1,
23
+ refs: [0, 1],
24
+ tags: {
25
+ highway: "primary",
26
+ },
27
+ });
28
+ }
29
+ /**
30
+ * Create a base OSM with one way and two nodes.
31
+ */
32
+ export function createMockBaseOsm() {
33
+ const base = new Osm();
34
+ addBaseNodes(base);
35
+ base.nodes.buildIndex();
36
+ addBaseWays(base);
37
+ base.buildIndexes();
38
+ return base;
39
+ }
40
+ /**
41
+ * Create a patch OSM with:
42
+ * - The same way as the base OSM, with new tags
43
+ * - A way that has an overlapping node with the first way, but does not share a node and so starts disconnected
44
+ * - A way that crosses over the first way, but does not share a node and so starts disconnected
45
+ */
46
+ export function createMockPatchOsm() {
47
+ const osm = new Osm();
48
+ addBaseNodes(osm);
49
+ // Add way the connects with base way node 0 (will replace it)
50
+ osm.nodes.addNode({
51
+ ...node0,
52
+ id: 2,
53
+ tags: {
54
+ crossing: "yes",
55
+ },
56
+ });
57
+ osm.nodes.addNode({
58
+ ...node1,
59
+ id: 3,
60
+ lon: YAKIM_LON + ONE_KM_LON, // ends 1km east of the center point
61
+ });
62
+ // Add nodes for disconnected way
63
+ osm.nodes.addNode({
64
+ id: 4,
65
+ lat: YAKIM_LAT - ONE_KM_LAT, // 1km south
66
+ lon: YAKIM_LON + ONE_KM_LON / 4, // 250m east
67
+ });
68
+ osm.nodes.addNode({
69
+ id: 5,
70
+ lat: YAKIM_LAT + ONE_KM_LAT, // 1km north
71
+ lon: YAKIM_LON + ONE_KM_LON / 4, // 250m east
72
+ });
73
+ // Add nodes for crossing way
74
+ osm.nodes.addNode({
75
+ id: 6,
76
+ lat: YAKIM_LAT - ONE_KM_LAT, // 1km south
77
+ lon: YAKIM_LON + ONE_KM_LON / 2, // 500m east
78
+ });
79
+ osm.nodes.addNode({
80
+ id: 7,
81
+ lat: YAKIM_LAT + ONE_KM_LAT, // 1km north
82
+ lon: YAKIM_LON + ONE_KM_LON / 2, // 500m east
83
+ });
84
+ osm.nodes.buildIndex();
85
+ // Add same base way with new tags
86
+ osm.ways.addWay({
87
+ id: 1,
88
+ refs: [0, 1],
89
+ tags: {
90
+ highway: "primary",
91
+ version: "2",
92
+ },
93
+ });
94
+ // Add way that overlaps with base way node 1. Node should be de-duplicated.
95
+ osm.ways.addWay({
96
+ id: 2,
97
+ refs: [2, 3],
98
+ tags: {
99
+ highway: "secondary",
100
+ },
101
+ });
102
+ // Add way that crosses way 2, and should generate 1 intersection.
103
+ osm.ways.addWay({
104
+ id: 3,
105
+ refs: [4, 5],
106
+ tags: {
107
+ highway: "primary",
108
+ },
109
+ });
110
+ // Add a way that crosses way 2, but has a tag indicating it is an underpass and should be left alone
111
+ osm.ways.addWay({
112
+ id: 4,
113
+ refs: [6, 7],
114
+ tags: {
115
+ highway: "underpass",
116
+ tunnel: "yes",
117
+ },
118
+ });
119
+ osm.buildIndexes();
120
+ return osm;
121
+ }
122
+ //# sourceMappingURL=mocks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mocks.js","sourceRoot":"","sources":["../src/mocks.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAE3B,MAAM,SAAS,GAAG,QAAQ,CAAA;AAC1B,MAAM,SAAS,GAAG,CAAC,UAAU,CAAA;AAE7B,MAAM,UAAU,GAAG,MAAM,CAAA,CAAC,gBAAgB;AAC1C,MAAM,UAAU,GAAG,KAAK,CAAA;AAExB,MAAM,KAAK,GAAY;IACtB,EAAE,EAAE,CAAC;IACL,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;CACd,CAAA;AAED,MAAM,KAAK,GAAY;IACtB,EAAE,EAAE,CAAC;IACL,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS,GAAG,UAAU,EAAE,yBAAyB;CACtD,CAAA;AAED,SAAS,YAAY,CAAC,GAAQ;IAC7B,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IACxB,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AACzB,CAAC;AAED,SAAS,WAAW,CAAC,GAAQ;IAC5B,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC;QACf,EAAE,EAAE,CAAC;QACL,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;QACZ,IAAI,EAAE;YACL,OAAO,EAAE,SAAS;SAClB;KACD,CAAC,CAAA;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB;IAChC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAE,CAAA;IACtB,YAAY,CAAC,IAAI,CAAC,CAAA;IAClB,IAAI,CAAC,KAA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AAE,CAAC;QACL,GAAG,EAAE,SAAS,GAAG,UAAU,EAAE,YAAY;QACzC,GAAG,EAAE,SAAS,GAAG,UAAU,GAAG,CAAC,EAAE,YAAY;KAC7C,CAAC,CAAA;IAEF,GAAG,CAAC,KAAK,CAAC,UAAU,EAAE,CAAA;IAEtB,kCAAkC;IAClC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC;QACf,EAAE,EAAE,CAAC;QACL,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;QACZ,IAAI,EAAE;YACL,OAAO,EAAE,SAAS;YAClB,OAAO,EAAE,GAAG;SACZ;KACD,CAAC,CAAA;IAEF,4EAA4E;IAC5E,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC;QACf,EAAE,EAAE,CAAC;QACL,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;QACZ,IAAI,EAAE;YACL,OAAO,EAAE,WAAW;SACpB;KACD,CAAC,CAAA;IAEF,kEAAkE;IAClE,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC;QACf,EAAE,EAAE,CAAC;QACL,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;QACZ,IAAI,EAAE;YACL,OAAO,EAAE,SAAS;SAClB;KACD,CAAC,CAAA;IAEF,qGAAqG;IACrG,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC;QACf,EAAE,EAAE,CAAC;QACL,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;QACZ,IAAI,EAAE;YACL,OAAO,EAAE,WAAW;YACpB,MAAM,EAAE,KAAK;SACb;KACD,CAAC,CAAA;IAEF,GAAG,CAAC,YAAY,EAAE,CAAA;IAClB,OAAO,GAAG,CAAA;AACX,CAAC"}
package/package.json CHANGED
@@ -1,55 +1,32 @@
1
1
  {
2
- "$schema": "https://json.schemastore.org/package",
2
+ "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@osmix/core",
4
4
  "type": "module",
5
- "version": "0.1.5",
5
+ "version": "0.1.7",
6
6
  "description": "An OSM PBF reader, writer, and merge tool written in TypeScript",
7
- "main": "./src/index.ts",
8
- "publishConfig": {
9
- "access": "public",
10
- "registry": "https://registry.npmjs.org/",
11
- "main": "./dist/index.js",
12
- "types": "./dist/index.d.ts",
13
- "exports": {
14
- ".": {
15
- "import": "./dist/index.js",
16
- "types": "./dist/index.d.ts"
17
- }
18
- },
19
- "files": [
20
- "dist",
21
- "README.md",
22
- "LICENSE"
23
- ]
24
- },
25
7
  "license": "MIT",
26
8
  "repository": {
27
9
  "type": "git",
28
10
  "url": "git+https://github.com/conveyal/osmix.git"
29
11
  },
30
- "homepage": "https://github.com/conveyal/osmix#readme",
31
- "bugs": {
32
- "url": "https://github.com/conveyal/osmix/issues"
33
- },
34
- "sideEffects": false,
12
+ "main": "./dist/index.js",
35
13
  "scripts": {
36
14
  "build": "tsc -p tsconfig.build.json",
37
15
  "bench": "bun test --bench",
38
- "prepare": "bun run build",
39
- "release": "bun publish",
40
16
  "test": "bun test",
41
17
  "typecheck": "tsgo --noEmit"
42
18
  },
43
19
  "devDependencies": {
44
- "@osmix/pbf": "0.0.6",
45
- "@types/bun": "^1.3.3",
20
+ "@osmix/pbf": "0.0.8",
21
+ "@types/bun": "^1.3.9",
46
22
  "typescript": "^5.9.0"
47
23
  },
48
24
  "dependencies": {
49
- "@osmix/shared": "0.0.10",
25
+ "@osmix/shared": "0.0.12",
50
26
  "flatbush": "^4.4.1",
51
27
  "geoflatbush": "^2.1.0",
52
28
  "geokdbush": "^2.0.1",
53
29
  "kdbush": "mourner/kdbush#16416cd"
54
- }
55
- }
30
+ },
31
+ "types": "./dist/index.d.ts"
32
+ }
package/src/index.ts CHANGED
@@ -26,6 +26,8 @@
26
26
  /// <reference path="./types/geokdbush.d.ts" />
27
27
  /// <reference path="./types/geoflatbush.d.ts" />
28
28
 
29
+ export type { IdOrIndex } from "./ids"
30
+ export * from "./mocks"
29
31
  export * from "./nodes"
30
32
  export * from "./osm"
31
33
  export * from "./relations"
@@ -1,5 +1,5 @@
1
1
  import type { OsmNode } from "@osmix/shared/types"
2
- import { Osm } from "../src/osm"
2
+ import { Osm } from "./osm"
3
3
 
4
4
  const YAKIM_LAT = 46.60207
5
5
  const YAKIM_LON = -120.505898
@@ -37,7 +37,7 @@ function addBaseWays(osm: Osm) {
37
37
  /**
38
38
  * Create a base OSM with one way and two nodes.
39
39
  */
40
- export function createBaseOsm(): Osm {
40
+ export function createMockBaseOsm(): Osm {
41
41
  const base = new Osm()
42
42
  addBaseNodes(base)
43
43
  base.nodes.buildIndex()
@@ -52,7 +52,7 @@ export function createBaseOsm(): Osm {
52
52
  * - A way that has an overlapping node with the first way, but does not share a node and so starts disconnected
53
53
  * - A way that crosses over the first way, but does not share a node and so starts disconnected
54
54
  */
55
- export function createPatchOsm(): Osm {
55
+ export function createMockPatchOsm(): Osm {
56
56
  const osm = new Osm()
57
57
 
58
58
  addBaseNodes(osm)