Skip to content

Commit dcc9f4f

Browse files
committed
Merge branch 'feature/vectorsets_squashed_commits' of github.com:rok4/core-python into feature/vectorsets_squashed_commits
2 parents 6719374 + d3425d1 commit dcc9f4f

File tree

1 file changed

+90
-61
lines changed

1 file changed

+90
-61
lines changed

src/rok4/vector.py

Lines changed: 90 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,13 @@ def from_list(
5656
cls,
5757
path: str,
5858
tables: dict[
59-
str, list[dict[str, Union[str, int, tuple[float, float, float, float], dict[str,str], list[str]]]]
59+
str,
60+
list[
61+
dict[
62+
str,
63+
Union[str, int, tuple[float, float, float, float], dict[str, str], list[str]],
64+
]
65+
],
6066
],
6167
) -> "VectorSet":
6268
"""Constructor method of a VectorSet from lists
@@ -167,8 +173,6 @@ class Vector:
167173
__tables (dict[str, Table]) : la clef est le nom de la table et la valeur de l'instance de Table
168174
"""
169175

170-
171-
172176
def __init__(self) -> None:
173177
"""Constructeur d'initialisation de la classe Vector"""
174178

@@ -213,67 +217,83 @@ def from_file(cls, path: str) -> "Vector":
213217

214218
# incrémentation du compteur
215219
index_path_vector_file += 1
216-
220+
217221
# affectation
218222
# récupération de chacun des chemins des fichiers vecteurs à partir de la "filelist.txt"
219-
vector.__path_vector_file = path
223+
vector.__path_vector_file = path
220224

221225
# remplissage du dictionnaire : vector.__tables
222-
for index_table in range(len(tables)-1):
226+
for index_table in range(len(tables) - 1):
223227
if vector.__path_vector_file.endswith("gpkg"):
224228

225229
try:
226-
227-
vector.__tables.append([{
228-
tables[index_path_vector_file][index_table]["name"]: Table(
229-
tables[index_path_vector_file][index_table]["name"],
230-
tables[index_path_vector_file][index_table]["srs"],
231-
tables[index_path_vector_file][index_table]["count"],
232-
tables[index_path_vector_file][index_table]["bbox"],
233-
tables[index_path_vector_file][index_table]["attributes"],
234-
tables[index_path_vector_file][index_table]["geometry_columns"],
235-
).__dict__,
236-
}])
230+
231+
vector.__tables.append(
232+
[
233+
{
234+
tables[index_path_vector_file][index_table]["name"]: Table(
235+
tables[index_path_vector_file][index_table]["name"],
236+
tables[index_path_vector_file][index_table]["srs"],
237+
tables[index_path_vector_file][index_table]["count"],
238+
tables[index_path_vector_file][index_table]["bbox"],
239+
tables[index_path_vector_file][index_table]["attributes"],
240+
tables[index_path_vector_file][index_table]["geometry_columns"],
241+
).__dict__,
242+
}
243+
]
244+
)
237245

238246
except KeyError as error_key:
239247
raise MissingAttributeError(
240248
f"l'attribut {error_key.args} est manquant dans le vecteur de données."
241249
)
242-
250+
243251
elif vector.__path_vector_file.endswith("geojson") and index_table == 0:
244-
252+
245253
try:
246254

247-
vector.__tables.append([{
248-
tables[index_path_vector_file-1][index_table]["name"]: Table(
249-
tables[index_path_vector_file-1][index_table]["name"],
250-
tables[index_path_vector_file-1][index_table]["srs"],
251-
tables[index_path_vector_file-1][index_table]["count"],
252-
tables[index_path_vector_file-1][index_table]["bbox"],
253-
tables[index_path_vector_file-1][index_table]["attributes"],
254-
tables[index_path_vector_file-1][index_table]["geometry_columns"],
255-
).__dict__,
256-
}])
255+
vector.__tables.append(
256+
[
257+
{
258+
tables[index_path_vector_file - 1][index_table]["name"]: Table(
259+
tables[index_path_vector_file - 1][index_table]["name"],
260+
tables[index_path_vector_file - 1][index_table]["srs"],
261+
tables[index_path_vector_file - 1][index_table]["count"],
262+
tables[index_path_vector_file - 1][index_table]["bbox"],
263+
tables[index_path_vector_file - 1][index_table]["attributes"],
264+
tables[index_path_vector_file - 1][index_table][
265+
"geometry_columns"
266+
],
267+
).__dict__,
268+
}
269+
]
270+
)
257271

