@india-boundary-corrector/data 0.0.1

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 ADDED
@@ -0,0 +1,20 @@
1
+ # Data Licenses
2
+
3
+ ## OpenStreetMap Data
4
+
5
+ The boundary data derived from OpenStreetMap is licensed under the **Open Data Commons Open Database License (ODbL)**.
6
+
7
+ © OpenStreetMap contributors
8
+
9
+ You are free to copy, distribute, transmit and adapt the data, as long as you credit OpenStreetMap and its contributors. If you alter or build upon the data, you may distribute the result only under the same licence.
10
+
11
+ - Full ODbL license: https://opendatacommons.org/licenses/odbl/
12
+ - OpenStreetMap copyright: https://www.openstreetmap.org/copyright
13
+
14
+ ## Natural Earth Data
15
+
16
+ Natural Earth data is in the **public domain**.
17
+
18
+ © Natural Earth
19
+
20
+ - Terms of use: https://www.naturalearthdata.com/about/terms-of-use/
package/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # @india-boundary-corrector/data
2
+
3
+ PMTiles data package for India boundary corrections.
4
+
5
+ ## Layers
6
+
7
+ The PMTiles file contains 4 layers:
8
+
9
+ | Layer | Description |
10
+ |-------|-------------|
11
+ | `to-add-osm` | Boundary lines to add over OSM-based tiles (higher zoom) |
12
+ | `to-del-osm` | Boundary lines to mask/delete from OSM-based tiles |
13
+ | `to-add-ne` | Boundary lines to add over Natural Earth tiles (lower zoom) |
14
+ | `to-del-ne` | Boundary lines to mask/delete from Natural Earth tiles |
15
+
16
+ ## Usage
17
+
18
+ ```javascript
19
+ import { layers, getPmtilesUrl, setPmtilesUrl, getDataVersion } from '@india-boundary-corrector/data';
20
+
21
+ // Get URL to PMTiles file (auto-detected from environment)
22
+ const url = getPmtilesUrl();
23
+
24
+ // Override the PMTiles URL for custom hosting
25
+ setPmtilesUrl('https://my-cdn.com/india_boundary_corrections.pmtiles');
26
+
27
+ // Get data version (OSM timestamp + NE version)
28
+ const version = getDataVersion(); // e.g., "osm_20231215_143022_ne_5.1.2"
29
+ ```
30
+
31
+ ## Data Sources
32
+
33
+ - OpenStreetMap boundary relations for India, Pakistan, and disputed territories
34
+ - Natural Earth Admin 0 Countries (standard and India-perspective versions)
35
+
36
+ ## License
37
+
38
+ Code: Unlicense
39
+
40
+ Data: See [LICENSE](LICENSE) file for OpenStreetMap (ODbL) and Natural Earth (Public Domain) data licenses.
@@ -0,0 +1 @@
1
+ export const dataVersion = 'osm_20251210_231743_ne_5.1.1';
package/index.d.ts ADDED
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Layer names in the PMTiles file
3
+ */
4
+ export const layers: {
5
+ toAddOsm: string;
6
+ toDelOsm: string;
7
+ toAddNe: string;
8
+ toDelNe: string;
9
+ };
10
+
11
+ /**
12
+ * Get the URL for the PMTiles file.
13
+ * Automatically detects the correct URL based on the environment:
14
+ * - ESM bundlers: Uses import.meta.url
15
+ * - CDN (unpkg/jsdelivr): Derives from script src
16
+ * - Fallback: unpkg CDN URL
17
+ */
18
+ export function getPmtilesUrl(): string;
19
+
20
+ /**
21
+ * Manually set the PMTiles URL (useful for custom hosting)
22
+ * @param url - The URL to the PMTiles file
23
+ */
24
+ export function setPmtilesUrl(url: string): void;
25
+
26
+ /**
27
+ * Get the data version string
28
+ * Format: osm_YYYYMMDD_HHMMSS_ne_VERSION
29
+ */
30
+ export function getDataVersion(): string;
package/index.js ADDED
@@ -0,0 +1,93 @@
1
+ import { dataVersion } from './data_version.js';
2
+ import { packageVersion } from './version.js';
3
+
4
+ // Package info for CDN URL construction
5
+ const PACKAGE_NAME = '@india-boundary-corrector/data';
6
+ const PMTILES_FILENAME = 'india_boundary_corrections.pmtiles';
7
+
8
+ // Default CDN URL with pinned package version
9
+ const DEFAULT_CDN_URL = `https://unpkg.com/${PACKAGE_NAME}@${packageVersion}/${PMTILES_FILENAME}`;
10
+
11
+ /**
12
+ * Layer names in the PMTiles file
13
+ */
14
+ export const layers = {
15
+ toAddOsm: 'to-add-osm',
16
+ toDelOsm: 'to-del-osm',
17
+ toAddNe: 'to-add-ne',
18
+ toDelNe: 'to-del-ne',
19
+ };
20
+
21
+ /**
22
+ * Detect the PMTiles URL from various sources:
23
+ * 1. import.meta.url (for ESM bundlers - most reliable)
24
+ * 2. Fallback to unpkg CDN with pinned version
25
+ *
26
+ * Note: When this package is bundled into another bundle, import.meta.url
27
+ * won't work and we fall back to the CDN URL. Users can override with
28
+ * setPmtilesUrl() for self-hosted scenarios.
29
+ */
30
+ function detectPmtilesUrl() {
31
+ // Try import.meta.url first (works in ESM environments)
32
+ try {
33
+ if (typeof import.meta !== 'undefined' && import.meta.url) {
34
+ const moduleUrl = new URL('.', import.meta.url);
35
+ return new URL(PMTILES_FILENAME, moduleUrl).href;
36
+ }
37
+ } catch {
38
+ // import.meta not available (UMD/CJS/bundled)
39
+ }
40
+
41
+ // Fallback to CDN with pinned version
42
+ // This ensures it works even when bundled into another package
43
+ return DEFAULT_CDN_URL;
44
+ }
45
+
46
+ // Cache the detected URL
47
+ let cachedPmtilesUrl = null;
48
+
49
+ /**
50
+ * Get the URL for the PMTiles file.
51
+ *
52
+ * Detection priority:
53
+ * 1. Manually set URL via setPmtilesUrl()
54
+ * 2. import.meta.url (ESM environments)
55
+ * 3. unpkg CDN fallback (pinned to current version)
56
+ *
57
+ * For self-hosted deployments or custom bundling scenarios,
58
+ * use setPmtilesUrl().
59
+ *
60
+ * @returns {string} URL to the PMTiles file
61
+ */
62
+ export function getPmtilesUrl() {
63
+ if (cachedPmtilesUrl === null) {
64
+ cachedPmtilesUrl = detectPmtilesUrl();
65
+ }
66
+ return cachedPmtilesUrl;
67
+ }
68
+
69
+ /**
70
+ * Manually set the PMTiles URL.
71
+ * Use this for self-hosted deployments or custom bundling scenarios.
72
+ *
73
+ * @param {string} url - The URL to the PMTiles file
74
+ *
75
+ * @example
76
+ * // Self-hosted
77
+ * setPmtilesUrl('/assets/india_boundary_corrections.pmtiles');
78
+ *
79
+ * @example
80
+ * // Different CDN
81
+ * setPmtilesUrl('https://my-cdn.com/india_boundary_corrections.pmtiles');
82
+ */
83
+ export function setPmtilesUrl(url) {
84
+ cachedPmtilesUrl = url;
85
+ }
86
+
87
+ /**
88
+ * Get the data version string
89
+ * @returns {string} Data version identifier
90
+ */
91
+ export function getDataVersion() {
92
+ return dataVersion;
93
+ }
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@india-boundary-corrector/data",
3
+ "version": "0.0.1",
4
+ "description": "PMTiles data for India boundary corrections (NE and OSM layers)",
5
+ "type": "module",
6
+ "main": "index.js",
7
+ "types": "index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./index.js",
11
+ "types": "./index.d.ts"
12
+ },
13
+ "./pmtiles": "./india_boundary_corrections.pmtiles"
14
+ },
15
+ "files": [
16
+ "index.js",
17
+ "index.d.ts",
18
+ "version.js",
19
+ "data_version.js",
20
+ "india_boundary_corrections.pmtiles"
21
+ ],
22
+ "scripts": {
23
+ "build": "node scripts/generate-version.js",
24
+ "generate": "cd generate && bash steps.sh"
25
+ },
26
+ "keywords": [
27
+ "india",
28
+ "boundary",
29
+ "map",
30
+ "pmtiles",
31
+ "natural-earth",
32
+ "openstreetmap"
33
+ ],
34
+ "author": "ramSeraph",
35
+ "license": "Unlicense",
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "git+https://github.com/ramSeraph/india_boundary_corrector.git",
39
+ "directory": "packages/data"
40
+ },
41
+ "bugs": {
42
+ "url": "https://github.com/ramSeraph/india_boundary_corrector/issues"
43
+ },
44
+ "homepage": "https://github.com/ramSeraph/india_boundary_corrector#readme"
45
+ }
package/version.js ADDED
@@ -0,0 +1,2 @@
1
+ // Auto-generated by scripts/generate-version.js - DO NOT EDIT
2
+ export const packageVersion = '0.0.1';