Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
235374f
vector.py : revue suite retour de Théo pour nouvelle implémentation d…
fbacquelot May 28, 2025
9c4d6c2
vector.py : suppression d'un import
fbacquelot May 28, 2025
030d4c4
test_vector.py : création des tests avec VectorSet
fbacquelot May 28, 2025
0c255ef
vector.py : mise en forme du skeleton du programme vector.py
fbacquelot Jun 13, 2025
4f894a8
vector.py : deux usages pour le chargement des données vecteur (en co…
fbacquelot Jun 13, 2025
3b4fc8d
vector.py : rajout du path relatif donnant accès au fichier shapefile…
fbacquelot Jun 13, 2025
a62d8f5
vector.py : chargement des données vecteur dans la partie main du pro…
fbacquelot Jun 13, 2025
49a1e5f
vector.py : rajout des types des arguments d'entrées et de sorties de…
fbacquelot Jun 13, 2025
d1c3559
vector.py : ajout d'un commentaire dans la partie 'main()'
fbacquelot Jun 13, 2025
055058a
vector.py : option json pour ogrinfo en ligne de commande
fbacquelot Jun 13, 2025
c0474d1
vector.py : description des arguments d'entrée et de sortie du constr…
fbacquelot Jun 13, 2025
9f461ed
vector.py : orthographe
fbacquelot Jun 13, 2025
7787cbb
vector.py : mise à jour de la liste des valeurs de srs uniques des ta…
fbacquelot Jun 13, 2025
5a9b48e
test_vector.py : mise à jour Table à la place de Layer
fbacquelot Jun 13, 2025
63d32c1
vector.py : import des librairies gdal et ogr
fbacquelot Jun 13, 2025
2cfcd5e
vector.py : esthétique
fbacquelot Jun 16, 2025
16cb56d
vector.py : mise dans l'ordre croissant des codes srs uniques des tables
fbacquelot Jun 16, 2025
65d2c5a
vector.py : rajouter l'instanciation des objets liés aux classes 'Vec…
fbacquelot Jun 16, 2025
41a970f
fichiers tests unitaires déplacés dans le sous-dossier 'unit_tests'
fbacquelot Jun 17, 2025
55c4d19
test_* : suppression de ces fichiers de tests unitaires car ils ont é…
fbacquelot Jun 17, 2025
a715dff
__init__.py & test_*.py : déplacement au bon endroit des tests unitaires
fbacquelot Jun 17, 2025
5f030d3
vector.py : mise à jour des classes et des méthodes associées
fbacquelot Jun 17, 2025
3745de0
suppression des fichiers car ils ont été déplacés dans le bon dossier
fbacquelot Jun 17, 2025
320e6bd
test_vector.py : ajout commentaire dans la docstring
fbacquelot Jun 17, 2025
fadf4f6
vector.py : ajout de la méthode 'get_data_str' de 'rok4.storage'
fbacquelot Jun 18, 2025
77cc3fe
test_vector.py : ajout des tests unitaires si les fichiers de données…
fbacquelot Jun 18, 2025
267be42
vector.py : chargement des données vecteur => construction des classe…
fbacquelot Jun 19, 2025
c602cf2
test_vector.py : suppression de tests inutiles
fbacquelot Jun 19, 2025
532a39d
test_vector.py : ajout de test pour tester que vector.from_file() ren…
fbacquelot Jun 19, 2025
54899c4
test_vector.py : esthétique
fbacquelot Jun 19, 2025
da2cbaf
vector.py : construction du jeu de données vecteur à partir du descri…
fbacquelot Jun 19, 2025
2e1e78e
vector.py & test_vector.py : couverture des tests passée à 63% reste …
fbacquelot Jun 19, 2025
43539c2
vector.py : revue du typage de tables
fbacquelot Jun 25, 2025
20380bd
test_vector.py : ajout des tests unitaires pour les méthodes 'from_fi…
fbacquelot Jun 25, 2025
cb326b7
vector.py & test_vector.py : manque quelques tests + couverture des t…
fbacquelot Jun 26, 2025
f4449b5
test_vector.py : quelques petites corrections dans le test 'test_vect…
fbacquelot Jun 26, 2025
acbacd2
test_vector.py : correction des tests de la classe 'VectorSet()' pou…
fbacquelot Jul 2, 2025
c898d45
rok4 : suppression dossier 'rok4' de l'environnement virtuel
fbacquelot Jul 7, 2025
2556195
test_vector.py : ajout de quelques tests d'intégration dans la foncti…
fbacquelot Jul 7, 2025
1798cbe
test_vector.py : insertion d'une en-tête au programme de tests et d'u…
fbacquelot Jul 7, 2025
b1aee5b
test_vector.py : ajout de la docstring aux deux fonctions suivantes d…
fbacquelot Jul 7, 2025
c044fac
test_vector.py : ajout de la docstring manquante dans les fonctions d…
fbacquelot Jul 8, 2025
3dffdd6
test_vector.py : esthétique => mise sur plusieurs lignes du contexte …
fbacquelot Jul 8, 2025
a3e03be
vector.py : première version suite issues #97 "Module de chargement d…
fbacquelot Jul 28, 2025
a450b26
filelist.txt : nouveau jeu de données d'entrées
fbacquelot Jul 28, 2025
a209d2e
[pre-commit.ci] Corrections automatiques appliquées par les git hooks.
pre-commit-ci[bot] Jul 29, 2025
86d485d
test_vector.py : tests à revoir car le code a été remis à plat suite …
fbacquelot Jul 29, 2025
8dc8267
Merge branch 'feature/vectorsets' of github.com:rok4/core-python into…
fbacquelot Jul 29, 2025
38c4b86
[pre-commit.ci] Corrections automatiques appliquées par les git hooks.
pre-commit-ci[bot] Jul 29, 2025
a8d065f
test_vector.py : formatage avec black
fbacquelot Jul 29, 2025
1d4e35d
Merge branch 'feature/vectorsets_squashed_commits' of github.com:rok4…
fbacquelot Jul 29, 2025
9b97917
[pre-commit.ci] Corrections automatiques appliquées par les git hooks.
pre-commit-ci[bot] Jul 29, 2025
11ae738
test_vector.py : création des tests avec VectorSet
fbacquelot Jul 29, 2025
730d032
Merge branch 'feature/vectorsets_squashed_commits' of github.com:rok4…
fbacquelot Jul 29, 2025
2c99529
première version suite issues #97 'Module de chargement de données ve…
fbacquelot Jul 29, 2025
5e5b259
première version de vector.py, les tests ne sont encore réalisés suit…
fbacquelot Jul 29, 2025
36d2c44
vector.py : première version de vector.py suite issues #97 avec nouve…
fbacquelot Jul 29, 2025
844e69e
Merge branch 'feature/vectorsets_squashed_commits' of github.com:rok4…
fbacquelot Jul 29, 2025
b56fb98
dossier rok4 dans tests inutile ici
fbacquelot Jul 30, 2025
80202ad
vector.py : première version de vector.py suite issues #97 avec nouve…
fbacquelot Jul 30, 2025
e13138b
Merge branch 'feature/vectorsets_squashed_commits' of github.com:rok4…
fbacquelot Jul 30, 2025
f46c77a
vector.py : première version de vector.py suite issues #97 avec nouve…
fbacquelot Jul 30, 2025
1028d10
Merge branch 'feature/vectorsets_squashed_commits' of github.com:rok4…
fbacquelot Jul 30, 2025
d3425d1
[pre-commit.ci] Corrections automatiques appliquées par les git hooks.
pre-commit-ci[bot] Jul 30, 2025
6719374
vector.py : renommage variable plus explicite pour compter le nombre …
fbacquelot Jul 30, 2025
dcc9f4f
Merge branch 'feature/vectorsets_squashed_commits' of github.com:rok4…
fbacquelot Jul 30, 2025
644218d
vector.py : revue suite retour de Théo pour nouvelle implémentation d…
fbacquelot Jul 30, 2025
3be6b8c
Merge branch 'feature/vectorsets_squashed_commits' of github.com:rok4…
fbacquelot Jul 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
972 changes: 799 additions & 173 deletions src/rok4/vector.py
100644 → 100755

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion tests/fixtures/ARRONDISSEMENT.cpg

This file was deleted.

Binary file removed tests/fixtures/ARRONDISSEMENT.dbf
Binary file not shown.
1 change: 0 additions & 1 deletion tests/fixtures/ARRONDISSEMENT.prj

This file was deleted.

Binary file removed tests/fixtures/ARRONDISSEMENT.shp
Binary file not shown.
Binary file removed tests/fixtures/ARRONDISSEMENT.shx
Binary file not shown.
Binary file added tests/fixtures/TM_WORLD_BORDERS-0.3.dbf
Binary file not shown.
1 change: 1 addition & 0 deletions tests/fixtures/TM_WORLD_BORDERS-0.3.prj
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]
Binary file added tests/fixtures/TM_WORLD_BORDERS-0.3.shp
Binary file not shown.
Binary file added tests/fixtures/TM_WORLD_BORDERS-0.3.shx
Binary file not shown.
3 changes: 3 additions & 0 deletions tests/fixtures/filelist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
tests/fixtures/states.geojson
tests/fixtures/martinique.gpkg
tests/fixtures/TM_WORLD_BORDERS-0.3.shp
Binary file added tests/fixtures/martinique.gpkg
Binary file not shown.
60 changes: 60 additions & 0 deletions tests/fixtures/states.geojson

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions tests/fixtures/vector.csv

