Skip to content

Commit

Permalink
Merge pull request #156 from IGNF/dev
Browse files Browse the repository at this point in the history
Version 0.2.1
  • Loading branch information
ACornuIGN authored Sep 30, 2024
2 parents eadaebf + 7d134a0 commit 4bf289a
Show file tree
Hide file tree
Showing 88 changed files with 1,635 additions and 356 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/test_mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
uses: actions/checkout@v4

- name: Install environment
uses: mamba-org/setup-micromamba@v1.4.3
uses: mamba-org/setup-micromamba@v1
with:
environment-file: borea_dependency/environment-dev.yml
environment-name: borea
Expand All @@ -35,11 +35,11 @@ jobs:

- name: Run regression test opk to opk
shell: bash -el {0}
run: python ./borea_tools/opk_to_opk.py -r ./dataset/23FD1305_alt_test.OPK -i NXYZOPKC -f 2 -e 2154 -y ./dataset/fr_ign_RAF20.tif -c ./dataset/Camera1.txt -m ./dataset/MNT_France_25m_h_crop.tif --fm height -n Test -w ./test/tmp/ -o NXYHPOKC -ou radian -oa False
run: python ./borea_tools/opk_to_opk.py -r ./dataset/23FD1305_alt_test.OPK -i NXYZOPKC -f 2 -e 2154 -y ./dataset/fr_ign_RAF20.tif -c ./dataset/Camera1.txt -m ./dataset/MNT_France_25m_h_crop.tif --fm height -n Test -w ./test/tmp/ -o NXYHPOKC --ou radian --oa False

- name: Run regression test opk to opk with multi epsg
shell: bash -el {0}
run : python ./borea_tools/opk_to_opk.py -r ./dataset/23FD1305_alt_test.OPK -i NXYZOPKC -f 2 -e 2154 0 4964 -y ./dataset/fr_ign_RAF20.tif -c ./dataset/Camera1.txt -m ./dataset/MNT_France_25m_h_crop.tif --fm height -n Test -w ./test/tmp/ -o NXYHPOKC -ou radian -oa False
run : python ./borea_tools/opk_to_opk.py -r ./dataset/23FD1305_alt_test.OPK -i NXYZOPKC -f 2 -e 2154 --geoc 4964 -y ./dataset/fr_ign_RAF20.tif -c ./dataset/Camera1.txt -m ./dataset/MNT_France_25m_h_crop.tif --fm height -n Test -w ./test/tmp/ -o NXYHPOKC --ou radian --oa False

- name: Run regression test control opk
shell: bash -el {0}
Expand Down Expand Up @@ -67,8 +67,12 @@ jobs:

- name: Run regression test spaceresection opk
shell: bash -el {0}
run: python ./borea_tools/spaceresection_opk.py -p 825439 6289034 1500 -d height -c ./dataset/Camera1.txt -e 2154 -y ./dataset/fr_ign_RAF20.tif -m ./dataset/MNT_France_25m_h_crop.tif --fm height -t ./test/data/dataset2/all_liaisons2.mes -g ./test/data/dataset2/all_liaisons2_world.mes -l PXYH -n SpaceResection -w ./test/tmp/ -o NXYZOPKC -ou degree -oa True
run: python ./borea_tools/spaceresection_opk.py -p 825439 6289034 1500 -d height -c ./dataset/Camera1.txt -e 2154 -y ./dataset/fr_ign_RAF20.tif -m ./dataset/MNT_France_25m_h_crop.tif --fm height -t ./test/data/dataset2/all_liaisons2.mes -g ./test/data/dataset2/all_liaisons2_world.mes -l PXYH -n SpaceResection -w ./test/tmp/ -o NXYZOPKC --ou degree --oa True

- name: Run regression test opk to conical
shell: bash -el {0}
run: python ./borea_tools/opk_to_conl.py -r ./dataset/23FD1305_alt_test.OPK -i NXYZOPKC -f 2 -e 2154 -y ./dataset/fr_ign_RAF20.tif -c ./dataset/Camera1.txt -m ./dataset/MNT_France_25m_h_crop.tif --fm height -w ./test/tmp/

