wolfhece 2.2.3__py3-none-any.whl → 2.2.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.
wolfhece/PyDraw.py CHANGED
@@ -41,7 +41,6 @@ try:
41
41
  from datetime import timedelta
42
42
  from multiprocessing import Pool
43
43
  from pathlib import Path
44
- from time import sleep
45
44
  except ImportError as e:
46
45
  print(e)
47
46
  raise ImportError("Error importing time, datetime, multiprocessing, pathlib. Please check your installation.")
@@ -131,7 +130,7 @@ except ImportError as e:
131
130
  raise ImportError("Error importing apps.curvedigitizer. Please check your installation.")
132
131
 
133
132
  try:
134
- from .drowning_victims.Class import Drowning_victim_Viewer
133
+ from .drowning_victims.drowning_class import Drowning_victim_Viewer
135
134
  except ImportError as e:
136
135
  print(e)
137
136
  raise ImportError("Error importing Drowning_victims.Class. Please check your installation.")
@@ -1957,6 +1956,27 @@ class WolfMapViewer(wx.Frame):
1957
1956
 
1958
1957
  active_fig: MplFigViewer
1959
1958
 
1959
+
1960
+ # def check_user_activity(self, *args):
1961
+ # while True:
1962
+ # sleep(1)
1963
+ # if datetime.now() - self._last_activity_time > timedelta(seconds=3): # 5 secondes d'inactivité
1964
+ # args[0]._user_active = False
1965
+
1966
+ # def _user_activity_true(self):
1967
+ # self._user_active = True
1968
+ # self._last_activity_time = datetime.now()
1969
+
1970
+ # def background_task(self, *args):
1971
+
1972
+ # while args[0]._user_active:
1973
+ # sleep(1)
1974
+
1975
+ # args[0]._update_background()
1976
+ # args[0].Paint()
1977
+
1978
+ # args[0]._thread_update_background = None
1979
+
1960
1980
  def __init__(self,
1961
1981
  wxparent = None,
1962
1982
  title:str = _('Default Wolf Map Viewer'),
@@ -1979,6 +1999,12 @@ class WolfMapViewer(wx.Frame):
1979
1999
 
1980
2000
  """
1981
2001
 
2002
+ # self._user_active = True # True if the user is active in the viewer
2003
+ # self._last_activity_time = datetime.now() # last time the user was active in the viewer
2004
+ # self._check_activity_thread = threading.Thread(target=self.check_user_activity, args=[self]) # thread to check user activity
2005
+ # self._check_activity_thread.start() # start the thread
2006
+ # self._thread_update_background = None # thread to update the background
2007
+
1982
2008
  self.treewidth = treewidth
1983
2009
  super(WolfMapViewer, self).__init__(wxparent, title=title, size=(w + self.treewidth, h))
1984
2010
 
@@ -4978,6 +5004,7 @@ class WolfMapViewer(wx.Frame):
4978
5004
  self.canvas.Bind(wx.EVT_RIGHT_DCLICK, self.On_Right_Double_Clicks)
4979
5005
  self.canvas.Bind(wx.EVT_LEFT_DCLICK, self.On_Left_Double_Clicks)
4980
5006
  self.canvas.Bind(wx.EVT_LEFT_DOWN, self.On_Mouse_Left_Down)
5007
+ self.canvas.Bind(wx.EVT_LEFT_UP, self.On_Mouse_Left_Up)
4981
5008
  self.canvas.Bind(wx.EVT_MIDDLE_DOWN, self.On_Mouse_Left_Down)
4982
5009
  self.canvas.Bind(wx.EVT_RIGHT_DOWN, self.On_Mouse_Right_Down)
4983
5010
  self.canvas.Bind(wx.EVT_RIGHT_UP, self.On_Mouse_Right_Up)
@@ -5255,9 +5282,8 @@ class WolfMapViewer(wx.Frame):
5255
5282
  '2019': '2019',
5256
5283
  '2020': '2020',
5257
5284
  '2021': '2021',
5258
- '2021': '2021',
5259
5285
  '2022': '2022',
5260
- }}
5286
+ }}
5261
5287
 
5262
5288
  for idx, (k, item) in enumerate(orthos.items()):
5263
5289
  for kdx, (m, subitem) in enumerate(item.items()):
@@ -11537,6 +11563,7 @@ class WolfMapViewer(wx.Frame):
11537
11563
  We use this event to manage "action" set by others objects.
11538
11564
 
11539
11565
  """
11566
+ #self._user_activity_true()
11540
11567
 
11541
11568
  pos = e.GetPosition()
11542
11569
  x, y = self.getXY(pos)
@@ -11956,6 +11983,9 @@ class WolfMapViewer(wx.Frame):
11956
11983
 
11957
11984
 
11958
11985
  def On_Mouse_Right_Up(self, e):
11986
+
11987
+ #self._user_activity_true()
11988
+
11959
11989
  pos = e.GetPosition()
11960
11990
  x, y = self.getXY(pos)
11961
11991
 
@@ -11984,6 +12014,9 @@ class WolfMapViewer(wx.Frame):
11984
12014
  pass
11985
12015
 
11986
12016
  def On_Mouse_Button(self, e: wx.MouseEvent):
12017
+
12018
+ #self._user_activity_true()
12019
+
11987
12020
  d = e.GetWheelDelta()
11988
12021
  r = e.GetWheelRotation()
11989
12022
  a = e.GetWheelAxis()
@@ -12092,6 +12125,7 @@ class WolfMapViewer(wx.Frame):
12092
12125
 
12093
12126
  def On_Mouse_Left_Down(self, e):
12094
12127
  """ Event when the left button of the mouse is pressed """
12128
+ #self._user_activity_true()
12095
12129
 
12096
12130
  # if not self.move:
12097
12131
  pos = e.GetPosition()
@@ -12099,6 +12133,14 @@ class WolfMapViewer(wx.Frame):
12099
12133
  self.mousedown = (x, y)
12100
12134
  # self.move = True
12101
12135
 
12136
+ def On_Mouse_Left_Up(self, e):
12137
+ """ Event when the left button of the mouse is released """
12138
+
12139
+ pass
12140
+ # if self._thread_update_background is None:
12141
+ # self._thread_update_background = threading.Thread(target=self.background_task, args=[self]) # thread to update the background
12142
+ # self._thread_update_background.start() # start the thread
12143
+
12102
12144
  def _set_active_bc(self):
12103
12145
  """Search and activate BCManager according to active_array"""
12104
12146
  if self.active_bc is not None:
@@ -12605,10 +12647,12 @@ class WolfMapViewer(wx.Frame):
12605
12647
 
12606
12648
  self.mytooltip.PopulateOnePage()
12607
12649
 
12608
-
12609
12650
  def On_Mouse_Motion(self, e: wx.MouseEvent):
12610
12651
  """ Mouse move event """
12611
12652
 
12653
+
12654
+ #self._user_activity_true()
12655
+
12612
12656
  # Déplacement de la souris sur le canvas OpenGL
12613
12657
  posframe = self.GetPosition() # Get the position of the frame -> useful to set the tooltip position
12614
12658
  pos = e.GetPosition() # Get the position of the mouse in the canvas
@@ -14110,20 +14154,33 @@ class WolfMapViewer(wx.Frame):
14110
14154
  self.update()
14111
14155
 
14112
14156
 
14113
- def update(self):
14157
+ def _update_background(self):
14114
14158
  """
14115
- Update backgournd et foreground elements and arrays if local minmax is checked.
14116
-
14159
+ Update background
14117
14160
  """
14118
14161
 
14119
14162
  # dessin du background
14120
14163
  for obj in self.iterator_over_objects(draw_type.WMSBACK):
14121
14164
  obj.reload()
14122
14165
 
14166
+ def _update_foreground(self):
14167
+ """
14168
+ Update foreground
14169
+ """
14123
14170
  # dessin du foreground
14124
14171
  for obj in self.iterator_over_objects(draw_type.WMSFORE):
14125
14172
  obj.reload()
14126
14173
 
14174
+ def update(self):
14175
+ """
14176
+ Update backgournd et foreground elements and arrays if local minmax is checked.
14177
+
14178
+ """
14179
+
14180
+ self._update_background()
14181
+
14182
+ self._update_foreground()
14183
+
14127
14184
  if self.locminmax.IsChecked() or self.update_absolute_minmax:
14128
14185
  for curarray in self.iterator_over_objects(draw_type.ARRAYS):
14129
14186
  curarray: WolfArray
wolfhece/PyPalette.py CHANGED
@@ -96,7 +96,10 @@ class wolfpalette(wx.Frame, LinearSegmentedColormap):
96
96
  self.set_over(tuple(self.colormax))
97
97
 
98
98
  def get_rgba(self, x: np.ndarray):
99
- """Récupération de la couleur en fonction de la valeur x"""
99
+ """Récupération de la couleur en fonction de la valeur x
100
+
101
+ :param x: tableau de valeurs
102
+ """
100
103
 
101
104
  dval = self.values[-1]-self.values[0]
102
105
  if dval == 0.:
@@ -260,6 +263,7 @@ class wolfpalette(wx.Frame, LinearSegmentedColormap):
260
263
  if self.interval_cst:
261
264
  discrete_cmap = ListedColormap(self.colorsflt[:, :3])
262
265
  colorbar = ScalarMappable(BoundaryNorm(self.values, ncolors=self.nb-1), cmap=discrete_cmap)
266
+ return colorbar
263
267
  else:
264
268
  return ScalarMappable(Normalize(self.values[0], self.values[-1]), cmap=self)
265
269
 
@@ -453,6 +457,26 @@ class wolfpalette(wx.Frame, LinearSegmentedColormap):
453
457
  ax.set_xticks(pos)
454
458
  ax.set_xticklabels(txt, rotation=30, fontsize=6)
455
459
 
460
+ @property
461
+ def cmap(self):
462
+ """ Récupération de la palette de couleurs """
463
+ return self
464
+
465
+ @property
466
+ def vmin(self):
467
+ """ Récupération de la valeur minimale """
468
+ return self.values[0]
469
+
470
+ @property
471
+ def vmax(self):
472
+ """ Récupération de la valeur maximale """
473
+ return self.values[-1]
474
+
475
+ @property
476
+ def norm(self):
477
+ """ Récupération de la normalisation """
478
+ return Normalize(self.values[0], self.values[-1])
479
+
456
480
  def fillgrid(self, gridto: CpGrid):
457
481
  """ Remplissage d'une grille avec les valeurs de la palette """
458
482
 
@@ -692,7 +716,7 @@ class wolfpalette(wx.Frame, LinearSegmentedColormap):
692
716
  normval = np.ones([len(self.values)])
693
717
 
694
718
  if dval > 0.:
695
- normval = (self.values-self.values[0])/(self.values[-1]-self.values[0])
719
+ normval = (self.values-self.values[0])/dval
696
720
 
697
721
  normval[0] = 0.
698
722
  normval[-1] = 1.
wolfhece/PyVertex.py CHANGED
@@ -822,6 +822,20 @@ class cloud_vertices(Element_To_Draw):
822
822
  # read data
823
823
  gdf:gpd.GeoDataFrame = gpd.read_file(fn, bbox=bbox)
824
824
 
825
+ if gdf is None:
826
+ logging.error(_('Error during import of shapefile : ')+fn)
827
+ return
828
+
829
+ # check if the file is empty
830
+ if gdf.empty:
831
+ logging.error(_('Imported shapefile is empty : ')+fn)
832
+ return
833
+
834
+ #check if the number of lines is > 0
835
+ if len(gdf) == 0:
836
+ logging.error(_('Imported shapefile is empty : ')+fn)
837
+ return
838
+
825
839
  # Bouclage sur les éléments du Shapefile
826
840
  if targetcolumn in gdf.columns:
827
841
  k=0
@@ -839,8 +853,7 @@ class cloud_vertices(Element_To_Draw):
839
853
  elif 'geometry' in gdf.columns:
840
854
 
841
855
  try:
842
- for k, (xx,yy) in enumerate(zip(gdf.get_coordinates()['x'], gdf.get_coordinates()['y'])):
843
-
856
+ for k, (xx,yy) in enumerate(zip(gdf.geometry.x, gdf.geometry.y)):
844
857
  curvert = wolfvertex(xx, yy)
845
858
  curdict = self.myvertices[k] = {}
846
859
  curdict['vertex'] = curvert
wolfhece/PyWMS.py CHANGED
@@ -202,7 +202,8 @@ def getLifeWatch(cat:Literal['None'],
202
202
  yr:float,
203
203
  w:int = None,
204
204
  h:int = None,
205
- tofile=True) -> BytesIO:
205
+ tofile=True,
206
+ format:Literal['image/png', 'image/png; mode=8bit']='image/png') -> BytesIO:
206
207
 
