wolfhece 2.1.21__py3-none-any.whl → 2.1.23__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.
@@ -1172,6 +1172,22 @@ class vector:
1172
1172
 
1173
1173
  coords=self.asnparray()
1174
1174
  return Polygon(coords)
1175
+
1176
+ def asshapely_pol3D(self) -> Polygon:
1177
+ """
1178
+ Conversion des coordonnées en Polygon Shapely
1179
+ """
1180
+
1181
+ coords=self.asnparray3d()
1182
+ return Polygon(coords)
1183
+
1184
+ def asshapely_ls3d(self) -> LineString:
1185
+ """
1186
+ Conversion des coordonnées en Linestring Shapely
1187
+ """
1188
+
1189
+ coords=self.asnparray3d()
1190
+ return LineString(coords)
1175
1191
 
1176
1192
  def asshapely_ls(self) -> LineString:
1177
1193
  """
@@ -3967,7 +3983,12 @@ class Zones(wx.Frame, Element_To_Draw):
3967
3983
  return len(self.myzones)
3968
3984
 
3969
3985
  def import_shapefile(self, fn:str, bbox:Polygon = None):
3970
- """ Import shapefile by using geopandas """
3986
+ """
3987
+ Import shapefile by using geopandas
3988
+
3989
+ Shapefile == 1 zone
3990
+
3991
+ """
3971
3992
 
3972
3993
  content = gpd.read_file(fn, bbox=bbox)
3973
3994
 
@@ -3987,6 +4008,60 @@ class Zones(wx.Frame, Element_To_Draw):
3987
4008
  newzone = zone(name=name, parent = self, fromshapely = poly)
3988
4009
  self.add_zone(newzone)
3989
4010
 
4011
+ def export_to_shapefile(self, filename:str):
4012
+ """
4013
+ Export to shapefile.
4014
+
4015
+ The first vector of each zone will be exported.
4016
+
4017
+ If you want to export all vectors, you have to use "export_shape" of the zone object.
4018
+
4019
+ FIXME: Add support of data fields
4020
+ """
4021
+
4022
+ import geopandas as gpd
4023
+
4024
+ names=[]
4025
+ geoms=[]
4026
+
4027
+ # One zone is a polygon
4028
+ for curzone in self.myzones:
4029
+ if curzone.nbvectors == 0:
4030
+ logging.warning(_('Zone {} contains no vector'.format(curzone.myname)))
4031
+ continue
4032
+
4033
+ elif curzone.nbvectors>1:
4034
+ logging.warning(_('Zone {} contains more than one vector -- only the first one will be exported'.format(curzone.myname)))
4035
+
4036
+ names.append(curzone.myname)
4037
+ for curvect in curzone.myvectors[:1]:
4038
+ if curvect.is2D:
4039
+ if curvect.closed:
4040
+ geoms.append(curvect.asshapely_pol())
4041
+ else:
4042
+ geoms.append(curvect.asshapely_ls())
4043
+ else:
4044
+ if curvect.closed:
4045
+ geoms.append(curvect.asshapely_pol3D())
4046
+ else:
4047
+ geoms.append(curvect.asshapely_ls3d())
4048
+
4049
+ gdf = gpd.GeoDataFrame({'id':names,'geometry':geoms})
4050
+ gdf.crs = 'EPSG:31370'
4051
+
4052
+ gdf.to_file(filename)
4053
+
4054
+ def export_active_zone_to_shapefile(self, filename:str):
4055
+ """
4056
+ Export the active_zone to shapefile.
4057
+ """
4058
+
4059
+ if self.active_zone is None:
4060
+ logging.warning(_('No active zone'))
4061
+ return
4062
+
4063
+ self.active_zone.export_shape(filename)
4064
+
3990
4065
  def import_gdb(self, fn:str, bbox:Polygon = None):
3991
4066
  """ Import gdb by using geopandas and Fiona"""
3992
4067
 
@@ -4302,7 +4377,7 @@ class Zones(wx.Frame, Element_To_Draw):
4302
4377
  """
4303
4378
  self.plotted = False
4304
4379
 
4305
- def saveas(self, filename=''):
4380
+ def saveas(self, filename:str=''):
4306
4381
  """
4307
4382
  Sauvegarde sur disque
4308
4383
 
@@ -4313,18 +4388,22 @@ class Zones(wx.Frame, Element_To_Draw):
4313
4388
  if filename!='':
4314
4389
  self.filename=filename
4315
4390
 
4316
- if self.filename.endswith('.vecz'):
4317
- self.force3D=True #on veut un fichier 3D --> forcage du paramètre
4391
+ if self.filename.endswith('.shp'):
4392
+ self.export_to_shapefile(self.filename)
4318
4393
 
4319
- with open(self.filename, 'w') as f:
4320
- f.write(f'{self.tx} {self.ty}'+'\n')
4321
- f.write(str(self.nbzones)+'\n')
4322
- for curzone in self.myzones:
4323
- curzone.save(f)
4394
+ else:
4395
+ if self.filename.endswith('.vecz'):
4396
+ self.force3D=True #on veut un fichier 3D --> forcage du paramètre
4324
4397
 
4325
- with open(self.filename + '.extra', 'w') as f:
4326
- for curzone in self.myzones:
4327
- curzone.save_extra(f)
4398
+ with open(self.filename, 'w') as f:
4399
+ f.write(f'{self.tx} {self.ty}'+'\n')
4400
+ f.write(str(self.nbzones)+'\n')
4401
+ for curzone in self.myzones:
4402
+ curzone.save(f)
4403
+
4404
+ with open(self.filename + '.extra', 'w') as f:
4405
+ for curzone in self.myzones:
4406
+ curzone.save_extra(f)
4328
4407
 
4329
4408
  def OnClose(self, e):
4330
4409
  """
wolfhece/apps/version.py CHANGED
@@ -5,7 +5,7 @@ class WolfVersion():
5
5
 
6
6
  self.major = 2
7
7
  self.minor = 1
8
- self.patch = 21
8
+ self.patch = 23
9
9
 
10
10
  def __str__(self):
11
11
 
File without changes