@hastehaul/common 3.8.0 → 3.10.0
Sign up to get free protection for your applications and to get access to all the features.
- package/build/utils/utils.d.ts +4 -2
- package/build/utils/utils.js +1 -12
- package/package.json +1 -1
package/build/utils/utils.d.ts
CHANGED
@@ -10,13 +10,15 @@ export declare function generateIdentifier(messageContent: string): string;
|
|
10
10
|
export declare function getValueFromSettings(settings: Setting[], key: string, envVar?: string, defaultValue?: any): any;
|
11
11
|
export declare function loadAsset(relativePath: string): Promise<string | null>;
|
12
12
|
export declare function loadAssetStream(relativePath: string): Promise<any>;
|
13
|
-
export declare function isPointInGeoJSON(latLng: number[],
|
13
|
+
export declare function isPointInGeoJSON(latLng: number[], cachedGeoJsonData: {
|
14
|
+
type: string;
|
15
|
+
features: any;
|
16
|
+
}): Promise<{
|
14
17
|
isInside: boolean;
|
15
18
|
properties: any;
|
16
19
|
} | {
|
17
20
|
isInside: null;
|
18
21
|
properties: null;
|
19
22
|
}>;
|
20
|
-
export declare function clearGeoJsonCache(): void;
|
21
23
|
export declare function generateCode<T extends Document>(model: Model<T>, filterProperty: keyof T): Promise<string>;
|
22
24
|
export {};
|
package/build/utils/utils.js
CHANGED
@@ -20,7 +20,6 @@ exports.getValueFromSettings = getValueFromSettings;
|
|
20
20
|
exports.loadAsset = loadAsset;
|
21
21
|
exports.loadAssetStream = loadAssetStream;
|
22
22
|
exports.isPointInGeoJSON = isPointInGeoJSON;
|
23
|
-
exports.clearGeoJsonCache = clearGeoJsonCache;
|
24
23
|
exports.generateCode = generateCode;
|
25
24
|
const fs_1 = __importDefault(require("fs"));
|
26
25
|
const boolean_point_in_polygon_1 = __importDefault(require("@turf/boolean-point-in-polygon"));
|
@@ -89,18 +88,11 @@ function loadAssetStream(relativePath) {
|
|
89
88
|
});
|
90
89
|
});
|
91
90
|
}
|
92
|
-
|
93
|
-
function isPointInGeoJSON(latLng, fileName) {
|
91
|
+
function isPointInGeoJSON(latLng, cachedGeoJsonData) {
|
94
92
|
return __awaiter(this, void 0, void 0, function* () {
|
95
93
|
try {
|
96
94
|
if (!latLng || latLng.length === 0)
|
97
95
|
return { isInside: false, properties: null };
|
98
|
-
// Load and parse GeoJSON data only if not already cached
|
99
|
-
if (!cachedGeoJsonData) {
|
100
|
-
cachedGeoJsonData = yield loadAssetStream(fileName);
|
101
|
-
console.log(cachedGeoJsonData);
|
102
|
-
// cachedGeoJsonData = JSON.parse(geoJsonData!);
|
103
|
-
}
|
104
96
|
// !NB points take the form longitude, latitude
|
105
97
|
const points = (0, helpers_1.point)([latLng[1], latLng[0]]);
|
106
98
|
for (const feature of cachedGeoJsonData.features) {
|
@@ -134,9 +126,6 @@ function isPointInGeoJSON(latLng, fileName) {
|
|
134
126
|
}
|
135
127
|
});
|
136
128
|
}
|
137
|
-
function clearGeoJsonCache() {
|
138
|
-
cachedGeoJsonData = null;
|
139
|
-
}
|
140
129
|
function generateCode(model, filterProperty) {
|
141
130
|
return __awaiter(this, void 0, void 0, function* () {
|
142
131
|
const batchSize = 10;
|