Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v4.0.0 #80

Open
wants to merge 67 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
243174f
Improving doc (#79)
procrastinatio Oct 2, 2024
3b884b2
Minor corrections (das) (#81)
procrastinatio Oct 3, 2024
f08091c
dumping from runamel (no content change)
procrastinatio Oct 8, 2024
9047e57
setting mandatory attributes
procrastinatio Oct 8, 2024
710047f
Merge pull request #82 from swisstopo/set_mandatory
procrastinatio Oct 8, 2024
06dcece
Split the main command (#83)
procrastinatio Oct 9, 2024
6457458
Using data model release info to name artifacts (#85)
procrastinatio Oct 9, 2024
ac627eb
importing/exporting to xlsx
procrastinatio Oct 9, 2024
739d624
add json schema and validate
procrastinatio Oct 9, 2024
1826ecf
add and export sub-command
procrastinatio Oct 9, 2024
d1dbf6b
building the excel in the Makefile (+ small glitches)
procrastinatio Oct 9, 2024
2d46ee9
files integrated into `geocover.model`
procrastinatio Oct 9, 2024
3d85471
Merge pull request #84 from swisstopo/read_write_xlsx
procrastinatio Oct 9, 2024
8e212bf
no need for suffix .zip
procrastinatio Oct 9, 2024
c30b661
bumping version
procrastinatio Oct 9, 2024
76c1109
Merge pull request #86 from swisstopo/artifacts_name
procrastinatio Oct 9, 2024
dd2447d
dynamic artefect name
procrastinatio Oct 9, 2024
241c3ab
Merge pull request #87 from swisstopo/fix_release_upload
procrastinatio Oct 9, 2024
d581d65
artifact name
procrastinatio Oct 9, 2024
ef57a7b
Merge pull request #88 from swisstopo/fix_release_upload
procrastinatio Oct 9, 2024
601240a
fixin bash
procrastinatio Oct 9, 2024
af60873
Merge pull request #91 from swisstopo/fix_bash
procrastinatio Oct 9, 2024
ca427a8
fixin bash
procrastinatio Oct 9, 2024
f229e58
Merge pull request #92 from swisstopo/fix_bash
procrastinatio Oct 9, 2024
ecaaf61
fixin bash
procrastinatio Oct 9, 2024
07d0f90
Merge pull request #93 from swisstopo/fix_bash
procrastinatio Oct 9, 2024
294c3ed
fixin bash
procrastinatio Oct 9, 2024
9e7ddb1
Merge pull request #94 from swisstopo/fix_bash
procrastinatio Oct 9, 2024
67477db
fixing dupplicated classe in xlsx export
procrastinatio Oct 21, 2024
5b20645
Merge pull request #96 from swisstopo/fix_dupplicated_classes
procrastinatio Oct 21, 2024
aea64ab
pre migration
ltmom Oct 26, 2024
1b924ef
post migration
ltmom Oct 26, 2024
c7532aa
added schema migration + some clairfication
procrastinatio Oct 27, 2024
4313b91
migration doc for october 2024
procrastinatio Oct 27, 2024
ef25b9e
Merge pull request #97 from swisstopo/migration_october
procrastinatio Nov 5, 2024
b35d7c2
update coded domains after schema migration
ltmom Nov 5, 2024
b4d7bab
Merge pull request #98 from swisstopo/update_coded_domain
procrastinatio Nov 5, 2024
b13c299
Older schema (#99)
procrastinatio Nov 6, 2024
f475725
Translation data (#100)
procrastinatio Nov 6, 2024
757b50d
korrektur DAS (#101)
procrastinatio Nov 7, 2024
4b22bef
Removing mandatory (#102)
procrastinatio Nov 7, 2024
b66c58d
Fix geolcodes (#103)
procrastinatio Nov 8, 2024
9a53ee9
Geolcode comparisons (#104)
procrastinatio Nov 8, 2024
27f91ac
Missing ttec (#105)
procrastinatio Nov 11, 2024
8d24449
Update .csv and .json after october migration (#106)
procrastinatio Nov 11, 2024
529ab4f
incorporating script into geocover command (#107)
procrastinatio Nov 11, 2024
d0cc1f3
using alias if available (#109)
procrastinatio Nov 12, 2024
66f962c
check attributes in model and fc
procrastinatio Nov 11, 2024
4ecf0b3
version
procrastinatio Nov 11, 2024
e76d997
less verbose
procrastinatio Nov 11, 2024
9eccfdb
attribute search (#110)
procrastinatio Nov 12, 2024
fd695e0
bumping
procrastinatio Nov 12, 2024
ad60388
formatting
procrastinatio Nov 12, 2024
4bac572
version
procrastinatio Nov 12, 2024
e24dd0a
Merge pull request #108 from swisstopo/check_model_vs_featureclass
procrastinatio Nov 12, 2024
db145c6
Missing prefixes and attributes alias (#111)
procrastinatio Nov 13, 2024
d6c3353
Corrections français (#112)
procrastinatio Nov 13, 2024
7deb72f
Fix schema model (#114)
procrastinatio Nov 14, 2024
87a1067
version (#115)
procrastinatio Nov 14, 2024
efd2e76
validate model against jsonschema (#116)
procrastinatio Nov 15, 2024
e23753b
typo and missing (#117)
procrastinatio Nov 15, 2024
0f5adc3
almost done (#118)
procrastinatio Nov 15, 2024
e13278f
gc_system is an annex (#119)
procrastinatio Nov 15, 2024
c5316b8
V4.0.0 rc.2 (#120)
procrastinatio Nov 16, 2024
0fe04ac
Release 4.0.0-rc-3 (#121)
procrastinatio Nov 17, 2024
9824451
Release 4.0.0-rc.4 (#123)
procrastinatio Nov 19, 2024
d4c2cfa
v4.0.0-rc.5 (#124)
procrastinatio Nov 19, 2024
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
21 changes: 18 additions & 3 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,25 @@ jobs:
conda config --show-sources
conda config --show
printenv | sort
- name: Set Package Version
shell: bash -l {0}
run: |
echo "version=$(<VERSION)" >> $GITHUB_ENV
echo "=== PKG_VERSION=$version ==="
echo "RELEASE=$(python -c "import yaml; print(yaml.safe_load(open('datamodel.yaml'))['model']['revision'])")" >> $GITHUB_ENV
echo "=== RELEASE=$RELEASE ==="


- shell: bash -el {0}
- name: Pip install
shell: bash -el {0}
run: pip install -e .

- name: Validate
shell: bash -el {0}
run: make validate

- shell: bash -el {0}
- name: Generate graph
shell: bash -el {0}
run: |
python ./create_gv.py

Expand All @@ -66,7 +79,7 @@ jobs:
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: document-artifacts
name: geology-data-model-${{ env.RELEASE }}
path: |
outputs/de/datamodel.pdf
outputs/fr/datamodel.pdf
Expand All @@ -86,4 +99,6 @@ jobs:
exports/all_geolcode.xlsx
exports/all_geolcode.json
exports/geocover-schema-sde.json
inputs/datamodel.xlsx
datamodel.yaml

11 changes: 10 additions & 1 deletion .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,19 @@ jobs:
runs-on: ubuntu-latest
needs: [build] # require build to pass before deploy runs
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set Package Version
shell: bash
run: |
echo "version=$(<VERSION)" >> $GITHUB_ENV
echo "=== PKG_VERSION=$version ==="
echo "RELEASE=$(python -c "import yaml; print(yaml.safe_load(open('datamodel.yaml'))['model']['revision'])")" >> $GITHUB_ENV
echo "=== RELEASE=$RELEASE ==="
- name: Download assets from build
uses: actions/download-artifact@v4
with:
name: document-artifacts
name: geology-data-model-${{ env.RELEASE }}
- name: Upload folder to bucket
uses: a-sync/s3-uploader@master
with:
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,17 @@ jobs:
runs-on: ubuntu-latest
needs: [build] # require build to pass before deploy runs
steps:
- name: Set Package Version
shell: bash -l {0}
run: |
echo "version=$(<VERSION)" >> $GITHUB_ENV
echo "=== PKG_VERSION=$version ==="
echo "RELEASE=$(python -c "import yaml; print(yaml.safe_load(open('datamodel.yaml'))['model']['revision'])")" >> $GITHUB_ENV
echo "=== RELEASE=$RELEASE ==="
- name: Download assets from build
uses: actions/download-artifact@v4
with:
name: document-artifacts
name: geology-data-model-${{ env.RELEASE }}
- name: Release assets
uses: softprops/action-gh-release@v2
env:
Expand Down
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ include LICENSE.txt
include VERSION
include README.md
include setup.py
recursive-include src/geocover/data *.csv
recursive-include src/geocover *.py
22 changes: 16 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,18 @@ PANDOC_ODT_OPTIONS=
# Help target
help:
@echo "Usage:"
@echo " make all - Generate all files (PDF, DOCX, HTML and ODT for all languages)"
@echo " make pdf - Generate only PDF files for all languages"
@echo " make docx - Generate only PDF files for all languages"
@echo " make all - Generate all files (PDF, DOCX, HTML and ODT for all languages)"
@echo " make pdfs - Generate only PDF files for all languages"
@echo " make docxs - Generate only DOCX files for all languages"
@echo " make odts - Generate only ODT files for all languages"
@echo " make htmls - Generate only HTML files for all languages"
@echo " make mds - Generate only Markdown files for all languages"
@echo " make de - Generate all files (PDF, DOCX, HTML and ODT) for German"
@echo " make fr - Generate all files (PDF, DOCX, HTML and ODT) for French"
@echo " make babel - Generate .mo translation files"
@echo " make markdown - Generate markdown files"
@echo " make diagram - Generate ER diagram"
@echo " make validate - Validate the datamodel against the schema"
@echo " make clean - Remove all generated files"
@echo " make help - Display this help message"

Expand Down Expand Up @@ -81,20 +85,23 @@ markdown: $(MO_FILES) $(INPUTS)

diagram: assets
python create_gv.py

$(INPUT_DIR)/datamodel.xlsx:
datamodel export datamodel.yaml -o $@


.PHONY: all
all: $(MO_FILES) $(INPUTS) $(OUTPUTS) diagram
all: $(MO_FILES) $(INPUTS) $(OUTPUTS) diagram $(INPUT_DIR)/datamodel.xlsx

# Define individual rules for each format and language
define build_rule
$(INPUT_DIR)/$(1)/metadata.yaml: assets $(MO_FILES)
mkdir -p $$(@D)
datamodel --lang=$(1) -o $(INPUT_DIR) datamodel.yaml
datamodel generate --lang=$(1) -o $(INPUT_DIR) datamodel.yaml

$(INPUT_DIR)/$(1)/datamodel.md: assets $(MO_FILES)
mkdir -p $$(@D)
datamodel --lang=$(1) -o $(INPUT_DIR) datamodel.yaml
datamodel generate --lang=$(1) -o $(INPUT_DIR) datamodel.yaml

$(OUTPUT_DIR)/$(1)/datamodel.pdf: $(INPUT_DIR)/$(1)/datamodel.md $(INPUT_DIR)/$(1)/metadata.yaml
mkdir -p $$(@D)
Expand Down Expand Up @@ -132,6 +139,9 @@ mds: $(foreach lang,$(LANGUAGES),$(INPUT_DIR)/$(lang)/datamodel.md)
de: $(foreach fmt,$(FORMATS),$(OUTPUT_DIR)/de/datamodel.$(fmt))
fr: $(foreach fmt,$(FORMATS),$(OUTPUT_DIR)/fr/datamodel.$(fmt))

.PHONY: validate
validate:
datamodel validate datamodel.yaml

# Clean up
# Clean up all generated files
Expand Down
108 changes: 59 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,54 +4,57 @@ Modèle de données géologiques
Le but de ces outils est de créer de manière plus au moins automatique le [modèle de données géologiques](https://www.geologieportal.ch/fr/connaissance/consulter/modeles-de-donnees/modele-de-donnees-geologiques.html), en
particulier la liste des valeurs attributaires possibles, et le modèle physique issu de ESRI ArcSDE.

Les fichiers d'intérêts sont dans le répertoire `outputs`:
Les exports de la base de données ArcSDE sont dans `exports`, les fichiers intermédiaires `markdown` dans `inputs`
et les différents formats du modèle final dans `outputs`.

* Pour l'instante, le modèle est disponible en allemand et en français.
* Pour l'instant, le modèle est disponible en allemand et en français.
* Plusieurs formats sont disponbiles : `datamodel.pdf`, ainsi que sous forme de fichier `.docx`, `.html` et `.odt`.
* le dump des informations de ESRI ArcSDE
* Le dump des informations de ESRI ArcSDE dans `exports`
* Le schéma ER de la base `ER-GCOVER.svg`, généré à partir d'un fichier `PlantUML`.



# Installation

Les scripts ne fonctionnent qu'avec Python3 et sont disponible comme paquet `conda`. Sur BURAUT, il faut cloner l'environnement par defaut
pour pouvoir le modifier. Sous Linux, il est possible de générer les fichiers finaux, mais l'extraction des données à partir de la
L'outil est disponbile comme paquets sur `anaconda.org` et `pypi.org`. La génération des fichiers finaux à partir des `exports`
est possible dans n'importe quel environnement, mais l'export des données nécessite `arcpy`et un accès à la base ESRI ArcSDE.
base de données ESRI ArcSDE n'est bien entendu pas possible.

## Windows

Open a Python Command Prompt windows and clone the default ESRI ArcGis `conda` environnement
Open a Python Command Prompt windows and clone the default ESRI ArcGis `conda` environnement

(arcgispro-py3) C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3>conda create --clone arcgispro-py3 --prefix C:\LegacySW\envs\arcgispro-py3_clone

Deactivate
Deactivate the default environment

(arcgispro-py3) C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3> deactivate

Activate
Activate the newly created cloned environment

C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3> activate C:\LegacySW\envs\arcgispro-py3_clone

Install the package

(arcgispro-py3) C:\LegacySW\envs\arcgispro-py3_clone> conda install swisstopo::geocover

Comme _pandoc.exe_ est un fichier unique, il peut être facilement téléchargé et installé dans _C:\LegacySW_ . Télécharger
la dernière version Windows disponible sur [Pandoc](https://github.com/jgm/pandoc/releases) et dézipper dans _C:>LegacySW_
To generate de final documents from the `markdown` sources, you need `pandoc`. As _pandoc.exe_ is a standalone binary on
Windows, simply download it and unzip it into _C:\LegacySW_ (see the latest available version on [Pandoc](https://github.com/jgm/pandoc/releases) ).

Pour tester l'installation (le numéro de version peut être différent):

C:\LegacySW\pandoc-3.1.13\pandoc.exe --version

## Linux

conda install swisstopo::geocover
You need `pandoc` and a fully-fledge `XeLaTeX` installation. Install it with `apt-get`, `yum`, etc.

Create a `conda` environement as normal and install the package:

Les scripts, _coded_domain.py_ et _subtype.py_ doivent être excécuté dans un projet ESRI ArcGis Pro avec une connection
sur la base SDE GCOVER.
conda install swisstopo::geocover

Le script `datamodel` qui génère le fichier _MarkDown_ n'a besoin que des libraries de base sus-mentionnées.
The subcommand of `geocover` requiring `arcpy` are not available on Linux. The
Le script `datamodel` qui génère le fichier _markdown_ n'a besoin que des libraries de base sus-mentionnées.


# Utilisation
Expand All @@ -78,32 +81,40 @@ Dans ArcGis Pro, charger et exécuter le script : `export_oracle_tables.py`

## Traductions

1. Extraction des chaînes de caractères pour traduction :
Extraction des chaînes de caractères pour traduction :

pybabel extract -F babel.cfg -o locale/app.pot .

2. Fusion des catalogues (`app` et `datamodel`):
Fusion des catalogues (`app` et `datamodel`):

pybabel update -i locale/app.pot -d locale -D app
pybabel update -i locale/datamodel.pot -d locale -D datamodel

3. Edition des fichiers .po dans `PoEdit` par exemple
Edition des fichiers .po dans `PoEdit` par exemple


4. Compiler les catalogues (`app` et `datamodel`) :
Compiler les catalogues (`app` et `datamodel`) :

pybabel compile --domain=app --directory=locale --use-fuzzy


## Création du fichier Markdown source

Le script _datamodel.py_ combine les informations de la configuration _datamodel.yaml_ avec _coded_domains.json_ , _subtypes.json_ et le fichier de traduction.
Le résultat est le fichier _Marcdown_ _datamodel_fr.md_ ou _datamodel_de.md_
Le script _datamodel_ combine les informations de la configuration _datamodel.yaml_ avec _coded_domains.json_ , _subtypes.json_ et le fichier de traduction.
Le résultat est le fichier _Marcdown_ _fr/datamodel.md_ ou _de/datamodel.md_

datamodel --lang de datamodel.yaml

## Génération des différents formats

simply use the latest https://github.com/swisstopo/lg-geology-data-model/releases

### Linux

Use `make`

make pdfs # or all

Creation d'un fichier PDF (possible uniquement avec une installation complète de _LaTeX_)

pandoc -s --pdf-engine=xelatex \
Expand All @@ -116,38 +127,17 @@ Creation d'un fichier PDF (possible uniquement avec une installation complète d
-V linkcolor=teal \
-V urlcolor=teal \
-V toccolor=gray \
-o datamodel.pdf datamodel.md
-o de/datamodel.pdf de/datamodel.md

Idem, mais pour un fichier Microsoft Word (.docx)

Sur Linux...

pandoc -s -V papersize:a4 \
--number-sections \
--shift-heading-level-by=-1 \
--metadata-file=metadata.yaml \
--variable mainfont="DejaVu Sans" \
-o datamodel.docx datamodel.md

..ou sur Windows:

C:\LegacySW\pandoc-3.1.13\pandoc.exe -s -V papersize:a4 --number-sections --shift-heading-level-by=-1
C:\LegacySW\pandoc-3.1.13\pandoc.exe -s -V papersize:a4 --number-sections --shift-heading-level-by=-1
--metadata-file=metadata.yaml --variable mainfont="DejaVu Sans" -o datamodel.docx datamodel.md

Pour HTML
For HTML

Sur Linux...

pandoc -s --toc \
--number-sections \
--shift-heading-level-by=-1 \
--css datamodel.css \
--metadata-file=metadata.yaml \
--variable mainfont="Sans" \
-o datamodel.html datamodel.md

.. ou Windows

C:\LegacySW\pandoc-3.1.13\pandoc.exe --toc --number-sections --shift-heading-level-by=-1 --css datamodel.css
--metadata-file=metadata.yaml --variable mainfont="Sans" -o datamodel.html datamodel.md

Expand All @@ -170,18 +160,38 @@ Convertir en PDF (A3)

# Autres fonctions

## Extraire les règles des layerfiles
## Extraire les règles utiisées dans layerfiles d'un projet ESRI ArcGis Pro

python geocover.py rules -l INFO
geocover rules -l INFO

## Compter les features dans un périmètre
## Compter les features dans un périmètre donné

Le fichier contenant les règles (`layer_symbols_rules.json`) a été généré avec la commande `geocover rules`.

With an arbitrary polyon (GeoJSON or ESRI Shapefile)

python geocover.py filter --geometry san_bernardino.geojson --gdb-path I:\backup\GCOVER\daily\20240425_0300_2030-12-31.gdb -s san_bernardino.json
geocover filter --geometry san_bernardino.geojson --gdb-path I:\backup\GCOVER\daily\20240425_0300_2030-12-31.gdb --ouput san_bernardino.json


Or with a bounding box:


python geocover.py filter --bbox 2760000,1146000,2777500,1158000 --gdb-path I:\backup\GCOVER\daily\20240425_0300_2030-12-31.gdb -s san_bernardino.xlsx
geocover filter --bbox 2760000,1146000,2777500,1158000 --gdb-path I:\backup\GCOVER\daily\20240425_0300_2030-12-31.gdb --ouput san_bernardino.xlsx

The ouput format is either `JSON`or `CSV` depending on the file extension of the ouput file (`.csv`, `.xlsx` or `.json` )

## Migration de schema


### Dumping schema

Exécuter la commande suivante avant et après la migration de schéma

geocover schema --workspace D:/connections/[email protected] --ouput dumps/PRODUCTION

### Différences

La commande suivante permet d'afficher les différences avant et après la migration :

jsondiff --indent 4 --preserve-unicode dumps/PRODUCTION/geocover-schema-sde-2024-10-24.json dumps/PRODUCTION/geocover-schema-sde-2024-10-26.json > production-diff-october-2024.txt

2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.18
0.0.32
7 changes: 5 additions & 2 deletions create_gv.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,11 @@ def __init__(self, name, type_, reference):


class Table:
def __init__(self, name, relation=False):
def __init__(self, name, relation=False, cardinality=None):
self.name = name
self.columns = []
self.relation = relation
self.cardinality = cardinality

def get_column(self, name, erase=True):
for i, c in enumerate(self.columns):
Expand Down Expand Up @@ -312,8 +313,10 @@ def get_keys(keys):
keys = {}
keys["origin"] = get_keys(ori_keys)
keys["destination"] = get_keys(dest_keys)

logger.warning(f'Relationships "ManyToMany" {ori_table.name} --> {dest_table.name}')

t = Table(new_table, relation=True)
t = Table(new_table, relation=True, cardinality='ManyToMany')
# t.columns.append(Column(keys["origin"]["fk"], "int"))
# t.columns.append(Column(keys["destination"]["fk"], "int"))
all_tables[new_table] = t
Expand Down
Loading
Loading