- name: Run transform projextion of points file
shell: bash -el {0}
run: python ./borea_tools/transform_proj_points.py -g ./dataset/GCP_test.app -l PTXYZ -e 2154 -y ./dataset/fr_ign_RAF20.tif --oe 4326 --oz height -n GCP_4326 -w ./test/tmp
9 changes: 6 additions & 3 deletions .github/workflows/test_ubu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ jobs:
run: ./ci/test_example.sh

- name: Run regression test opk to opk
run: python3 ./borea_tools/opk_to_opk.py -r ./dataset/23FD1305_alt_test.OPK -i NXYZOPKC -f 2 -e 2154 -y ./dataset/fr_ign_RAF20.tif -c ./dataset/Camera1.txt -m ./dataset/MNT_France_25m_h_crop.tif --fm height -n Test -w ./test/tmp/ -o NXYHPOKC -ou radian -oa False
run: python3 ./borea_tools/opk_to_opk.py -r ./dataset/23FD1305_alt_test.OPK -i NXYZOPKC -f 2 -e 2154 -y ./dataset/fr_ign_RAF20.tif -c ./dataset/Camera1.txt -m ./dataset/MNT_France_25m_h_crop.tif --fm height -n Test -w ./test/tmp/ -o NXYHPOKC --ou radian --oa False

- name: Run regression test opk to opk with multi epsg
run : python3 ./borea_tools/opk_to_opk.py -r ./dataset/23FD1305_alt_test.OPK -i NXYZOPKC -f 2 -e 2154 0 4964 -y ./dataset/fr_ign_RAF20.tif -c ./dataset/Camera1.txt -m ./dataset/MNT_France_25m_h_crop.tif --fm height -n Test -w ./test/tmp/ -o NXYHPOKC -ou radian -oa False
run : python3 ./borea_tools/opk_to_opk.py -r ./dataset/23FD1305_alt_test.OPK -i NXYZOPKC -f 2 -e 2154 --geoc 4964 -y ./dataset/fr_ign_RAF20.tif -c ./dataset/Camera1.txt -m ./dataset/MNT_France_25m_h_crop.tif --fm height -n Test -w ./test/tmp/ -o NXYHPOKC --ou radian --oa False

- name: Run regression test control opk
run: python3 ./borea_tools/opk_control.py -r ./dataset/23FD1305_alt_test.OPK -i NXYZOPKC -f 2 -c ./dataset/Camera1.txt -e 2154 -y ./dataset/fr_ign_RAF20.tif -m ./dataset/MNT_France_25m_h_crop.tif --fm height -t ./dataset/terrain_test.mes -g ./dataset/GCP_test.app -d 13 -l PTXYH -p inter -w ./test/tmp/
Expand All @@ -57,7 +57,10 @@ jobs:
run: python3 ./borea_tools/ptfile_image_to_world.py -r ./dataset/23FD1305_alt_test.OPK -i NXYZOPKC -f 2 -c ./dataset/Camera1.txt -e 2154 -y ./dataset/fr_ign_RAF20.tif -m ./dataset/MNT_France_25m_h_crop.tif --fm height -t ./dataset/terrain_test.mes -p square -n Coor3d_pt_image -w ./test/tmp/

- name: Run regression test spaceresection opk
run: python3 ./borea_tools/spaceresection_opk.py -p 825439 6289034 1500 -d height -c ./dataset/Camera1.txt -e 2154 -y ./dataset/fr_ign_RAF20.tif -m ./dataset/MNT_France_25m_h_crop.tif --fm height -t ./test/data/dataset2/all_liaisons2.mes -g ./test/data/dataset2/all_liaisons2_world.mes -l PXYH -n SpaceResection -w ./test/tmp/ -o NXYZOPKC -ou degree -oa True
run: python3 ./borea_tools/spaceresection_opk.py -p 825439 6289034 1500 -d height -c ./dataset/Camera1.txt -e 2154 -y ./dataset/fr_ign_RAF20.tif -m ./dataset/MNT_France_25m_h_crop.tif --fm height -t ./test/data/dataset2/all_liaisons2.mes -g ./test/data/dataset2/all_liaisons2_world.mes -l PXYH -n SpaceResection -w ./test/tmp/ -o NXYZOPKC --ou degree --oa True

