Skip to content

Commit 6e25aff

Browse files
authored
Merge pull request #1 from norwegian-geotechnical-institute/develop
Publish first version
2 parents 0c067b7 + b14deb0 commit 6e25aff

File tree

21 files changed

+1101
-693
lines changed

21 files changed

+1101
-693
lines changed

.github/workflows/branch.yaml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Push
2+
on: [push]
3+
4+
jobs:
5+
test:
6+
strategy:
7+
fail-fast: false
8+
matrix:
9+
python-version: ['3.9']
10+
poetry-version: ['1.1.14']
11+
os: [ubuntu-latest]
12+
runs-on: ${{ matrix.os }}
13+
steps:
14+
- uses: actions/checkout@v3
15+
- uses: actions/setup-python@v3
16+
with:
17+
python-version: ${{ matrix.python-version }}
18+
- name: Run image
19+
uses: abatilo/[email protected]
20+
with:
21+
poetry-version: ${{ matrix.poetry-version }}
22+
- name: Install dependencies
23+
run: poetry install
24+
- name: Run tests
25+
run: poetry run pytest --cov=./ --cov-report=xml
26+
- name: Upload coverage to Codecov
27+
uses: codecov/codecov-action@v2
28+
code-quality:
29+
strategy:
30+
fail-fast: false
31+
matrix:
32+
python-version: ['3.9']
33+
poetry-version: ['1.1.14']
34+
os: [ubuntu-latest]
35+
runs-on: ${{ matrix.os }}
36+
steps:
37+
- uses: actions/checkout@v3
38+
- uses: actions/setup-python@v3
39+
with:
40+
python-version: ${{ matrix.python-version }}
41+
- name: Run image
42+
uses: abatilo/[email protected]
43+
with:
44+
poetry-version: ${{ matrix.poetry-version }}
45+
- name: Install dependencies
46+
run: poetry install
47+
- name: Run black
48+
run: poetry run black . --check
49+
# - name: Run isort
50+
# run: poetry run isort . --check-only --profile black
51+
# - name: Run flake8
52+
# run: poetry run flake8 .
53+
- name: Run mypy
54+
run: poetry run mypy .
55+
- name: Run bandit
56+
run: poetry run bandit .
57+
- name: Run safety
58+
run: poetry run safety check
59+
- name: Check for acceptable licenses
60+
run: poetry run pip-licenses --allow-only="MIT License;BSD License;Python Software Foundation License;Apache Software License;Mozilla Public License 2.0 (MPL 2.0);GNU Library or Lesser General Public License (LGPL)"

.github/workflows/release.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Release
2+
on:
3+
release:
4+
types:
5+
- created
6+
7+
jobs:
8+
publish:
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
python-version: ['3.9']
13+
poetry-version: ['1.1.14']
14+
os: [ubuntu-latest]
15+
runs-on: ${{ matrix.os }}
16+
steps:
17+
- uses: actions/checkout@v3
18+
- uses: actions/setup-python@v3
19+
with:
20+
python-version: ${{ matrix.python-version }}
21+
- name: Run image
22+
uses: abatilo/[email protected]
23+
with:
24+
poetry-version: ${{ matrix.poetry-version }}
25+
- name: Publish
26+
env:
27+
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
28+
run: |
29+
poetry config pypi-token.pypi $PYPI_TOKEN
30+
poetry publish --build

CHANGES.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
# NGI Python KOF Parser Package
22

3+
## Version 0.0.8
4+
_2022-08-22_
5+
6+
Add
7+
8+
- Refractoring to support most encodings in input files.
9+
10+
## Version 0.0.7
11+
_2022-04-20_
12+
13+
Add
14+
15+
- Transformation of coordinates in output file.
16+
- Add support for swapping easting and northing in the input or output kof file.
17+
318
## Version 0.0.6
419
_2022-03-02_
520

README.md

Lines changed: 33 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
# NGI KOF Parser
22