This file was deleted.

8 changes: 0 additions & 8 deletions tests/fixtures/vector.geojson

This file was deleted.

Binary file removed tests/fixtures/vector.gpkg
Binary file not shown.
2 changes: 0 additions & 2 deletions tests/fixtures/vector2.csv

This file was deleted.

99 changes: 99 additions & 0 deletions tests/fixtures/vectorset.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
[
{
"path": "file://./data/martinique.gpkg",
"tables": [
{
"name": "arrondissement",
"count": 4,
"srs": "EPSG:4559",
"bbox": [690574.399999426, 1592426.09999943, 736126.499998242, 1645659.8],
"geometry_columns": ["geom"],
"attributes": {
"fid": "Integer",
"id": "Integer",
"id_geofla": "String",
"code_arr": "String",
"code_chf": "String",
"nom_chf": "String",
"x_chf_lieu": "Integer",
"y_chf_lieu": "Integer",
"x_centroid": "Integer",
"y_centroid": "Integer",
"code_dept": "String",
"nom_dept": "String",
"code_reg": "String",
"nom_reg": "String"
}
},
{
"name": "departement",
"count": 1,
"srs": "EPSG:4559",
"bbox": [690574.399999426, 1592426.09999943, 736126.499998242, 1645659.8],
"geometry_columns": ["geom"],
"attributes": {
"fid": "Integer",
"id": "Integer",
"id_geofla": "String",
"code_dept": "String",
"nom_dept": "String",
"code_chf": "String",
"nom_chf": "String",
"x_chf_lieu": "Integer",
"y_chf_lieu": "Integer",
"x_centroid": "Integer",
"y_centroid": "Integer",
"code_reg": "String",
"nom_reg": "String"
}
}
]
},
{
"path": "file://./data/states.geojson",
"tables": [
{
"name": "states",
"count": 52,
"srs": "EPSG:3857",
"bbox": [-19951818.272319775, 2017836.357428821, -7254560.414595957, 11553642.98126969],
"geometry_columns": ["geom"],
"attributes": {
"id": "String",
"STATE_ABBR": "String",
"STATE_NAME": "String",
"AREA_LAND": "Real",
"AREA_WATER": "Real",
"PERSONS": "Integer",
"MALE": "Integer",
"FEMALE": "Integer"
}
}
]
},
{
"path": "file://./data/TM_WORLD_BORDERS-0.3.shp",
"tables": [
{
"name": "TM_WORLD_BORDERS-0.3",
"count": 246,
"srs": "EPSG:4326",
"bbox": [-179.99999999999997, 180.0, -90.0, 83.62359600000008],
"geometry_columns": ["geom"],
"attributes": {
"FIPS": "String",
"ISO2": "String",
"ISO3": "String",
"UN": "Integer",
"NAME": "String",
"AREA": "Integer",
"POP2005": "Integer64",
"REGION": "Integer",
"SUBREGION": "Integer",
"LON": "Real",
"LAT": "Real"
}
}
]
}
]
241 changes: 241 additions & 0 deletions tests/rok4/bin/Activate.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,241 @@
<#
.Synopsis
Activate a Python virtual environment for the current PowerShell session.