- name: Run regression test opk to conical
run: python3 ./borea_tools/opk_to_conl.py -r ./dataset/23FD1305_alt_test.OPK -i NXYZOPKC -f 2 -e 2154 -y ./dataset/fr_ign_RAF20.tif -c ./dataset/Camera1.txt -m ./dataset/MNT_France_25m_h_crop.tif --fm height -w ./test/tmp/

- name: Run transform projextion of points file
run: python3 ./borea_tools/transform_proj_points.py -g ./dataset/GCP_test.app -l PTXYZ -e 2154 -y ./dataset/fr_ign_RAF20.tif --oe 4326 --oz height -n GCP_4326 -w ./test/tmp
12 changes: 8 additions & 4 deletions .github/workflows/test_win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
uses: actions/checkout@v4

- name: Install environment
uses: mamba-org/setup-micromamba@v1.4.3
uses: mamba-org/setup-micromamba@v1
with:
environment-file: borea_dependency/environment-dev.yml
environment-name: borea
Expand All @@ -35,11 +35,11 @@ jobs:

- name: Run regression test conv opk
shell: bash -el {0}
run: python ./borea_tools/opk_to_opk.py -r ./dataset/23FD1305_alt_test.OPK -i NXYZOPKC -f 2 -e 2154 -y ./dataset/fr_ign_RAF20.tif -c ./dataset/Camera1.txt -m ./dataset/MNT_France_25m_h_crop.tif --fm height -n Test -w ./test/tmp/ -o NXYHPOKC -ou radian -oa False
run: python ./borea_tools/opk_to_opk.py -r ./dataset/23FD1305_alt_test.OPK -i NXYZOPKC -f 2 -e 2154 -y ./dataset/fr_ign_RAF20.tif -c ./dataset/Camera1.txt -m ./dataset/MNT_France_25m_h_crop.tif --fm height -n Test -w ./test/tmp/ -o NXYHPOKC --ou radian --oa False

- name: Run regression test opk to opk with multi epsg
shell: bash -el {0}
run : python ./borea_tools/opk_to_opk.py -r ./dataset/23FD1305_alt_test.OPK -i NXYZOPKC -f 2 -e 2154 0 4964 -y ./dataset/fr_ign_RAF20.tif -c ./dataset/Camera1.txt -m ./dataset/MNT_France_25m_h_crop.tif --fm height -n Test -w ./test/tmp/ -o NXYHPOKC -ou radian -oa False
run : python ./borea_tools/opk_to_opk.py -r ./dataset/23FD1305_alt_test.OPK -i NXYZOPKC -f 2 -e 2154 --geoc 4964 -y ./dataset/fr_ign_RAF20.tif -c ./dataset/Camera1.txt -m ./dataset/MNT_France_25m_h_crop.tif --fm height -n Test -w ./test/tmp/ -o NXYHPOKC --ou radian --oa False

- name: Run regression test control opk
shell: bash -el {0}
Expand Down Expand Up @@ -67,8 +67,12 @@ jobs:

- name: Run regression test spaceresection opk
shell: bash -el {0}
run: python ./borea_tools/spaceresection_opk.py -p 825439 6289034 1500 -d height -c ./dataset/Camera1.txt -e 2154 -y ./dataset/fr_ign_RAF20.tif -m ./dataset/MNT_France_25m_h_crop.tif --fm height -t ./test/data/dataset2/all_liaisons2.mes -g ./test/data/dataset2/all_liaisons2_world.mes -l PXYH -n SpaceResection -w ./test/tmp/ -o NXYZOPKC -ou degree -oa True
run: python ./borea_tools/spaceresection_opk.py -p 825439 6289034 1500 -d height -c ./dataset/Camera1.txt -e 2154 -y ./dataset/fr_ign_RAF20.tif -m ./dataset/MNT_France_25m_h_crop.tif --fm height -t ./test/data/dataset2/all_liaisons2.mes -g ./test/data/dataset2/all_liaisons2_world.mes -l PXYH -n SpaceResection -w ./test/tmp/ -o NXYZOPKC --ou degree --oa True