258272
except KeyError as error_key:
259273
raise MissingAttributeError(
260274
f"l'attribut {error_key.args} est manquant dans le vecteur de données."
261275
)
262276
elif vector.__path_vector_file.endswith("shp") and index_table == 0:
263-
277+
264278
try:
265279

266-
vector.__tables.append([{
267-
tables[index_path_vector_file+1][index_table]["name"]: Table(
268-
tables[index_path_vector_file+1][index_table]["name"],
269-
tables[index_path_vector_file+1][index_table]["srs"],
270-
tables[index_path_vector_file+1][index_table]["count"],
271-
tables[index_path_vector_file+1][index_table]["bbox"],
272-
tables[index_path_vector_file+1][index_table]["attributes"],
273-
tables[index_path_vector_file+1][index_table]["geometry_columns"],
274-
).__dict__,
275-
}])
276-
280+
vector.__tables.append(
281+
[
282+
{
283+
tables[index_path_vector_file + 1][index_table]["name"]: Table(
284+
tables[index_path_vector_file + 1][index_table]["name"],
285+
tables[index_path_vector_file + 1][index_table]["srs"],
286+
tables[index_path_vector_file + 1][index_table]["count"],
287+
tables[index_path_vector_file + 1][index_table]["bbox"],
288+
tables[index_path_vector_file + 1][index_table]["attributes"],
289+
tables[index_path_vector_file + 1][index_table][
290+
"geometry_columns"
291+
],
292+
).__dict__,
293+
}
294+
]
295+
)
296+
277297
except KeyError as error_key:
278298
raise MissingAttributeError(
279299
f"l'attribut {error_key.args} est manquant dans le vecteur de données."
@@ -396,7 +416,7 @@ def from_file(cls, path: str) -> "Vector":
396416
)
397417

398418
else:
399-
pass
419+
pass
400420

401421
return vector
402422

@@ -429,31 +449,40 @@ def from_parameters(cls, path: str, table: dict[str, "Table"]) -> "Vector":
429449
for index_table in range(len(table)):
430450
if vector.__path_vector_file.endswith("gpkg"):
431451
try:
432-
vector.__tables.append([
433-
{
434-
table[index_table]["name"]: Table(
435-
table[index_table]["name"],
436-
table[index_table]["srs"],
437-
table[index_table]["count"],
438-
table[index_table]["bbox"],
439-
table[index_table]["attributes"],
440-
table[index_table]["geometry_columns"],
441-
).__dict__}])
452+
vector.__tables.append(
453+
[
454+
{
455+
table[index_table]["name"]: Table(
456+
table[index_table]["name"],
457+
table[index_table]["srs"],
458+
table[index_table]["count"],
459+
table[index_table]["bbox"],
460+
table[index_table]["attributes"],
461+
table[index_table]["geometry_columns"],
462+
).__dict__
463+
}
464+
]
465+
)
442466
except KeyError as error_key:
443467
raise MissingAttributeError(
444468
f"l'attribut {error_key.args} est manquant dans le vecteur de données."
445469
)
446470
else:
447471
try:
448-
vector.__tables.append([{
449-
table[index_table-1]["name"]: Table(
450-
table[index_table-1]["name"],
451-
table[index_table-1]["srs"],
452-
table[index_table-1]["count"],
453-
table[index_table-1]["bbox"],
454-
table[index_table-1]["attributes"],
455-
table[index_table-1]["geometry_columns"],
456-
).__dict__}]),
472+
vector.__tables.append(
473+
[
474+
{
475+
table[index_table - 1]["name"]: Table(
476+
table[index_table - 1]["name"],
477+
table[index_table - 1]["srs"],
478+
table[index_table - 1]["count"],
479+
table[index_table - 1]["bbox"],
480+
table[index_table - 1]["attributes"],
481+
table[index_table - 1]["geometry_columns"],
482+
).__dict__
483+
}
484+
]
485+
),
457486
except KeyError as error_key:
458487
raise MissingAttributeError(
459488
f"l'attribut {error_key.args} est manquant dans le vecteur de données."

0 commit comments

Comments
 (0)