.Description
Pushes the python executable for a virtual environment to the front of the
$Env:PATH environment variable and sets the prompt to signify that you are
in a Python virtual environment. Makes use of the command line switches as
well as the `pyvenv.cfg` file values present in the virtual environment.

.Parameter VenvDir
Path to the directory that contains the virtual environment to activate. The
default value for this is the parent of the directory that the Activate.ps1
script is located within.

.Parameter Prompt
The prompt prefix to display when this virtual environment is activated. By
default, this prompt is the name of the virtual environment folder (VenvDir)
surrounded by parentheses and followed by a single space (ie. '(.venv) ').

.Example
Activate.ps1
Activates the Python virtual environment that contains the Activate.ps1 script.

.Example
Activate.ps1 -Verbose
Activates the Python virtual environment that contains the Activate.ps1 script,
and shows extra information about the activation as it executes.

.Example
Activate.ps1 -VenvDir C:\Users\MyUser\Common\.venv
Activates the Python virtual environment located in the specified location.

.Example
Activate.ps1 -Prompt "MyPython"
Activates the Python virtual environment that contains the Activate.ps1 script,
and prefixes the current prompt with the specified string (surrounded in
parentheses) while the virtual environment is active.

.Notes
On Windows, it may be required to enable this Activate.ps1 script by setting the
execution policy for the user. You can do this by issuing the following PowerShell
command:

PS C:\> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

For more information on Execution Policies:
https://go.microsoft.com/fwlink/?LinkID=135170

#>
Param(
[Parameter(Mandatory = $false)]
[String]
$VenvDir,
[Parameter(Mandatory = $false)]
[String]
$Prompt
)

<# Function declarations --------------------------------------------------- #>

<#
.Synopsis
Remove all shell session elements added by the Activate script, including the
addition of the virtual environment's Python executable from the beginning of
the PATH variable.

.Parameter NonDestructive
If present, do not remove this function from the global namespace for the
session.

#>
function global:deactivate ([switch]$NonDestructive) {
# Revert to original values

# The prior prompt:
if (Test-Path -Path Function:_OLD_VIRTUAL_PROMPT) {
Copy-Item -Path Function:_OLD_VIRTUAL_PROMPT -Destination Function:prompt
Remove-Item -Path Function:_OLD_VIRTUAL_PROMPT
}

# The prior PYTHONHOME:
if (Test-Path -Path Env:_OLD_VIRTUAL_PYTHONHOME) {
Copy-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME -Destination Env:PYTHONHOME
Remove-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME
}

# The prior PATH:
if (Test-Path -Path Env:_OLD_VIRTUAL_PATH) {
Copy-Item -Path Env:_OLD_VIRTUAL_PATH -Destination Env:PATH
Remove-Item -Path Env:_OLD_VIRTUAL_PATH
}

# Just remove the VIRTUAL_ENV altogether:
if (Test-Path -Path Env:VIRTUAL_ENV) {
Remove-Item -Path env:VIRTUAL_ENV
}

# Just remove the _PYTHON_VENV_PROMPT_PREFIX altogether:
if (Get-Variable -Name "_PYTHON_VENV_PROMPT_PREFIX" -ErrorAction SilentlyContinue) {
Remove-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Scope Global -Force
}

# Leave deactivate function in the global namespace if requested:
if (-not $NonDestructive) {
Remove-Item -Path function:deactivate
}
}

<#
.Description
Get-PyVenvConfig parses the values from the pyvenv.cfg file located in the
given folder, and returns them in a map.

For each line in the pyvenv.cfg file, if that line can be parsed into exactly
two strings separated by `=` (with any amount of whitespace surrounding the =)
then it is considered a `key = value` line. The left hand string is the key,
the right hand is the value.

If the value starts with a `'` or a `"` then the first and last character is
stripped from the value before being captured.

.Parameter ConfigDir
Path to the directory that contains the `pyvenv.cfg` file.
#>
function Get-PyVenvConfig(
[String]
$ConfigDir
) {
Write-Verbose "Given ConfigDir=$ConfigDir, obtain values in pyvenv.cfg"

# Ensure the file exists, and issue a warning if it doesn't (but still allow the function to continue).
$pyvenvConfigPath = Join-Path -Resolve -Path $ConfigDir -ChildPath 'pyvenv.cfg' -ErrorAction Continue

# An empty map will be returned if no config file is found.
$pyvenvConfig = @{ }

if ($pyvenvConfigPath) {

Write-Verbose "File exists, parse `key = value` lines"
$pyvenvConfigContent = Get-Content -Path $pyvenvConfigPath

$pyvenvConfigContent | ForEach-Object {
$keyval = $PSItem -split "\s*=\s*", 2
if ($keyval[0] -and $keyval[1]) {
$val = $keyval[1]

# Remove extraneous quotations around a string value.
if ("'""".Contains($val.Substring(0, 1))) {
$val = $val.Substring(1, $val.Length - 2)
}

$pyvenvConfig[$keyval[0]] = $val
Write-Verbose "Adding Key: '$($keyval[0])'='$val'"
}
}
}
return $pyvenvConfig
}


