@golemio/city-districts 1.2.8-dev.986383403 → 1.2.8
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/docs/implementation-documentation.md +145 -0
- package/docs/openapi-output.yaml +215 -0
- package/package.json +7 -4
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# Implementační dokumentace modulu *city-districts (Městské části Prahy)*
|
|
2
|
+
|
|
3
|
+
## Záměr
|
|
4
|
+
|
|
5
|
+
Modul slouží k uložení mapových podkladů (polygonů) všech městských částí Prahy. Tyto polygony jsou využívány primárně pro vyhledání v jaké městské části leží konkrétní gps bod.
|
|
6
|
+
|
|
7
|
+
## Vstupní data
|
|
8
|
+
|
|
9
|
+
### Data aktivně stahujeme
|
|
10
|
+
|
|
11
|
+
Data stahujeme pravidelně z Geoportálu IPR Praha. Je to pouze jeden zdroj dat.
|
|
12
|
+
|
|
13
|
+
#### Datový zdroj *CityDistricts*
|
|
14
|
+
|
|
15
|
+
- zdroj dat
|
|
16
|
+
- [Geoportál IPR](http://opendata.iprpraha.cz/CUR/DTMP/TMMESTSKECASTI_P/WGS_84/TMMESTSKECASTI_P.json)
|
|
17
|
+
- [IE config](https://gitlab.com/operator-ict/golemio/code/integration-engine/-/blob/development/config/datasources.template.json#L10)
|
|
18
|
+
- bez parametrů
|
|
19
|
+
- formát dat
|
|
20
|
+
- HTTP GET
|
|
21
|
+
- json (geojson)
|
|
22
|
+
- [validační schéma](https://gitlab.com/operator-ict/golemio/code/modules/city-districts/-/blob/development/src/schema-definitions/datasources/CityDistrictsJsonSchema.ts)
|
|
23
|
+
- ukázka dat
|
|
24
|
+
```json
|
|
25
|
+
{
|
|
26
|
+
"type" : "FeatureCollection",
|
|
27
|
+
"name" : "TMMESTSKECASTI_P",
|
|
28
|
+
"features" : [
|
|
29
|
+
{
|
|
30
|
+
"type" : "Feature",
|
|
31
|
+
"geometry" : {
|
|
32
|
+
"type" : "Polygon",
|
|
33
|
+
"coordinates" : [
|
|
34
|
+
[
|
|
35
|
+
[ 14.456427018000056, 50.137023240000076 ],
|
|
36
|
+
[ 14.456422205000024, 50.13706565100006 ],
|
|
37
|
+
[ 14.456333703000041, 50.13785701200004 ],
|
|
38
|
+
[ 14.456314870000028, 50.13802469500007 ],
|
|
39
|
+
[ 14.456295597000064, 50.13819642300007 ],
|
|
40
|
+
[ 14.45628073000006, 50.13832897200007 ],
|
|
41
|
+
[ 14.456265882000025, 50.13846143100005 ],
|
|
42
|
+
[ 14.456427018000056, 50.137023240000076 ]
|
|
43
|
+
]
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
"properties" : {
|
|
47
|
+
"OBJECTID" : 1,
|
|
48
|
+
"DAT_VZNIK" : "20160422155519",
|
|
49
|
+
"DAT_ZMENA" : "20160603135317",
|
|
50
|
+
"PLOCHA" : 7379375.56,
|
|
51
|
+
"ID" : 23,
|
|
52
|
+
"KOD_MC" : 547298,
|
|
53
|
+
"NAZEV_MC" : "Praha-Ďáblice",
|
|
54
|
+
"KOD_MO" : 86,
|
|
55
|
+
"KOD_SO" : "86",
|
|
56
|
+
"TID_TMMESTSKECASTI_P" : 23,
|
|
57
|
+
"POSKYT" : "HMP-IPR",
|
|
58
|
+
"ID_POSKYT" : 43,
|
|
59
|
+
"STAV_ZMENA" : "U",
|
|
60
|
+
"NAZEV_1" : "Ďáblice",
|
|
61
|
+
"Shape_Length" : 0.17478098296491398,
|
|
62
|
+
"Shape_Area" : 7379375.560788
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
- frekvence stahování
|
|
69
|
+
- [dev](https://gitlab.com/operator-ict/golemio/devops/infrastructure/-/blob/master/cluster_development/golemio_golemio-values.yaml#L261)
|
|
70
|
+
- `0 22 7 * * *`, tzn. každý den v 7:22
|
|
71
|
+
- [prod](https://gitlab.com/operator-ict/golemio/devops/infrastructure/-/blob/master/cluster_production/golemio_golemio-values.yaml#L259)
|
|
72
|
+
- `0 30 2 1 * *`, tzn. první den v měsíci v 2:30
|
|
73
|
+
- název rabbitmq fronty
|
|
74
|
+
- `dataplatform.citydistricts.refreshDataInDB`
|
|
75
|
+
- bez parametrů
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
## Zpracování dat / transformace
|
|
80
|
+
|
|
81
|
+
Existuje pouze jeden worker. Data se nijak neobohacují ani složitě netransformují.
|
|
82
|
+
|
|
83
|
+
### Worker task _RefreshDataInDBTask_
|
|
84
|
+
|
|
85
|
+
[Odkaz](https://gitlab.com/operator-ict/golemio/code/modules/city-districts/-/blob/development/src/integration-engine/workers/tasks/RefreshDataInDBTask.ts).
|
|
86
|
+
|
|
87
|
+
- vstupní rabbitmq fronta
|
|
88
|
+
- `dataplatform.citydistricts.refreshDataInDB`
|
|
89
|
+
- bez parametrů
|
|
90
|
+
- datové zdroje
|
|
91
|
+
- `CityDistricts` (viz výše)
|
|
92
|
+
- transformace
|
|
93
|
+
- [`CityDistrictsPostgresTransformation`](https://gitlab.com/operator-ict/golemio/code/modules/city-districts/-/blob/development/src/integration-engine/transformations/CityDistrictsPostgresTransformation.ts)
|
|
94
|
+
- jednoduché transformace pro uložení dat do databází
|
|
95
|
+
- data modely
|
|
96
|
+
- [CityDistrictPostgresRepository](https://gitlab.com/operator-ict/golemio/code/modules/city-districts/-/blob/development/src/integration-engine/repositories/CityDistrictPostgresRepository.ts)
|
|
97
|
+
- (viz níže)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
## Uložení dat
|
|
102
|
+
|
|
103
|
+
### Obecné
|
|
104
|
+
|
|
105
|
+
- typ databáze
|
|
106
|
+
- PSQL
|
|
107
|
+
- datábázové schéma
|
|
108
|
+
- PSQL
|
|
109
|
+
- jedna tabulka `citydistricts`
|
|
110
|
+
- tabulka je ve schématu `common`
|
|
111
|
+
- retence dat
|
|
112
|
+
- data se nepromazávají
|
|
113
|
+
|
|
114
|
+
### *PSQL* model
|
|
115
|
+
|
|
116
|
+
- tabulka `common.citydistricts`
|
|
117
|
+
- struktura tabulky
|
|
118
|
+
- [model](https://gitlab.com/operator-ict/golemio/code/modules/city-districts/-/blob/development/src/schema-definitions/models/CityDistrictModel.ts)
|
|
119
|
+
- migrace
|
|
120
|
+
- v modulu [db-common](https://gitlab.com/operator-ict/golemio/code/modules/db-common/-/tree/development/db/migrations/common/postgresql/sqls?ref_type=heads)
|
|
121
|
+
|
|
122
|
+
## Output API
|
|
123
|
+
|
|
124
|
+
Standardní output geojson api. `CityDistrictsPostgresRouter` implementuje `GeoJsonRouter`.
|
|
125
|
+
|
|
126
|
+
### Obecné
|
|
127
|
+
|
|
128
|
+
- OpenAPI v3 dokumentace
|
|
129
|
+
- [OpenAPI](./openapi.yaml)
|
|
130
|
+
- veřejné / neveřejné endpointy
|
|
131
|
+
- veřejná open data
|
|
132
|
+
|
|
133
|
+
#### _/citydistricts_
|
|
134
|
+
|
|
135
|
+
*Postgres:*
|
|
136
|
+
- zdrojové tabulky
|
|
137
|
+
- `citydistricts`
|
|
138
|
+
- dodatečná transformace: Feature collection
|
|
139
|
+
|
|
140
|
+
#### _/citydistricts/:id_
|
|
141
|
+
|
|
142
|
+
*Postgres:*
|
|
143
|
+
- zdrojové tabulky
|
|
144
|
+
- `citydistricts`
|
|
145
|
+
- dodatečná transformace: Feature
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
# prettier-ignore
|
|
2
|
+
|
|
3
|
+
openapi: 3.0.3
|
|
4
|
+
info:
|
|
5
|
+
title: 🗺 Prague City Districts
|
|
6
|
+
description: >-
|
|
7
|
+
<p>💡 Polygons of Prague City Districts</p>
|
|
8
|
+
version: 1.0.0
|
|
9
|
+
contact:
|
|
10
|
+
name: Golemio Prague Data Platform
|
|
11
|
+
email: golemio@operatorict.cz
|
|
12
|
+
url: https://golemio.cz
|
|
13
|
+
servers:
|
|
14
|
+
- url: https://rabin.golemio.cz
|
|
15
|
+
description: Test (development) server
|
|
16
|
+
- url: https://api.golemio.cz
|
|
17
|
+
description: Main (production) server
|
|
18
|
+
tags:
|
|
19
|
+
- name: 🗺 Prague City Districts (v2)
|
|
20
|
+
description: <img src="https://img.shields.io/badge/opendata-available-green" alt="golemioapi-opendata-badge" /> 💡 Polygons of Prague City Districts.
|
|
21
|
+
paths:
|
|
22
|
+
/v2/citydistricts:
|
|
23
|
+
get:
|
|
24
|
+
tags:
|
|
25
|
+
- 🗺 Prague City Districts (v2)
|
|
26
|
+
summary: GET All Districts
|
|
27
|
+
parameters:
|
|
28
|
+
- name: latlng
|
|
29
|
+
in: query
|
|
30
|
+
description: Sorting by location (Latitude and Longitude separated by comma,
|
|
31
|
+
latitude first).
|
|
32
|
+
schema:
|
|
33
|
+
type: string
|
|
34
|
+
example: 50.124935,14.457204
|
|
35
|
+
- name: range
|
|
36
|
+
in: query
|
|
37
|
+
description: Filter by distance from latlng in meters (range query). Depends
|
|
38
|
+
on the latlng parameter.
|
|
39
|
+
schema:
|
|
40
|
+
type: number
|
|
41
|
+
example: 5000
|
|
42
|
+
- name: limit
|
|
43
|
+
in: query
|
|
44
|
+
description: Limits number of retrieved items.
|
|
45
|
+
schema:
|
|
46
|
+
type: number
|
|
47
|
+
example: 10
|
|
48
|
+
- name: offset
|
|
49
|
+
in: query
|
|
50
|
+
description: Number of the first items that are skipped.
|
|
51
|
+
schema:
|
|
52
|
+
type: number
|
|
53
|
+
example: 0
|
|
54
|
+
- name: updatedSince
|
|
55
|
+
in: query
|
|
56
|
+
description: Filters all results with older updated_at than this parameter
|
|
57
|
+
schema:
|
|
58
|
+
type: string
|
|
59
|
+
format: date-time
|
|
60
|
+
example: 2019-05-18T07:38:37.000Z
|
|
61
|
+
responses:
|
|
62
|
+
200:
|
|
63
|
+
description: OK
|
|
64
|
+
content:
|
|
65
|
+
application/json; charset=utf-8:
|
|
66
|
+
schema:
|
|
67
|
+
type: object
|
|
68
|
+
properties:
|
|
69
|
+
features:
|
|
70
|
+
type: array
|
|
71
|
+
items:
|
|
72
|
+
$ref: '#/components/schemas/CityDistrictFeature'
|
|
73
|
+
type:
|
|
74
|
+
type: string
|
|
75
|
+
example: FeatureCollection
|
|
76
|
+
required:
|
|
77
|
+
- features
|
|
78
|
+
- type
|
|
79
|
+
401:
|
|
80
|
+
$ref: "#/components/responses/UnauthorizedError"
|
|
81
|
+
403:
|
|
82
|
+
$ref: "#/components/responses/ForbiddenError"
|
|
83
|
+
/v2/citydistricts/{id}:
|
|
84
|
+
get:
|
|
85
|
+
tags:
|
|
86
|
+
- 🗺 Prague City Districts (v2)
|
|
87
|
+
summary: GET District
|
|
88
|
+
parameters:
|
|
89
|
+
- name: id
|
|
90
|
+
in: path
|
|
91
|
+
description: Identifier or slug of the city district.
|
|
92
|
+
required: true
|
|
93
|
+
schema:
|
|
94
|
+
type: string
|
|
95
|
+
example: praha-1
|
|
96
|
+
responses:
|
|
97
|
+
200:
|
|
98
|
+
description: OK
|
|
99
|
+
content:
|
|
100
|
+
application/json; charset=utf-8:
|
|
101
|
+
schema:
|
|
102
|
+
$ref: '#/components/schemas/CityDistrictFeature'
|
|
103
|
+
401:
|
|
104
|
+
$ref: "#/components/responses/UnauthorizedError"
|
|
105
|
+
403:
|
|
106
|
+
$ref: "#/components/responses/ForbiddenError"
|
|
107
|
+
404:
|
|
108
|
+
description: Not found
|
|
109
|
+
|
|
110
|
+
components:
|
|
111
|
+
responses:
|
|
112
|
+
UnauthorizedError:
|
|
113
|
+
description: API key is missing or invalid
|
|
114
|
+
headers:
|
|
115
|
+
x-access-token:
|
|
116
|
+
schema:
|
|
117
|
+
type: string
|
|
118
|
+
ForbiddenError:
|
|
119
|
+
description: Forbidden
|
|
120
|
+
headers: {}
|
|
121
|
+
content:
|
|
122
|
+
application/json; charset=utf-8:
|
|
123
|
+
schema:
|
|
124
|
+
type: object
|
|
125
|
+
properties:
|
|
126
|
+
error_message:
|
|
127
|
+
type: string
|
|
128
|
+
error_status:
|
|
129
|
+
type: number
|
|
130
|
+
required:
|
|
131
|
+
- error_message
|
|
132
|
+
- error_status
|
|
133
|
+
examples:
|
|
134
|
+
response:
|
|
135
|
+
value:
|
|
136
|
+
error_message: Forbidden
|
|
137
|
+
error_status: 403
|
|
138
|
+
schemas:
|
|
139
|
+
CityDistrictFeature:
|
|
140
|
+
type: object
|
|
141
|
+
properties:
|
|
142
|
+
geometry:
|
|
143
|
+
type: object
|
|
144
|
+
description: GeoJson geometry
|
|
145
|
+
properties:
|
|
146
|
+
coordinates:
|
|
147
|
+
oneOf:
|
|
148
|
+
- type: array
|
|
149
|
+
items:
|
|
150
|
+
type: array
|
|
151
|
+
items:
|
|
152
|
+
type: array
|
|
153
|
+
items:
|
|
154
|
+
type: number
|
|
155
|
+
example:
|
|
156
|
+
[[
|
|
157
|
+
[14.50823156003554, 50.10498927328214],
|
|
158
|
+
[14.505782430390298, 50.1031042405622],
|
|
159
|
+
[14.509701037821998, 50.1029471511537],
|
|
160
|
+
[14.50823156003554, 50.10498927328214]
|
|
161
|
+
]]
|
|
162
|
+
description: Polygon
|
|
163
|
+
- type: array
|
|
164
|
+
items:
|
|
165
|
+
type: array
|
|
166
|
+
items:
|
|
167
|
+
type: array
|
|
168
|
+
items:
|
|
169
|
+
type: array
|
|
170
|
+
items:
|
|
171
|
+
type: number
|
|
172
|
+
example:
|
|
173
|
+
[
|
|
174
|
+
[[
|
|
175
|
+
[14.50823156003554, 50.10498927328214],
|
|
176
|
+
[14.505782430390298, 50.1031042405622],
|
|
177
|
+
[14.509701037821998, 50.1029471511537],
|
|
178
|
+
[14.50823156003554, 50.10498927328214]
|
|
179
|
+
]],
|
|
180
|
+
[[
|
|
181
|
+
[14.50823156003554, 50.10498927328214],
|
|
182
|
+
[14.505782430390298, 50.1031042405622],
|
|
183
|
+
[14.509701037821998, 50.1029471511537],
|
|
184
|
+
[14.50823156003554, 50.10498927328214]
|
|
185
|
+
]]
|
|
186
|
+
]
|
|
187
|
+
description: MultiPolygon
|
|
188
|
+
type:
|
|
189
|
+
type: string
|
|
190
|
+
enum:
|
|
191
|
+
- Polygon
|
|
192
|
+
- MultiPolygon
|
|
193
|
+
properties:
|
|
194
|
+
type: object
|
|
195
|
+
properties:
|
|
196
|
+
id:
|
|
197
|
+
type: integer
|
|
198
|
+
example: 43
|
|
199
|
+
name:
|
|
200
|
+
type: string
|
|
201
|
+
example: Praha 1
|
|
202
|
+
slug:
|
|
203
|
+
type: string
|
|
204
|
+
example: praha-1
|
|
205
|
+
updated_at:
|
|
206
|
+
type: string
|
|
207
|
+
format: date-time
|
|
208
|
+
example: 2018-09-10T11:32:34.000Z
|
|
209
|
+
required:
|
|
210
|
+
- id
|
|
211
|
+
- name
|
|
212
|
+
- slug
|
|
213
|
+
type:
|
|
214
|
+
type: string
|
|
215
|
+
example: Feature
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@golemio/city-districts",
|
|
3
|
-
"version": "1.2.8
|
|
3
|
+
"version": "1.2.8",
|
|
4
4
|
"description": "Golemio City Districts Module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
"build-watch": "run-s 'build -- --watch --preserveWatchOutput'",
|
|
11
11
|
"pretest": "golemio import-db-data --postgres",
|
|
12
12
|
"test": "cross-env NODE_ENV=test mocha --exit --check-leaks --timeout 120000 -r ts-node/register -r tsconfig-paths/register -r dotenv/config --file 'test/setup.ts' 'test/**/*.test.ts'",
|
|
13
|
+
"apidocs-test": "npm run apidocs-test-output",
|
|
14
|
+
"apidocs-test-output": "cross-env NODE_ENV=test golemio swagger api-test --oas docs/openapi-output.yaml --script test/api-docs/output-gateway/server.js",
|
|
13
15
|
"test-debug": "run-s 'test -- --inspect-brk=9230'",
|
|
14
16
|
"code-coverage": "nyc run-s 'test -- -r source-map-support/register'",
|
|
15
17
|
"generate-docs": "typedoc --out docs/typedoc src",
|
|
@@ -30,11 +32,12 @@
|
|
|
30
32
|
"yarn": "Use npm!"
|
|
31
33
|
},
|
|
32
34
|
"devDependencies": {
|
|
35
|
+
"@apideck/portman": "^1.14.2",
|
|
33
36
|
"@commitlint/cli": "^11.0.0",
|
|
34
37
|
"@commitlint/config-conventional": "^11.0.0",
|
|
35
38
|
"@golemio/cli": "1.5.0",
|
|
36
|
-
"@golemio/core": "1.
|
|
37
|
-
"@golemio/db-common": "1.1.
|
|
39
|
+
"@golemio/core": "1.9.3",
|
|
40
|
+
"@golemio/db-common": "1.1.2",
|
|
38
41
|
"@golemio/eslint-config": "1.1.1",
|
|
39
42
|
"@golemio/schema-definitions": "2.3.9",
|
|
40
43
|
"@types/chai": "4.2.3",
|
|
@@ -66,7 +69,7 @@
|
|
|
66
69
|
"typescript-transform-paths": "^3.4.6"
|
|
67
70
|
},
|
|
68
71
|
"peerDependencies": {
|
|
69
|
-
"@golemio/core": ">=1.
|
|
72
|
+
"@golemio/core": ">=1.9.0"
|
|
70
73
|
},
|
|
71
74
|
"dependencies": {
|
|
72
75
|
"slugify": "1.3.2"
|