Skip to content

Commit f5fab2f

Browse files
committed
Change Python to src, modify doc and format code
1 parent 17846cd commit f5fab2f

20 files changed

+2853
-2315
lines changed

Documentation/dev-doc.md

Lines changed: 33 additions & 33 deletions
Large diffs are not rendered by default.

Documentation/user-doc.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ The database used in this repository is:
5050
- `user`: `postgres`
5151
- `password`: `postgres`
5252

53+
These information can be changed by modifying the [.env](../.env) file directly.
54+
5355
### Common model
5456

5557
To compare OSM and OMF data, a common model was created (for transportation data), mainly based on the OMF transportation model. The model is as follows:
@@ -106,7 +108,7 @@ CREATE SCHEMA IF NOT EXISTS omf;
106108
CREATE SCHEMA IF NOT EXISTS results;
107109
```
108110

109-
*Note*: It is sufficient to create the database, as in the [data_integration.py](../Python/Assessment/data_integration.py#L24), these SQL commands are executed (inside the `utils.initialisePostgreSQL(connection)` function).
111+
*Note*: It is sufficient to create the database, as in the [data_integration.py](../src/Assessment/data_integration.py#L24), these SQL commands are executed (inside the `utils.initialisePostgreSQL()` function).
110112

111113
## Python
112114

@@ -214,7 +216,7 @@ In the Python files, the database connection can take one of three forms:
214216

215217
- `initialiseDuckDB()`: Initializes DuckDB and connects it to a PostgreSQL database.
216218

217-
These functions are defined in the [utils.py](../Python/Utils/utils.py) script.
219+
These functions are defined in the [utils.py](../src/Utils/utils.py) script.
218220
They require one argument, a path to a `.env` file. If no path is provided, the default path will be:
219221

220222
```python
@@ -242,14 +244,14 @@ The same environment file is used for the data integration, quality assessment,
242244

243245
## Download and Process Data
244246

245-
Data corresponding to the chosen areas can be downloaded using the [data_integration.py](../Python/Assessment/data_integration.py) script.
247+
Data corresponding to the chosen areas can be downloaded using the [data_integration.py](../src/Assessment/data_integration.py) script.
246248
Certain attribute values in this file can be modified, such as:
247249

