@map-colonies/mc-utils 4.0.4 → 5.0.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/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -2
- package/dist/files/index.d.ts +0 -2
- package/dist/files/index.d.ts.map +0 -1
- package/dist/files/index.js +0 -18
- package/dist/files/index.js.map +0 -1
- package/dist/files/shapefile/core/chunkBuilder.d.ts +0 -19
- package/dist/files/shapefile/core/chunkBuilder.d.ts.map +0 -1
- package/dist/files/shapefile/core/chunkBuilder.js +0 -75
- package/dist/files/shapefile/core/chunkBuilder.js.map +0 -1
- package/dist/files/shapefile/core/gdalShapefileReader.d.ts +0 -65
- package/dist/files/shapefile/core/gdalShapefileReader.d.ts.map +0 -1
- package/dist/files/shapefile/core/gdalShapefileReader.js +0 -112
- package/dist/files/shapefile/core/gdalShapefileReader.js.map +0 -1
- package/dist/files/shapefile/core/metricsManager.d.ts +0 -24
- package/dist/files/shapefile/core/metricsManager.d.ts.map +0 -1
- package/dist/files/shapefile/core/metricsManager.js +0 -54
- package/dist/files/shapefile/core/metricsManager.js.map +0 -1
- package/dist/files/shapefile/core/progressTracker.d.ts +0 -60
- package/dist/files/shapefile/core/progressTracker.d.ts.map +0 -1
- package/dist/files/shapefile/core/progressTracker.js +0 -87
- package/dist/files/shapefile/core/progressTracker.js.map +0 -1
- package/dist/files/shapefile/core/shapeFileReader.d.ts +0 -30
- package/dist/files/shapefile/core/shapeFileReader.d.ts.map +0 -1
- package/dist/files/shapefile/core/shapeFileReader.js +0 -212
- package/dist/files/shapefile/core/shapeFileReader.js.map +0 -1
- package/dist/files/shapefile/index.d.ts +0 -4
- package/dist/files/shapefile/index.d.ts.map +0 -1
- package/dist/files/shapefile/index.js +0 -24
- package/dist/files/shapefile/index.js.map +0 -1
- package/dist/files/shapefile/types/index.d.ts +0 -35
- package/dist/files/shapefile/types/index.d.ts.map +0 -1
- package/dist/files/shapefile/types/index.js +0 -26
- package/dist/files/shapefile/types/index.js.map +0 -1
- package/dist/files/shapefile/types/metrics.d.ts +0 -26
- package/dist/files/shapefile/types/metrics.d.ts.map +0 -1
- package/dist/files/shapefile/types/metrics.js +0 -3
- package/dist/files/shapefile/types/metrics.js.map +0 -1
- package/dist/files/shapefile/types/state.d.ts +0 -29
- package/dist/files/shapefile/types/state.d.ts.map +0 -1
- package/dist/files/shapefile/types/state.js +0 -3
- package/dist/files/shapefile/types/state.js.map +0 -1
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,kDAAgC;AAChC,6CAA2B;AAC3B,wCAAsB;AACtB,2CAAyB;AACzB,0CAAwB
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,kDAAgC;AAChC,6CAA2B;AAC3B,wCAAsB;AACtB,2CAAyB;AACzB,0CAAwB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@map-colonies/mc-utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"description": "MapColonies utility library for http, geo, arrays and interfaces",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -66,7 +66,6 @@
|
|
|
66
66
|
"@turf/turf": "^6.5.0",
|
|
67
67
|
"axios": "^1.10.0",
|
|
68
68
|
"axios-retry": "^4.5.0",
|
|
69
|
-
"gdal-async": "^3.12.1",
|
|
70
69
|
"http-status-codes": "^2.3.0",
|
|
71
70
|
"lodash": "^4.17.21",
|
|
72
71
|
"ngeohash": "^0.6.3",
|
package/dist/files/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/files/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
|
package/dist/files/index.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./shapefile"), exports);
|
|
18
|
-
//# sourceMappingURL=index.js.map
|
package/dist/files/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/files/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { Feature } from 'geojson';
|
|
2
|
-
import { FeatureStatus, ShapefileChunk } from '../types/index';
|
|
3
|
-
export declare class ChunkBuilder {
|
|
4
|
-
private readonly maxVertices;
|
|
5
|
-
private chunkIndex;
|
|
6
|
-
private features;
|
|
7
|
-
private skippedFeatures;
|
|
8
|
-
private currentVerticesCount;
|
|
9
|
-
private skippedVerticesCount;
|
|
10
|
-
constructor(maxVertices: number, chunkIndex?: number);
|
|
11
|
-
get chunkId(): number;
|
|
12
|
-
canAddFeature(feature: Feature): FeatureStatus;
|
|
13
|
-
addFeature(feature: Feature): void;
|
|
14
|
-
build(): ShapefileChunk;
|
|
15
|
-
nextChunk(): void;
|
|
16
|
-
private withinSkipped;
|
|
17
|
-
private validateFeatureId;
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=chunkBuilder.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"chunkBuilder.d.ts","sourceRoot":"","sources":["../../../../src/files/shapefile/core/chunkBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAI/D,qBAAa,YAAY;IAOrB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,UAAU;IAPpB,OAAO,CAAC,QAAQ,CAAY;IAC5B,OAAO,CAAC,eAAe,CAAY;IACnC,OAAO,CAAC,oBAAoB,CAAS;IACrC,OAAO,CAAC,oBAAoB,CAAS;gBAGlB,WAAW,EAAE,MAAM,EAC5B,UAAU,GAAE,MAAU;IAQhC,IAAW,OAAO,IAAI,MAAM,CAE3B;IAEM,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,aAAa;IAgB9C,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IASlC,KAAK,IAAI,cAAc;IAUvB,SAAS,IAAI,IAAI;IAOxB,OAAO,CAAC,aAAa;IAQrB,OAAO,CAAC,iBAAiB;CAM1B"}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ChunkBuilder = void 0;
|
|
4
|
-
const index_1 = require("../types/index");
|
|
5
|
-
const vertices_1 = require("../../../geo/vertices");
|
|
6
|
-
const validation_1 = require("../../../utils/validation");
|
|
7
|
-
class ChunkBuilder {
|
|
8
|
-
maxVertices;
|
|
9
|
-
chunkIndex;
|
|
10
|
-
features;
|
|
11
|
-
skippedFeatures;
|
|
12
|
-
currentVerticesCount;
|
|
13
|
-
skippedVerticesCount;
|
|
14
|
-
constructor(maxVertices, chunkIndex = 0) {
|
|
15
|
-
this.maxVertices = maxVertices;
|
|
16
|
-
this.chunkIndex = chunkIndex;
|
|
17
|
-
this.features = [];
|
|
18
|
-
this.skippedFeatures = [];
|
|
19
|
-
this.currentVerticesCount = 0;
|
|
20
|
-
this.skippedVerticesCount = 0;
|
|
21
|
-
}
|
|
22
|
-
get chunkId() {
|
|
23
|
-
return this.chunkIndex;
|
|
24
|
-
}
|
|
25
|
-
canAddFeature(feature) {
|
|
26
|
-
this.validateFeatureId(feature);
|
|
27
|
-
const featureVertices = (0, vertices_1.countVertices)(feature.geometry);
|
|
28
|
-
if (featureVertices > this.maxVertices) {
|
|
29
|
-
const featureWithVertices = { ...feature, properties: { ...feature.properties, vertices: featureVertices } };
|
|
30
|
-
this.skippedFeatures.push(featureWithVertices);
|
|
31
|
-
this.skippedVerticesCount += featureVertices;
|
|
32
|
-
return index_1.FeatureStatus.SKIPPED;
|
|
33
|
-
}
|
|
34
|
-
const canAdd = this.currentVerticesCount + featureVertices <= this.maxVertices;
|
|
35
|
-
return canAdd ? index_1.FeatureStatus.ADD : index_1.FeatureStatus.FULL;
|
|
36
|
-
}
|
|
37
|
-
addFeature(feature) {
|
|
38
|
-
this.validateFeatureId(feature);
|
|
39
|
-
if (this.withinSkipped(feature)) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
this.features.push(feature);
|
|
43
|
-
this.currentVerticesCount += (0, vertices_1.countVertices)(feature.geometry);
|
|
44
|
-
}
|
|
45
|
-
build() {
|
|
46
|
-
return {
|
|
47
|
-
id: this.chunkIndex,
|
|
48
|
-
features: this.features,
|
|
49
|
-
verticesCount: this.currentVerticesCount,
|
|
50
|
-
skippedFeatures: this.skippedFeatures,
|
|
51
|
-
skippedVerticesCount: this.skippedVerticesCount,
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
nextChunk() {
|
|
55
|
-
this.features = [];
|
|
56
|
-
this.skippedFeatures = [];
|
|
57
|
-
this.currentVerticesCount = 0;
|
|
58
|
-
this.chunkIndex++;
|
|
59
|
-
}
|
|
60
|
-
withinSkipped(feature) {
|
|
61
|
-
const featureId = validation_1.featurePropertiesSchema.safeParse(feature.properties).data?.id;
|
|
62
|
-
return this.skippedFeatures.some((skipped) => {
|
|
63
|
-
const skippedId = validation_1.featurePropertiesSchema.safeParse(skipped.properties).data?.id;
|
|
64
|
-
return skippedId === featureId;
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
validateFeatureId(feature) {
|
|
68
|
-
const parsed = validation_1.featurePropertiesSchema.safeParse(feature.properties);
|
|
69
|
-
if (!parsed.success) {
|
|
70
|
-
throw new Error('Feature must have an id');
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
exports.ChunkBuilder = ChunkBuilder;
|
|
75
|
-
//# sourceMappingURL=chunkBuilder.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"chunkBuilder.js","sourceRoot":"","sources":["../../../../src/files/shapefile/core/chunkBuilder.ts"],"names":[],"mappings":";;;AACA,0CAA+D;AAC/D,oDAAsD;AACtD,0DAAoE;AAEpE,MAAa,YAAY;IAOJ;IACT;IAPF,QAAQ,CAAY;IACpB,eAAe,CAAY;IAC3B,oBAAoB,CAAS;IAC7B,oBAAoB,CAAS;IAErC,YACmB,WAAmB,EAC5B,aAAqB,CAAC;QADb,gBAAW,GAAX,WAAW,CAAQ;QAC5B,eAAU,GAAV,UAAU,CAAY;QAE9B,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;QACnB,IAAI,CAAC,eAAe,GAAG,EAAE,CAAC;QAC1B,IAAI,CAAC,oBAAoB,GAAG,CAAC,CAAC;QAC9B,IAAI,CAAC,oBAAoB,GAAG,CAAC,CAAC;IAChC,CAAC;IAED,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAEM,aAAa,CAAC,OAAgB;QACnC,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;QAEhC,MAAM,eAAe,GAAG,IAAA,wBAAa,EAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAExD,IAAI,eAAe,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;YACvC,MAAM,mBAAmB,GAAY,EAAE,GAAG,OAAO,EAAE,UAAU,EAAE,EAAE,GAAG,OAAO,CAAC,UAAU,EAAE,QAAQ,EAAE,eAAe,EAAE,EAAE,CAAC;YACtH,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;YAC/C,IAAI,CAAC,oBAAoB,IAAI,eAAe,CAAC;YAC7C,OAAO,qBAAa,CAAC,OAAO,CAAC;QAC/B,CAAC;QACD,MAAM,MAAM,GAAG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,OAAO,SAAS,KAAK,SAAS,CAAC;QACjC,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,iBAAiB,CAAC,OAAgB;QACxC,MAAM,MAAM,GAAG,oCAAuB,CAAC,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QACrE,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;CACF;AA5ED,oCA4EC"}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import type { Feature } from 'geojson';
|
|
2
|
-
/**
|
|
3
|
-
* Result of reading a feature from the shapefile
|
|
4
|
-
* Matches the interface pattern used by the shapefile package
|
|
5
|
-
*/
|
|
6
|
-
export interface ShapefileReadResult {
|
|
7
|
-
done: boolean;
|
|
8
|
-
value: Feature;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Interface for shapefile reader that can be used interchangeably
|
|
12
|
-
* with either gdal-async or the shapefile package
|
|
13
|
-
*/
|
|
14
|
-
export interface IShapefileSource {
|
|
15
|
-
read: () => Promise<ShapefileReadResult>;
|
|
16
|
-
close: () => void;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Adapter class that wraps gdal-async to provide a shapefile reader
|
|
20
|
-
* compatible with the interface expected by ShapefileChunkReader.
|
|
21
|
-
*
|
|
22
|
-
* This adapter allows seamless migration from the 'shapefile' npm package
|
|
23
|
-
* to 'gdal-async' while maintaining the same API contract.
|
|
24
|
-
*/
|
|
25
|
-
export declare class GdalShapefileReader implements IShapefileSource {
|
|
26
|
-
private readonly dataset;
|
|
27
|
-
private readonly layer;
|
|
28
|
-
private isFirstRead;
|
|
29
|
-
private constructor();
|
|
30
|
-
/**
|
|
31
|
-
* Opens a shapefile using gdal-async and returns a reader instance.
|
|
32
|
-
* This is the async factory method to create a GdalShapefileReader.
|
|
33
|
-
*
|
|
34
|
-
* @param shapefilePath - Path to the .shp file
|
|
35
|
-
* @returns Promise resolving to a GdalShapefileReader instance
|
|
36
|
-
*/
|
|
37
|
-
static open(shapefilePath: string): Promise<GdalShapefileReader>;
|
|
38
|
-
/**
|
|
39
|
-
* Reads the next feature from the shapefile.
|
|
40
|
-
* Returns { done: true, value: undefined } when no more features are available.
|
|
41
|
-
*
|
|
42
|
-
* @returns Promise resolving to the read result with done flag and feature value
|
|
43
|
-
*/
|
|
44
|
-
readonly read: () => Promise<ShapefileReadResult>;
|
|
45
|
-
/**
|
|
46
|
-
* Closes the underlying dataset and releases resources.
|
|
47
|
-
* Should be called when done reading the shapefile.
|
|
48
|
-
*/
|
|
49
|
-
close(): void;
|
|
50
|
-
/**
|
|
51
|
-
* Converts a GDAL feature to a GeoJSON Feature object.
|
|
52
|
-
*
|
|
53
|
-
* @param gdalFeature - The GDAL feature to convert
|
|
54
|
-
* @returns GeoJSON Feature object
|
|
55
|
-
*/
|
|
56
|
-
private convertToGeoJsonFeature;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Factory function to open a shapefile using gdal-async.
|
|
60
|
-
*
|
|
61
|
-
* @param shapefilePath - Path to the .shp file
|
|
62
|
-
* @returns Promise resolving to a shapefile reader
|
|
63
|
-
*/
|
|
64
|
-
export declare function openShapefile(shapefilePath: string): Promise<IShapefileSource>;
|
|
65
|
-
//# sourceMappingURL=gdalShapefileReader.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"gdalShapefileReader.d.ts","sourceRoot":"","sources":["../../../../src/files/shapefile/core/gdalShapefileReader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAA+B,MAAM,SAAS,CAAC;AAEpE;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACzC,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED;;;;;;GAMG;AACH,qBAAa,mBAAoB,YAAW,gBAAgB;IAItC,OAAO,CAAC,QAAQ,CAAC,OAAO;IAH5C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAa;IACnC,OAAO,CAAC,WAAW,CAAQ;IAE3B,OAAO;IAIP;;;;;;OAMG;WACiB,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAO7E;;;;;OAKG;IAEH,SAAgB,IAAI,QAAO,OAAO,CAAC,mBAAmB,CAAC,CAyBrD;IAEF;;;OAGG;IACI,KAAK,IAAI,IAAI;IAIpB;;;;;OAKG;IACH,OAAO,CAAC,uBAAuB;CAyBhC;AAED;;;;;GAKG;AACH,wBAAsB,aAAa,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAEpF"}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.GdalShapefileReader = void 0;
|
|
7
|
-
exports.openShapefile = openShapefile;
|
|
8
|
-
const gdal_async_1 = __importDefault(require("gdal-async"));
|
|
9
|
-
/**
|
|
10
|
-
* Adapter class that wraps gdal-async to provide a shapefile reader
|
|
11
|
-
* compatible with the interface expected by ShapefileChunkReader.
|
|
12
|
-
*
|
|
13
|
-
* This adapter allows seamless migration from the 'shapefile' npm package
|
|
14
|
-
* to 'gdal-async' while maintaining the same API contract.
|
|
15
|
-
*/
|
|
16
|
-
class GdalShapefileReader {
|
|
17
|
-
dataset;
|
|
18
|
-
layer;
|
|
19
|
-
isFirstRead = true;
|
|
20
|
-
constructor(dataset) {
|
|
21
|
-
this.dataset = dataset;
|
|
22
|
-
this.layer = dataset.layers.get(0);
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Opens a shapefile using gdal-async and returns a reader instance.
|
|
26
|
-
* This is the async factory method to create a GdalShapefileReader.
|
|
27
|
-
*
|
|
28
|
-
* @param shapefilePath - Path to the .shp file
|
|
29
|
-
* @returns Promise resolving to a GdalShapefileReader instance
|
|
30
|
-
*/
|
|
31
|
-
static async open(shapefilePath) {
|
|
32
|
-
// Note: GDAL handles .dbf file association automatically based on the .shp path
|
|
33
|
-
// and typically reads encoding from .cpg file if present, or uses UTF-8 by default
|
|
34
|
-
const dataset = await gdal_async_1.default.openAsync(shapefilePath);
|
|
35
|
-
return new GdalShapefileReader(dataset);
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Reads the next feature from the shapefile.
|
|
39
|
-
* Returns { done: true, value: undefined } when no more features are available.
|
|
40
|
-
*
|
|
41
|
-
* @returns Promise resolving to the read result with done flag and feature value
|
|
42
|
-
*/
|
|
43
|
-
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
44
|
-
read = () => {
|
|
45
|
-
// Note: GDAL types say Feature is always returned, but in practice it returns null when done
|
|
46
|
-
let gdalFeature;
|
|
47
|
-
if (this.isFirstRead) {
|
|
48
|
-
this.isFirstRead = false;
|
|
49
|
-
gdalFeature = this.layer.features.first();
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
gdalFeature = this.layer.features.next();
|
|
53
|
-
}
|
|
54
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, @typescript-eslint/strict-boolean-expressions
|
|
55
|
-
if (!gdalFeature) {
|
|
56
|
-
return Promise.resolve({
|
|
57
|
-
done: true,
|
|
58
|
-
value: undefined,
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
const feature = this.convertToGeoJsonFeature(gdalFeature);
|
|
62
|
-
return Promise.resolve({
|
|
63
|
-
done: false,
|
|
64
|
-
value: feature,
|
|
65
|
-
});
|
|
66
|
-
};
|
|
67
|
-
/**
|
|
68
|
-
* Closes the underlying dataset and releases resources.
|
|
69
|
-
* Should be called when done reading the shapefile.
|
|
70
|
-
*/
|
|
71
|
-
close() {
|
|
72
|
-
this.dataset.close();
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Converts a GDAL feature to a GeoJSON Feature object.
|
|
76
|
-
*
|
|
77
|
-
* @param gdalFeature - The GDAL feature to convert
|
|
78
|
-
* @returns GeoJSON Feature object
|
|
79
|
-
*/
|
|
80
|
-
convertToGeoJsonFeature(gdalFeature) {
|
|
81
|
-
const geometry = gdalFeature.getGeometry();
|
|
82
|
-
const properties = gdalFeature.fields.toObject();
|
|
83
|
-
// Convert GDAL geometry to GeoJSON
|
|
84
|
-
let geoJsonGeometry = null;
|
|
85
|
-
if (geometry) {
|
|
86
|
-
geoJsonGeometry = geometry.toObject();
|
|
87
|
-
}
|
|
88
|
-
const feature = {
|
|
89
|
-
type: 'Feature',
|
|
90
|
-
geometry: geoJsonGeometry,
|
|
91
|
-
properties,
|
|
92
|
-
};
|
|
93
|
-
// Preserve feature ID if present
|
|
94
|
-
const fid = gdalFeature.fid;
|
|
95
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
96
|
-
if (fid !== undefined) {
|
|
97
|
-
feature.id = fid;
|
|
98
|
-
}
|
|
99
|
-
return feature;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
exports.GdalShapefileReader = GdalShapefileReader;
|
|
103
|
-
/**
|
|
104
|
-
* Factory function to open a shapefile using gdal-async.
|
|
105
|
-
*
|
|
106
|
-
* @param shapefilePath - Path to the .shp file
|
|
107
|
-
* @returns Promise resolving to a shapefile reader
|
|
108
|
-
*/
|
|
109
|
-
async function openShapefile(shapefilePath) {
|
|
110
|
-
return GdalShapefileReader.open(shapefilePath);
|
|
111
|
-
}
|
|
112
|
-
//# sourceMappingURL=gdalShapefileReader.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"gdalShapefileReader.js","sourceRoot":"","sources":["../../../../src/files/shapefile/core/gdalShapefileReader.ts"],"names":[],"mappings":";;;;;;AAmIA,sCAEC;AArID,4DAA8B;AAqB9B;;;;;;GAMG;AACH,MAAa,mBAAmB;IAIO;IAHpB,KAAK,CAAa;IAC3B,WAAW,GAAG,IAAI,CAAC;IAE3B,YAAqC,OAAqB;QAArB,YAAO,GAAP,OAAO,CAAc;QACxD,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACrC,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,aAAqB;QAC5C,gFAAgF;QAChF,mFAAmF;QACnF,MAAM,OAAO,GAAG,MAAM,oBAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;QACpD,OAAO,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;IAED;;;;;OAKG;IACH,qEAAqE;IACrD,IAAI,GAAG,GAAiC,EAAE;QACxD,6FAA6F;QAC7F,IAAI,WAAgC,CAAC;QAErC,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;YACzB,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QAC5C,CAAC;aAAM,CAAC;YACN,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;QAC3C,CAAC;QAED,sHAAsH;QACtH,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,OAAO,OAAO,CAAC,OAAO,CAAC;gBACrB,IAAI,EAAE,IAAI;gBACV,KAAK,EAAE,SAA+B;aACvC,CAAC,CAAC;QACL,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC;QAE1D,OAAO,OAAO,CAAC,OAAO,CAAC;YACrB,IAAI,EAAE,KAAK;YACX,KAAK,EAAE,OAAO;SACf,CAAC,CAAC;IACL,CAAC,CAAC;IAEF;;;OAGG;IACI,KAAK;QACV,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;IAED;;;;;OAKG;IACK,uBAAuB,CAAC,WAAyB;QACvD,MAAM,QAAQ,GAAG,WAAW,CAAC,WAAW,EAAE,CAAC;QAC3C,MAAM,UAAU,GAAG,WAAW,CAAC,MAAM,CAAC,QAAQ,EAAuB,CAAC;QAEtE,mCAAmC;QACnC,IAAI,eAAe,GAAoB,IAAI,CAAC;QAC5C,IAAI,QAAQ,EAAE,CAAC;YACb,eAAe,GAAG,QAAQ,CAAC,QAAQ,EAAc,CAAC;QACpD,CAAC;QAED,MAAM,OAAO,GAAY;YACvB,IAAI,EAAE,SAAS;YACf,QAAQ,EAAE,eAA2B;YACrC,UAAU;SACX,CAAC;QAEF,iCAAiC;QACjC,MAAM,GAAG,GAAG,WAAW,CAAC,GAAG,CAAC;QAC5B,uEAAuE;QACvE,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACtB,OAAO,CAAC,EAAE,GAAG,GAAG,CAAC;QACnB,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AA/FD,kDA+FC;AAED;;;;;GAKG;AACI,KAAK,UAAU,aAAa,CAAC,aAAqB;IACvD,OAAO,mBAAmB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { FileMetrics, MetricsCollector, ShapefileChunk } from '../types';
|
|
2
|
-
export interface IMetricsManager {
|
|
3
|
-
/**
|
|
4
|
-
* Updates metrics with chunk processing information
|
|
5
|
-
* @param chunk The chunk that was processed
|
|
6
|
-
* @param readTime Time spent reading the chunk in milliseconds
|
|
7
|
-
* @param processTime Time spent processing the chunk in milliseconds
|
|
8
|
-
*/
|
|
9
|
-
sendChunkMetrics: (chunk: ShapefileChunk, readTime: number, processTime: number) => void;
|
|
10
|
-
/**
|
|
11
|
-
* Finalizes metrics collection and notifies collectors
|
|
12
|
-
* @returns The finalized file metrics
|
|
13
|
-
*/
|
|
14
|
-
sendFileMetrics: () => FileMetrics;
|
|
15
|
-
}
|
|
16
|
-
export declare class MetricsManager implements IMetricsManager {
|
|
17
|
-
private readonly metricsCollector?;
|
|
18
|
-
private readonly fileMetrics;
|
|
19
|
-
constructor(metricsCollector?: MetricsCollector | undefined);
|
|
20
|
-
sendChunkMetrics(chunk: ShapefileChunk, readTime: number, processTime: number): void;
|
|
21
|
-
sendFileMetrics(): FileMetrics;
|
|
22
|
-
private initializeFileMetrics;
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=metricsManager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"metricsManager.d.ts","sourceRoot":"","sources":["../../../../src/files/shapefile/core/metricsManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,WAAW,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAEvF,MAAM,WAAW,eAAe;IAC9B;;;;;OAKG;IACH,gBAAgB,EAAE,CAAC,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IAEzF;;;OAGG;IACH,eAAe,EAAE,MAAM,WAAW,CAAC;CACpC;AAED,qBAAa,cAAe,YAAW,eAAe;IAGjC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC;IAFrD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAc;gBAEN,gBAAgB,CAAC,EAAE,gBAAgB,YAAA;IAIhE,gBAAgB,CAAC,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI;IA4BpF,eAAe,IAAI,WAAW;IAOrC,OAAO,CAAC,qBAAqB;CAY9B"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MetricsManager = void 0;
|
|
4
|
-
class MetricsManager {
|
|
5
|
-
metricsCollector;
|
|
6
|
-
fileMetrics;
|
|
7
|
-
constructor(metricsCollector) {
|
|
8
|
-
this.metricsCollector = metricsCollector;
|
|
9
|
-
this.fileMetrics = this.initializeFileMetrics();
|
|
10
|
-
}
|
|
11
|
-
sendChunkMetrics(chunk, readTime, processTime) {
|
|
12
|
-
const totalTime = readTime + processTime;
|
|
13
|
-
// Update file metrics
|
|
14
|
-
this.fileMetrics.totalFeatures += chunk.features.length;
|
|
15
|
-
this.fileMetrics.totalSkippedFeatures += chunk.skippedFeatures.length;
|
|
16
|
-
this.fileMetrics.totalVertices += chunk.verticesCount;
|
|
17
|
-
this.fileMetrics.totalChunks++;
|
|
18
|
-
this.fileMetrics.totalReadTimeMs += readTime;
|
|
19
|
-
this.fileMetrics.totalProcessTimeMs += processTime;
|
|
20
|
-
this.fileMetrics.totalTimeMs += totalTime;
|
|
21
|
-
// Create chunk metrics
|
|
22
|
-
const chunkMetrics = {
|
|
23
|
-
chunkIndex: chunk.id,
|
|
24
|
-
featuresCount: chunk.features.length,
|
|
25
|
-
skippedFeaturesCount: chunk.skippedFeatures.length,
|
|
26
|
-
verticesCount: chunk.verticesCount,
|
|
27
|
-
readTimeMs: readTime,
|
|
28
|
-
processTimeMs: processTime,
|
|
29
|
-
totalTimeMs: totalTime,
|
|
30
|
-
timestamp: new Date(),
|
|
31
|
-
};
|
|
32
|
-
// Notify metrics collector
|
|
33
|
-
this.metricsCollector?.onChunkMetrics?.(chunkMetrics);
|
|
34
|
-
}
|
|
35
|
-
sendFileMetrics() {
|
|
36
|
-
this.fileMetrics.endTime = new Date();
|
|
37
|
-
this.metricsCollector?.onFileMetrics?.(this.fileMetrics);
|
|
38
|
-
return this.fileMetrics;
|
|
39
|
-
}
|
|
40
|
-
initializeFileMetrics() {
|
|
41
|
-
return {
|
|
42
|
-
totalFeatures: 0,
|
|
43
|
-
totalSkippedFeatures: 0,
|
|
44
|
-
totalVertices: 0,
|
|
45
|
-
totalChunks: 0,
|
|
46
|
-
totalReadTimeMs: 0,
|
|
47
|
-
totalProcessTimeMs: 0,
|
|
48
|
-
totalTimeMs: 0,
|
|
49
|
-
startTime: new Date(),
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
exports.MetricsManager = MetricsManager;
|
|
54
|
-
//# sourceMappingURL=metricsManager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"metricsManager.js","sourceRoot":"","sources":["../../../../src/files/shapefile/core/metricsManager.ts"],"names":[],"mappings":";;;AAkBA,MAAa,cAAc;IAGW;IAFnB,WAAW,CAAc;IAE1C,YAAoC,gBAAmC;QAAnC,qBAAgB,GAAhB,gBAAgB,CAAmB;QACrE,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,qBAAqB,EAAE,CAAC;IAClD,CAAC;IAEM,gBAAgB,CAAC,KAAqB,EAAE,QAAgB,EAAE,WAAmB;QAClF,MAAM,SAAS,GAAG,QAAQ,GAAG,WAAW,CAAC;QAEzC,sBAAsB;QACtB,IAAI,CAAC,WAAW,CAAC,aAAa,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC;QACxD,IAAI,CAAC,WAAW,CAAC,oBAAoB,IAAI,KAAK,CAAC,eAAe,CAAC,MAAM,CAAC;QACtE,IAAI,CAAC,WAAW,CAAC,aAAa,IAAI,KAAK,CAAC,aAAa,CAAC;QACtD,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC;QAC/B,IAAI,CAAC,WAAW,CAAC,eAAe,IAAI,QAAQ,CAAC;QAC7C,IAAI,CAAC,WAAW,CAAC,kBAAkB,IAAI,WAAW,CAAC;QACnD,IAAI,CAAC,WAAW,CAAC,WAAW,IAAI,SAAS,CAAC;QAE1C,uBAAuB;QACvB,MAAM,YAAY,GAAiB;YACjC,UAAU,EAAE,KAAK,CAAC,EAAE;YACpB,aAAa,EAAE,KAAK,CAAC,QAAQ,CAAC,MAAM;YACpC,oBAAoB,EAAE,KAAK,CAAC,eAAe,CAAC,MAAM;YAClD,aAAa,EAAE,KAAK,CAAC,aAAa;YAClC,UAAU,EAAE,QAAQ;YACpB,aAAa,EAAE,WAAW;YAC1B,WAAW,EAAE,SAAS;YACtB,SAAS,EAAE,IAAI,IAAI,EAAE;SACtB,CAAC;QAEF,2BAA2B;QAC3B,IAAI,CAAC,gBAAgB,EAAE,cAAc,EAAE,CAAC,YAAY,CAAC,CAAC;IACxD,CAAC;IAEM,eAAe;QACpB,IAAI,CAAC,WAAW,CAAC,OAAO,GAAG,IAAI,IAAI,EAAE,CAAC;QAEtC,IAAI,CAAC,gBAAgB,EAAE,aAAa,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACzD,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAEO,qBAAqB;QAC3B,OAAO;YACL,aAAa,EAAE,CAAC;YAChB,oBAAoB,EAAE,CAAC;YACvB,aAAa,EAAE,CAAC;YAChB,WAAW,EAAE,CAAC;YACd,eAAe,EAAE,CAAC;YAClB,kBAAkB,EAAE,CAAC;YACrB,WAAW,EAAE,CAAC;YACd,SAAS,EAAE,IAAI,IAAI,EAAE;SACtB,CAAC;IACJ,CAAC;CACF;AAtDD,wCAsDC"}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { InitialProgress, ProgressInfo } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Interface for progress tracking functionality
|
|
4
|
-
*/
|
|
5
|
-
export interface IProgressTracker {
|
|
6
|
-
/**
|
|
7
|
-
* Increments the features counter vertices processed
|
|
8
|
-
* @param featuresCount Number of features processed in the current operation
|
|
9
|
-
* @param processedVertices Number of vertices processed in the current operation
|
|
10
|
-
*/
|
|
11
|
-
addProcessedFeatures: (featuresCount: number, processedVertices: number) => void;
|
|
12
|
-
/**
|
|
13
|
-
* Increments the skipped features counter
|
|
14
|
-
* @param count Number of skipped features
|
|
15
|
-
*/
|
|
16
|
-
addSkippedFeatures: (count: number) => void;
|
|
17
|
-
/**
|
|
18
|
-
* Increments the chunks counter
|
|
19
|
-
*/
|
|
20
|
-
incrementChunks: () => void;
|
|
21
|
-
/**
|
|
22
|
-
* Gets the number of processed features
|
|
23
|
-
* @returns Number of processed features
|
|
24
|
-
*/
|
|
25
|
-
getProcessedFeatures: () => number;
|
|
26
|
-
/**
|
|
27
|
-
* Calculates and returns current progress information
|
|
28
|
-
* @returns Current progress information
|
|
29
|
-
*/
|
|
30
|
-
calculateProgress: () => ProgressInfo;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Configuration options for ProgressTracker constructor
|
|
34
|
-
*/
|
|
35
|
-
export interface ProgressTrackerOptions {
|
|
36
|
-
totalVertices: number;
|
|
37
|
-
totalFeatures: number;
|
|
38
|
-
maxVerticesPerChunk: number;
|
|
39
|
-
initialProgress?: InitialProgress;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Implementation of progress tracking for shapefile processing
|
|
43
|
-
*/
|
|
44
|
-
export declare class ProgressTracker implements IProgressTracker {
|
|
45
|
-
private readonly startTime;
|
|
46
|
-
private readonly totalVertices;
|
|
47
|
-
private readonly totalFeatures;
|
|
48
|
-
private readonly maxVerticesPerChunk;
|
|
49
|
-
private processedVertices;
|
|
50
|
-
private processedFeatures;
|
|
51
|
-
private skippedFeatures;
|
|
52
|
-
private processedChunks;
|
|
53
|
-
constructor(options: ProgressTrackerOptions);
|
|
54
|
-
addProcessedFeatures(featuresCount: number, processedVertices: number): void;
|
|
55
|
-
addSkippedFeatures(count: number): void;
|
|
56
|
-
getProcessedFeatures(): number;
|
|
57
|
-
incrementChunks(): void;
|
|
58
|
-
calculateProgress(): ProgressInfo;
|
|
59
|
-
}
|
|
60
|
-
//# sourceMappingURL=progressTracker.d.ts.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,GAAG,IAAI;IAIvC,oBAAoB,IAAI,MAAM;IAI9B,eAAe,IAAI,IAAI;IAIvB,iBAAiB,IAAI,YAAY;CA4CzC"}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ProgressTracker = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Implementation of progress tracking for shapefile processing
|
|
6
|
-
*/
|
|
7
|
-
class ProgressTracker {
|
|
8
|
-
startTime;
|
|
9
|
-
totalVertices;
|
|
10
|
-
totalFeatures;
|
|
11
|
-
maxVerticesPerChunk;
|
|
12
|
-
processedVertices;
|
|
13
|
-
processedFeatures;
|
|
14
|
-
skippedFeatures;
|
|
15
|
-
processedChunks;
|
|
16
|
-
constructor(options) {
|
|
17
|
-
this.totalVertices = options.totalVertices;
|
|
18
|
-
this.totalFeatures = options.totalFeatures;
|
|
19
|
-
this.maxVerticesPerChunk = options.maxVerticesPerChunk;
|
|
20
|
-
const initialProgress = options.initialProgress ?? {
|
|
21
|
-
processedChunks: 0,
|
|
22
|
-
processedFeatures: 0,
|
|
23
|
-
processedVertices: 0,
|
|
24
|
-
skippedFeatures: 0,
|
|
25
|
-
startTime: Date.now(),
|
|
26
|
-
};
|
|
27
|
-
this.startTime = initialProgress.startTime;
|
|
28
|
-
this.processedVertices = initialProgress.processedVertices;
|
|
29
|
-
this.processedFeatures = initialProgress.processedFeatures;
|
|
30
|
-
this.processedChunks = initialProgress.processedChunks;
|
|
31
|
-
this.skippedFeatures = initialProgress.skippedFeatures;
|
|
32
|
-
}
|
|
33
|
-
addProcessedFeatures(featuresCount, processedVertices) {
|
|
34
|
-
this.processedVertices += processedVertices;
|
|
35
|
-
this.processedFeatures += featuresCount;
|
|
36
|
-
}
|
|
37
|
-
addSkippedFeatures(count) {
|
|
38
|
-
this.skippedFeatures += count;
|
|
39
|
-
}
|
|
40
|
-
getProcessedFeatures() {
|
|
41
|
-
return this.processedFeatures;
|
|
42
|
-
}
|
|
43
|
-
incrementChunks() {
|
|
44
|
-
this.processedChunks++;
|
|
45
|
-
}
|
|
46
|
-
calculateProgress() {
|
|
47
|
-
const currentTime = Date.now();
|
|
48
|
-
const elapsedTimeMs = currentTime - this.startTime;
|
|
49
|
-
// Calculate percentage based on vertices processed
|
|
50
|
-
let percentage = 0;
|
|
51
|
-
const maxPercentage = 100;
|
|
52
|
-
if (this.totalVertices > 0) {
|
|
53
|
-
percentage = Math.min((this.processedVertices / this.totalVertices) * maxPercentage, maxPercentage);
|
|
54
|
-
}
|
|
55
|
-
// Calculate processing speeds
|
|
56
|
-
const millisecondsPerSecond = 1000;
|
|
57
|
-
const elapsedSeconds = elapsedTimeMs / millisecondsPerSecond;
|
|
58
|
-
const featuresPerSecond = elapsedSeconds > 0 ? this.processedFeatures / elapsedSeconds : 0;
|
|
59
|
-
const verticesPerSecond = elapsedSeconds > 0 ? this.processedVertices / elapsedSeconds : 0;
|
|
60
|
-
const chunksPerSecond = elapsedSeconds > 0 ? this.processedChunks / elapsedSeconds : 0;
|
|
61
|
-
// Estimate remaining time
|
|
62
|
-
let estimatedRemainingTimeMs = 0;
|
|
63
|
-
if (percentage > 0 && percentage < maxPercentage) {
|
|
64
|
-
const totalEstimatedTimeMs = (elapsedTimeMs / percentage) * maxPercentage;
|
|
65
|
-
estimatedRemainingTimeMs = totalEstimatedTimeMs - elapsedTimeMs;
|
|
66
|
-
}
|
|
67
|
-
const endTime = this.processedFeatures === this.totalFeatures ? currentTime : undefined;
|
|
68
|
-
return {
|
|
69
|
-
processedFeatures: this.processedFeatures,
|
|
70
|
-
totalFeatures: this.totalFeatures,
|
|
71
|
-
processedChunks: this.processedChunks,
|
|
72
|
-
processedVertices: this.processedVertices,
|
|
73
|
-
totalVertices: this.totalVertices,
|
|
74
|
-
skippedFeatures: this.skippedFeatures,
|
|
75
|
-
percentage,
|
|
76
|
-
elapsedTimeMs,
|
|
77
|
-
estimatedRemainingTimeMs,
|
|
78
|
-
featuresPerSecond,
|
|
79
|
-
verticesPerSecond,
|
|
80
|
-
chunksPerSecond,
|
|
81
|
-
startTime: this.startTime,
|
|
82
|
-
endTime,
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
exports.ProgressTracker = ProgressTracker;
|
|
87
|
-
//# sourceMappingURL=progressTracker.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"progressTracker.js","sourceRoot":"","sources":["../../../../src/files/shapefile/core/progressTracker.ts"],"names":[],"mappings":";;;AA+CA;;GAEG;AACH,MAAa,eAAe;IACT,SAAS,CAAS;IAClB,aAAa,CAAS;IACtB,aAAa,CAAS;IACtB,mBAAmB,CAAS;IACrC,iBAAiB,CAAS;IAC1B,iBAAiB,CAAS;IAC1B,eAAe,CAAS;IACxB,eAAe,CAAS;IAEhC,YAAmB,OAA+B;QAChD,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;QAC3C,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;QAC3C,IAAI,CAAC,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,CAAC;QAEvD,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe,IAAI;YACjD,eAAe,EAAE,CAAC;YAClB,iBAAiB,EAAE,CAAC;YACpB,iBAAiB,EAAE,CAAC;YACpB,eAAe,EAAE,CAAC;YAClB,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;SACtB,CAAC;QAEF,IAAI,CAAC,SAAS,GAAG,eAAe,CAAC,SAAS,CAAC;QAC3C,IAAI,CAAC,iBAAiB,GAAG,eAAe,CAAC,iBAAiB,CAAC;QAC3D,IAAI,CAAC,iBAAiB,GAAG,eAAe,CAAC,iBAAiB,CAAC;QAC3D,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC,eAAe,CAAC;QACvD,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC,eAAe,CAAC;IACzD,CAAC;IAEM,oBA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CAAC,CAAC;QAEvF,0BAA0B;QAC1B,IAAI,wBAAwB,GAAG,CAAC,CAAC;QACjC,IAAI,UAAU,GAAG,CAAC,IAAI,UAAU,GAAG,aAAa,EAAE,CAAC;YACjD,MAAM,oBAAoB,GAAG,CAAC,aAAa,GAAG,UAAU,CAAC,GAAG,aAAa,CAAC;YAC1E,wBAAwB,GAAG,oBAAoB,GAAG,aAAa,CAAC;QAClE,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,iBAAiB,KAAK,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC;QAExF,OAAO;YACL,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;YACzC,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;YACzC,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,UAAU;YACV,aAAa;YACb,wBAAwB;YACxB,iBAAiB;YACjB,iBAAiB;YACjB,eAAe;YACf,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,OAAO;SACR,CAAC;IACJ,CAAC;CACF;AA3FD,0CA2FC"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { ChunkProcessor, ProgressInfo, ReaderOptions } from '../types';
|
|
2
|
-
export declare class ShapefileChunkReader {
|
|
3
|
-
private readonly options;
|
|
4
|
-
private metricsManager?;
|
|
5
|
-
private progressTracker?;
|
|
6
|
-
private lastState;
|
|
7
|
-
constructor(options: ReaderOptions);
|
|
8
|
-
/**
|
|
9
|
-
* Reads a shapefile and processes it in chunks.
|
|
10
|
-
* @param shapefilePath Path to the shapefile to read
|
|
11
|
-
* @param processor Processor to handle each chunk of features
|
|
12
|
-
*/
|
|
13
|
-
readAndProcess(shapefilePath: string, processor: ChunkProcessor): Promise<void>;
|
|
14
|
-
/**
|
|
15
|
-
* Count total features and vertices in the shapefile for progress calculation
|
|
16
|
-
* @param shapefilePath Path to the shapefile
|
|
17
|
-
* @returns Total number of features and vertices in the shapefile
|
|
18
|
-
*/
|
|
19
|
-
getShapefileStats(shapefilePath: string): Promise<Pick<ProgressInfo, 'totalVertices' | 'totalFeatures'>>;
|
|
20
|
-
private processChunk;
|
|
21
|
-
/**
|
|
22
|
-
* Save processing state if state manager is available
|
|
23
|
-
* @param state State object containing the required state information
|
|
24
|
-
*/
|
|
25
|
-
private saveProcessingState;
|
|
26
|
-
private initializeReading;
|
|
27
|
-
private shouldSkipFeature;
|
|
28
|
-
private hasContentToProcess;
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=shapeFileReader.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"shapeFileReader.d.ts","sourceRoot":"","sources":["../../../../src/files/shapefile/core/shapeFileReader.ts"],"names":[],"mappings":"AAGA,OAAO,EAAiB,cAAc,EAAmB,YAAY,EAAE,aAAa,EAAkB,MAAM,UAAU,CAAC;AAMvH,qBAAa,oBAAoB;IAKZ,OAAO,CAAC,QAAQ,CAAC,OAAO;IAJ3C,OAAO,CAAC,cAAc,CAAC,CAAkB;IACzC,OAAO,CAAC,eAAe,CAAC,CAAmB;IAC3C,OAAO,CAAC,SAAS,CAAgC;gBAEb,OAAO,EAAE,aAAa;IAE1D;;;;OAIG;IACU,cAAc,CAAC,aAAa,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IA0F5F;;;;OAIG;IACU,iBAAiB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,eAAe,GAAG,eAAe,CAAC,CAAC;YA0CvG,YAAY;IA+B1B;;;OAGG;YACW,mBAAmB;YAenB,iBAAiB;IAuB/B,OAAO,CAAC,iBAAiB;IAIzB,OAAO,CAAC,mBAAmB;CAG5B"}
|
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ShapefileChunkReader = void 0;
|
|
4
|
-
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
|
|
5
|
-
const node_crypto_1 = require("node:crypto");
|
|
6
|
-
const vertices_1 = require("../../../geo/vertices");
|
|
7
|
-
const types_1 = require("../types");
|
|
8
|
-
const chunkBuilder_1 = require("./chunkBuilder");
|
|
9
|
-
const gdalShapefileReader_1 = require("./gdalShapefileReader");
|
|
10
|
-
const metricsManager_1 = require("./metricsManager");
|
|
11
|
-
const progressTracker_1 = require("./progressTracker");
|
|
12
|
-
class ShapefileChunkReader {
|
|
13
|
-
options;
|
|
14
|
-
metricsManager;
|
|
15
|
-
progressTracker;
|
|
16
|
-
lastState = null;
|
|
17
|
-
constructor(options) {
|
|
18
|
-
this.options = options;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Reads a shapefile and processes it in chunks.
|
|
22
|
-
* @param shapefilePath Path to the shapefile to read
|
|
23
|
-
* @param processor Processor to handle each chunk of features
|
|
24
|
-
*/
|
|
25
|
-
async readAndProcess(shapefilePath, processor) {
|
|
26
|
-
const chunkIndex = await this.initializeReading(shapefilePath);
|
|
27
|
-
let readFeatureIndex = -1;
|
|
28
|
-
const chunkBuilder = new chunkBuilder_1.ChunkBuilder(this.options.maxVerticesPerChunk, chunkIndex);
|
|
29
|
-
let reader;
|
|
30
|
-
try {
|
|
31
|
-
reader = await (0, gdalShapefileReader_1.openShapefile)(shapefilePath);
|
|
32
|
-
this.options.logger?.info({ msg: 'Reading started' });
|
|
33
|
-
const generateFeatureId = this.options.generateFeatureId ?? false;
|
|
34
|
-
let readStart = performance.now();
|
|
35
|
-
while (true) {
|
|
36
|
-
const { done, value: shapeFeature } = await reader.read();
|
|
37
|
-
if (done) {
|
|
38
|
-
break;
|
|
39
|
-
}
|
|
40
|
-
readFeatureIndex++;
|
|
41
|
-
if (this.shouldSkipFeature(readFeatureIndex)) {
|
|
42
|
-
continue;
|
|
43
|
-
}
|
|
44
|
-
const feature = {
|
|
45
|
-
...shapeFeature,
|
|
46
|
-
properties: {
|
|
47
|
-
...shapeFeature.properties,
|
|
48
|
-
...(generateFeatureId && { id: (0, node_crypto_1.randomUUID)() }),
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
if (feature.properties.id !== undefined) {
|
|
52
|
-
this.options.logger?.debug({ msg: `Feature ID: ${feature.properties.id}` });
|
|
53
|
-
}
|
|
54
|
-
const canAddFeature = chunkBuilder.canAddFeature(feature);
|
|
55
|
-
if (canAddFeature === types_1.FeatureStatus.SKIPPED) {
|
|
56
|
-
this.options.logger?.warn({
|
|
57
|
-
msg: `Feature skipped due to exceeding max vertices`,
|
|
58
|
-
featureId: feature.properties.id,
|
|
59
|
-
});
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
if (canAddFeature === types_1.FeatureStatus.FULL) {
|
|
63
|
-
const readTime = performance.now() - readStart;
|
|
64
|
-
const chunk = chunkBuilder.build();
|
|
65
|
-
this.options.logger?.info({ msg: 'Chunk reading finished', readTime, chunkIndex: chunk.id, featuresCount: chunk.features.length });
|
|
66
|
-
if (this.hasContentToProcess(chunk)) {
|
|
67
|
-
await this.processChunk(chunk, processor, shapefilePath, readTime);
|
|
68
|
-
}
|
|
69
|
-
chunkBuilder.nextChunk();
|
|
70
|
-
readStart = performance.now();
|
|
71
|
-
}
|
|
72
|
-
chunkBuilder.addFeature(feature);
|
|
73
|
-
}
|
|
74
|
-
// Process any remaining features
|
|
75
|
-
const readTime = performance.now() - readStart;
|
|
76
|
-
const finalChunk = chunkBuilder.build();
|
|
77
|
-
if (this.hasContentToProcess(finalChunk)) {
|
|
78
|
-
this.options.logger?.info({
|
|
79
|
-
msg: 'Final chunk reading finished',
|
|
80
|
-
});
|
|
81
|
-
await this.processChunk(finalChunk, processor, shapefilePath, readTime);
|
|
82
|
-
}
|
|
83
|
-
this.metricsManager?.sendFileMetrics();
|
|
84
|
-
}
|
|
85
|
-
catch (error) {
|
|
86
|
-
const lastFeatureIndex = (this.progressTracker?.getProcessedFeatures() ?? 0) - 1;
|
|
87
|
-
this.options.logger?.error({ msg: 'Error processing shapefile', shapefilePath, lastFeatureIndex, error });
|
|
88
|
-
await this.saveProcessingState({
|
|
89
|
-
filePath: shapefilePath,
|
|
90
|
-
chunkIndex: chunkBuilder.chunkId,
|
|
91
|
-
lastFeatureIndex,
|
|
92
|
-
});
|
|
93
|
-
throw error;
|
|
94
|
-
}
|
|
95
|
-
finally {
|
|
96
|
-
reader?.close();
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Count total features and vertices in the shapefile for progress calculation
|
|
101
|
-
* @param shapefilePath Path to the shapefile
|
|
102
|
-
* @returns Total number of features and vertices in the shapefile
|
|
103
|
-
*/
|
|
104
|
-
async getShapefileStats(shapefilePath) {
|
|
105
|
-
let reader;
|
|
106
|
-
let totalVertices = 0;
|
|
107
|
-
let totalFeatures = 0;
|
|
108
|
-
try {
|
|
109
|
-
reader = await (0, gdalShapefileReader_1.openShapefile)(shapefilePath);
|
|
110
|
-
while (true) {
|
|
111
|
-
const { done, value: feature } = await reader.read();
|
|
112
|
-
if (done) {
|
|
113
|
-
break;
|
|
114
|
-
}
|
|
115
|
-
const vertices = (0, vertices_1.countVertices)(feature.geometry);
|
|
116
|
-
if (vertices > this.options.maxVerticesPerChunk) {
|
|
117
|
-
this.options.logger?.warn({
|
|
118
|
-
msg: `Feature exceeds maximum vertices limit: ${vertices} > ${this.options.maxVerticesPerChunk}`,
|
|
119
|
-
featureId: feature.id,
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
totalFeatures++;
|
|
123
|
-
totalVertices += vertices;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
catch (error) {
|
|
127
|
-
this.options.logger?.error({ msg: 'Error counting vertices in shapefile', shapefilePath, error });
|
|
128
|
-
throw error;
|
|
129
|
-
}
|
|
130
|
-
finally {
|
|
131
|
-
reader?.close();
|
|
132
|
-
}
|
|
133
|
-
if (totalFeatures === 0 || totalVertices === 0) {
|
|
134
|
-
const message = `Shapefile ${shapefilePath} has no valid features or vertices`;
|
|
135
|
-
this.options.logger?.error({ msg: message });
|
|
136
|
-
throw new Error(message);
|
|
137
|
-
}
|
|
138
|
-
return { totalVertices, totalFeatures };
|
|
139
|
-
}
|
|
140
|
-
async processChunk(chunk, processor, filePath, readTime = 0) {
|
|
141
|
-
const processStart = performance.now();
|
|
142
|
-
try {
|
|
143
|
-
this.options.logger?.info({ msg: 'Processing chunk', chunkIndex: chunk.id, featuresCount: chunk.features.length, filePath, readTime });
|
|
144
|
-
await processor.process(chunk);
|
|
145
|
-
this.options.logger?.info({ msg: 'Chunk processing finished', chunkIndex: chunk.id });
|
|
146
|
-
}
|
|
147
|
-
catch (error) {
|
|
148
|
-
this.options.logger?.error({ msg: `Error processing chunk ${chunk.id}`, error });
|
|
149
|
-
throw error;
|
|
150
|
-
}
|
|
151
|
-
const processTime = performance.now() - processStart;
|
|
152
|
-
this.metricsManager?.sendChunkMetrics(chunk, readTime, processTime);
|
|
153
|
-
const chunkTotalFeatures = chunk.features.length + chunk.skippedFeatures.length;
|
|
154
|
-
const chunkTotalVertices = chunk.verticesCount + chunk.skippedVerticesCount;
|
|
155
|
-
this.progressTracker?.addProcessedFeatures(chunkTotalFeatures, chunkTotalVertices);
|
|
156
|
-
this.progressTracker?.addSkippedFeatures(chunk.skippedFeatures.length);
|
|
157
|
-
this.progressTracker?.incrementChunks();
|
|
158
|
-
const lastFeatureIndex = (this.progressTracker?.getProcessedFeatures() ?? 0) - 1;
|
|
159
|
-
// Save state after successful processing with progress information
|
|
160
|
-
await this.saveProcessingState({
|
|
161
|
-
filePath,
|
|
162
|
-
chunkIndex: chunk.id,
|
|
163
|
-
lastFeatureIndex,
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Save processing state if state manager is available
|
|
168
|
-
* @param state State object containing the required state information
|
|
169
|
-
*/
|
|
170
|
-
async saveProcessingState(state) {
|
|
171
|
-
if (!this.options.stateManager) {
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
const currentState = {
|
|
175
|
-
filePath: state.filePath,
|
|
176
|
-
lastProcessedChunkIndex: state.chunkIndex,
|
|
177
|
-
lastProcessedFeatureIndex: state.lastFeatureIndex,
|
|
178
|
-
timestamp: new Date(),
|
|
179
|
-
progress: this.progressTracker?.calculateProgress(),
|
|
180
|
-
};
|
|
181
|
-
await this.options.stateManager.saveState(currentState);
|
|
182
|
-
}
|
|
183
|
-
async initializeReading(shapefilePath) {
|
|
184
|
-
try {
|
|
185
|
-
if (this.options.metricsCollector) {
|
|
186
|
-
this.metricsManager = new metricsManager_1.MetricsManager(this.options.metricsCollector);
|
|
187
|
-
}
|
|
188
|
-
this.lastState = (await this.options.stateManager?.loadState()) ?? null;
|
|
189
|
-
const { totalFeatures, totalVertices } = this.lastState?.progress ?? (await this.getShapefileStats(shapefilePath));
|
|
190
|
-
this.progressTracker = new progressTracker_1.ProgressTracker({
|
|
191
|
-
totalVertices,
|
|
192
|
-
totalFeatures,
|
|
193
|
-
maxVerticesPerChunk: this.options.maxVerticesPerChunk,
|
|
194
|
-
initialProgress: this.lastState?.progress,
|
|
195
|
-
});
|
|
196
|
-
const chunkIndex = this.lastState?.lastProcessedChunkIndex ?? 0;
|
|
197
|
-
return chunkIndex;
|
|
198
|
-
}
|
|
199
|
-
catch (error) {
|
|
200
|
-
this.options.logger?.error({ msg: 'Failed to initialize reading', error });
|
|
201
|
-
throw error;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
shouldSkipFeature(featureIndex) {
|
|
205
|
-
return this.lastState !== null && featureIndex <= this.lastState.lastProcessedFeatureIndex;
|
|
206
|
-
}
|
|
207
|
-
hasContentToProcess(chunk) {
|
|
208
|
-
return chunk.features.length > 0 || chunk.skippedFeatures.length > 0;
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
exports.ShapefileChunkReader = ShapefileChunkReader;
|
|
212
|
-
//# sourceMappingURL=shapeFileReader.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"shapeFileReader.js","sourceRoot":"","sources":["../../../../src/files/shapefile/core/shapeFileReader.ts"],"names":[],"mappings":";;;AAAA,gEAAgE;AAChE,6CAAyC;AACzC,oDAAsD;AACtD,oCAAuH;AACvH,iDAA8C;AAC9C,+DAAwE;AACxE,qDAAmE;AACnE,uDAAsE;AAEtE,MAAa,oBAAoB;IAKK;IAJ5B,cAAc,CAAmB;IACjC,eAAe,CAAoB;IACnC,SAAS,GAA2B,IAAI,CAAC;IAEjD,YAAoC,OAAsB;QAAtB,YAAO,GAAP,OAAO,CAAe;IAAG,CAAC;IAE9D;;;;OAIG;IACI,KAAK,CAAC,cAAc,CAAC,aAAqB,EAAE,SAAyB;QAC1E,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,aAAa,CAAC,CAAC;QAC/D,IAAI,gBAAgB,GAAG,CAAC,CAAC,CAAC;QAE1B,MAAM,YAAY,GAAG,IAAI,2BAAY,CAAC,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE,UAAU,CAAC,CAAC;QACpF,IAAI,MAAoC,CAAC;QACzC,IAAI,CAAC;YACH,MAAM,GAAG,MAAM,IAAA,mCAAa,EAAC,aAAa,CAAC,CAAC;YAC5C,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,iBAAiB,EAAE,CAAC,CAAC;YAEtD,MAAM,iBAAiB,GAAG,IAAI,CAAC,OAAO,CAAC,iBAAiB,IAAI,KAAK,CAAC;YAElE,IAAI,SAAS,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;YAElC,OAAO,IAAI,EAAE,CAAC;gBACZ,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE,GA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-1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/files/shapefile/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACvH,cAAc,SAAS,CAAC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.GdalShapefileReader = exports.openShapefile = exports.ShapefileChunkReader = void 0;
|
|
18
|
-
var shapeFileReader_1 = require("./core/shapeFileReader");
|
|
19
|
-
Object.defineProperty(exports, "ShapefileChunkReader", { enumerable: true, get: function () { return shapeFileReader_1.ShapefileChunkReader; } });
|
|
20
|
-
var gdalShapefileReader_1 = require("./core/gdalShapefileReader");
|
|
21
|
-
Object.defineProperty(exports, "openShapefile", { enumerable: true, get: function () { return gdalShapefileReader_1.openShapefile; } });
|
|
22
|
-
Object.defineProperty(exports, "GdalShapefileReader", { enumerable: true, get: function () { return gdalShapefileReader_1.GdalShapefileReader; } });
|
|
23
|
-
__exportStar(require("./types"), exports);
|
|
24
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/files/shapefile/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,0DAA8D;AAArD,uHAAA,oBAAoB,OAAA;AAC7B,kEAAuH;AAA9G,oHAAA,aAAa,OAAA;AAAE,0HAAA,mBAAmB,OAAA;AAC3C,0CAAwB"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { Feature } from 'geojson';
|
|
2
|
-
import { Logger } from '@map-colonies/js-logger';
|
|
3
|
-
import { StateManager } from '../types';
|
|
4
|
-
import { MetricsCollector } from './metrics';
|
|
5
|
-
export * from './metrics';
|
|
6
|
-
export * from './state';
|
|
7
|
-
export interface ShapefileChunk {
|
|
8
|
-
id: number;
|
|
9
|
-
features: Feature[];
|
|
10
|
-
verticesCount: number;
|
|
11
|
-
skippedFeatures: Feature[];
|
|
12
|
-
skippedVerticesCount: number;
|
|
13
|
-
}
|
|
14
|
-
export interface ChunkProcessor {
|
|
15
|
-
process: (chunk: ShapefileChunk) => Promise<void>;
|
|
16
|
-
}
|
|
17
|
-
export interface ReaderOptions {
|
|
18
|
-
/** Maximum vertices per chunk to control memory usage */
|
|
19
|
-
maxVerticesPerChunk: number;
|
|
20
|
-
/** Determines whether a unique feature identifier should be automatically generated for each feature missing an indentifier */
|
|
21
|
-
generateFeatureId?: boolean;
|
|
22
|
-
/** Logger for debugging and monitoring */
|
|
23
|
-
logger?: Logger;
|
|
24
|
-
/** State manager for resumable processing */
|
|
25
|
-
stateManager?: StateManager;
|
|
26
|
-
/** Metrics collector for performance monitoring */
|
|
27
|
-
metricsCollector?: MetricsCollector;
|
|
28
|
-
}
|
|
29
|
-
export declare const FeatureStatus: {
|
|
30
|
-
readonly ADD: "ADD";
|
|
31
|
-
readonly FULL: "FULL";
|
|
32
|
-
readonly SKIPPED: "SKIPPED";
|
|
33
|
-
};
|
|
34
|
-
export type FeatureStatus = keyof typeof FeatureStatus;
|
|
35
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/files/shapefile/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AAExB,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,OAAO,EAAE,CAAC;IAC3B,oBAAoB,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACnD;AAED,MAAM,WAAW,aAAa;IAC5B,yDAAyD;IACzD,mBAAmB,EAAE,MAAM,CAAC;IAC5B,+HAA+H;IAC/H,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,0CAA0C;IAC1C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,mDAAmD;IACnD,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACrC;AAGD,eAAO,MAAM,aAAa;;;;CAIhB,CAAC;AAGX,MAAM,MAAM,aAAa,GAAG,MAAM,OAAO,aAAa,CAAC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.FeatureStatus = void 0;
|
|
18
|
-
__exportStar(require("./metrics"), exports);
|
|
19
|
-
__exportStar(require("./state"), exports);
|
|
20
|
-
/* eslint-disable @typescript-eslint/naming-convention */
|
|
21
|
-
exports.FeatureStatus = {
|
|
22
|
-
ADD: 'ADD',
|
|
23
|
-
FULL: 'FULL',
|
|
24
|
-
SKIPPED: 'SKIPPED',
|
|
25
|
-
};
|
|
26
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/files/shapefile/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAKA,4CAA0B;AAC1B,0CAAwB;AA2BxB,yDAAyD;AAC5C,QAAA,aAAa,GAAG;IAC3B,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;CACV,CAAC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export interface ChunkMetrics {
|
|
2
|
-
chunkIndex: number;
|
|
3
|
-
featuresCount: number;
|
|
4
|
-
skippedFeaturesCount: number;
|
|
5
|
-
verticesCount: number;
|
|
6
|
-
readTimeMs: number;
|
|
7
|
-
processTimeMs: number;
|
|
8
|
-
totalTimeMs: number;
|
|
9
|
-
timestamp: Date;
|
|
10
|
-
}
|
|
11
|
-
export interface FileMetrics {
|
|
12
|
-
totalFeatures: number;
|
|
13
|
-
totalSkippedFeatures: number;
|
|
14
|
-
totalVertices: number;
|
|
15
|
-
totalChunks: number;
|
|
16
|
-
totalReadTimeMs: number;
|
|
17
|
-
totalProcessTimeMs: number;
|
|
18
|
-
totalTimeMs: number;
|
|
19
|
-
startTime: Date;
|
|
20
|
-
endTime?: Date;
|
|
21
|
-
}
|
|
22
|
-
export interface MetricsCollector {
|
|
23
|
-
onChunkMetrics?: (metrics: ChunkMetrics) => void;
|
|
24
|
-
onFileMetrics?: (metrics: FileMetrics) => void;
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=metrics.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../../../../src/files/shapefile/types/metrics.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,WAAW;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,IAAI,CAAC;IAChB,OAAO,CAAC,EAAE,IAAI,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,CAAC;IACjD,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,CAAC;CAChD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../../../src/files/shapefile/types/metrics.ts"],"names":[],"mappings":""}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export interface StateManager {
|
|
2
|
-
saveState: (state: ProcessingState) => Promise<void> | void;
|
|
3
|
-
loadState: () => (ProcessingState | null) | Promise<ProcessingState | null>;
|
|
4
|
-
}
|
|
5
|
-
export interface ProgressInfo {
|
|
6
|
-
startTime: number;
|
|
7
|
-
endTime?: number;
|
|
8
|
-
processedFeatures: number;
|
|
9
|
-
totalFeatures: number;
|
|
10
|
-
processedChunks: number;
|
|
11
|
-
processedVertices: number;
|
|
12
|
-
totalVertices: number;
|
|
13
|
-
skippedFeatures: number;
|
|
14
|
-
percentage: number;
|
|
15
|
-
elapsedTimeMs: number;
|
|
16
|
-
estimatedRemainingTimeMs: number;
|
|
17
|
-
featuresPerSecond: number;
|
|
18
|
-
verticesPerSecond: number;
|
|
19
|
-
chunksPerSecond: number;
|
|
20
|
-
}
|
|
21
|
-
export type InitialProgress = Pick<ProgressInfo, 'startTime' | 'processedVertices' | 'processedFeatures' | 'processedChunks' | 'skippedFeatures'>;
|
|
22
|
-
export interface ProcessingState {
|
|
23
|
-
filePath: string;
|
|
24
|
-
lastProcessedChunkIndex: number;
|
|
25
|
-
lastProcessedFeatureIndex: number;
|
|
26
|
-
timestamp: Date;
|
|
27
|
-
progress?: ProgressInfo;
|
|
28
|
-
}
|
|
29
|
-
//# sourceMappingURL=state.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../../src/files/shapefile/types/state.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAC5D,SAAS,EAAE,MAAM,CAAC,eAAe,GAAG,IAAI,CAAC,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAAC;CAC7E;AAED,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,wBAAwB,EAAE,MAAM,CAAC;IACjC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,YAAY,EAAE,WAAW,GAAG,mBAAmB,GAAG,mBAAmB,GAAG,iBAAiB,GAAG,iBAAiB,CAAC,CAAC;AAElJ,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,uBAAuB,EAAE,MAAM,CAAC;IAChC,yBAAyB,EAAE,MAAM,CAAC;IAClC,SAAS,EAAE,IAAI,CAAC;IAChB,QAAQ,CAAC,EAAE,YAAY,CAAC;CACzB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"state.js","sourceRoot":"","sources":["../../../../src/files/shapefile/types/state.ts"],"names":[],"mappings":""}
|