33
[![security: bandit](https://img.shields.io/badge/security-bandit-yellow.svg)](https://github.com/PyCQA/bandit)
4+
[![security: safety](https://img.shields.io/badge/security-safety-yellow.svg)](https://github.com/pyupio/safety)
5+
[![code style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)
6+
[![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)
7+
[![python](https://img.shields.io/badge/Python-3.9-3776AB.svg?style=flat&logo=python&logoColor=white)](https://www.python.org)
48

5-
This is the NGI Python package for parsing kof files.
9+
10+
11+
Python package for parsing KOF files.
612

713
References:
814

@@ -11,72 +17,72 @@ NORWEGIAN GEOTECHNICAL SOCIETY
1117
SYMBOLER OG DEFINISJONER I GEOTEKNIKK](http://ngf.no/wp-content/uploads/2015/03/2_NGF-ny-melding-2-endelig-utgave-2011-12-04-med-topp-og-bunntekst-Alt-3.pdf)
1218
- [Norkart KOF specification](http://www.anleggsdata.no/wp-content/uploads/2018/04/KOF-BESKRIVELSE-Oppdatert2005.pdf)
1319

14-
Latest releases see [CHANGES.md](CHANGES.md)
20+
Latest releases see [CHANGES.md](https://github.com/norwegian-geotechnical-institute/kof-parser/blob/main/CHANGES.md)
1521

1622
# Installation (end user)
1723

1824
```bash
1925

20-
pip install ngi-kof-parser
26+
pip install kof-parser
2127

2228
```
2329

2430
## Basic usage
2531

2632
### Read a kof file
33+
2734
```python
28-
from ngi_kof_parser import KOFParser
35+
from kof_parser import KOFParser
2936

3037
parser = KOFParser()
3138

3239
# ETRS89/NTM10:
3340
srid = 5110
34-
# Please note that the parser do not handle any coordinate system transformations,
35-
# so you need to use the same input and output SRIDs (for now).
41+
3642
locations = parser.parse('tests/data/test.kof', result_srid=srid, file_srid=srid)
3743

3844
for location in locations:
39-
print(location)
45+
print(location)
4046

4147
# Output:
42-
# name='SMPLOC1' point_easting=112892.81 point_northing=1217083.64 point_z=1.0 srid=5110 methods=[]
43-
# name='SMPLOC2' point_easting=112893.15 point_northing=1217079.46 point_z=2.0 srid=5110 methods=['TOT']
44-
# name='SMPLOC3' point_easting=112891.88 point_northing=1217073.01 point_z=0.0 srid=5110 methods=['CPT']
45-
# name='SMPLOC4' point_easting=112891.9 point_northing=1217067.54 point_z=0.0 srid=5110 methods=['RP']
46-
# name='SMPLOC5' point_easting=112902.92 point_northing=1217074.73 point_z=0.0 srid=5110 methods=['SA']
47-
# name='SMPLOC6' point_easting=112901.11 point_northing=1217069.56 point_z=0.0 srid=5110 methods=['PZ']
48-
# name='SMPLOC7' point_easting=1217069.56 point_northing=112901.11 point_z=0.0 srid=5110 methods=['PZ']
48+
# name='SMPLOC1' methods=[] point_easting=112892.81 point_northing=1217083.64 point_z=1.0 srid=5110
49+
# name='SMPLOC2' methods=['TOT'] point_easting=112893.15 point_northing=1217079.46 point_z=2.0 srid=5110
50+
# name='SMPLOC3' methods=['CPT'] point_easting=112891.88 point_northing=1217073.01 point_z=0.0 srid=5110
51+
# name='SMPLOC4' methods=['RP'] point_easting=112891.9 point_northing=1217067.54 point_z=0.0 srid=5110
52+
# name='SMPLOC5' methods=['SA'] point_easting=112902.92 point_northing=1217074.73 point_z=0.0 srid=5110
53+
# name='SMPLOC6' methods=['PZ'] point_easting=112901.11 point_northing=1217069.56 point_z=0.0 srid=5110
54+
# name='SMPLOC7' methods=['PZ'] point_easting=1217069.56 point_northing=112901.11 point_z=0.0 srid=5110
4955

5056
```
5157

5258
### Write a kof file
5359

5460
```python
55-
from ngi_kof_parser import KOFWriter
56-
from ngi_kof_parser import Location
61+
from kof_parser import KOFWriter
62+
from kof_parser import Location
5763

5864
kof_writer = KOFWriter()
5965

6066
srid = 5110
6167
locations = [Location(name='SMPLOC1', point_easting=112892.81, point_northing=1217083.64, point_z=1.0),
6268
Location(name='SMPLOC2', point_easting=112893.15, point_northing=1217079.46, point_z=2.0, methods=['TOT']),
63-
Location(name='SMPLOC3',point_easting=112891.88, point_northing=1217073.01, point_z=0.0, methods=['CPT'])]
64-
69+
Location(name='SMPLOC3', point_easting=112891.88, point_northing=1217073.01, point_z=0.0, methods=['CPT'])]
70+
6571
kof_string = kof_writer.writeKOF(
6672
project_id='project_id', project_name='cool-name', locations=locations, srid=srid
6773
)
6874

6975
print(kof_string)
7076
# Output:
71-
# 00 KOF Export from NGI Field Manager
77+
# 00 KOF Export from NGI's KOF parser
7278
# 00 Project: project_id. Name: cool-name
7379
# 00 Spatial Reference ID (SRID): 5110
74-
# 00 Export date (UTC): 2022-02-17 13:23:43.204875
80+
# 00 Export date (UTC): 2022-08-22 13:49:44.394607
7581
# 00 Oppdrag Dato Ver K.sys Komm $21100000000 Observer
76-
# 01 cool-name 17022022 1 210 $21100000000
77-
# 05 SMPLOC1 112892.810 1217083.640 1.000
78-
# 05 SMPLOC2 2418 112893.150 1217079.460 2.000
79-
# 05 SMPLOC3 2407 112891.880 1217073.010 0.000
82+
# 01 cool-name 22082022 1 210 $11100000000
83+
# 05 SMPLOC1 1217083.640 112892.810 1.000
84+
# 05 SMPLOC2 2418 1217079.460 112893.150 2.000
85+
# 05 SMPLOC3 2407 1217073.010 112891.880 0.000
8086
```
8187

8288
# Getting Started developing
@@ -105,53 +111,22 @@ There are several combinations of how to set up a local development environment.
105111

106112
We use Poetry for dependency management. See [Install poetry](https://python-poetry.org/docs/) if needed.
107113

108-
To set up a local development environment on you local machine, make sure you have set up your NGI credentials.
109-
You need to generate Personal Access Token (PAT). Follow
110-
[this guide](https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate)
111-
for how to get a PAT via the Azure DevOps GUI. `Packaging (Read)` access is sufficient.
112-
113-
After generating the PAT, run this command:
114-
115-
poetry config http-basic.ngi-fm build <PAT>
116-
117114
Then, from the project root folder run:
118115

119116
poetry install
120117

121118

122-
123119
# Build and Test
124120

125121
Run in the project root folder:
126122

127123
poetry install
128-
pytest
124+
poetry run pytest
129125

130126
Build the package wheel:
131127

132128
poetry build
133129

130+
# Contribute
134131

135-
# Publish
136-
137-
To publish the package to NGI's private Azure Artifacts repository set the following configuration:
138-
139-
poetry config repositories.ngi https://pkgs.dev.azure.com/ngi001/277b2f77-691a-4d92-bd89-8e7cac121676/_packaging/fieldmanager/pypi/upload
140-
141-
To publish the package to Azure Artifacts, make sure you have set up your NGI credentials.
142-
143-
You need to generate Personal Access Token (PAT). Follow
144-
[this guide](https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate)
145-
for how to get a PAT via the Azure DevOps GUI. `Packaging (Read, write, & manage)` access is sufficient.
146-
147-
If you want to publish your newly built package you need to set your NGI credentials:
148-
149-
poetry config pypi-token.ngi <PAT>
150-
151-
poetry publish -r ngi
152-
153-
# TODOs
154-
155-
- Add tests
156-
- Extend with position transformation from file data srid (input) to project srid (output)
157-
- Extend with position transformation from file srid (input) to new output fields in wgs84
132+
Please start by adding an issue before submitting any pull requests.

0 commit comments

Comments
 (0)