- name: Run regression test opk to conical
shell: bash -el {0}
run: python ./borea_tools/opk_to_conl.py -r ./dataset/23FD1305_alt_test.OPK -i NXYZOPKC -f 2 -e 2154 -y ./dataset/fr_ign_RAF20.tif -c ./dataset/Camera1.txt -m ./dataset/MNT_France_25m_h_crop.tif --fm height -w ./test/tmp/

- name: Run transform projextion of points file
shell: bash -el {0}
run: python ./borea_tools/transform_proj_points.py -g ./dataset/GCP_test.app -l PTXYZ -e 2154 -y ./dataset/fr_ign_RAF20.tif --oe 4326 --oz height -n GCP_4326 -w ./test/tmp
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Why Borea? B for Box and orea is a back slang of aero.
* Transforms coordinates file terrain from image: [borea_tools/docs_tools/README_ptfile_image_to_world.md](./borea_tools/docs_tools/README_ptfile_image_to_world.md)
* Transforms coordinates file image from terrain: [borea_tools/docs_tools/README_ptfile_world_to_image.md](./borea_tools/docs_tools/README_ptfile_world_to_image.md)
* Calculates opk by space resection: [borea_tools/docs_tools/README_spaceresection_opk.md](./borea_tools/docs_tools/README_spaceresection_opk.md)
* Transform projection of points file: [borea_tools/docs_tools/README_transform_proj_points.md](./borea_tools/docs_tools/README_transform_proj_points.md)
* Python lib: [README_borea_lib.md](./README_borea_lib.md)

