text-to-map 1.1.15 → 1.1.16
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/bin/parse-ordinance.js +0 -1
- package/dist/db/address-points.js +5 -6
- package/dist/db/cities.js +2 -3
- package/dist/db/db.d.ts +1 -0
- package/dist/db/db.js +8 -1
- package/package.json +1 -1
|
@@ -36,7 +36,6 @@ function main() {
|
|
|
36
36
|
};
|
|
37
37
|
console.time("downloadAndImportAllLatestAddressPoints");
|
|
38
38
|
const { municipality } = yield getNewMunicipality("Česká Lípa");
|
|
39
|
-
console.log(municipality.founder.schools[0].locations);
|
|
40
39
|
const addressPoints = yield parseOrdinanceToAddressPoints(lines, {
|
|
41
40
|
// currentMunicipality: municipality,
|
|
42
41
|
}, reportErrors, reportWarnings);
|
|
@@ -11,7 +11,7 @@ import { AddressPointType, createSingleLineAddress } from "czech-address";
|
|
|
11
11
|
import { SeriesType, isNegativeSeriesSpec, isRange, isSeriesSpecArray, } from "../street-markdown/types";
|
|
12
12
|
import { findClosestString } from "../utils/helpers";
|
|
13
13
|
import jtsk2wgs84 from "../utils/jtsk2wgs84";
|
|
14
|
-
import { extractKeyValuesPairs, generate2DPlaceholders, getKnexDb, insertMultipleRows, isMysql, isSqlite, nonEmptyOrNull, } from "./db";
|
|
14
|
+
import { extractKeyValuesPairs, generate2DPlaceholders, getKnexDb, insertMultipleRows, isMysql, isSqlite, nonEmptyOrNull, rawQuery, } from "./db";
|
|
15
15
|
import { getFounderCityCode } from "./founders";
|
|
16
16
|
import { MunicipalityType } from "./types";
|
|
17
17
|
const DescriptiveType = "č.p.";
|
|
@@ -80,7 +80,7 @@ export const commitAddressPoints = (buffer) => __awaiter(void 0, void 0, void 0,
|
|
|
80
80
|
});
|
|
81
81
|
const placeHolders = generate2DPlaceholders(columnNames.length, buffer.length);
|
|
82
82
|
const knex = getKnexDb();
|
|
83
|
-
yield
|
|
83
|
+
yield rawQuery(`INSERT ${isMysql(knex) ? "IGNORE" : ""} INTO address_point (${columnNames.join(",")}) VALUES ${placeHolders} ${!isMysql(knex) ? "ON CONFLICT (id) DO NOTHING" : ""}`, params);
|
|
84
84
|
return buffer.length;
|
|
85
85
|
});
|
|
86
86
|
export const insertCities = (buffer) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -129,8 +129,7 @@ const addressPointSelect = `
|
|
|
129
129
|
LEFT JOIN prague_district p ON a.prague_district_code = p.code
|
|
130
130
|
LEFT JOIN municipality_part m ON a.municipality_part_code = m.code`;
|
|
131
131
|
export const getAddressPointById = (addressPointId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
132
|
-
const
|
|
133
|
-
const row = yield knex.raw(`${addressPointSelect}
|
|
132
|
+
const row = yield rawQuery(`${addressPointSelect}
|
|
134
133
|
WHERE a.id = ?`, [addressPointId]);
|
|
135
134
|
if (row.length === 0) {
|
|
136
135
|
return null;
|
|
@@ -144,7 +143,7 @@ export const checkStreetExists = (streetName, founder) => __awaiter(void 0, void
|
|
|
144
143
|
const errors = [];
|
|
145
144
|
// we check the whole city
|
|
146
145
|
const cityCode = yield getFounderCityCode(founder);
|
|
147
|
-
const rowList = yield
|
|
146
|
+
const rowList = yield rawQuery(`SELECT name AS street_name
|
|
148
147
|
FROM street
|
|
149
148
|
WHERE city_code = ? AND name = ? ${isSqlite(knex) ? "COLLATE NOCASE" : ""}`, [cityCode, streetName]);
|
|
150
149
|
if (rowList.length > 0) {
|
|
@@ -207,7 +206,7 @@ export const findAddressPoints = (params) => __awaiter(void 0, void 0, void 0, f
|
|
|
207
206
|
(params.type === FindAddressPointsType.WholeMunicipalityNoStreetName
|
|
208
207
|
? " AND a.street_code IS NULL"
|
|
209
208
|
: "");
|
|
210
|
-
const queryResult = yield
|
|
209
|
+
const queryResult = yield rawQuery(`SELECT a.id, s.name AS street_name, o.name AS object_type_name, a.descriptive_number,
|
|
211
210
|
a.orientational_number, a.orientational_number_letter, c.name AS city_name,
|
|
212
211
|
d.name AS district_name, m.name AS municipality_part_name, p.name AS prague_district_name,
|
|
213
212
|
a.postal_code, a.wgs84_latitude, a.wgs84_longitude
|
package/dist/db/cities.js
CHANGED
|
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import chunk from "lodash/chunk";
|
|
11
|
-
import { extractKeyValuesPairs,
|
|
11
|
+
import { extractKeyValuesPairs, insertMultipleRows, rawQuery } from "./db";
|
|
12
12
|
const citiesColumn = {
|
|
13
13
|
cityName: 0,
|
|
14
14
|
cityCode: 1,
|
|
@@ -26,11 +26,10 @@ export const insertCityPositions = (data) => __awaiter(void 0, void 0, void 0, f
|
|
|
26
26
|
// we need to insert them before updating them with region data
|
|
27
27
|
changes += yield insertCities(data);
|
|
28
28
|
const prev = changes;
|
|
29
|
-
const knex = getKnexDb();
|
|
30
29
|
for (const arrayChunk of chunk(data, 1000)) {
|
|
31
30
|
const queries = [];
|
|
32
31
|
for (const row of arrayChunk) {
|
|
33
|
-
queries.push(
|
|
32
|
+
queries.push(rawQuery(`UPDATE city SET wgs84_latitude = ?, wgs84_longitude = ? WHERE code = ?`, [
|
|
34
33
|
row[citiesColumn.latitude],
|
|
35
34
|
row[citiesColumn.longitude],
|
|
36
35
|
row[citiesColumn.cityCode],
|
package/dist/db/db.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export declare const initDb: (config?: Partial<DbConfig>) => Promise<Knex>;
|
|
|
20
20
|
export declare const clearDb: (config?: Partial<DbConfig>) => Promise<Knex>;
|
|
21
21
|
export declare const disconnectKnex: () => Promise<void>;
|
|
22
22
|
export declare const nonEmptyOrNull: (value: string) => string | null;
|
|
23
|
+
export declare const rawQuery: (query: string, ...bindings: readonly Knex.RawBinding[]) => Promise<any[]>;
|
|
23
24
|
/**
|
|
24
25
|
* Efficiently insert multiple rows. If preventDuplicatesByFirstColumn is true, the first
|
|
25
26
|
* column should be unique (PK or UNIQUE).
|
package/dist/db/db.js
CHANGED
|
@@ -57,6 +57,7 @@ export const getKnexDb = (config = {}) => {
|
|
|
57
57
|
client: DbClient[SupportedDbType.postgres],
|
|
58
58
|
connection: _knexDbConfig.pgConnectionString,
|
|
59
59
|
useNullAsDefault: true,
|
|
60
|
+
debug: _knexDbConfig.verbose,
|
|
60
61
|
});
|
|
61
62
|
}
|
|
62
63
|
else if (_knexDbConfig.dbType === SupportedDbType.mysql) {
|
|
@@ -71,6 +72,7 @@ export const getKnexDb = (config = {}) => {
|
|
|
71
72
|
database,
|
|
72
73
|
},
|
|
73
74
|
useNullAsDefault: true,
|
|
75
|
+
debug: _knexDbConfig.verbose,
|
|
74
76
|
});
|
|
75
77
|
}
|
|
76
78
|
else {
|
|
@@ -141,6 +143,11 @@ const getEnvConfig = () => {
|
|
|
141
143
|
export const nonEmptyOrNull = (value) => {
|
|
142
144
|
return value ? value : null;
|
|
143
145
|
};
|
|
146
|
+
export const rawQuery = (query, ...bindings) => __awaiter(void 0, void 0, void 0, function* () {
|
|
147
|
+
const knex = getKnexDb();
|
|
148
|
+
const result = yield knex.raw(query, ...bindings);
|
|
149
|
+
return isMysql(knex) ? result[0] : result;
|
|
150
|
+
});
|
|
144
151
|
/**
|
|
145
152
|
* Efficiently insert multiple rows. If preventDuplicatesByFirstColumn is true, the first
|
|
146
153
|
* column should be unique (PK or UNIQUE).
|
|
@@ -152,7 +159,7 @@ export const insertMultipleRows = (rows, table, columnNames, preventDuplicates =
|
|
|
152
159
|
const insertPlaceholders = generate2DPlaceholders(columnNames.length, rows.length);
|
|
153
160
|
const knex = getKnexDb();
|
|
154
161
|
const onConfict = preventDuplicates && !isMysql(knex) ? `ON CONFLICT DO NOTHING` : "";
|
|
155
|
-
yield
|
|
162
|
+
yield rawQuery(`INSERT ${isMysql(knex) ? "IGNORE" : ""} INTO ${table} (${columnNames.join(",")}) VALUES ${insertPlaceholders} ${onConfict}`, rows.flat());
|
|
156
163
|
return rows.length;
|
|
157
164
|
});
|
|
158
165
|
/**
|
package/package.json
CHANGED
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
},
|
|
58
58
|
"name": "text-to-map",
|
|
59
59
|
"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.",
|
|
60
|
-
"version": "1.1.
|
|
60
|
+
"version": "1.1.16",
|
|
61
61
|
"main": "dist/index.js",
|
|
62
62
|
"types": "dist/index.d.ts",
|
|
63
63
|
"files": [
|