Skip to content

Commit

Permalink
Merge pull request #7 from HakaiInstitute/deps
Browse files Browse the repository at this point in the history
Update libraries
  • Loading branch information
tayden authored Sep 24, 2024
2 parents d395b28 + 53db3c1 commit 5f6df80
Show file tree
Hide file tree
Showing 16 changed files with 578 additions and 727 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,5 @@ cython_debug/


testfiles/

.idea/
21 changes: 0 additions & 21 deletions .idea/Las-TRX.iml

This file was deleted.

17 changes: 0 additions & 17 deletions .idea/aws.xml

This file was deleted.

17 changes: 0 additions & 17 deletions .idea/inspectionProfiles/Project_Default.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/inspectionProfiles/profiles_settings.xml

This file was deleted.

4 changes: 0 additions & 4 deletions .idea/misc.xml

This file was deleted.

9 changes: 0 additions & 9 deletions .idea/modules.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/other.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

25 changes: 0 additions & 25 deletions .idea/watcherTasks.xml

This file was deleted.

15 changes: 7 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,21 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-added-large-files
- repo: https://github.com/python-poetry/poetry
rev: 1.4.0
rev: 1.8.3
hooks:
- id: poetry-check
- id: poetry-lock
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.265
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.2
hooks:
# Run the linter.
- id: ruff
args: [ --fix ]
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
# Run the formatter.
- id: ruff-format
2 changes: 1 addition & 1 deletion las_trx/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
)

from csrspy.enums import CoordType, Reference, VerticalDatum
from csrspy.utils import sync_missing_grid_files
from las_trx import __version__
from las_trx.config import TransformConfig
from las_trx.utils import (
REFERENCE_LOOKUP,
VD_LOOKUP,
sync_missing_grid_files,
utm_zone_to_coord_type,
resource_path,
get_upgrade_version,
Expand Down
7 changes: 3 additions & 4 deletions las_trx/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
from pyproj.crs.coordinate_system import Cartesian2DCS

from csrspy import enums
from las_trx.utils import date_to_decimal_year, get_utm_zone, is_utm_coord_type
from csrspy.utils import date_to_decimal_year
from las_trx.utils import get_utm_zone, is_utm_coord_type


class TransformConfig(BaseModel):
Expand All @@ -29,9 +30,7 @@ class TransformConfig(BaseModel):

@field_validator("s_epoch", "t_epoch")
@classmethod
def date2decimal(
cls, v: Union[float, date], info: FieldValidationInfo
) -> float:
def date2decimal(cls, v: Union[float, date], info: FieldValidationInfo) -> float:
if isinstance(v, float):
return v
elif isinstance(v, date):
Expand Down
28 changes: 0 additions & 28 deletions las_trx/utils.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
import logging
import sys
from datetime import date
from os import path
from typing import TypeVar, List, Mapping, Any, Optional

import pyproj.sync

from csrspy.enums import CoordType, Reference, VerticalDatum

T = TypeVar("T")

logger = logging.getLogger(__name__)


def date_to_decimal_year(d: date) -> float:
year_part = d - date(d.year, 1, 1)
year_length = date(d.year + 1, 1, 1) - date(d.year, 1, 1)
return d.year + year_part / year_length


VD_LOOKUP = {
"WGS84": VerticalDatum.WGS84,
"GRS80": VerticalDatum.GRS80,
Expand Down Expand Up @@ -46,24 +36,6 @@ def date_to_decimal_year(d: date) -> float:
}


def sync_missing_grid_files():
target_directory = pyproj.sync.get_user_data_dir(True)
endpoint = pyproj.sync.get_proj_endpoint()
grids = pyproj.sync.get_transform_grid_list(area_of_use="Canada")

if len(grids):
logger.info("Syncing PROJ grid files.")

for grid in grids:
filename = grid["properties"]["name"]
pyproj.sync._download_resource_file(
file_url=f"{endpoint}/{filename}",
short_name=filename,
directory=target_directory,
sha256=grid["properties"]["sha256sum"],
)


def is_utm_coord_type(coords: CoordType) -> bool:
# TODO: This is awful, fix it
return coords in [
Expand Down
Loading

0 comments on commit 5f6df80

Please sign in to comment.