Skip to content

Commit 3c63cdf

Browse files
authored
Add support for all EPSG SRIDs (#9)
* Support for all EPSG SRID codes that PYPROJ does. * Breaking change in return type of get_supported_projections(). Now return a dictionary of dict[srid:str, pyproj.CRS] * Update packages * Update CHANGES.md * Bump version to 0.0.11 * Ditched python version 3.9 * Add test of TWD97 * Upgrade actions * Remove codecov attempt
1 parent 2b75552 commit 3c63cdf

12 files changed

Lines changed: 945 additions & 1056 deletions

File tree

.github/workflows/branch.yaml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ jobs:
66
strategy:
77
fail-fast: false
88
matrix:
9-
python-version: ['3.9', '3.10', '3.11']
10-
poetry-version: ['1.6.1']
9+
python-version: ['3.10', '3.11', '3.12']
10+
poetry-version: ['1.8.3']
1111
os: [ubuntu-latest]
1212
runs-on: ${{ matrix.os }}
1313
steps:
14-
- uses: actions/checkout@v3
15-
- uses: actions/setup-python@v4
14+
- uses: actions/checkout@v4
15+
- uses: actions/setup-python@v5
1616
with:
1717
python-version: ${{ matrix.python-version }}
1818
- name: Run image
@@ -23,19 +23,19 @@ jobs:
2323
run: poetry install
2424
- name: Run tests
2525
run: poetry run pytest --cov=./ --cov-report=xml
26-
- name: Upload coverage to Codecov
27-
uses: codecov/codecov-action@v3
26+
# - name: Upload coverage to Codecov
27+
# uses: codecov/codecov-action@v4
2828
code-quality:
2929
strategy:
3030
fail-fast: false
3131
matrix:
32-
python-version: ['3.9', '3.10', '3.11']
33-
poetry-version: ['1.6.1']
32+
python-version: ['3.10', '3.11', '3.12']
33+
poetry-version: ['1.8.3']
3434
os: [ubuntu-latest]
3535
runs-on: ${{ matrix.os }}
3636
steps:
37-
- uses: actions/checkout@v3
38-
- uses: actions/setup-python@v3
37+
- uses: actions/checkout@v4
38+
- uses: actions/setup-python@v5
3939
with:
4040
python-version: ${{ matrix.python-version }}
4141
- name: Run image
@@ -51,6 +51,6 @@ jobs:
5151
- name: Run bandit
5252
run: poetry run bandit .
5353
- name: Run safety
54-
run: poetry run safety check
54+
run: poetry run safety check -i 70612
5555
- name: Check for acceptable licenses
56-
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)"
56+
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);The Unlicense (Unlicense);ISC License (ISCL)"

.github/workflows/release.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ jobs:
99
strategy:
1010
fail-fast: false
1111
matrix:
12-
python-version: ['3.11']
13-
poetry-version: ['1.7.1']
12+
python-version: ['3.12']
13+
poetry-version: ['1.8.3']
1414
os: [ubuntu-latest]
1515
runs-on: ${{ matrix.os }}
1616
steps:
17-
- uses: actions/checkout@v3
18-
- uses: actions/setup-python@v4
17+
- uses: actions/checkout@v4
18+
- uses: actions/setup-python@v5
1919
with:
2020
python-version: ${{ matrix.python-version }}
2121
- name: Run image

CHANGES.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# NGI Python Coordinate Projector Package
22

3+
4+
_2024-08-13_
5+
6+
Version 0.0.11
7+
8+
Add
9+
10+
- Support for all EPSG SRID codes that PYPROJ does.
11+
312
_2024-01-15_
413

514
Version 0.0.10

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ print(f"{projected_east=}, {projected_north=}")
4949

5050
- Python 3.9 or higher
5151
- Poetry
52-
- black code formatter
52+
- Ruff code formatter
5353

5454
2. Clone this repository
5555

poetry.lock

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

pyproject.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ exclude = '''
1515

1616
[tool.poetry]
1717
name = "coordinate-projector"
18-
version = "0.0.10"
18+
version = "0.0.11"
1919
description = "Project points from one projection to another using pyproj"
2020
license = "MIT"
2121
authors = ["Helge Smebye", "Jostein Leira <jostein@leira.net>"]
@@ -38,19 +38,18 @@ packages = [
3838
line-length = 120
3939
src = ["src", "tests"]
4040

41-
[tool.ruff.per-file-ignores]
41+
[tool.ruff.lint.per-file-ignores]
4242
"__init__.py" = ["F401"]
4343

4444
[tool.poetry.dependencies]
45-
python = ">=3.9,<4"
45+
python = ">=3.10,<4"
4646
pyproj = "^3.6.1"
4747
python-dateutil = "^2.8.2"
4848
types-python-dateutil = "^2.8.19"
4949
timezonefinder = "*"
5050

5151

5252
[tool.poetry.group.dev.dependencies]
53-
black = "*"
5453
pytest = "*"
5554
pytest-cov = "*"
5655
mypy = "*"

src/coordinate_projector/datetime_parser.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
"""
22
Datetime utilities for converting to and from datetime.datetime, json, naive and time zone aware
33
"""
4+
45
from datetime import datetime
5-
from typing import Optional
6+
67

78
from dateutil import tz
89
from timezonefinder import TimezoneFinder
@@ -11,15 +12,15 @@
1112

1213
projector = Projector()
1314

14-
_time_zone_finder: Optional[TimezoneFinder] = None
15+
_time_zone_finder: TimezoneFinder | None = None
1516

1617

1718
def ensure_tz(
18-
dt: Optional[datetime],
19-
longitude: Optional[float] = None,
20-
latitude: Optional[float] = None,
19+
dt: datetime | None,
20+
longitude: float | None = None,
21+
latitude: float | None = None,
2122
srid: int = 4326,
22-
) -> Optional[datetime]:
23+
) -> datetime | None:
2324
"""
2425
Return passed datetime dt enriched with timezone.
2526
@@ -43,8 +44,6 @@ def ensure_tz(
4344
# timezone naive (no time zone in dt)
4445
if longitude is not None and latitude is not None:
4546
if srid and srid != 4326:
46-
# TODO: Use a single common transformer for the whole library
47-
4847
longitude, latitude = projector.transform(from_srid=srid, to_srid=4326, east=longitude, north=latitude)
4948

5049
# find timezone from position
@@ -62,11 +61,11 @@ def ensure_tz(
6261

6362

6463
def datetime_to_json(
65-
dt: Optional[datetime],
66-
longitude: Optional[float] = None,
67-
latitude: Optional[float] = None,
64+
dt: datetime | None,
65+
longitude: float | None = None,
66+
latitude: float | None = None,
6867
srid: int = 4326,
69-
) -> Optional[str]:
68+
) -> str | None:
7069
"""
7170
Return passed datetime.datetime as json-formatted (iso-8601) string with UTC timezone. Sub-second time information
7271
is removed.

0 commit comments

Comments
 (0)