207
208
  wms=WebMapService(f'https://maps.elie.ucl.ac.be/cgi-bin/mapserv72?map=/maps_server/lifewatch/mapfiles/LW_Ecotopes/latest/{cat}.map&SERVICE=wms',
208
209
  version='1.3.0')
@@ -226,6 +227,16 @@ def getLifeWatch(cat:Literal['None'],
226
227
  # w = int(real_w * ppkm)
227
228
  h = int(real_h * ppkm)
228
229
 
230
+ MAXSIZE = 2048
231
+ if w > MAXSIZE:
232
+ pond = w / MAXSIZE
233
+ w = MAXSIZE
234
+ h = int(h / pond)
235
+ if h > MAXSIZE:
236
+ pond = h / MAXSIZE
237
+ h = MAXSIZE
238
+ w = int(w / pond)
239
+
229
240
  if tofile:
230
241
  img=wms.getmap(layers=['lc_hr_raster'],
231
242
  # styles=['default'],
@@ -250,7 +261,7 @@ def getLifeWatch(cat:Literal['None'],
250
261
  srs='EPSG:31370',
251
262
  bbox=(xl,yl,xr,yr),
252
263
  size=(w,h),
253
- format='image/png',
264
+ format=format,
254
265
  transparent=False)
255
266
  return BytesIO(img.read())
256
267
  except:
wolfhece/apps/version.py CHANGED
@@ -5,7 +5,7 @@ class WolfVersion():
5
5
 
6
6
  self.major = 2
7
7
  self.minor = 2
8
- self.patch = 3
8
+ self.patch = 5
9
9
 
10
10
  def __str__(self):
11
11