<# Begin Activate script --------------------------------------------------- #>

# Determine the containing directory of this script
$VenvExecPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
$VenvExecDir = Get-Item -Path $VenvExecPath

Write-Verbose "Activation script is located in path: '$VenvExecPath'"
Write-Verbose "VenvExecDir Fullname: '$($VenvExecDir.FullName)"
Write-Verbose "VenvExecDir Name: '$($VenvExecDir.Name)"

# Set values required in priority: CmdLine, ConfigFile, Default
# First, get the location of the virtual environment, it might not be
# VenvExecDir if specified on the command line.
if ($VenvDir) {
Write-Verbose "VenvDir given as parameter, using '$VenvDir' to determine values"
}
else {
Write-Verbose "VenvDir not given as a parameter, using parent directory name as VenvDir."
$VenvDir = $VenvExecDir.Parent.FullName.TrimEnd("\\/")
Write-Verbose "VenvDir=$VenvDir"
}

# Next, read the `pyvenv.cfg` file to determine any required value such
# as `prompt`.
$pyvenvCfg = Get-PyVenvConfig -ConfigDir $VenvDir

# Next, set the prompt from the command line, or the config file, or
# just use the name of the virtual environment folder.
if ($Prompt) {
Write-Verbose "Prompt specified as argument, using '$Prompt'"
}
else {
Write-Verbose "Prompt not specified as argument to script, checking pyvenv.cfg value"
if ($pyvenvCfg -and $pyvenvCfg['prompt']) {
Write-Verbose " Setting based on value in pyvenv.cfg='$($pyvenvCfg['prompt'])'"
$Prompt = $pyvenvCfg['prompt'];
}
else {
Write-Verbose " Setting prompt based on parent's directory's name. (Is the directory name passed to venv module when creating the virutal environment)"
Write-Verbose " Got leaf-name of $VenvDir='$(Split-Path -Path $venvDir -Leaf)'"
$Prompt = Split-Path -Path $venvDir -Leaf
}
}

Write-Verbose "Prompt = '$Prompt'"
Write-Verbose "VenvDir='$VenvDir'"

# Deactivate any currently active virtual environment, but leave the
# deactivate function in place.
deactivate -nondestructive

# Now set the environment variable VIRTUAL_ENV, used by many tools to determine
# that there is an activated venv.
$env:VIRTUAL_ENV = $VenvDir

if (-not $Env:VIRTUAL_ENV_DISABLE_PROMPT) {

Write-Verbose "Setting prompt to '$Prompt'"

# Set the prompt to include the env name
# Make sure _OLD_VIRTUAL_PROMPT is global
function global:_OLD_VIRTUAL_PROMPT { "" }
Copy-Item -Path function:prompt -Destination function:_OLD_VIRTUAL_PROMPT
New-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Description "Python virtual environment prompt prefix" -Scope Global -Option ReadOnly -Visibility Public -Value $Prompt

function global:prompt {
Write-Host -NoNewline -ForegroundColor Green "($_PYTHON_VENV_PROMPT_PREFIX) "
_OLD_VIRTUAL_PROMPT
}
}

# Clear PYTHONHOME
if (Test-Path -Path Env:PYTHONHOME) {
Copy-Item -Path Env:PYTHONHOME -Destination Env:_OLD_VIRTUAL_PYTHONHOME
Remove-Item -Path Env:PYTHONHOME
}

# Add the venv to the PATH
Copy-Item -Path Env:PATH -Destination Env:_OLD_VIRTUAL_PATH
$Env:PATH = "$VenvExecDir$([System.IO.Path]::PathSeparator)$Env:PATH"
9 changes: 9 additions & 0 deletions tests/rok4/bin/pip
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/home/FBacquelot/repositories/rok4/core-python/core-python/tests/rok4/bin/python3
import re
import sys

from pip._internal.cli.main import main

if __name__ == "__main__":
sys.argv[0] = re.sub(r"(-script\.pyw|\.exe)?$", "", sys.argv[0])
sys.exit(main())
9 changes: 9 additions & 0 deletions tests/rok4/bin/pip3
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/home/FBacquelot/repositories/rok4/core-python/core-python/tests/rok4/bin/python3
import re
import sys

from pip._internal.cli.main import main

if __name__ == "__main__":
sys.argv[0] = re.sub(r"(-script\.pyw|\.exe)?$", "", sys.argv[0])
sys.exit(main())
Loading