248-
- [`createBoundingBoxTable`](../Python/Assessment/data_integration.py#L19): If `True`, it will create the bounding box table, even if it has already been created. Defaults to `True`.
250+
- [`createBoundingBoxTable`](../src/Assessment/data_integration.py#L20): If `True`, it will create the bounding box table, even if it has already been created. Defaults to `True`.
249251

250-
- [`skip<theme>Check`](../Python/Assessment/data_integration.py#L57): If `True`, it will recreate all layers of each area for the specified theme (one of `Graph`, `Building`, or `Place`). Otherwise, layers will be created only if they have not been created yet. Defaults to `False`.
252+
- [`skip<theme>Check`](../src/Assessment/data_integration.py#L58): If `True`, it will recreate all layers of each area for the specified theme (one of `Graph`, `Building`, or `Place`). Otherwise, layers will be created only if they have not been created yet. Defaults to `False`.
251253

252-
- [`ox.settings.overpass_settings`](../Python/Assessment/data_integration.py#L37): This setting is used to limit OSM data to a specific date. The default date is `2024-06-07T23:59:59Z`. This date can be changed if desired, but it is preferable to select a date approximately the same as the one used by the `overturemaps.py` tool (the default date corresponds to the 2024-06-13-beta.1 release).
254+
- [`ox.settings.overpass_settings`](../src/Assessment/data_integration.py#L38): This setting is used to limit OSM data to a specific date. The default date is `2024-06-07T23:59:59Z`. This date can be changed if desired, but it is preferable to select a date approximately the same as the one used by the `overturemaps.py` tool (the default date corresponds to the 2024-06-13-beta.1 release).
253255

254256
Normally, no additional changes should be necessary (such as altering template names for the layer, schema names, or the path to the bbox file, etc.).
255257
If changes are required, they should be made consistently across the different files.
@@ -265,15 +267,15 @@ Or directly by running the script in an IDE of choice.
265267
## Quality Assessment Criteria
266268

267269
Once the data has been downloaded, the necessary scripts can be run to assess the quality of the different layers.
268-
Currently, the criteria are focused on graph data. The Python script is [quality_assessment.py](../Python/Assessment/quality_assessment.py), that uses the function in the [quality.py](../Python/Assessment/quality.py) script.
270+
Currently, the criteria are focused on graph data. The Python script is [quality_assessment.py](../src/Assessment/quality_assessment.py), that uses the function in the [quality.py](../src/Assessment/quality.py) script.
269271

270272
Certain attribute values can be modified, such as:
271273

272-
- [`fileName`](../Python/Assessment/quality_assessment.py#L21): The name of the markdown file that will be produced. Defaults to `Automatic_result.md`.
274+
- [`fileName`](../src/Assessment/quality_assessment.py#L20): The name of the markdown file that will be produced. Defaults to `Automatic_result.md`.
273275

274-
- [`pathSave`](../Python/Assessment/quality_assessment.py#L23): The path to save the markdown file. If the folder does not exist, an error will be returned. Defaults to `./Data/Results/<fileName>`, where `<fileName>` is the previously mentioned variable.
276+
- [`pathSave`](../src/Assessment/quality_assessment.py#L22): The path to save the markdown file. If the folder does not exist, an error will be returned. Defaults to `./Data/Results/<fileName>`, where `<fileName>` is the previously mentioned variable.
275277

276-
- [`bounding_box_table`](../Python/Assessment/quality_assessment.py#60): The name of the bounding box table in the public schema of the database. Defaults to `bounding_box`.
278+
- [`bounding_box_table`](../src/Assessment/quality_assessment.py#L59): The name of the bounding box table in the public schema of the database. Defaults to `bounding_box`.
277279

278280
Other variables can also be changed, but this is not recommended, especially since changes would need to be updated in the dashboard as well.
279281

@@ -300,4 +302,4 @@ Then, open your browser and navigate to [http://127.0.0.1:8000](http://127.0.0.1
300302

301303
## Use the Application
302304

303-
To use the application, refer to the `Help` panel within the application or consult the [help.md](../Python/GeoDataCompare/help.md) file directly.
305+
To use the application, refer to the `Help` panel within the application or consult the [help.md](../src/GeoDataCompare/help.md) file directly.

Readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,12 @@ python Python\Assessment\data_integration.py
121121

122122
It uses the file containing the bounding box: [bboxs.json](./Data/bboxs.json).
123123
Refer to the [user documentation](./Documentation/user-doc.md#adding-areas) for more information about how to add new areas.
124-
You will also find information about how to configurate the [data_integration.py](Python/Assessment/data_integration.py/) file for forcing the data download or preventing the bounding box table to be recreated again.
124+
You will also find information about how to configurate the [data_integration.py](src/Assessment/data_integration.py/) file for forcing the data download or preventing the bounding box table to be recreated again.
125125

126126
## Quality assessment
127127

128128
This script needs to be run after the data integration process, but before running the DashBoard.
129-
It is contained in the [quality_assessment.py](./Python/Assessment/quality_assessment.py)
129+
It is contained in the [quality_assessment.py](./src/Assessment/quality_assessment.py)
130130
To run this script:
131131

132132
```cmd
Lines changed: 90 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import sys
22
import os
3-
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..')))
4-
from Python.Utils import utils
5-
from Python.Assessment import osm
6-
from Python.Assessment import omf
3+
from src.Utils import utils
4+
from src.Assessment import osm
5+
from src.Assessment import omf
76
import osmnx as ox
87
import time
98
import json
109

10+
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")))
11+
1112

1213
# Number of seconds in total
1314
total = 0
@@ -34,7 +35,9 @@
3435
print("The bounding box table was not created")
3536

3637
# Limit date of data
37-
ox.settings.overpass_settings = '[out:json][timeout:{timeout}]{maxsize}[date:"2024-08-31T23:59:59Z"]'
38+
ox.settings.overpass_settings = (
39+
'[out:json][timeout:{timeout}]{maxsize}[date:"2024-08-31T23:59:59Z"]'
40+
)
3841

3942
curdir = os.getcwd()
4043

@@ -67,105 +70,111 @@
6770
# Get the element we need from the json
6871
bbox = elem["bbox"]
6972
area = elem["area"].lower()
70-
73+
7174
print(f"Start process {area.capitalize()}")
72-
75+
7376
## Insert bounding box
74-
# Tranform bbox to OGC WKT format and insert into bounding box table
77+
# Tranform bbox to OGC WKT format and insert into bounding box table
7578
wktGeom = utils.bboxCSVToBboxWKT(bbox)
7679

7780
# Insert bbox in bounding box table
7881
utils.insertBoundingBox(
79-
connection = connection,
80-
wktGeom = wktGeom,
81-
aeraName = area.capitalize(),
82-
tableName = "bounding_box")
83-
82+
connection=connection,
83+
wktGeom=wktGeom,
84+
aeraName=area.capitalize(),
85+
tableName="bounding_box",
86+
)
87+
8488
end = time.time()
8589
print(f"Insert bounding box of {area}: {end - start} seconds")
86-
90+
8791
print()
88-
92+
8993
### Places ###
9094
## OMF
9195
# Check if the process has already been done
92-
if not utils.isProcessAlreadyDone(connection, placeTable.format(area), schema_omf, skipPlaceCheck):
93-
96+
if not utils.isProcessAlreadyDone(
97+
connection, placeTable.format(area), schema_omf, skipPlaceCheck
98+
):
99+
94100
omf.createPlaceFromBbox(
95-
bbox = bbox,
96-
savePathFolder = folderSave,
97-
area = area,
98-
schema = schema_omf
101+
bbox=bbox, savePathFolder=folderSave, area=area, schema=schema_omf
99102
)
100-
103+
101104
end = time.time()
102105
print(f"OMF places of {area}: {end - start} seconds")
103-
106+
104107
else:
105108
print("OMF places already downloaded")
106-
109+
107110
## OSM
108111
# Check if the process has already been done
109-
if not utils.isProcessAlreadyDone(connection, placeTable.format(area), schema_osm, skipPlaceCheck):
110-
112+
if not utils.isProcessAlreadyDone(
113+
connection, placeTable.format(area), schema_osm, skipPlaceCheck
114+
):
115+
111116
osm.createPlaceFromBbox(
112-
connection = connection,
113-
engine = engine,
114-
bbox = bbox,
115-
area = area,
116-
schema = schema_osm
117+
connection=connection,
118+
engine=engine,
119+
bbox=bbox,
120+
area=area,
121+
schema=schema_osm,
117122
)
118-
123+
119124
end = time.time()
120125
print(f"OSM places of {area}: {end - start} seconds")
121-
126+
122127
else:
123128
print("OSM places already downloaded")
124-
129+
125130
print()
126-
131+
127132
### Buildings ###
128133
## OMF
129134
# Check if the process has already been done
130-
if not utils.isProcessAlreadyDone(connection, buildingTable.format(area), schema_omf, skipBuildingCheck):
131-
135+
if not utils.isProcessAlreadyDone(
136+
connection, buildingTable.format(area), schema_omf, skipBuildingCheck
137+
):
138+
132139
omf.createBuildingFromBbox(
133-
bbox = bbox,
134-
savePathFolder = folderSave,
135-
area = area,
136-
schema = schema_omf
140+
bbox=bbox, savePathFolder=folderSave, area=area, schema=schema_omf
137141
)
138-
142+
139143
end = time.time()
140144
print(f"OMF buildings of {area}: {end - start} seconds")
141-
145+
142146
else:
143147
print("OMF buildings already downloaded")
144-
148+
145149
## OSM
146150
# Check if the process has already been done
147-
if not utils.isProcessAlreadyDone(connection, buildingTable.format(area), schema_osm, skipBuildingCheck):
148-
151+
if not utils.isProcessAlreadyDone(
152+
connection, buildingTable.format(area), schema_osm, skipBuildingCheck
153+
):
154+
149155
osm.createBuildingFromBbox(
150-
engine = engine,
151-
bbox = bbox,
152-
area = area,
153-
schema = schema_osm
156+
engine=engine, bbox=bbox, area=area, schema=schema_osm
154157
)
155-
158+
156159
end = time.time()
157160
print(f"OSM buildings of {area}: {end - start} seconds")
158-
161+
159162
else:
160163
print("OSM buildings already downloaded")
161-
164+
162165
print()
163-
166+
164167
### Graph ###
165168
## OMF
166169
# Check if the process has already been done
167-
if not (utils.isProcessAlreadyDone(connection, edgeTable.format(area), schema_omf, skipGraphCheck) and
168-
utils.isProcessAlreadyDone(connection, nodeTable.format(area), schema_omf, True)):
170+
if not (
171+
utils.isProcessAlreadyDone(
172+
connection, edgeTable.format(area), schema_omf, skipGraphCheck
173+
)
174+
and utils.isProcessAlreadyDone(
175+
connection, nodeTable.format(area), schema_omf, True
176+
)
177+
):
169178

170179
# # Old version
171180
# omf.createGraphFromBbox(
@@ -175,46 +184,52 @@
175184
# connection = connection,
176185
# schema = schema_omf
177186
# )
178-
187+
179188
# New version
180189
omf.createGraphFromBboxNewVersion(
181190
bbox=bbox,
182191
savePathFolder=folderSave,
183192
area=area,
184193
connection=connection,
185-
schema=schema_omf
194+
schema=schema_omf,
186195
)
187-
196+
188197
end = time.time()
189198
print(f"OMF graph of {area}: {end - start} seconds")
190-
199+
191200
else:
192201
print("OMF graph already downloaded")
193-
202+
194203
## OSM
195204
# Check if the process has already been done
196-
if not (utils.isProcessAlreadyDone(connection, edgeTable.format(area), schema_osm, skipGraphCheck) and
197-
utils.isProcessAlreadyDone(connection, nodeTable.format(area), schema_osm, skipGraphCheck)):
198-
205+
if not (
206+
utils.isProcessAlreadyDone(
207+
connection, edgeTable.format(area), schema_osm, skipGraphCheck
208+
)
209+
and utils.isProcessAlreadyDone(
210+
connection, nodeTable.format(area), schema_osm, skipGraphCheck
211+
)
212+
):
213+
199214
osm.createGraphFromBbox(
200-
connection = connection,
201-
engine = engine,
202-
bbox = bbox,
203-
area = area,
204-
schema = schema_osm
215+
connection=connection,
216+
engine=engine,
217+
bbox=bbox,
218+
area=area,
219+
schema=schema_osm,
205220
)
206-
221+
207222
end = time.time()
208223
print(f"OSM graph of {area}: {end - start} seconds")
209-
224+
210225
else:
211226
print("OSM graph already downloaded")
212-
227+
213228
end = time.time()
214229
print(f"Download everything for {area}: {end - start} seconds")
215230
print()
216-
231+
217232
total += end - start
218-
219233

220-
print(f"It took {total} seconds in total")
234+
235+
print(f"It took {total} seconds in total")

0 commit comments

Comments
 (0)