Skip to content

Commit d091f32

Browse files
authored
Merge pull request #14 from josteinl/fix/output-format
Fix a bug in the KOF writer format (output)
2 parents ef87438 + 501d860 commit d091f32

7 files changed

Lines changed: 386 additions & 370 deletions

File tree

.github/workflows/branch.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
strategy:
77
fail-fast: false
88
matrix:
9-
python-version: ['3.9', '3.10', '3.11']
9+
python-version: ['3.9', '3.10', '3.11', '3.12']
1010
poetry-version: ['1.6.1']
1111
os: [ubuntu-latest]
1212
runs-on: ${{ matrix.os }}
@@ -29,7 +29,7 @@ jobs:
2929
strategy:
3030
fail-fast: false
3131
matrix:
32-
python-version: ['3.9', '3.10', '3.11']
32+
python-version: ['3.9', '3.10', '3.11', '3.12']
3333
poetry-version: ['1.6.1']
3434
os: [ubuntu-latest]
3535
runs-on: ${{ matrix.os }}

CHANGES.md

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

3+
## Version 0.0.19
4+
_2023-10-04_
5+
6+
Fix
7+
8+
- Fix a bug in the KOF writer format (output). Now right align the coordinate numbers in the coordinate block (05).
9+
310
## Version 0.0.18
411
_2023-08-24_
512

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![security: safety](https://img.shields.io/badge/security-safety-yellow.svg)](https://github.com/pyupio/safety)
55
[![code style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)
66
[![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)
7+
[![python](https://img.shields.io/badge/Python-3.11-3776AB.svg?style=flat&logo=python&logoColor=white)](https://www.python.org)
88

99

1010
Python package for parsing and generating KOF files.
@@ -91,7 +91,7 @@ print(kof_string)
9191
Before you start, install:
9292

9393
- Python 3.9 or higher
94-
- Poetry 1.4.2
94+
- Poetry 1.6.1
9595
- black code formatter
9696

9797
## Clone this repository

poetry.lock

Lines changed: 362 additions & 361 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ src = ["src", "tests"]
1919

2020
[tool.poetry]
2121
name = "kof-parser"
22-
version = "0.0.18"
22+
version = "0.0.19"
2323
description = "A KOF file parser. Follows Norkart's KOF 2.0 specification from 2005."
2424
license = "MIT"
2525
authors = ["Magnus Mariero <magnus@neate.no>", "Jostein Leira <jostein@leira.net>"]
26-
maintainers = ["Jostein Leira <jostein@leira.net>", "Magnus Mariero <magnus@neate.no>"]
26+
maintainers = ["Jostein Leira <jostein@leira.net>"]
2727
readme = "README.md"
2828
homepage = "https://github.com/norwegian-geotechnical-institute/kof-parser"
2929
repository = "https://github.com/norwegian-geotechnical-institute/kof-parser"

src/kof_parser/writer.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,16 @@ def create_admin_block(self, project_name: str, srid: int, swap_easting_northing
5656

5757
@staticmethod
5858
def create_kof_coordinate_block(id: str, temakode: str, x: float, y: float, z: float) -> str:
59-
coord_block = f" 05 {id[0:10]:<10} {temakode:<8} {y:<12.3f} {x:<11.3f} {z:<8.3f} "
59+
"""
60+
Example:
61+
62+
-05 PPPPPPPPPP KKKKKKKK XXXXXXXX.XXX YYYYYYY.YYY ZZZZ.ZZZ Bk MMMMMMM
63+
64+
Some equipment is depending on the coordinates (X, Y and Z) to be right aligned.
65+
"""
66+
coord_block = f" 05 {id[0:10]:<10} {temakode:<8} {y:>12.3f} {x:>11.3f} {z:>8.3f} "
6067
coord_block = f"{coord_block:<70}\n"
68+
6169
return coord_block
6270

6371
@staticmethod

tests/test_write.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def test_write(self):
2121

2222
assert "\n 01 " in kof_string, "Administration block present"
2323
assert "\n 05 " in kof_string, "Coordinate block present"
24-
assert "05 SMPLOC2 2418 1217079.460 112893.150 2.000" in kof_string
24+
assert " 05 SMPLOC2 2418 1217079.460 112893.150 2.000 " in kof_string
2525

2626
kof_string = KOFWriter().writeKOF(
2727
project_id=uuid.uuid4(),
@@ -30,7 +30,7 @@ def test_write(self):
3030
srid=srid,
3131
swap_easting_northing=True,
3232
)
33-
assert "05 SMPLOC2 2418 112893.150 1217079.460 2.000" in kof_string
33+
assert " 05 SMPLOC2 2418 112893.150 1217079.460 2.000 " in kof_string
3434

3535
def test_write_all_method_types(self):
3636
"""

0 commit comments

Comments
 (0)