|
1 | | -# KOF Parser |
2 | | - |
3 | | -[](https://github.com/PyCQA/bandit) |
4 | | -[](https://github.com/pyupio/safety) |
5 | | -[](https://github.com/ambv/black) |
6 | | -[](http://mypy-lang.org/) |
7 | | -[](https://www.python.org) |
8 | | - |
9 | | - |
10 | | -Python package for parsing and generating KOF files. |
11 | | - |
12 | | -References: |
13 | | - |
14 | | -NORWEGIAN GEOTECHNICAL SOCIETY |
15 | | -- [NGF - VEILEDNING FOR |
16 | | -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) |
17 | | -- [Norkart KOF specification](http://www.anleggsdata.no/wp-content/uploads/2018/04/KOF-BESKRIVELSE-Oppdatert2005.pdf) |
18 | | - |
19 | | -Latest releases see [CHANGES.md](https://github.com/norwegian-geotechnical-institute/kof-parser/blob/main/CHANGES.md) |
20 | | - |
21 | | -# Installation (end user) |
22 | | - |
23 | | -```bash |
24 | | -pip install kof-parser |
25 | | -``` |
26 | | - |
27 | | -## Basic usage |
28 | | - |
29 | | -### Read a kof file |
30 | | - |
31 | | -```python |
32 | | -from kof_parser import KOFParser |
33 | | - |
34 | | -parser = KOFParser() |
35 | | - |
36 | | -# ETRS89/NTM10: |
37 | | -srid = 5110 |
38 | | - |
39 | | -locations = parser.parse('tests/data/test.kof', result_srid=srid, file_srid=srid) |
40 | | - |
41 | | -for location in locations: |
42 | | - print(location) |
43 | | - |
44 | | -# Output: |
45 | | -# name='SMPLOC1' methods=[] point_easting=112892.81 point_northing=1217083.64 point_z=1.0 srid=5110 |
46 | | -# name='SMPLOC2' methods=['TOT'] point_easting=112893.15 point_northing=1217079.46 point_z=2.0 srid=5110 |
47 | | -# name='SMPLOC3' methods=['CPT'] point_easting=112891.88 point_northing=1217073.01 point_z=0.0 srid=5110 |
48 | | -# name='SMPLOC4' methods=['RP'] point_easting=112891.9 point_northing=1217067.54 point_z=0.0 srid=5110 |
49 | | -# name='SMPLOC5' methods=['SA'] point_easting=112902.92 point_northing=1217074.73 point_z=0.0 srid=5110 |
50 | | -# name='SMPLOC6' methods=['PZ'] point_easting=112901.11 point_northing=1217069.56 point_z=0.0 srid=5110 |
51 | | -# name='SMPLOC7' methods=['PZ'] point_easting=1217069.56 point_northing=112901.11 point_z=0.0 srid=5110 |
52 | | - |
53 | | -``` |
54 | | - |
55 | | -### Write a kof file |
56 | | - |
57 | | -To write a KOF file you need to build up a model of locations and methods. |
58 | | - |
59 | | -```python |
60 | | -from kof_parser import KOFWriter |
61 | | -from kof_parser import Location |
62 | | - |
63 | | -kof_writer = KOFWriter() |
64 | | - |
65 | | -srid = 5110 |
66 | | -locations = [Location(name='SMPLOC1', point_easting=112892.81, point_northing=1217083.64, point_z=1.0), |
67 | | - Location(name='SMPLOC2', point_easting=112893.15, point_northing=1217079.46, point_z=2.0, methods=['TOT']), |
68 | | - Location(name='SMPLOC3', point_easting=112891.88, point_northing=1217073.01, point_z=0.0, methods=['CPT'])] |
69 | | - |
70 | | -kof_string = kof_writer.writeKOF( |
71 | | - project_id='project_id', project_name='cool-name', locations=locations, srid=srid |
72 | | -) |
73 | | - |
74 | | -print(kof_string) |
75 | | -# Output: |
76 | | -# 00 KOF Export from NGI's KOF parser |
77 | | -# 00 Project: project_id. Name: cool-name |
78 | | -# 00 Spatial Reference ID (SRID): 5110 |
79 | | -# 00 Export date (UTC): 2022-08-22 13:49:44.394607 |
80 | | -# 00 Oppdrag Dato Ver K.sys Komm $21100000000 Observer |
81 | | -# 01 cool-name 22082022 1 210 $11100000000 |
82 | | -# 05 SMPLOC1 1217083.640 112892.810 1.000 |
83 | | -# 05 SMPLOC2 2418 1217079.460 112893.150 2.000 |
84 | | -# 05 SMPLOC3 2407 1217073.010 112891.880 0.000 |
85 | | -``` |
86 | | - |
87 | | -# Getting Started developing |
88 | | - |
89 | | -## Software dependencies |
90 | | - |
91 | | -Before you start, install: |
92 | | - |
93 | | - - Python 3.9 or higher |
94 | | - - Poetry |
95 | | - - black code formatter |
96 | | - |
97 | | -## Clone this repository |
98 | | - |
99 | | -Use git to clone this repository. |
100 | | - |
101 | | -## Install |
102 | | - |
103 | | -There are several combinations of how to set up a local development environment. |
104 | | - |
105 | | -We use Poetry for dependency management. See [Install poetry](https://python-poetry.org/docs/) if needed. |
106 | | - |
107 | | -Then, from the project root folder run: |
108 | | - |
109 | | - poetry install |
110 | | - |
111 | | - |
112 | | -# Build and Test |
113 | | - |
114 | | -Run in the project root folder: |
115 | | - |
116 | | - poetry run pytest |
117 | | - |
118 | | -Build the package wheel: |
119 | | - |
120 | | - poetry build |
121 | | - |
122 | | -# Contribute |
123 | | - |
| 1 | +# KOF Parser |
| 2 | + |
| 3 | +[](https://github.com/PyCQA/bandit) |
| 4 | +[](https://github.com/pyupio/safety) |
| 5 | +[](https://github.com/ambv/black) |
| 6 | +[](http://mypy-lang.org/) |
| 7 | +[](https://www.python.org) |
| 8 | + |
| 9 | + |
| 10 | +Python package for parsing and generating KOF files. |
| 11 | + |
| 12 | +References: |
| 13 | + |
| 14 | +NORWEGIAN GEOTECHNICAL SOCIETY |
| 15 | +- [NGF - VEILEDNING FOR |
| 16 | +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) |
| 17 | +- [Norkart KOF specification](http://www.anleggsdata.no/wp-content/uploads/2018/04/KOF-BESKRIVELSE-Oppdatert2005.pdf) |
| 18 | + |
| 19 | +Latest releases see [CHANGES.md](https://github.com/norwegian-geotechnical-institute/kof-parser/blob/main/CHANGES.md) |
| 20 | + |
| 21 | +# Installation (end user) |
| 22 | + |
| 23 | +```bash |
| 24 | +pip install kof-parser |
| 25 | +``` |
| 26 | + |
| 27 | +## Basic usage |
| 28 | + |
| 29 | +### Read a kof file |
| 30 | + |
| 31 | +```python |
| 32 | +from kof_parser import KOFParser |
| 33 | + |
| 34 | +parser = KOFParser() |
| 35 | + |
| 36 | +# ETRS89/NTM10: |
| 37 | +srid = 5110 |
| 38 | + |
| 39 | +locations = parser.parse('tests/data/test.kof', result_srid=srid, file_srid=srid) |
| 40 | + |
| 41 | +for location in locations: |
| 42 | + print(location) |
| 43 | + |
| 44 | +# Output: |
| 45 | +# name='SMPLOC1' methods=[] point_easting=112892.81 point_northing=1217083.64 point_z=1.0 srid=5110 |
| 46 | +# name='SMPLOC2' methods=['TOT'] point_easting=112893.15 point_northing=1217079.46 point_z=2.0 srid=5110 |
| 47 | +# name='SMPLOC3' methods=['CPT'] point_easting=112891.88 point_northing=1217073.01 point_z=0.0 srid=5110 |
| 48 | +# name='SMPLOC4' methods=['RP'] point_easting=112891.9 point_northing=1217067.54 point_z=0.0 srid=5110 |
| 49 | +# name='SMPLOC5' methods=['SA'] point_easting=112902.92 point_northing=1217074.73 point_z=0.0 srid=5110 |
| 50 | +# name='SMPLOC6' methods=['PZ'] point_easting=112901.11 point_northing=1217069.56 point_z=0.0 srid=5110 |
| 51 | +# name='SMPLOC7' methods=['PZ'] point_easting=1217069.56 point_northing=112901.11 point_z=0.0 srid=5110 |
| 52 | + |
| 53 | +``` |
| 54 | + |
| 55 | +### Write a kof file |
| 56 | + |
| 57 | +To write a KOF file you need to build up a model of locations and methods. |
| 58 | + |
| 59 | +```python |
| 60 | +from kof_parser import KOFWriter |
| 61 | +from kof_parser import Location |
| 62 | + |
| 63 | +kof_writer = KOFWriter() |
| 64 | + |
| 65 | +srid = 5110 |
| 66 | +locations = [Location(name='SMPLOC1', point_easting=112892.81, point_northing=1217083.64, point_z=1.0), |
| 67 | + Location(name='SMPLOC2', point_easting=112893.15, point_northing=1217079.46, point_z=2.0, methods=['TOT']), |
| 68 | + Location(name='SMPLOC3', point_easting=112891.88, point_northing=1217073.01, point_z=0.0, methods=['CPT'])] |
| 69 | + |
| 70 | +kof_string = kof_writer.writeKOF( |
| 71 | + project_id='project_id', project_name='cool-name', locations=locations, srid=srid |
| 72 | +) |
| 73 | + |
| 74 | +print(kof_string) |
| 75 | +# Output: |
| 76 | +# 00 KOF Export from NGI's KOF parser |
| 77 | +# 00 Project: project_id. Name: cool-name |
| 78 | +# 00 Spatial Reference ID (SRID): 5110 |
| 79 | +# 00 Export date (UTC): 2022-08-22 13:49:44.394607 |
| 80 | +# 00 Oppdrag Dato Ver K.sys Komm $21100000000 Observer |
| 81 | +# 01 cool-name 22082022 1 210 $11100000000 |
| 82 | +# 05 SMPLOC1 1217083.640 112892.810 1.000 |
| 83 | +# 05 SMPLOC2 2418 1217079.460 112893.150 2.000 |
| 84 | +# 05 SMPLOC3 2407 1217073.010 112891.880 0.000 |
| 85 | +``` |
| 86 | + |
| 87 | +# Getting Started developing |
| 88 | + |
| 89 | +## Software dependencies |
| 90 | + |
| 91 | +Before you start, install: |
| 92 | + |
| 93 | + - Python 3.9 or higher |
| 94 | + - Poetry 1.4.2 |
| 95 | + - black code formatter |
| 96 | + |
| 97 | +## Clone this repository |
| 98 | + |
| 99 | +Use git to clone this repository. |
| 100 | + |
| 101 | +## Install |
| 102 | + |
| 103 | +There are several combinations of how to set up a local development environment. |
| 104 | + |
| 105 | +We use Poetry for dependency management. See [Install poetry](https://python-poetry.org/docs/) if needed. |
| 106 | + |
| 107 | +Then, from the project root folder run: |
| 108 | + |
| 109 | + poetry install |
| 110 | + |
| 111 | + |
| 112 | +# Build and Test |
| 113 | + |
| 114 | +Run in the project root folder: |
| 115 | + |
| 116 | + poetry run pytest |
| 117 | + |
| 118 | +Build the package wheel: |
| 119 | + |
| 120 | + poetry build |
| 121 | + |
| 122 | +# Contribute |
| 123 | + |
124 | 124 | Please start by adding an issue before submitting any pull requests. |
0 commit comments