## Dependency
Expand Down
1 change: 1 addition & 0 deletions README_borea_lib.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Some tools are already implemented in the library:
* Transforms coordinates file terrain from image: `ptfile-image-to-world -h` [doc](https://github.com/IGNF/Borea/tree/main/borea_tools/docs_tools/README_ptfile_image_to_world.md)
* Transforms coordinates file image from terrain: `ptfile-world-to-image -h` [doc](https://github.com/IGNF/Borea/tree/main/borea_tools/docs_tools/README_ptfile_world_to_image.md)
* Calculates opk by space resection: `spaceresection-opk -h` [doc](https://github.com/IGNF/Borea/tree/main/borea_tools/docs_tools/README_spaceresection_opk.md)
* Transform projection of points file: `transform-proj-points -h` [doc](./borea_tools/docs_tools/README_transform_proj_points.md)

## Read data and instantiate worksite

Expand Down
6 changes: 6 additions & 0 deletions borea/datastruct/shot.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ def set_order_axe(self, order_axe: str) -> None:
self.ori_shot = -(R.from_euler("x", np.pi) *
R.from_matrix(self.mat_rot)).as_euler(order_xyz, degrees=unitori)

def set_proj_pos(self) -> None:
"""
Change the projection of the position shot with the epsg_output.
"""
self.pos_shot = np.array(ProjEngine().tf.proj_to_proj_out(*self.pos_shot))

def get_z_remove_scale_factor(self) -> float:
"""
Return Z after removing the scale factor. The Z of the object is NOT modified.
Expand Down
21 changes: 13 additions & 8 deletions borea/datastruct/workdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def __init__(self, name: str) -> None:
self.type_z_data = None
self.type_z_shot = None
self.approxeucli = False
self.epsg_output = False

# pylint: disable-next=too-many-arguments too-many-positional-arguments
def add_shot(self, name_shot: str, pos_shot: np.ndarray,
Expand All @@ -59,24 +60,28 @@ def add_shot(self, name_shot: str, pos_shot: np.ndarray,
linear_alteration=linear_alteration,
order_axe=order_axe)

def set_proj(self, epsg: list, path_geoid: list = None) -> None:
def set_proj(self, epsg: list, path_geoid: list = None, epsg_output: int = None) -> None:
"""
Setup a projection system to the worksite.
Args:
epsg (list): Code epsg of the porjection ex: 2154.
epsg (list): Code epsg of the projection ex: [2154].
path_geoid (str): List of GeoTIFF which represents the geoid in grid form.
epsg_output (int): Code epsg of the output projection. If you want to change.
"""
ProjEngine.clear()
try: # Check if the epsg exist
for idepsg in epsg:
if idepsg:
for idepsg in [*epsg, epsg_output]:
if idepsg:
try: # Check if the epsg exist
_ = CRS.from_epsg(idepsg)
del _
except exceptions.CRSError as e_info:
raise exceptions.CRSError(f"Your EPSG:{epsg} doesn't exist in pyproj.") from e_info
except exceptions.CRSError as e_info:
raise exceptions.CRSError(f"Your EPSG:{epsg}"
" doesn't exist in pyproj.") from e_info
if epsg_output:
self.epsg_output = True

ProjEngine().set_epsg(epsg, path_geoid)
ProjEngine().set_epsg(epsg, path_geoid, epsg_output)

# pylint: disable-next=too-many-arguments too-many-positional-arguments
def add_camera(self, name_camera: str, ppax: float, ppay: float,
Expand Down
6 changes: 1 addition & 5 deletions borea/format/conl.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,15 @@ class Conl:
cam: Camera
proj: str

def save_conl(self, path_conical: Path, linalt: bool = True) -> None:
def save_conl(self, path_conical: Path) -> None:
"""
Save the shot as light conical file.
Args:
path_conical (Path): path to the light conical file.
linalt (bool): If you want z shot corrected by linear alteration.
"""
date_now = datetime.now()

# Scale factor correction
self.shot.set_linear_alteration(linalt)

# creation XML
ori = ET.Element("orientation", {})
ET.SubElement(ori, "lastmodificationbylibori",
Expand Down
9 changes: 4 additions & 5 deletions borea/format/rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Rpc:
def __init__(self) -> None:
self.param_rpc = {}
self.fact_rpc = None
self.output_epsg = None
self.output_epsg = False

@classmethod
def from_shot(cls, shot: Shot, cam: Camera, param_rpc: dict, unit_data: dict) -> None:
Expand Down Expand Up @@ -110,10 +110,9 @@ def normalize_data(self, grid_img: np.ndarray, grid_world: np.ndarray) -> tuple:
"""
if self.fact_rpc is None:
if self.output_epsg:
ProjEngine().set_epsg_tf_geog_output(self.output_epsg)
x_geog, y_geog, z_geog = ProjEngine().tf.carto_to_geog_out(grid_world[0],
grid_world[1],
grid_world[2])
x_geog, y_geog, z_geog = ProjEngine().tf.proj_to_proj_out(grid_world[0],
grid_world[1],
grid_world[2])
else:
x_geog, y_geog, z_geog = ProjEngine().tf.carto_to_geog(grid_world[0],
grid_world[1],
Expand Down
17 changes: 5 additions & 12 deletions borea/geodesy/proj_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,23 @@ def __post_init__(self) -> None:
if self.epsg:
self.crs = pyproj.CRS.from_epsg(self.epsg[0])
self.proj = pyproj.Proj(self.crs)
self.tf = TransformGeodesy(self.epsg, self.geoid)
self.tf = TransformGeodesy(self.epsg, self.geoid, self.epsg_output)

def set_epsg(self, epsg: list, geoid: list = None) -> None:
def set_epsg(self, epsg: list, geoid: list = None, epsg_output: int = None) -> None:
"""
Setter of the class ProjEngine.
Allows to init the class with data.
Args:
epsg (list): Code epsg of the projection ex: 2154.
epsg (list): Code epsg of the projection ex: [2154].
geoid (list): List of geoid to use.
epsg_output (int): Code epsg of the output projection. If you want to change.
"""
self.epsg = epsg
self.geoid = geoid
self.epsg_output = epsg_output
self.__post_init__()

def set_epsg_tf_geog_output(self, epsg_output: int) -> None:
"""
Create the pyproj Transformer from crs of worksite to crs geographic ask.
Args:
epsg_out (int): Code epsg of the output crs.
"""
self.tf.tf_output(epsg_output)

def get_meridian_convergence(self, x_carto: Union[np.ndarray, List[float], float],
y_carto: Union[np.ndarray, List[float], float]) -> np.ndarray:
"""
Expand Down
Loading

0 comments on commit 4bf289a

Please sign in to comment.