Skip to content

Commit 0c067b7

Browse files
committed
Merged PR 2556: Release 0.0.6
- Merged PR 2463: Add KOF writer - Merged PR 2471: Add handling of admin block (01) - Merged PR 2488: Add new methods. revised default and OTHER handling - Merged PR 2522: Add transformations during parsing of kof files. - Add authentication to our private pypi (azure artifiacts). - Add onlyAddExtraIndex for the authentication to our private pypi (azure artifiacts). - Upgrade to typed version of ngi-projector package. - Forgot the lock file. - Use the new ngi-projector version 0.0.3 with new Projector.transform() method signature. Related work items: #5559, #5972, #6068
2 parents f7b61cc + eabaabf commit 0c067b7

23 files changed

+994
-107
lines changed

.gitattributes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# This .gitattributes file primarily made for the test files. Some test files are deliberatly constructed with wrong
2+
# line endings for test purposes and should be specified here.
3+
4+
# Don't let git modify the end-of-line characters:
5+
*.[Kk][Oo][Ff] binary

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ coverage.xml
5050
.hypothesis/
5151
.pytest_cache/
5252
cover/
53+
test-output.xml
5354

5455
# Translations
5556
*.mo

CHANGES.md

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,41 @@
1-
# NGI Python KOF Parser
1+
# NGI Python KOF Parser Package
22

3-
## Version 0.0.1
3+
## Version 0.0.6
4+
_2022-03-02_
45

6+
Add
7+
8+
- Use new ngi-projector version 0.0.3.
9+
- Add transformations.
10+
- Support for more methods. Complete list:
11+
- RO: 2251
12+
- RW: 2401
13+
- SA: 2402
14+
- TP: 2403
15+
- SS: 2405
16+
- RP: 2406
17+
- CPT: 2407
18+
- RS: 2409
19+
- SR: 2410
20+
- SPT: 2411
21+
- RCD: 2412
22+
- PZ: 2413
23+
- PT: 2414
24+
- SVT: 2415
25+
- INC: 2417
26+
- TOT: 2418
27+
- Support parsing of letter tema codes F, VB and GVR.
28+
- KOF Writer for creating KOF files.
29+
- Add coordinate system handling in the admin block (01).
30+
31+
32+
## Version 0.0.5
33+
_2022-02-10_
34+
35+
36+
## Version 0.0.3
37+
_2022-01-31_
38+
39+
- Initial version
540

641

README.md

Lines changed: 64 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# NGI KOF Parser
22

3+
[![security: bandit](https://img.shields.io/badge/security-bandit-yellow.svg)](https://github.com/PyCQA/bandit)
4+
35
This is the NGI Python package for parsing kof files.
46

57
References:
@@ -21,14 +23,17 @@ pip install ngi-kof-parser
2123

2224
## Basic usage
2325

26+
### Read a kof file
2427
```python
2528
from ngi_kof_parser import KOFParser
2629

2730
parser = KOFParser()
2831

2932
# ETRS89/NTM10:
3033
srid = 5110
31-
locations = parser.parse('tests/data/test.kof', srid)
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).
36+
locations = parser.parse('tests/data/test.kof', result_srid=srid, file_srid=srid)
3237

3338
for location in locations:
3439
print(location)
@@ -44,19 +49,74 @@ for location in locations:
4449

4550
```
4651

52+
### Write a kof file
53+
54+
```python
55+
from ngi_kof_parser import KOFWriter
56+
from ngi_kof_parser import Location
57+
58+
kof_writer = KOFWriter()
59+
60+
srid = 5110
61+
locations = [Location(name='SMPLOC1', point_easting=112892.81, point_northing=1217083.64, point_z=1.0),
62+
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+
65+
kof_string = kof_writer.writeKOF(
66+
project_id='project_id', project_name='cool-name', locations=locations, srid=srid
67+
)
68+
69+
print(kof_string)
70+
# Output:
71+
# 00 KOF Export from NGI Field Manager
72+
# 00 Project: project_id. Name: cool-name
73+
# 00 Spatial Reference ID (SRID): 5110
74+
# 00 Export date (UTC): 2022-02-17 13:23:43.204875
75+
# 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
80+
```
81+
4782
# Getting Started developing
4883

4984
1. Software dependencies
5085

86+
2. Clone this repository
87+
88+
3. Install
89+
90+
## Software dependencies
91+
92+
Before you start, install:
93+
5194
- Python 3.9 or higher
5295
- Poetry
5396
- black code formatter
97+
98+
## Clone this repository
5499

55-
2. Clone this repository
100+
Use git to clone this repository.
56101

57-
3. Install
102+
## Install
58103

59-
`poetry install`
104+
There are several combinations of how to set up a local development environment.
105+
106+
We use Poetry for dependency management. See [Install poetry](https://python-poetry.org/docs/) if needed.
107+
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+
117+
Then, from the project root folder run:
118+
119+
poetry install
60120

61121

62122

azure-pipelines.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,26 @@ steps:
1616
versionSpec: "3.9"
1717
displayName: "Use Python 3.9"
1818

19+
- task: PipAuthenticate@1
20+
displayName: 'Pip Authenticate'
21+
inputs:
22+
artifactFeeds: '277b2f77-691a-4d92-bd89-8e7cac121676/fieldmanager'
23+
onlyAddExtraIndex: True
24+
25+
1926
- script: |
2027
python -m pip install --upgrade pip
2128
pip install poetry
2229
pip install twine
30+
export PAT=$(echo "$PIP_EXTRA_INDEX_URL" | sed 's/.*build:\(.*\)@pkgs.*/\1/')
31+
poetry config http-basic.ngi-fm build "$PAT"
2332
poetry install
2433
displayName: "Install dependencies"
2534
35+
- script: |
36+
poetry run bandit -r src
37+
displayName: "bandit"
38+
2639
- script: |
2740
poetry run mypy .
2841
displayName: "mypy"

0 commit comments

Comments
 (0)