text-to-map 1.1.5 → 1.1.6
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/db/db.d.ts +0 -1
- package/dist/db/db.js +1 -15
- package/dist/db/founders.js +8 -7
- package/dist/open-data-sync/schools.d.ts +1 -1
- package/dist/open-data-sync/schools.js +1 -1
- package/dist/open-data-sync/streets.d.ts +1 -1
- package/dist/open-data-sync/streets.js +1 -1
- package/package.json +1 -1
package/dist/db/db.d.ts
CHANGED
|
@@ -27,7 +27,6 @@ export declare const insertMultipleRows: (rows: string[][], table: string, colum
|
|
|
27
27
|
*/
|
|
28
28
|
export declare const insertAutoincrementRow: (row: any[], table: string, columnNames: string[]) => Promise<number | null>;
|
|
29
29
|
export declare const deleteMultipleRowsKnex: (keys: string[], table: string, keyColumnName: string) => Promise<void>;
|
|
30
|
-
export declare const clearDuplicates: (rows: string[][], table: string, columnNames: string[]) => Promise<string[][]>;
|
|
31
30
|
export declare const generatePlaceholders: (n: number) => string;
|
|
32
31
|
export declare const generate2DPlaceholders: (inner: number, outer: number) => string;
|
|
33
32
|
export declare const extractKeyValuesPairs: (array: string[][], keyIndex: number, valuesIndices: number[]) => string[][];
|
package/dist/db/db.js
CHANGED
|
@@ -41,7 +41,7 @@ export const getKnexDb = (config = {}) => {
|
|
|
41
41
|
},
|
|
42
42
|
pool: {
|
|
43
43
|
afterCreate: (db, done) => {
|
|
44
|
-
db.pragma(
|
|
44
|
+
db.pragma("journal_mode = WAL;");
|
|
45
45
|
done(false, done);
|
|
46
46
|
},
|
|
47
47
|
},
|
|
@@ -119,12 +119,6 @@ export const insertMultipleRows = (rows, table, columnNames, preventDuplicates =
|
|
|
119
119
|
if (rows.length === 0) {
|
|
120
120
|
return 0;
|
|
121
121
|
}
|
|
122
|
-
// if (preventDuplicatesByFirstColumn) {
|
|
123
|
-
// rows = await clearDuplicates(rows, table, columnNames);
|
|
124
|
-
// if (rows.length === 0) {
|
|
125
|
-
// return 0;
|
|
126
|
-
// }
|
|
127
|
-
// }
|
|
128
122
|
const insertPlaceholders = generate2DPlaceholders(columnNames.length, rows.length);
|
|
129
123
|
if (preventDuplicates && keyColumns.length === 0) {
|
|
130
124
|
keyColumns = [columnNames[0]];
|
|
@@ -152,14 +146,6 @@ export const deleteMultipleRowsKnex = (keys, table, keyColumnName) => __awaiter(
|
|
|
152
146
|
}
|
|
153
147
|
yield getKnexDb().from(table).whereIn(keyColumnName, keys).del();
|
|
154
148
|
});
|
|
155
|
-
export const clearDuplicates = (rows, table, columnNames) => __awaiter(void 0, void 0, void 0, function* () {
|
|
156
|
-
const existing = yield getKnexDb()
|
|
157
|
-
.select(columnNames[0])
|
|
158
|
-
.from(table)
|
|
159
|
-
.whereIn(columnNames[0], rows.map((row) => row[0]));
|
|
160
|
-
const keys = existing.map((row) => row[columnNames[0]].toString());
|
|
161
|
-
return rows.filter((row) => !keys.includes(row[0]));
|
|
162
|
-
});
|
|
163
149
|
const generateRepetitiveString = (value, glue, n) => {
|
|
164
150
|
return new Array(n).fill(value).join(glue);
|
|
165
151
|
};
|
package/dist/db/founders.js
CHANGED
|
@@ -15,7 +15,7 @@ import { MunicipalityType, } from "./types";
|
|
|
15
15
|
const cityTypeCode = 261;
|
|
16
16
|
const cityDistrictTypeCode = 263;
|
|
17
17
|
export const insertFounders = (founders) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
-
var _a;
|
|
18
|
+
var _a, _b, _c;
|
|
19
19
|
let insertedFounders = 0;
|
|
20
20
|
const schoolFounderConnectionData = [];
|
|
21
21
|
for (const founder of founders) {
|
|
@@ -63,8 +63,9 @@ export const insertFounders = (founders) => __awaiter(void 0, void 0, void 0, fu
|
|
|
63
63
|
name: sanitizeMunicipalityName(founder.name),
|
|
64
64
|
ico: founder.ico,
|
|
65
65
|
});
|
|
66
|
+
let founderId = (_c = (_b = existing[0]) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : null;
|
|
66
67
|
if (existing.length === 0) {
|
|
67
|
-
|
|
68
|
+
founderId = yield insertAutoincrementRow([
|
|
68
69
|
sanitizeMunicipalityName(founder.name),
|
|
69
70
|
sanitizeMunicipalityName(extractedMunicipalityName),
|
|
70
71
|
founder.ico,
|
|
@@ -80,10 +81,10 @@ export const insertFounders = (founders) => __awaiter(void 0, void 0, void 0, fu
|
|
|
80
81
|
"city_district_code",
|
|
81
82
|
]);
|
|
82
83
|
insertedFounders++;
|
|
83
|
-
founder.schools.forEach((school) => {
|
|
84
|
-
schoolFounderConnectionData.push([school.izo, founderId]);
|
|
85
|
-
});
|
|
86
84
|
}
|
|
85
|
+
founder.schools.forEach((school) => {
|
|
86
|
+
schoolFounderConnectionData.push([school.izo, founderId]);
|
|
87
|
+
});
|
|
87
88
|
}
|
|
88
89
|
const insertedConnections = yield insertMultipleRows(schoolFounderConnectionData, "school_founder", ["school_izo", "founder_id"], true, ["school_izo", "founder_id"]);
|
|
89
90
|
return insertedFounders + insertedConnections;
|
|
@@ -174,14 +175,14 @@ const fixFounderProblems = (founder, municipalityCode, differingSchools, extract
|
|
|
174
175
|
}
|
|
175
176
|
});
|
|
176
177
|
const getCityCodeByDistrictCode = (districtCode) => __awaiter(void 0, void 0, void 0, function* () {
|
|
177
|
-
var
|
|
178
|
+
var _d;
|
|
178
179
|
const result = yield getKnexDb()
|
|
179
180
|
.first("city.code")
|
|
180
181
|
.from("city_district")
|
|
181
182
|
.join("city", "city_district.city_code", "city.code")
|
|
182
183
|
.where("city_district.code", districtCode)
|
|
183
184
|
.limit(1);
|
|
184
|
-
return (
|
|
185
|
+
return (_d = result === null || result === void 0 ? void 0 : result.code) !== null && _d !== void 0 ? _d : null;
|
|
185
186
|
});
|
|
186
187
|
const findMunicipalitiesAndPositionsByNameAndType = (name, type) => __awaiter(void 0, void 0, void 0, function* () {
|
|
187
188
|
const knex = getKnexDb();
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { OpenDataSyncOptionsPartial } from "../utils/helpers";
|
|
2
|
-
export declare const downloadAndImportSchools: (options
|
|
2
|
+
export declare const downloadAndImportSchools: (options?: OpenDataSyncOptionsPartial, saveFoundersToCsv?: boolean, saveSchoolsWithoutRuianToCsv?: boolean) => Promise<void>;
|
|
3
3
|
export declare const deleteSchoolsXmlFile: (options?: OpenDataSyncOptionsPartial) => void;
|
|
@@ -299,7 +299,7 @@ const importDataToDb = (options, saveFoundersToCsv = false, saveSchoolsWithoutRu
|
|
|
299
299
|
const getXmlFilePath = (options) => {
|
|
300
300
|
return join(options.tmpDir, options.schoolsXmlFileName);
|
|
301
301
|
};
|
|
302
|
-
export const downloadAndImportSchools = (options, saveFoundersToCsv = false, saveSchoolsWithoutRuianToCsv = false) => __awaiter(void 0, void 0, void 0, function* () {
|
|
302
|
+
export const downloadAndImportSchools = (options = {}, saveFoundersToCsv = false, saveSchoolsWithoutRuianToCsv = false) => __awaiter(void 0, void 0, void 0, function* () {
|
|
303
303
|
yield runSyncPart(SyncPart.Schools, [SyncPart.AddressPoints], () => __awaiter(void 0, void 0, void 0, function* () {
|
|
304
304
|
const runOptions = prepareOptions(options);
|
|
305
305
|
yield downloadXml(runOptions);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { OpenDataSyncOptionsPartial } from "../utils/helpers";
|
|
2
|
-
export declare const downloadAndImportStreets: (options
|
|
2
|
+
export declare const downloadAndImportStreets: (options?: OpenDataSyncOptionsPartial) => Promise<void>;
|
|
@@ -47,7 +47,7 @@ const importDataToDb = (data) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
47
47
|
}
|
|
48
48
|
yield insertStreetsFromDbf(data);
|
|
49
49
|
});
|
|
50
|
-
export const downloadAndImportStreets = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
50
|
+
export const downloadAndImportStreets = (options = {}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
51
51
|
yield runSyncPart(SyncPart.Streets, [SyncPart.AddressPoints], () => __awaiter(void 0, void 0, void 0, function* () {
|
|
52
52
|
console.log("Starting to download and import streets. This takes up to 1 hour.");
|
|
53
53
|
const completeOptions = prepareOptions(options);
|
package/package.json
CHANGED
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
},
|
|
54
54
|
"name": "text-to-map",
|
|
55
55
|
"description": "Text To Map usiluje o lepší, strojově zpracovatelné využití částí vyhlášek s výčtem ulic a dalších lokací. Jde o rozšiřitelnou sadu konceptů a nástrojů, které zajistí hladký převod výčtu ulic a jejich rozsahů v lidsky srozumitelném jazyce do strojově zpracovatelného, uchopitelného formátu.",
|
|
56
|
-
"version": "1.1.
|
|
56
|
+
"version": "1.1.6",
|
|
57
57
|
"main": "dist/index.js",
|
|
58
58
|
"types": "dist/index.d.ts",
|
|
59
59
|
"files": [
|