wolfhece 2.1.108__py3-none-any.whl → 2.1.110__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.
- wolfhece/PyDraw.py +234 -5
- wolfhece/PyVertex.py +17 -1
- wolfhece/PyVertexvectors.py +732 -112
- wolfhece/apps/curvedigitizer.py +197 -141
- wolfhece/apps/version.py +1 -1
- wolfhece/lazviewer/laz_viewer.py +22 -0
- wolfhece/matplotlib_fig.py +433 -66
- wolfhece/pybridges.py +227 -87
- {wolfhece-2.1.108.dist-info → wolfhece-2.1.110.dist-info}/METADATA +1 -1
- {wolfhece-2.1.108.dist-info → wolfhece-2.1.110.dist-info}/RECORD +13 -13
- {wolfhece-2.1.108.dist-info → wolfhece-2.1.110.dist-info}/WHEEL +0 -0
- {wolfhece-2.1.108.dist-info → wolfhece-2.1.110.dist-info}/entry_points.txt +0 -0
- {wolfhece-2.1.108.dist-info → wolfhece-2.1.110.dist-info}/top_level.txt +0 -0
wolfhece/apps/curvedigitizer.py
CHANGED
@@ -13,170 +13,226 @@ myappid = 'wolf_hece_uliege' # arbitrary string
|
|
13
13
|
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)
|
14
14
|
|
15
15
|
from ..PyTranslate import _
|
16
|
+
from ..matplotlib_fig import Matplotlib_Figure, PRESET_LAYOUTS
|
16
17
|
|
17
18
|
import wx
|
18
19
|
import numpy as np
|
19
20
|
import matplotlib.pyplot as plt
|
20
21
|
import matplotlib.image as mpimg
|
22
|
+
from matplotlib.axes import Axes
|
23
|
+
from matplotlib.figure import Figure
|
24
|
+
from matplotlib.backend_bases import KeyEvent, MouseEvent
|
25
|
+
from PIL import Image, ImageOps
|
21
26
|
|
22
|
-
|
23
|
-
"""
|
24
|
-
Main function of curve digitizer
|
27
|
+
import logging
|
25
28
|
|
26
|
-
|
27
|
-
plt.ion()
|
28
|
-
ex = wx.App()
|
29
|
-
ex.MainLoop()
|
30
|
-
curves=[]
|
31
|
-
# open the dialog
|
32
|
-
file=wx.FileDialog(None,_("Select image to digitize"),
|
33
|
-
wildcard="jpeg image (*.jpg)|*.jpg|png image (*.png)|*.png")
|
34
|
-
if file.ShowModal() == wx.ID_CANCEL:
|
35
|
-
return
|
36
|
-
else:
|
37
|
-
#récuparétaion du nom de fichier avec chemin d'accès
|
38
|
-
filein =file.GetPath()
|
39
|
-
|
40
|
-
# show the image
|
41
|
-
img = mpimg.imread(filein)
|
42
|
-
fig, ax = plt.subplots()
|
43
|
-
ax.imshow(img)
|
44
|
-
ax.axis('off') # clear x-axis and y-axis
|
45
|
-
|
46
|
-
# get reference length in x direction
|
47
|
-
xfactor = getReferenceLength(0)
|
48
|
-
|
49
|
-
MsgBox = wx.MessageDialog(None,_('Do you want to use the same reference along Y?'),style=wx.YES_NO)
|
50
|
-
result=MsgBox.ShowModal()
|
51
|
-
if result == wx.ID_YES:
|
52
|
-
yfactor=xfactor
|
53
|
-
else:
|
54
|
-
# get the reference length in y direction
|
55
|
-
yfactor = getReferenceLength(1)
|
56
|
-
|
57
|
-
print(xfactor)
|
58
|
-
print(yfactor)
|
59
|
-
|
60
|
-
origin = getOrigin()
|
61
|
-
|
62
|
-
# digitize curves until stoped by the user
|
63
|
-
reply = wx.ID_YES
|
64
|
-
show=True
|
65
|
-
while reply==wx.ID_YES:
|
66
|
-
if show:
|
67
|
-
wx.MessageBox(_("Please digitize the curve.\n" +
|
68
|
-
"Left click: select point\n"+
|
69
|
-
"Right click: undo\n"+
|
70
|
-
"Middle click or Return: finish"),
|
71
|
-
_("Digitize curve"))
|
72
|
-
show=False
|
73
|
-
|
74
|
-
# get the curve points
|
75
|
-
x = plt.ginput(
|
76
|
-
-1,
|
77
|
-
timeout=0,
|
78
|
-
show_clicks=True
|
79
|
-
)
|
80
|
-
x = np.asarray(x)
|
29
|
+
class Digitizer:
|
81
30
|
|
82
|
-
|
31
|
+
def __init__(self):
|
83
32
|
|
84
|
-
|
85
|
-
|
86
|
-
|
33
|
+
"""
|
34
|
+
Main function of curve digitizer
|
35
|
+
"""
|
87
36
|
|
88
|
-
|
89
|
-
print(x)
|
37
|
+
plt.ion()
|
90
38
|
|
91
|
-
|
92
|
-
reply=MsgBox.ShowModal()
|
39
|
+
# self.curves=[]
|
93
40
|
|
94
|
-
|
95
|
-
|
96
|
-
|
41
|
+
# open the dialog
|
42
|
+
file = wx.FileDialog(None,_("Select image to digitize"),
|
43
|
+
wildcard="gif image (*.gif)|*.gif|jpeg image (*.jpg)|*.jpg|png image (*.png)|*.png|All files (*.*)|*.*",)
|
97
44
|
|
98
|
-
while not validFile:
|
99
|
-
file=wx.FileDialog(None,_("Select file to save the data"), wildcard=_("Simple text files (.txt)|*.txt"))
|
100
45
|
if file.ShowModal() == wx.ID_CANCEL:
|
101
|
-
|
46
|
+
return
|
102
47
|
else:
|
103
48
|
#récuparétaion du nom de fichier avec chemin d'accès
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
49
|
+
self.filein =file.GetPath()
|
50
|
+
|
51
|
+
# show the image
|
52
|
+
self.figure = Matplotlib_Figure(PRESET_LAYOUTS.DEFAULT_EQUAL)
|
53
|
+
self.figure.cur_ax.set_aspect('equal')
|
54
|
+
self.figure.fig_properties._axes[0]._equal_axis == 1
|
55
|
+
|
56
|
+
# win = self.figure._collaps_pane.GetPane()
|
57
|
+
# self._convert_xy = wx.Button(win, -1, 'Convert XY to world coordinates')
|
58
|
+
# self._convert_xy.Bind(wx.EVT_BUTTON, self.convert_xy)
|
59
|
+
# self.figure._sizer_xls.Add(self._convert_xy, 0, wx.EXPAND)
|
60
|
+
# self.figure.Layout()
|
61
|
+
|
62
|
+
self.figure.add_image(self.filein, origin='lower')
|
63
|
+
self.fig.tight_layout()
|
64
|
+
|
65
|
+
self.ref_x = []
|
66
|
+
self.ref_y = []
|
67
|
+
|
68
|
+
self.ref_x_length = 0
|
69
|
+
self.ref_y_length = 0
|
70
|
+
|
71
|
+
self.xy = []
|
72
|
+
|
73
|
+
# get reference length in x direction
|
74
|
+
wx.MessageBox(_("Use SHIFT + Right Mouse Button to select two points as X reference.\n\nWe will use only the delta X to calculate the scaling factor.\nSo, the Y distance will be ignored."),_("Select reference X"))
|
75
|
+
self.new_line(is_world=False, label = 'Reference X', color='black', linewidth=2)
|
76
|
+
self.figure.action = ('Ref X', self._callback_pt)
|
77
|
+
|
78
|
+
@property
|
79
|
+
def ax(self) -> Axes:
|
80
|
+
return self.figure.ax[0]
|
81
|
+
|
82
|
+
@property
|
83
|
+
def fig(self) -> Figure:
|
84
|
+
return self.figure.fig
|
85
|
+
|
86
|
+
# def convert_xy(self, event):
|
87
|
+
# """
|
88
|
+
# Convert the pixel coordinates to world coordinates
|
89
|
+
# """
|
90
|
+
# xy = self.figure.get_xy_from_grid()
|
91
|
+
|
92
|
+
# xy[:,0] = (xy[:,0] - self.origin_img[0]) * self.factor_X + self.origin_world[0]
|
93
|
+
# xy[:,1] = (xy[:,1] - self.origin_img[1]) * self.factor_Y + self.origin_world[1]
|
94
|
+
|
95
|
+
# self.figure.fill_grid_with_xy_np(xy)
|
96
|
+
|
97
|
+
def new_line(self, is_world:bool = True, ax=None, **kwargs):
|
98
|
+
|
99
|
+
line_props = self.figure.new_line(ax=ax, **kwargs)
|
100
|
+
|
101
|
+
if is_world:
|
102
|
+
line_props.xscale = self.factor_X
|
103
|
+
line_props.yscale = self.factor_Y
|
104
|
+
line_props.xorigin_world = self.origin_world[0]
|
105
|
+
line_props.yorigin_world = self.origin_world[1]
|
106
|
+
line_props.xorigin_local = self.origin_img[0]
|
107
|
+
line_props.yorigin_local = self.origin_img[1]
|
108
|
+
line_props.populate()
|
109
|
+
|
110
|
+
def _callback_digitize(self, xy, which):
|
111
|
+
|
112
|
+
if which == 'Digitize':
|
113
|
+
pass
|
114
|
+
# self.xy.append(xy)
|
115
|
+
elif which == 'End Digitize':
|
116
|
+
|
117
|
+
MsgBox = wx.MessageDialog(None,_("Digitize another curve?"),style=wx.YES_NO)
|
118
|
+
reply=MsgBox.ShowModal()
|
119
|
+
|
120
|
+
if reply == wx.ID_YES:
|
121
|
+
self.new_line()
|
153
122
|
else:
|
154
|
-
|
123
|
+
self.figure.action = None
|
155
124
|
|
156
|
-
|
157
|
-
deltaref=coord[1][index]-coord[0][index]
|
158
|
-
factor=reflength/deltaref
|
125
|
+
def _callback_origin(self, xy, which):
|
159
126
|
|
160
|
-
|
127
|
+
if which == 'Origin':
|
128
|
+
self.origin_img = xy
|
161
129
|
|
162
|
-
|
130
|
+
valid_origin = False
|
131
|
+
while not valid_origin:
|
132
|
+
dlg = wx.TextEntryDialog(None,_("Set the origin coordinate (X,Y)"),_("Set the origin"), "0,0")
|
133
|
+
ret = dlg.ShowModal()
|
163
134
|
|
164
|
-
|
165
|
-
|
166
|
-
Get the Origin
|
135
|
+
if ret == wx.ID_OK:
|
136
|
+
origin = dlg.GetValue().split(',')
|
167
137
|
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
show_clicks=True
|
174
|
-
) # capture only one points
|
138
|
+
try:
|
139
|
+
self.origin_world = (float(origin[0]),float(origin[1]))
|
140
|
+
valid_origin = True
|
141
|
+
except:
|
142
|
+
valid_origin = False
|
175
143
|
|
176
|
-
|
177
|
-
|
178
|
-
|
144
|
+
wx.MessageBox(_("Please digitize the curve.\n\n" +
|
145
|
+
" - MAJ + Right click : add point\n"+
|
146
|
+
" - Press Enter : finish"),
|
147
|
+
_("Digitize curve"))
|
148
|
+
|
149
|
+
self.new_line(is_world = True, label = 'Curve', linewidth=1.5)
|
150
|
+
self.figure.action = ('Digitize', self._callback_digitize)
|
151
|
+
|
152
|
+
def _callback_pt(self, xy, which):
|
153
|
+
|
154
|
+
if which == 'Ref X':
|
155
|
+
self.ref_x.append(xy)
|
156
|
+
|
157
|
+
if len(self.ref_x) == 2:
|
158
|
+
|
159
|
+
validLength = False
|
160
|
+
dlg=wx.TextEntryDialog(None,_("Enter the reference length [user unit | mm | cm | m | km]"))
|
161
|
+
|
162
|
+
while not validLength:
|
163
|
+
dlg.ShowModal()
|
164
|
+
|
165
|
+
try:
|
166
|
+
self.ref_x_length = float(dlg.GetValue())
|
167
|
+
if self.ref_x_length > 0:
|
168
|
+
validLength = True
|
169
|
+
except:
|
170
|
+
validLength = False
|
171
|
+
|
172
|
+
dlg.Destroy()
|
173
|
+
|
174
|
+
# calculate scaling factor
|
175
|
+
deltaref = np.abs(self.ref_x[1][0] - self.ref_x[0][0])
|
176
|
+
self.factor_X = self.ref_x_length / deltaref
|
177
|
+
|
178
|
+
reply = wx.MessageDialog(None,"{:4.0f} pixels in {:s} direction corresponding to {:4.4f} units. Is this correct?".format(deltaref, 'X', self.ref_x_length),style=wx.YES_NO)
|
179
|
+
|
180
|
+
if reply.ShowModal() == wx.ID_NO:
|
181
|
+
logging.info(_('Retry !'))
|
182
|
+
self.ref_x = []
|
183
|
+
self.ref_x_length = 0
|
184
|
+
else:
|
185
|
+
self.figure.action = None
|
186
|
+
MsgBox = wx.MessageDialog(None,_('Do you want to use the same reference along Y?'),style=wx.YES_NO)
|
187
|
+
result=MsgBox.ShowModal()
|
188
|
+
if result == wx.ID_YES:
|
189
|
+
self.factor_Y = self.factor_X
|
190
|
+
|
191
|
+
wx.MessageBox(_("Click one point for a reference in local axis (s,z)"),_("Select an origin"))
|
192
|
+
self.new_line(is_world = False, label = 'Origin', color='red', linewidth=4)
|
193
|
+
self.figure.action = ('Origin', self._callback_origin)
|
194
|
+
else:
|
195
|
+
# get the reference length in y direction
|
196
|
+
self.new_line(is_world = False, label = 'Reference Y', color='black', linewidth=2)
|
197
|
+
wx.MessageBox(_("Use SHIFT + Right Mouse Button to select two points as Y reference.\n\nWe will use only the delta Y to calculate the scaling factor.\nSo, the X distance will be ignored."),_("Select reference Y"))
|
198
|
+
self.figure.action = ('Ref Y', self._callback_pt)
|
199
|
+
|
200
|
+
elif which == 'Ref Y':
|
201
|
+
self.ref_y.append(xy)
|
202
|
+
|
203
|
+
if len(self.ref_y) == 2:
|
204
|
+
|
205
|
+
validLength = False
|
206
|
+
dlg=wx.TextEntryDialog(None,_("Enter the reference length [user unit | mm | cm | m | km]"))
|
207
|
+
while not validLength:
|
208
|
+
dlg.ShowModal()
|
209
|
+
|
210
|
+
try:
|
211
|
+
self.ref_y_length = float(dlg.GetValue())
|
212
|
+
if self.ref_y_length > 0:
|
213
|
+
validLength = True
|
214
|
+
except:
|
215
|
+
validLength = False
|
216
|
+
|
217
|
+
dlg.Destroy()
|
218
|
+
|
219
|
+
# calculate scaling factor
|
220
|
+
deltaref = np.abs(self.ref_y[1][1] - self.ref_y[0][1])
|
221
|
+
self.factor_Y = self.ref_y_length / deltaref
|
222
|
+
|
223
|
+
reply = wx.MessageDialog(None,"{:4.0f} pixels in {:s} direction corresponding to {:4.4f} units. Is this correct?".format(deltaref, 'Y', self.ref_y_length),style=wx.YES_NO)
|
224
|
+
|
225
|
+
if reply.ShowModal() == wx.ID_NO:
|
226
|
+
logging.info(_('Retry !'))
|
227
|
+
self.ref_y = []
|
228
|
+
self.ref_y_length = 0
|
229
|
+
else:
|
230
|
+
wx.MessageBox(_("Click one point for a reference in local axis (s,z)"),_("Select an origin"))
|
231
|
+
self.new_line(is_world = False, label = 'Origin', color='red', linewidth=4)
|
232
|
+
self.figure.action = ('Origin', self._callback_origin)
|
179
233
|
|
180
234
|
if __name__ == "__main__":
|
181
235
|
# run the main function
|
182
|
-
|
236
|
+
ex = wx.App()
|
237
|
+
digit = Digitizer()
|
238
|
+
ex.MainLoop()
|
wolfhece/apps/version.py
CHANGED
wolfhece/lazviewer/laz_viewer.py
CHANGED
@@ -23,6 +23,7 @@ from ..PyWMS import getWalonmap
|
|
23
23
|
from ..PyTranslate import _
|
24
24
|
from ..color_constants import Colors
|
25
25
|
from ..PyParams import Wolf_Param
|
26
|
+
from ..matplotlib_fig import Matplotlib_Figure as mplfig
|
26
27
|
|
27
28
|
"""
|
28
29
|
Importation et visualisation de données LAS et LAZ
|
@@ -620,6 +621,27 @@ class xyz_laz_grids():
|
|
620
621
|
|
621
622
|
return fig,ax
|
622
623
|
|
624
|
+
def plot_laz_wx(self, xy:Union[LineString, list[list[float], list[float]]], length_buffer=5., show=True):
|
625
|
+
"""
|
626
|
+
Dessin des points LAZ sur un graphique Matplotlib
|
627
|
+
"""
|
628
|
+
|
629
|
+
(up_s, up_z, up_color), (down_s, down_z, down_color) = self.scan_around(xy, length_buffer)
|
630
|
+
|
631
|
+
figmpl = mplfig()
|
632
|
+
figmpl.presets()
|
633
|
+
fig = figmpl.fig
|
634
|
+
ax = figmpl.cur_ax
|
635
|
+
|
636
|
+
logging.info(_('Plotting'))
|
637
|
+
ax.scatter(up_s, up_z, c=up_color ,marker='.')
|
638
|
+
ax.scatter(down_s, down_z,c=down_color,marker='+')
|
639
|
+
|
640
|
+
if show:
|
641
|
+
figmpl.Show()
|
642
|
+
|
643
|
+
return figmpl
|
644
|
+
|
623
645
|
def create_from_laz(self, dir_laz:str, shape:str, ds:float = 50, force_format = np.float64):
|
624
646
|
|
625
647
|
try:
|