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
713References:
814
@@ -11,72 +17,72 @@ NORWEGIAN GEOTECHNICAL SOCIETY
1117SYMBOLER 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
3037parser = KOFParser()
3138
3239# ETRS89/NTM10:
3340srid = 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+
3642locations = parser.parse(' tests/data/test.kof' , result_srid = srid, file_srid = srid)
3743
3844for 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
5864kof_writer = KOFWriter()
5965
6066srid = 5110
6167locations = [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+
6571kof_string = kof_writer.writeKOF(
6672 project_id = ' project_id' , project_name = ' cool-name' , locations = locations, srid = srid
6773)
6874
6975print (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
106112We 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-
117114Then, from the project root folder run:
118115
119116 poetry install
120117
121118
122-
123119# Build and Test
124120
125121Run in the project root folder:
126122
127123 poetry install
128- pytest
124+ poetry run pytest
129125
130126Build 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