@golemio/energetics 1.4.11 → 1.4.12-rc.1866081884

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.
@@ -12,9 +12,15 @@
12
12
  - pro importer setings zaškrtnuto nastavení `Set empty string to null`, `Trim whitespace` a také nastaveno `Sample rows count` na 10000 (kvůli možnému podhodnocení datových typů)
13
13
  - v `Table mapping` kliknout na tlačítko `configure` a nastavit všechny sloupce jako varchar
14
14
 
15
- 4. Vytvořit pohled nad importovanými tabulkami
15
+ 4. Spustit sql nad importovanými tabulkami (doplnění gps viz níže)
16
16
 
17
17
  ```sql
18
+ CREATE TABLE eno_address_gps (
19
+ adresa varchar(250) NULL,
20
+ longitude float4 NULL,
21
+ latitude float4 NULL
22
+ );
23
+
18
24
  CREATE VIEW v_eno_map_objects AS
19
25
  with base as (
20
26
  select
@@ -41,8 +47,11 @@ select
41
47
  "NAZEV_EJ" as "nazev_ej",
42
48
  "NAZEV_EJ_OTEC" as "ej_otec",
43
49
  "TYP_SPRAVCE" as "typ_spravce",
44
- "nazev_pozice_v_mape"
45
- from base
50
+ "nazev_pozice_v_mape",
51
+ ST_SetSRID(ST_MakePoint(ag.longitude, ag.latitude), 4326) as "gps_poloha"
52
+ from base b
53
+ left join eno_address_gps ag on
54
+ b."POPIS_ADRESA" = ag.adresa
46
55
  where "POPIS_ADRESA" is not null
47
56
  ```
48
57
 
@@ -55,10 +64,26 @@ GRANT ALL ON TABLE energetics.eno_raw_budova_majetek_mc TO dataplatform_energeti
55
64
  GRANT REFERENCES, SELECT ON TABLE energetics.eno_raw_budova_majetek_mhmp TO dataplatform_energetics_ro;
56
65
  GRANT ALL ON TABLE energetics.eno_raw_budova_majetek_mhmp TO dataplatform_energetics_rw;
57
66
 
67
+ GRANT SELECT, REFERENCES ON TABLE energetics.eno_address_gps TO dataplatform_energetics_ro;
68
+ GRANT ALL ON TABLE energetics.eno_address_gps TO dataplatform_energetics_rw;
69
+
58
70
  GRANT REFERENCES, SELECT ON TABLE energetics.v_eno_map_objects TO dataplatform_energetics_ro;
59
71
  GRANT ALL ON TABLE energetics.v_eno_map_objects TO dataplatform_energetics_rw;
60
72
  ```
61
73
 
74
+ ## Doplnění GPS souřadnic
75
+
76
+ 1. exportovat relevatní adresy
77
+ ```sql
78
+ select distinct "adresa", LENGTH("adresa") from energetics.v_eno_map_objects
79
+ where
80
+ (adresa like '%Praha%' and LENGTH("adresa")>19
81
+ or adresa not like '%Praha%' and LENGTH("adresa")>11)
82
+ ```
83
+
84
+ 2. použít přiložený skript se správným tokenem
85
+ 3. importovat výstupní csv do mapovací tabulky `eno_address_gps`
86
+
62
87
  ## Postup aktualizace dat
63
88
 
64
89
  Stačí kroky 1-3., s tím že data se importují do existujících tabulek a stará data se smažou.
@@ -0,0 +1,32 @@
1
+ import * as fs from "fs";
2
+
3
+ // seznam adres, co adresa to nový řádek
4
+ const rawInput = fs.readFileSync("addresses.txt").toString("utf-8");
5
+ const addresses = rawInput.split("\r\n");
6
+
7
+ // výstup v csv adresa;longitude;latitude
8
+ const outputFile = "addressesOutput.txt";
9
+
10
+ const endpointCheck = "https://photon-test.ipt.oict.cz/api/?q=";
11
+ const apiKey = "TOKEN_HERE";
12
+
13
+ (async () => {
14
+ for (let index = 0; index < addresses.length; index++) {
15
+ const element = addresses[index];
16
+ const result = await fetch(endpointCheck + element, {
17
+ headers: {
18
+ "x-access-token": apiKey,
19
+ },
20
+ });
21
+ const data = await result.json();
22
+ if (data.features.length > 0) {
23
+ const coordinates = data.features[0].geometry.coordinates;
24
+ const output = `"${element}";"${coordinates[0]}";"${coordinates[1]}"\r\n`;
25
+
26
+ fs.appendFileSync(outputFile, output);
27
+ } else {
28
+ // seznam nenalezených adres
29
+ console.log(`${element}`);
30
+ }
31
+ }
32
+ })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@golemio/energetics",
3
- "version": "1.4.11",
3
+ "version": "1.4.12-rc.1866081884",
4
4
  "description": "Golemio Energetics Module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -35,9 +35,9 @@
35
35
  "@apideck/portman": "^1.26.5",
36
36
  "@commitlint/cli": "^11.0.0",
37
37
  "@commitlint/config-conventional": "^11.0.0",
38
- "@golemio/cli": "1.9.2",
39
- "@golemio/core": "1.20.6",
40
- "@golemio/db-common": "1.1.4",
38
+ "@golemio/cli": "1.10.0",
39
+ "@golemio/core": "1.20.8",
40
+ "@golemio/db-common": "1.2.0",
41
41
  "@golemio/eslint-config": "1.1.2",
42
42
  "@types/chai": "4.2.3",
43
43
  "@types/chai-as-promised": "7.1.2",