wolfhece 2.1.112__py3-none-any.whl → 2.1.114__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
@@ -6760,7 +6760,7 @@ class WolfMapViewer(wx.Frame):
6760
6760
 
6761
6761
  # Création d'une nouvelle vue
6762
6762
  newview = WolfViews(mapviewer=self)
6763
- self.add_object('array', newobj=newarray)
6763
+ self.add_object('views', newobj=newview)
6764
6764
 
6765
6765
  elif itemlabel==_('Create Wolf2D manager ...'):
6766
6766
  autoscale = False
@@ -1091,7 +1091,8 @@ class vector:
1091
1091
  mytree:TreeListCtrl
1092
1092
  myitem:TreeItemId
1093
1093
 
1094
- def __init__(self, lines:list=[], is2D=True, name='NoName', parentzone:"zone"=None, fromshapely=None) -> None:
1094
+ def __init__(self, lines:list=[], is2D=True, name='NoName',
1095
+ parentzone:"zone"=None, fromshapely=None, fromnumpy:np.ndarray = None) -> None:
1095
1096
  """
1096
1097
 
1097
1098
  :param lines: utile pour lecture de fichier
@@ -1102,8 +1103,8 @@ class vector:
1102
1103
  """
1103
1104
 
1104
1105
  self.myname=''
1105
- self.is2D = is2D
1106
- self.closed=False
1106
+ self.is2D = is2D # Force a 2D interpretation of the vertices, even if a z coordinate is present.
1107
+ self.closed=False # True if the vector is a polygon. !! The last vertex is not necessarily the same as the first one. In this case, some routines will add a virtual segment at the end. !!
1107
1108
 
1108
1109
  self.mytree = None
1109
1110
 
@@ -1172,6 +1173,9 @@ class vector:
1172
1173
  if fromshapely is not None:
1173
1174
  self.import_shapelyobj(fromshapely)
1174
1175
 
1176
+ if fromnumpy is not None:
1177
+ self.add_vertices_from_array(fromnumpy)
1178
+
1175
1179
  def set_cache(self):
1176
1180
  """ Set the cache for the vertices """
1177
1181
 
@@ -1723,7 +1727,7 @@ class vector:
1723
1727
 
1724
1728
  if is_open:
1725
1729
  self.add_vertex(self.myvertices[0])
1726
- self.closed=True
1730
+ self.closed=True
1727
1731
 
1728
1732
  def _nblines(self):
1729
1733
  """
@@ -2991,6 +2995,45 @@ class vector:
2991
2995
 
2992
2996
  return cloud_inside, cloud_outside
2993
2997
 
2998
+
2999
+ def check_if_closed(self) -> bool:
3000
+ """
3001
+ Check if the vector is closed
3002
+ """
3003
+
3004
+ return not self.check_if_open()
3005
+
3006
+
3007
+ def check_if_open(self) -> bool:
3008
+ """ Check if the vector is open """
3009
+
3010
+ is_open = not((self.myvertices[-1] is self.myvertices[0]) or \
3011
+ (self.myvertices[-1].x==self.myvertices[0].x and \
3012
+ self.myvertices[-1].y==self.myvertices[0].y))
3013
+
3014
+ if not self.is2D :
3015
+ is_open = is_open or self.myvertices[-1].z!=self.myvertices[0].z
3016
+
3017
+ self.closed = not is_open
3018
+
3019
+ return is_open
3020
+
3021
+ @property
3022
+ def surface(self):
3023
+ """
3024
+ Compute the surface of the vector
3025
+ """
3026
+
3027
+ if self.closed:
3028
+ return self.asshapely_pol().area
3029
+ else:
3030
+ return 0.
3031
+
3032
+ @property
3033
+ def area(self):
3034
+ """ Alias for surface """
3035
+ return self.surface
3036
+
2994
3037
  class zone:
2995
3038
  """
2996
3039
  Objet de gestion d'informations vectorielles
@@ -3072,6 +3115,11 @@ class zone:
3072
3115
  # Object can be created from a shapely object
3073
3116
  self.import_shapelyobj(fromshapely)
3074
3117
 
3118
+ @property
3119
+ def area(self):
3120
+ """ Compute the area of the zone """
3121
+ return sum([curvec.surface for curvec in self.myvectors])
3122
+
3075
3123
  def set_cache(self):
3076
3124
  """
3077
3125
  Set the cache for the zone and all its vectors
@@ -3436,6 +3484,11 @@ class zone:
3436
3484
 
3437
3485
  inside : True = le point est contenu ; False = le point le plus proche
3438
3486
  """
3487
+
3488
+ if self.nbvectors==0:
3489
+ logging.warning(_('No vector in zone -- {}').format(self.myname))
3490
+ return
3491
+
3439
3492
  curvect:vector
3440
3493
  self.selected_vectors.clear()
3441
3494