ign-borea 0.1.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- borea/__init__.py +0 -0
- borea/datastruct/__init__.py +0 -0
- borea/datastruct/camera.py +25 -0
- borea/datastruct/dtm.py +119 -0
- borea/datastruct/gcp.py +22 -0
- borea/datastruct/shot.py +222 -0
- borea/datastruct/workdata.py +220 -0
- borea/format/__init__.py +0 -0
- borea/format/conl.py +143 -0
- borea/format/rpc.py +244 -0
- borea/geodesy/__init__.py +0 -0
- borea/geodesy/approx_euclidean_proj.py +91 -0
- borea/geodesy/euclidean_proj.py +25 -0
- borea/geodesy/local_euclidean_proj.py +127 -0
- borea/geodesy/proj_engine.py +70 -0
- borea/geodesy/projectionlist/__init__.py +0 -0
- borea/geodesy/projectionlist/search_proj.py +60 -0
- borea/geodesy/transform_geodesy.py +114 -0
- borea/process/__init__.py +0 -0
- borea/process/p_add_data/__init__.py +0 -0
- borea/process/p_add_data/p_add_shot.py +63 -0
- borea/process/p_add_data/p_file_gcp2d.py +55 -0
- borea/process/p_add_data/p_file_gcp3d.py +53 -0
- borea/process/p_add_data/p_gen_param.py +76 -0
- borea/process/p_add_data/p_pt2d.py +48 -0
- borea/process/p_add_data/p_pt3d.py +48 -0
- borea/process/p_add_data/p_unit_shot.py +48 -0
- borea/process/p_add_data/p_write.py +23 -0
- borea/process/p_format/__init__.py +0 -0
- borea/process/p_format/p_read_opk.py +78 -0
- borea/process/p_format/p_write_con.py +36 -0
- borea/process/p_format/p_write_opk.py +64 -0
- borea/process/p_format/p_write_rpc.py +48 -0
- borea/process/p_func/__init__.py +0 -0
- borea/process/p_func/p_control.py +67 -0
- borea/process/p_func/p_image_world.py +48 -0
- borea/process/p_func/p_spaceresection.py +51 -0
- borea/process/p_func/p_world_image.py +49 -0
- borea/reader/__init__.py +0 -0
- borea/reader/orientation/__init__.py +0 -0
- borea/reader/orientation/manage_reader.py +33 -0
- borea/reader/orientation/reader_opk.py +58 -0
- borea/reader/reader_camera.py +52 -0
- borea/reader/reader_point.py +113 -0
- borea/stat/__init__.py +0 -0
- borea/stat/statistics.py +215 -0
- borea/transform_world_image/__init__.py +0 -0
- borea/transform_world_image/transform_dtm/__init__.py +0 -0
- borea/transform_world_image/transform_dtm/world_image_dtm.py +47 -0
- borea/transform_world_image/transform_shot/__init__.py +0 -0
- borea/transform_world_image/transform_shot/conversion_coor_shot.py +58 -0
- borea/transform_world_image/transform_shot/image_world_shot.py +153 -0
- borea/transform_world_image/transform_shot/world_image_shot.py +117 -0
- borea/transform_world_image/transform_worksite/__init__.py +0 -0
- borea/transform_world_image/transform_worksite/image_world_intersection.py +154 -0
- borea/transform_world_image/transform_worksite/image_world_least_square.py +184 -0
- borea/transform_world_image/transform_worksite/image_world_work.py +49 -0
- borea/transform_world_image/transform_worksite/space_resection.py +343 -0
- borea/transform_world_image/transform_worksite/world_image_work.py +43 -0
- borea/utils/__init__.py +0 -0
- borea/utils/check/__init__.py +0 -0
- borea/utils/check/check_args_opk.py +59 -0
- borea/utils/check/check_args_reader_pt.py +44 -0
- borea/utils/check/check_array.py +56 -0
- borea/utils/check/check_header.py +90 -0
- borea/utils/check/check_order_axe.py +50 -0
- borea/utils/miscellaneous/__init__.py +0 -0
- borea/utils/miscellaneous/miscellaneous.py +83 -0
- borea/utils/miscellaneous/param_bundle.py +36 -0
- borea/utils/miscellaneous/sparse.py +31 -0
- borea/utils/singleton/__init__.py +0 -0
- borea/utils/singleton/singleton.py +23 -0
- borea/utils/xml/__init__.py +0 -0
- borea/utils/xml/xml.py +63 -0
- borea/worksite/__init__.py +0 -0
- borea/worksite/worksite.py +240 -0
- borea/writer/__init__.py +0 -0
- borea/writer/manage_writer.py +23 -0
- borea/writer/writer_con.py +29 -0
- borea/writer/writer_df_to_txt.py +32 -0
- borea/writer/writer_opk.py +70 -0
- borea/writer/writer_rpc.py +55 -0
- borea_tools/__init__.py +0 -0
- borea_tools/opk_control.py +33 -0
- borea_tools/opk_to_conl.py +33 -0
- borea_tools/opk_to_opk.py +33 -0
- borea_tools/opk_to_rpc.py +33 -0
- borea_tools/pt_image_to_world.py +32 -0
- borea_tools/pt_world_to_image.py +32 -0
- borea_tools/ptfile_image_to_world.py +32 -0
- borea_tools/ptfile_world_to_image.py +32 -0
- borea_tools/spaceresection_opk.py +34 -0
- ign_borea-0.1.5.dist-info/LICENSE +21 -0
- ign_borea-0.1.5.dist-info/METADATA +274 -0
- ign_borea-0.1.5.dist-info/RECORD +98 -0
- ign_borea-0.1.5.dist-info/WHEEL +5 -0
- ign_borea-0.1.5.dist-info/entry_points.txt +10 -0
- ign_borea-0.1.5.dist-info/top_level.txt +2 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Module for manipulating a cartographic system.
|
|
3
|
+
"""
|
|
4
|
+
from typing import Union, List
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
import pyproj
|
|
7
|
+
import numpy as np
|
|
8
|
+
from borea.geodesy.transform_geodesy import TransformGeodesy
|
|
9
|
+
from borea.utils.singleton.singleton import Singleton
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
# pylint: disable=unpacking-non-sequence
|
|
13
|
+
@dataclass
|
|
14
|
+
class ProjEngine(TransformGeodesy, metaclass=Singleton):
|
|
15
|
+
"""
|
|
16
|
+
This class provides functions for using a cartographic system.
|
|
17
|
+
"""
|
|
18
|
+
epsg: int = None
|
|
19
|
+
geoid: list = None
|
|
20
|
+
|
|
21
|
+
def __post_init__(self) -> None:
|
|
22
|
+
if self.epsg:
|
|
23
|
+
self.crs = pyproj.CRS.from_epsg(self.epsg)
|
|
24
|
+
self.proj = pyproj.Proj(self.crs)
|
|
25
|
+
TransformGeodesy.__tf_init__(self, self.geoid, self.crs)
|
|
26
|
+
|
|
27
|
+
def set_epsg(self, epsg: int, geoid: list = None) -> None:
|
|
28
|
+
"""
|
|
29
|
+
Setter of the class ProjEngine.
|
|
30
|
+
Allows to init the class with data.
|
|
31
|
+
|
|
32
|
+
Args:
|
|
33
|
+
epsg (int): Code epsg of the porjection ex: "EPSG:2154".
|
|
34
|
+
geoid (list): List of geoid to use.
|
|
35
|
+
"""
|
|
36
|
+
self.epsg = epsg
|
|
37
|
+
self.geoid = geoid
|
|
38
|
+
self.__post_init__()
|
|
39
|
+
|
|
40
|
+
def get_meridian_convergence(self, x_carto: Union[np.ndarray, List[float], float],
|
|
41
|
+
y_carto: Union[np.ndarray, List[float], float]) -> np.ndarray:
|
|
42
|
+
"""
|
|
43
|
+
Compute meridian convergence.
|
|
44
|
+
Values are extracted from pyproj.
|
|
45
|
+
|
|
46
|
+
Args:
|
|
47
|
+
x_carto (np.array, List[float], float): x cartographic coordinates.
|
|
48
|
+
y_carto (np.array, List[float], float): y cartographic coordinates.
|
|
49
|
+
|
|
50
|
+
Returns:
|
|
51
|
+
np.array : Meridian convergence in degree.
|
|
52
|
+
"""
|
|
53
|
+
(x_geog, y_geog) = self.carto_to_geog(x_carto, y_carto)
|
|
54
|
+
return -np.array(self.proj.get_factors(x_geog, y_geog).meridian_convergence)
|
|
55
|
+
|
|
56
|
+
def get_scale_factor(self, x_carto: Union[np.ndarray, List[float], float],
|
|
57
|
+
y_carto: Union[np.ndarray, List[float], float]) -> np.ndarray:
|
|
58
|
+
"""
|
|
59
|
+
Compute scale factor.
|
|
60
|
+
Values are extracted from pyproj.
|
|
61
|
+
|
|
62
|
+
Args:
|
|
63
|
+
x_carto (Union[np.array, List[float], float]): x cartographic coordinates.
|
|
64
|
+
y_carto (Union[np.array, List[float], float]): y cartographic coordinates.
|
|
65
|
+
|
|
66
|
+
Returns:
|
|
67
|
+
np.array: Scale factor and meridian convergence.
|
|
68
|
+
"""
|
|
69
|
+
x_geog, y_geog = self.carto_to_geog(x_carto, y_carto)
|
|
70
|
+
return np.array(self.proj.get_factors(x_geog, y_geog).meridional_scale) - 1
|
|
File without changes
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Research data in ProjectionList.txt.
|
|
3
|
+
"""
|
|
4
|
+
import os
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
PATH_FILE = os.path.join(os.path.dirname(__file__), "ProjectionList.txt")
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def convert_line_list(line: str) -> list:
|
|
11
|
+
"""
|
|
12
|
+
Convert type of all element in list in str.
|
|
13
|
+
|
|
14
|
+
Args:
|
|
15
|
+
list_data(str): One line of file.
|
|
16
|
+
|
|
17
|
+
Returns:
|
|
18
|
+
list: List with str object.
|
|
19
|
+
"""
|
|
20
|
+
return [x[1:-1] for x in line[1:-2].split(',')]
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def search_info(type_input: str, data_input: str, type_output: str) -> str:
|
|
24
|
+
"""
|
|
25
|
+
Research data in ProjectionList.txt.
|
|
26
|
+
header: ["SD","BDORTHO","EPSG","GEOVIEW","MAPINFO","PROJ4","TA","TOPAERO","WKT"]
|
|
27
|
+
|
|
28
|
+
Args:
|
|
29
|
+
type_input (str): type of data input to refer.
|
|
30
|
+
data_input (str): data to refer.
|
|
31
|
+
type_output (str): type of data output to research.
|
|
32
|
+
|
|
33
|
+
Returns:
|
|
34
|
+
str: data output.
|
|
35
|
+
"""
|
|
36
|
+
try:
|
|
37
|
+
with open(PATH_FILE, 'r', encoding="utf-8") as file_proj:
|
|
38
|
+
list_data = file_proj.readlines()
|
|
39
|
+
header = convert_line_list(list_data[0])
|
|
40
|
+
if type_input.upper() not in header and type_output.upper() not in header:
|
|
41
|
+
raise ValueError(f"{type_input} or {type_output} not in header: {header}")
|
|
42
|
+
|
|
43
|
+
id_input = header.index(type_input)
|
|
44
|
+
id_output = header.index(type_output)
|
|
45
|
+
|
|
46
|
+
for info_proj in list_data[1:]:
|
|
47
|
+
data = convert_line_list(info_proj)
|
|
48
|
+
if data[id_input] == "null" or data[id_output] == "null":
|
|
49
|
+
continue
|
|
50
|
+
if data[id_input] == data_input:
|
|
51
|
+
data_research = data[id_output]
|
|
52
|
+
break
|
|
53
|
+
|
|
54
|
+
file_proj.close()
|
|
55
|
+
except FileNotFoundError as e:
|
|
56
|
+
raise FileNotFoundError(f"The path {PATH_FILE} is incorrect !!!") from e
|
|
57
|
+
|
|
58
|
+
if data_research == "null":
|
|
59
|
+
return None
|
|
60
|
+
return data_research
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Module for class ProjEngine, transform geodesy
|
|
3
|
+
"""
|
|
4
|
+
from dataclasses import dataclass
|
|
5
|
+
import pyproj
|
|
6
|
+
import numpy as np
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
# pylint: disable=unsubscriptable-object
|
|
10
|
+
@dataclass
|
|
11
|
+
class TransformGeodesy():
|
|
12
|
+
"""
|
|
13
|
+
This class provides functions to tranform coordinate system.
|
|
14
|
+
Class parent of ProjEngine.
|
|
15
|
+
Implemented by ProjEngine.
|
|
16
|
+
|
|
17
|
+
Args:
|
|
18
|
+
geoid (list): List of geoid to use.
|
|
19
|
+
crs (pyproj): CRS pyproj of the worksite.
|
|
20
|
+
"""
|
|
21
|
+
carto_to_geoc = None
|
|
22
|
+
geoc_to_carto = None
|
|
23
|
+
carto_to_geog = None
|
|
24
|
+
geog_to_carto = None
|
|
25
|
+
geog_to_geoid = None
|
|
26
|
+
geoid_to_geog = None
|
|
27
|
+
|
|
28
|
+
def __tf_init__(self, geoid: list, crs: pyproj) -> None:
|
|
29
|
+
crs_geoc = pyproj.crs.GeocentricCRS(name=crs.name, datum=crs.datum.name)
|
|
30
|
+
crs_geog = pyproj.crs.GeographicCRS(name=crs.name, datum=crs.datum.name)
|
|
31
|
+
# Transform cartographic coordinates to geographic coordinates
|
|
32
|
+
self.carto_to_geog = pyproj.Transformer.from_crs(crs, crs_geog).transform
|
|
33
|
+
# Transform geographic coordinates to cartographic coordinates
|
|
34
|
+
self.geog_to_carto = pyproj.Transformer.from_crs(crs_geog, crs).transform
|
|
35
|
+
# Transform cartographic coordinates to geocentric coordinates
|
|
36
|
+
self.carto_to_geoc = pyproj.Transformer.from_crs(crs, crs_geoc).transform
|
|
37
|
+
# Transform geocentric coordinates to cartographic coordinates
|
|
38
|
+
self.geoc_to_carto = pyproj.Transformer.from_crs(crs_geoc, crs).transform
|
|
39
|
+
|
|
40
|
+
if geoid:
|
|
41
|
+
self.tf_geoid(geoid)
|
|
42
|
+
|
|
43
|
+
def tf_geoid(self, geoid: list) -> None:
|
|
44
|
+
"""
|
|
45
|
+
Create attribute transform, to transform geographic coordinates to geoide coordinates.
|
|
46
|
+
|
|
47
|
+
Args:
|
|
48
|
+
geoid (list): List of geoid to use.
|
|
49
|
+
"""
|
|
50
|
+
try:
|
|
51
|
+
# Transform geoide coordinates to geographic coordinates
|
|
52
|
+
self.geoid_to_geog = pyproj.Transformer.from_pipeline(f"+proj=vgridshift "
|
|
53
|
+
f"+grids={','.join(geoid)} "
|
|
54
|
+
"+multiplier=1").transform
|
|
55
|
+
# Transform geographic coordinates to geoide coordinates
|
|
56
|
+
self.geog_to_geoid = pyproj.Transformer.from_pipeline(f"+proj=vgridshift "
|
|
57
|
+
f"+grids={','.join(geoid)} "
|
|
58
|
+
"+multiplier=-1").transform
|
|
59
|
+
except pyproj.exceptions.ProjError as e:
|
|
60
|
+
raise pyproj.exceptions.ProjError(f"{geoid} The name or path of geotif is incorrect or "
|
|
61
|
+
"does not exist in "
|
|
62
|
+
f"{pyproj.datadir.get_data_dir()}!!!{e}") from e
|
|
63
|
+
|
|
64
|
+
def tranform_height(self, coor: np.ndarray) -> float:
|
|
65
|
+
"""
|
|
66
|
+
Converting z in altitude to z in height of point.
|
|
67
|
+
|
|
68
|
+
Args:
|
|
69
|
+
coor (np.array): [X, Y, Z] coordinate of the point.
|
|
70
|
+
|
|
71
|
+
Returns:
|
|
72
|
+
float: New height Z.
|
|
73
|
+
"""
|
|
74
|
+
coor_geog = self.carto_to_geog(coor[0], coor[1], coor[2])
|
|
75
|
+
try:
|
|
76
|
+
coor_geog = self.geoid_to_geog(coor_geog[0],
|
|
77
|
+
coor_geog[1],
|
|
78
|
+
coor_geog[2])
|
|
79
|
+
new_z = self.geog_to_carto(coor_geog[0],
|
|
80
|
+
coor_geog[1],
|
|
81
|
+
coor_geog[2])[2]
|
|
82
|
+
except AttributeError as info:
|
|
83
|
+
raise ValueError("The geoid has not been entered, "
|
|
84
|
+
"cannot transform z altitude to height.") from info
|
|
85
|
+
|
|
86
|
+
if new_z == np.inf:
|
|
87
|
+
raise ValueError("out geoid")
|
|
88
|
+
return new_z
|
|
89
|
+
|
|
90
|
+
def tranform_altitude(self, coor: np.ndarray) -> float:
|
|
91
|
+
"""
|
|
92
|
+
Converting z in height to z in altitude of point.
|
|
93
|
+
|
|
94
|
+
Args:
|
|
95
|
+
coor (np.array): [X, Y, Z] coordinate of the point.
|
|
96
|
+
|
|
97
|
+
Returns:
|
|
98
|
+
float: New altitude Z.
|
|
99
|
+
"""
|
|
100
|
+
coor_geog = self.carto_to_geog(coor[0], coor[1], coor[2])
|
|
101
|
+
try:
|
|
102
|
+
coor_geog = self.geog_to_geoid(coor_geog[0],
|
|
103
|
+
coor_geog[1],
|
|
104
|
+
coor_geog[2])
|
|
105
|
+
new_z = self.geog_to_carto(coor_geog[0],
|
|
106
|
+
coor_geog[1],
|
|
107
|
+
coor_geog[2])[2]
|
|
108
|
+
except AttributeError as info:
|
|
109
|
+
raise ValueError("The geoid has not been entered, "
|
|
110
|
+
"cannot transform z height to altitude.") from info
|
|
111
|
+
|
|
112
|
+
if np.all(new_z == np.inf):
|
|
113
|
+
raise ValueError("out geoid")
|
|
114
|
+
return new_z
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Args of parser for adding one shot
|
|
3
|
+
"""
|
|
4
|
+
import argparse
|
|
5
|
+
import numpy as np
|
|
6
|
+
from borea.process.p_add_data.p_gen_param import args_general_param, process_args_gen_param
|
|
7
|
+
from borea.process.p_add_data.p_unit_shot import args_input_shot
|
|
8
|
+
from borea.worksite.worksite import Worksite
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def args_add_shot(parser: argparse) -> argparse:
|
|
12
|
+
"""
|
|
13
|
+
Args for adding one shot.
|
|
14
|
+
|
|
15
|
+
Args:
|
|
16
|
+
parser (argparse): Parser to add argument.
|
|
17
|
+
|
|
18
|
+
Returns:
|
|
19
|
+
argsparse: Parser with argument.
|
|
20
|
+
"""
|
|
21
|
+
parser.add_argument('-n', '--name_shot',
|
|
22
|
+
type=str, default='Test',
|
|
23
|
+
help='Name of the shot.')
|
|
24
|
+
parser.add_argument('-s', '--pos_shot',
|
|
25
|
+
type=float, nargs=3,
|
|
26
|
+
help='Position of the shot X Y Z.')
|
|
27
|
+
parser.add_argument('-t', '--unit_z_shot',
|
|
28
|
+
type=str, choices=['altitude', 'height'],
|
|
29
|
+
help='Unit of the z of the shot.')
|
|
30
|
+
parser.add_argument('-o', '--ori_shot',
|
|
31
|
+
type=float, nargs=3,
|
|
32
|
+
help='Orientation of the shot Omega Phi Kappa.')
|
|
33
|
+
parser = args_input_shot(parser)
|
|
34
|
+
parser = args_general_param(parser)
|
|
35
|
+
return parser
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def process_add_shot(args: argparse) -> Worksite:
|
|
39
|
+
"""
|
|
40
|
+
Processing args with data.
|
|
41
|
+
|
|
42
|
+
Args:
|
|
43
|
+
args (argparse): Arg to apply on worksite (data)
|
|
44
|
+
|
|
45
|
+
Returns:
|
|
46
|
+
Worksite: data
|
|
47
|
+
"""
|
|
48
|
+
work = Worksite("Calc_one_img")
|
|
49
|
+
work = process_args_gen_param(args, work)
|
|
50
|
+
|
|
51
|
+
work.add_shot(args.name_shot,
|
|
52
|
+
np.array(args.pos_shot),
|
|
53
|
+
np.array(args.ori_shot),
|
|
54
|
+
work.cameras[list(work.cameras.keys())[0]].name_camera,
|
|
55
|
+
args.unit_angle,
|
|
56
|
+
args.linear_alteration,
|
|
57
|
+
args.order_axe_input)
|
|
58
|
+
|
|
59
|
+
work.set_param_shot(args.approx_system)
|
|
60
|
+
|
|
61
|
+
work.type_z_shot = args.unit_z_shot
|
|
62
|
+
|
|
63
|
+
return work
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Args of parser to read gcp 2D file.
|
|
3
|
+
"""
|
|
4
|
+
import argparse
|
|
5
|
+
from borea.worksite.worksite import Worksite
|
|
6
|
+
from borea.reader.reader_point import read_file_pt
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def args_gcp2d(parser: argparse) -> argparse:
|
|
10
|
+
"""
|
|
11
|
+
Args to read gcp 2D file.
|
|
12
|
+
|
|
13
|
+
Args:
|
|
14
|
+
parser (argparse): Parser to add argument.
|
|
15
|
+
|
|
16
|
+
Returns:
|
|
17
|
+
argsparse: Parser with argument.
|
|
18
|
+
"""
|
|
19
|
+
parser.add_argument('-t', '--gcp2d',
|
|
20
|
+
type=str, default=None,
|
|
21
|
+
help='File path of ground control points in images.')
|
|
22
|
+
parser.add_argument('-k', '--head_gcp2d',
|
|
23
|
+
type=str, default="PNXY",
|
|
24
|
+
help='Header of the file gcp2d.'
|
|
25
|
+
'e.g. PNXY'
|
|
26
|
+
'S: to ignore the column'
|
|
27
|
+
'P: name of point'
|
|
28
|
+
'N: name of shot'
|
|
29
|
+
'X: coordinate x (column) in the image'
|
|
30
|
+
'Y: coordinate y (line) in the image')
|
|
31
|
+
return parser
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def process_gcp2d(args, work: Worksite) -> Worksite:
|
|
35
|
+
"""
|
|
36
|
+
Processing args with data.
|
|
37
|
+
|
|
38
|
+
Args:
|
|
39
|
+
args (argparse): Arg to apply on worksite (data).
|
|
40
|
+
work (Worksite): Data.
|
|
41
|
+
|
|
42
|
+
Returns:
|
|
43
|
+
Worksite: data
|
|
44
|
+
"""
|
|
45
|
+
# Reading ground point image
|
|
46
|
+
if args.gcp2d is not None:
|
|
47
|
+
read_file_pt(args.gcp2d, list(args.head_gcp2d.upper()), "gcp2d", work)
|
|
48
|
+
print("Connecting point reading done.")
|
|
49
|
+
count = 0
|
|
50
|
+
for k in work.gcp2d.values():
|
|
51
|
+
count += len(k)
|
|
52
|
+
print(f"Number of gcp 2D in image: {len(work.gcp2d)}")
|
|
53
|
+
print(f"Number of image with gcp 2D: {count}")
|
|
54
|
+
|
|
55
|
+
return work
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Args of parser to read gcp 3D file.
|
|
3
|
+
"""
|
|
4
|
+
import argparse
|
|
5
|
+
from borea.worksite.worksite import Worksite
|
|
6
|
+
from borea.reader.reader_point import read_file_pt
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def args_gcp3d(parser: argparse) -> argparse:
|
|
10
|
+
"""
|
|
11
|
+
Args to read gcp 3D file.
|
|
12
|
+
|
|
13
|
+
Args:
|
|
14
|
+
parser (argparse): Parser to add argument.
|
|
15
|
+
|
|
16
|
+
Returns:
|
|
17
|
+
argsparse: Parser with argument.
|
|
18
|
+
"""
|
|
19
|
+
parser.add_argument('-g', '--gcp3d',
|
|
20
|
+
type=str, default=None,
|
|
21
|
+
help='File path of ground control points in terrain.')
|
|
22
|
+
parser.add_argument('-l', '--head_gcp3d',
|
|
23
|
+
type=str, default="PTXYZ",
|
|
24
|
+
help='Header of the file gcp3d.'
|
|
25
|
+
'e.g. PTXYZ'
|
|
26
|
+
'S: to ignore the column'
|
|
27
|
+
'P: name of point'
|
|
28
|
+
'T: Type of gcp to control.'
|
|
29
|
+
'X: coordinate x of the shot position'
|
|
30
|
+
'Y: coordinate y of the shot position'
|
|
31
|
+
'Z: coordinate z altitude of the shot position'
|
|
32
|
+
'H: coordinate z height of the shot position')
|
|
33
|
+
return parser
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def process_gcp3d(args, work: Worksite) -> Worksite:
|
|
37
|
+
"""
|
|
38
|
+
Processing args with data.
|
|
39
|
+
|
|
40
|
+
Args:
|
|
41
|
+
args (argparse): Arg to apply on worksite (data).
|
|
42
|
+
work (Worksite): Data.
|
|
43
|
+
|
|
44
|
+
Returns:
|
|
45
|
+
Worksite: data
|
|
46
|
+
"""
|
|
47
|
+
# Reading GCP 3D
|
|
48
|
+
if args.gcp3d is not None:
|
|
49
|
+
read_file_pt(args.gcp3d, list(args.head_gcp3d.upper()), "gcp3d", work)
|
|
50
|
+
print("GCP reading done.")
|
|
51
|
+
print(f"Number of gcp: {len(work.gcp3d)}")
|
|
52
|
+
|
|
53
|
+
return work
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Args of parser for reading generals parameters
|
|
3
|
+
"""
|
|
4
|
+
import argparse
|
|
5
|
+
import pyproj
|
|
6
|
+
from borea.worksite.worksite import Worksite
|
|
7
|
+
from borea.reader.reader_camera import read_camera
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def args_general_param(parser: argparse) -> argparse:
|
|
11
|
+
"""
|
|
12
|
+
Args for adding general parameter.
|
|
13
|
+
|
|
14
|
+
Args:
|
|
15
|
+
parser (argparse): Parser to add argument.
|
|
16
|
+
|
|
17
|
+
Returns:
|
|
18
|
+
argsparse: Parser with argument.
|
|
19
|
+
"""
|
|
20
|
+
parser.add_argument('-e', '--epsg',
|
|
21
|
+
type=int, default=None,
|
|
22
|
+
help='EPSG codifier number of the reference system used e.g. "2154".')
|
|
23
|
+
parser.add_argument('-y', '--pathgeoid',
|
|
24
|
+
type=str, nargs='*', default=None,
|
|
25
|
+
help='Path to the pyproj GeoTIFF of the geoid e.g../test/data/geoid.tif'
|
|
26
|
+
f' or they must be in {pyproj.datadir.get_data_dir()} and just'
|
|
27
|
+
' need name of file e.g. geoid.tif.')
|
|
28
|
+
parser.add_argument('-c', '--camera',
|
|
29
|
+
type=str, nargs='*',
|
|
30
|
+
help='Files paths of cameras (xml or txt).')
|
|
31
|
+
parser.add_argument('-m', '--dtm',
|
|
32
|
+
type=str, default=None,
|
|
33
|
+
help='DtM of the worksite.')
|
|
34
|
+
parser.add_argument('--fm', '--format_dtm',
|
|
35
|
+
type=str, default=None,
|
|
36
|
+
help='Format of Dtm "altitude" or "height".')
|
|
37
|
+
parser.add_argument('-x', '--approx_system',
|
|
38
|
+
type=bool, default=False,
|
|
39
|
+
help="To use an approximate system.")
|
|
40
|
+
return parser
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def process_args_gen_param(args: argparse, work: Worksite) -> Worksite:
|
|
44
|
+
"""
|
|
45
|
+
Processing args with data.
|
|
46
|
+
|
|
47
|
+
Args:
|
|
48
|
+
args (argparse): Arg to apply on worksite (data).
|
|
49
|
+
work (Worksite): Worksite to work on.
|
|
50
|
+
|
|
51
|
+
Returns:
|
|
52
|
+
Worksite: data
|
|
53
|
+
"""
|
|
54
|
+
# Add a projection to the worksite
|
|
55
|
+
if args.epsg is not None:
|
|
56
|
+
work.set_proj(args.epsg, args.pathgeoid)
|
|
57
|
+
print(f"Projection set-up with EPSG:{args.epsg}.")
|
|
58
|
+
else:
|
|
59
|
+
print("There is no given projection.")
|
|
60
|
+
|
|
61
|
+
# Reading camera file
|
|
62
|
+
if args.camera is not None:
|
|
63
|
+
read_camera(args.camera, work)
|
|
64
|
+
print(f"Camera file reading done. {len(args.camera)} read")
|
|
65
|
+
else:
|
|
66
|
+
print("There is no given camera.")
|
|
67
|
+
|
|
68
|
+
# Add Dem
|
|
69
|
+
work.set_dtm(args.dtm, args.fm)
|
|
70
|
+
if args.dtm is not None:
|
|
71
|
+
print("Add dtm to the worksite done.")
|
|
72
|
+
else:
|
|
73
|
+
print("Not Dtm in the worksite.")
|
|
74
|
+
|
|
75
|
+
work.set_param_shot(args.approx_system)
|
|
76
|
+
return work
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Args of parser for world coordinate of image point
|
|
3
|
+
"""
|
|
4
|
+
import argparse
|
|
5
|
+
import numpy as np
|
|
6
|
+
from borea.transform_world_image.transform_shot.image_world_shot import ImageWorldShot
|
|
7
|
+
from borea.worksite.worksite import Worksite
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def args_add_pt2d(parser: argparse) -> argparse:
|
|
11
|
+
"""
|
|
12
|
+
Args for 2D point
|
|
13
|
+
|
|
14
|
+
Args:
|
|
15
|
+
parser (argparse): Parser to add argument.
|
|
16
|
+
|
|
17
|
+
Returns:
|
|
18
|
+
argsparse: Parser with argument.
|
|
19
|
+
"""
|
|
20
|
+
parser.add_argument('-p', '--point2d',
|
|
21
|
+
type=float, nargs=2,
|
|
22
|
+
help='Coordinate of the 2D point Column Line.')
|
|
23
|
+
parser.add_argument('-d', '--type_z_data',
|
|
24
|
+
type=str, default=None, choices=['altitude', 'height', None],
|
|
25
|
+
help='Unit of the z of the data in output.')
|
|
26
|
+
|
|
27
|
+
return parser
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def process_image_world(args: argparse, work: Worksite) -> None:
|
|
31
|
+
"""
|
|
32
|
+
Processing args to calculate world coordinate of the point.
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
args (argparse): Arg to apply on worksite (data).
|
|
36
|
+
work (Worksite): Worksite to work on.
|
|
37
|
+
"""
|
|
38
|
+
work.set_type_z_data(args.type_z_data)
|
|
39
|
+
|
|
40
|
+
coor3d = ImageWorldShot(work.shots[args.name_shot],
|
|
41
|
+
work.cameras[list(work.cameras.keys())[0]]
|
|
42
|
+
).image_to_world(np.array(args.point2d),
|
|
43
|
+
work.type_z_data,
|
|
44
|
+
work.type_z_shot)
|
|
45
|
+
print(f"World coordinate of the point 2D {args.point2d} is : {np.round(coor3d, 2)}")
|
|
46
|
+
print("Data summary:")
|
|
47
|
+
print(f"* position shot {work.shots[args.name_shot].pos_shot}")
|
|
48
|
+
print(f"* orientation shot {work.shots[args.name_shot].ori_shot}")
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Args of parser for image coordinate of ground point
|
|
3
|
+
"""
|
|
4
|
+
import argparse
|
|
5
|
+
import numpy as np
|
|
6
|
+
from borea.transform_world_image.transform_shot.world_image_shot import WorldImageShot
|
|
7
|
+
from borea.worksite.worksite import Worksite
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def args_add_pt3d(parser: argparse) -> argparse:
|
|
11
|
+
"""
|
|
12
|
+
Args for 3D point
|
|
13
|
+
|
|
14
|
+
Args:
|
|
15
|
+
parser (argparse): Parser to add argument.
|
|
16
|
+
|
|
17
|
+
Returns:
|
|
18
|
+
argsparse: Parser with argument.
|
|
19
|
+
"""
|
|
20
|
+
parser.add_argument('-p', '--point3d',
|
|
21
|
+
type=float, nargs=3,
|
|
22
|
+
help='Coordinate of the 3D point X Y Z.')
|
|
23
|
+
parser.add_argument('-d', '--type_z_data',
|
|
24
|
+
type=str, default=None, choices=['altitude', 'height', None],
|
|
25
|
+
help='Unit of the z of the data.')
|
|
26
|
+
|
|
27
|
+
return parser
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def process_world_image(args: argparse, work: Worksite) -> None:
|
|
31
|
+
"""
|
|
32
|
+
Processing args to calculate image coordinate of the point.
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
args (argparse): Arg to apply on worksite (data).
|
|
36
|
+
work (Worksite): Worksite to work on.
|
|
37
|
+
"""
|
|
38
|
+
work.set_type_z_data(args.type_z_data)
|
|
39
|
+
|
|
40
|
+
coor2d = WorldImageShot(work.shots[args.name_shot],
|
|
41
|
+
work.cameras[list(work.cameras.keys())[0]]
|
|
42
|
+
).world_to_image(np.array(args.point3d),
|
|
43
|
+
work.type_z_data,
|
|
44
|
+
work.type_z_shot)
|
|
45
|
+
print(f"Image coordinate of the point 3D {args.point3d} is : {np.round(coor2d, 2)}")
|
|
46
|
+
print("Data summary:")
|
|
47
|
+
print(f"* position shot {work.shots[args.name_shot].pos_shot}")
|
|
48
|
+
print(f"* orientation shot {work.shots[args.name_shot].ori_shot}")
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Args of parser for unit of shot
|
|
3
|
+
"""
|
|
4
|
+
import argparse
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def args_input_shot(parser: argparse) -> argparse:
|
|
8
|
+
"""
|
|
9
|
+
Args for reading opk file.
|
|
10
|
+
|
|
11
|
+
Args:
|
|
12
|
+
parser (argparse): Parser to add argument.
|
|
13
|
+
|
|
14
|
+
Returns:
|
|
15
|
+
argsparse: Parser with argument.
|
|
16
|
+
"""
|
|
17
|
+
parser.add_argument('-b', '--order_axe_input',
|
|
18
|
+
type=str, default="opk",
|
|
19
|
+
help="Order of rotation matrix axes.")
|
|
20
|
+
parser.add_argument('-u', '--unit_angle',
|
|
21
|
+
type=str, default="degree", choices=['degree', 'radian'],
|
|
22
|
+
help="Unit of the angle of shooting, 'degree' or 'radian'.")
|
|
23
|
+
parser.add_argument('-a', '--linear_alteration',
|
|
24
|
+
type=bool, default=True,
|
|
25
|
+
help="True if z shot corrected by linear alteration.")
|
|
26
|
+
return parser
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def args_output_shot(parser: argparse) -> argparse:
|
|
30
|
+
"""
|
|
31
|
+
Args for reading opk file.
|
|
32
|
+
|
|
33
|
+
Args:
|
|
34
|
+
parser (argparse): Parser to add argument.
|
|
35
|
+
|
|
36
|
+
Returns:
|
|
37
|
+
argsparse: Parser with argument.
|
|
38
|
+
"""
|
|
39
|
+
parser.add_argument('-ob', '--order_axe_output',
|
|
40
|
+
type=str, default=None,
|
|
41
|
+
help="Order of rotation matrix axes you want in output.")
|
|
42
|
+
parser.add_argument('-ou', '--output_unit_angle',
|
|
43
|
+
type=str, default=None, choices=["degree", "radian", None],
|
|
44
|
+
help="Unit of the angle of shooting, 'degree' or 'radian'")
|
|
45
|
+
parser.add_argument('-oa', '--output_linear_alteration',
|
|
46
|
+
type=bool, default=None,
|
|
47
|
+
help="True if z shot corrected by linear alteration.")
|
|
48
|
+
return parser
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Args of parser to write file.
|
|
3
|
+
"""
|
|
4
|
+
import argparse
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def args_writer(parser: argparse) -> argparse:
|
|
8
|
+
"""
|
|
9
|
+
Args to write file.
|
|
10
|
+
|
|
11
|
+
Args:
|
|
12
|
+
parser (argparse): Parser to add argument.
|
|
13
|
+
|
|
14
|
+
Returns:
|
|
15
|
+
argsparse: Parser with argument.
|
|
16
|
+
"""
|
|
17
|
+
parser.add_argument('-n', '--namereturn',
|
|
18
|
+
type=str,
|
|
19
|
+
help='Name of the new file.')
|
|
20
|
+
parser.add_argument('-w', '--pathreturn',
|
|
21
|
+
type=str, default='./',
|
|
22
|
+
help='Conversion path e.g. test/tmp/.')
|
|
23
|
+
return parser
|
|
File without changes
|