lits_majeur = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "lit_majeur.shp"), "lit_majeur_PolyXY", True, 5)
iles = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "ile.shp"), "ile_PolyXY", True, 4)
-Cloud_02 = importBathymetry(hydro_doc, "Cloud_02", HYDRO_SAMPLES)
-garonne_point_L93 = importBathymetry(hydro_doc, "garonne_point_L93", HYDRO_SAMPLES)
+Cloud_02 = importBathymetry(hydro_doc, os.path.join(HYDRO_SAMPLES, "Cloud_02.xyz"))
+garonne_point_L93 = importBathymetry(hydro_doc, os.path.join(HYDRO_SAMPLES, "garonne_point_L93.xyz"))
domaineEtendu = createImmersibleZone(hydro_doc, "domaineEtendu", limites_domaine[0], Cloud_02, True, 0)
litMineur = createImmersibleZone(hydro_doc, "litMineur", garonnes[0], garonne_point_L93, True, 2)
limites_amont = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "domaineAmont.shp"), "domaineAmont_PolyXY", False, 4)
garonnes_amont = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "garonneAmont.shp"), "garonneAmont_PolyXY", True, 3)
-Cloud_02 = importBathymetry(hydro_doc, "Cloud_02", HYDRO_SAMPLES)
-garonne_point_L93 = importBathymetry(hydro_doc, "garonne_point_L93", HYDRO_SAMPLES)
+Cloud_02 = importBathymetry(hydro_doc, os.path.join(HYDRO_SAMPLES, "Cloud_02.xyz"))
+garonne_point_L93 = importBathymetry(hydro_doc, os.path.join(HYDRO_SAMPLES, "garonne_point_L93.xyz"))
domaine_amont = createImmersibleZone(hydro_doc, "domaine_amont", limites_amont[0], Cloud_02, True, 0)
garonne_amont = createImmersibleZone(hydro_doc, "garonne_amont", garonnes_amont[0], garonne_point_L93, True, 0)
limites_amont = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "domaineAmontChevauchant.shp"), "domaineAmontChevauchant_PolyXY", False, 4)
garonnes_amont = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "garonneAmont.shp"), "garonneAmont_PolyXY", True, 3)
-Cloud_02 = importBathymetry(hydro_doc, "Cloud_02", HYDRO_SAMPLES)
-garonne_point_L93 = importBathymetry(hydro_doc, "garonne_point_L93", HYDRO_SAMPLES)
+Cloud_02 = importBathymetry(hydro_doc, os.path.join(HYDRO_SAMPLES, "Cloud_02.xyz"))
+garonne_point_L93 = importBathymetry(hydro_doc, os.path.join(HYDRO_SAMPLES, "garonne_point_L93.xyz"))
domaine_amont = createImmersibleZone(hydro_doc, "domaine_amont", limites_amont[0], Cloud_02, True, 0)
garonne_amont = createImmersibleZone(hydro_doc, "garonne_amont", garonnes_amont[0], garonne_point_L93, True, 0)
limites_domaine = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "domaine.shp"), "domaine_PolyXY", False, 6)
lits_majeur = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "lit_majeur.shp"), "lit_majeur_PolyXY", True, 7)
-Cloud_02 = importBathymetry(hydro_doc, "Cloud_02", HYDRO_SAMPLES)
-garonne_point_L93 = importBathymetry(hydro_doc, "garonne_point_L93", HYDRO_SAMPLES)
+Cloud_02 = importBathymetry(hydro_doc, os.path.join(HYDRO_SAMPLES, "Cloud_02.xyz"))
+garonne_point_L93 = importBathymetry(hydro_doc, os.path.join(HYDRO_SAMPLES, "garonne_point_L93.xyz"))
domaineEtendu = createImmersibleZone(hydro_doc, "domaineEtendu", limites_domaine[0], Cloud_02, True, 2)
litMajeur = createImmersibleZone(hydro_doc, "litMajeur", lits_majeur[0], garonne_point_L93, True, 3)
limites_domaine = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "domaine.shp"), "domaine_PolyXY", False, 6)
lits_majeur = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "lit_majeur.shp"), "lit_majeur_PolyXY", True, 7)
-Cloud_02 = importBathymetry(hydro_doc, "Cloud_02", HYDRO_SAMPLES)
-garonne_point_L93 = importBathymetry(hydro_doc, "garonne_point_L93", HYDRO_SAMPLES)
+Cloud_02 = importBathymetry(hydro_doc, os.path.join(HYDRO_SAMPLES, "Cloud_02.xyz"))
+garonne_point_L93 = importBathymetry(hydro_doc, os.path.join(HYDRO_SAMPLES, "garonne_point_L93.xyz"))
domaineEtendu = createImmersibleZone(hydro_doc, "domaineEtendu", limites_domaine[0], Cloud_02, True, 2)
litMajeur = createImmersibleZone(hydro_doc, "litMajeur", lits_majeur[0], garonne_point_L93, True, 3)
limites_domaine = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "domaine.shp"), "domaine_PolyXY", False, 6)
lits_majeur = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "lit_majeur.shp"), "lit_majeur_PolyXY", True, 7)
-Cloud_02 = importBathymetry(hydro_doc, "Cloud_02", HYDRO_SAMPLES)
-garonne_point_L93 = importBathymetry(hydro_doc, "garonne_point_L93", HYDRO_SAMPLES)
+Cloud_02 = importBathymetry(hydro_doc, os.path.join(HYDRO_SAMPLES, "Cloud_02.xyz"))
+garonne_point_L93 = importBathymetry(hydro_doc, os.path.join(HYDRO_SAMPLES, "garonne_point_L93.xyz"))
domaineEtendu = createImmersibleZone(hydro_doc, "domaineEtendu", limites_domaine[0], Cloud_02, True, 2)
litMajeur = createImmersibleZone(hydro_doc, "litMajeur", lits_majeur[0], garonne_point_L93, True, 3)
lits_majeur = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "lit_majeur.shp"), "lit_majeur_PolyXY", True, 8)
axesDigue = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "axeDigue.shp"), "axeDigue_PolyXY", True, 9)
-Cloud_02 = importBathymetry(hydro_doc, "Cloud_02", HYDRO_SAMPLES)
-garonne_point_L93 = importBathymetry(hydro_doc, "garonne_point_L93", HYDRO_SAMPLES)
+Cloud_02 = importBathymetry(hydro_doc, os.path.join(HYDRO_SAMPLES, "Cloud_02.xyz"))
+garonne_point_L93 = importBathymetry(hydro_doc, os.path.join(HYDRO_SAMPLES, "garonne_point_L93.xyz"))
domaineEtendu = createImmersibleZone(hydro_doc, "domaineEtendu", limites_domaine[0], Cloud_02, True, 2)
litMajeur = createImmersibleZone(hydro_doc, "litMajeur", lits_majeur[0], garonne_point_L93, True, 3)
lits_majeur = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "lit_majeur.shp"), "lit_majeur_PolyXY", True, 8)
axesDigue = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "axeDigue.shp"), "axeDigue_PolyXY", True, 9)
-Cloud_02 = importBathymetry(hydro_doc, "Cloud_02", HYDRO_SAMPLES)
-garonne_point_L93 = importBathymetry(hydro_doc, "garonne_point_L93", HYDRO_SAMPLES)
+Cloud_02 = importBathymetry(hydro_doc, os.path.join(HYDRO_SAMPLES, "Cloud_02.xyz"))
+garonne_point_L93 = importBathymetry(hydro_doc, os.path.join(HYDRO_SAMPLES, "garonne_point_L93.xyz"))
domaineEtendu = createImmersibleZone(hydro_doc, "domaineEtendu", limites_domaine[0], Cloud_02, True, 2)
litMajeur = createImmersibleZone(hydro_doc, "litMajeur", lits_majeur[0], garonne_point_L93, True, 3)
lits_majeur = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "lit_majeur.shp"), "lit_majeur_PolyXY", True, 8)
axesDigue = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "axeDigue.shp"), "axeDigue_PolyXY", True, 9)
-Cloud_02 = importBathymetry(hydro_doc, "Cloud_02", HYDRO_SAMPLES)
-garonne_point_L93 = importBathymetry(hydro_doc, "garonne_point_L93", HYDRO_SAMPLES)
+Cloud_02 = importBathymetry(hydro_doc, os.path.join(HYDRO_SAMPLES, "Cloud_02.xyz"))
+garonne_point_L93 = importBathymetry(hydro_doc, os.path.join(HYDRO_SAMPLES, "garonne_point_L93.xyz"))
domaineEtendu = createImmersibleZone(hydro_doc, "domaineEtendu", limites_domaine[0], Cloud_02, True, 2)
litMajeur = createImmersibleZone(hydro_doc, "litMajeur", lits_majeur[0], garonne_point_L93, True, 3)
limites_domaine = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "domaine.shp"), "domaine_PolyXY", False, 6)
lits_majeur = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "lit_majeur.shp"), "lit_majeur_PolyXY", True, 7)
-Cloud_02 = importBathymetry(hydro_doc, "Cloud_02", HYDRO_SAMPLES)
-garonne_point_L93 = importBathymetry(hydro_doc, "garonne_point_L93", HYDRO_SAMPLES)
+Cloud_02 = importBathymetry(hydro_doc, os.path.join(HYDRO_SAMPLES, "Cloud_02.xyz"))
+garonne_point_L93 = importBathymetry(hydro_doc, os.path.join(HYDRO_SAMPLES, "garonne_point_L93.xyz"))
domaineEtendu = createImmersibleZone(hydro_doc, "domaineEtendu", limites_domaine[0], Cloud_02, True, 2)
litMajeur = createImmersibleZone(hydro_doc, "litMajeur", lits_majeur[0], garonne_point_L93, True, 3)
limites_domaine = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "domaine.shp"), "domaine_PolyXY", False, 6)
lits_majeur = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "lit_majeur.shp"), "lit_majeur_PolyXY", True, 7)
-Cloud_02 = importBathymetry(hydro_doc, "Cloud_02", HYDRO_SAMPLES)
-garonne_point_L93 = importBathymetry(hydro_doc, "garonne_point_L93", HYDRO_SAMPLES)
+Cloud_02 = importBathymetry(hydro_doc, os.path.join(HYDRO_SAMPLES, "Cloud_02.xyz"))
+garonne_point_L93 = importBathymetry(hydro_doc, os.path.join(HYDRO_SAMPLES, "garonne_point_L93.xyz"))
domaineEtendu = createImmersibleZone(hydro_doc, "domaineEtendu", limites_domaine[0], Cloud_02, True, 2)
litMajeur = createImmersibleZone(hydro_doc, "litMajeur", lits_majeur[0], garonne_point_L93, True, 3)
limites_domaine = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "domaine.shp"), "domaine_PolyXY", False, 6)
lits_majeur = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "lit_majeur.shp"), "lit_majeur_PolyXY", True, 7)
-Cloud_02 = importBathymetry(hydro_doc, "Cloud_02", HYDRO_SAMPLES)
-garonne_point_L93 = importBathymetry(hydro_doc, "garonne_point_L93", HYDRO_SAMPLES)
+Cloud_02 = importBathymetry(hydro_doc, os.path.join(HYDRO_SAMPLES, "Cloud_02.xyz"))
+garonne_point_L93 = importBathymetry(hydro_doc, os.path.join(HYDRO_SAMPLES, "garonne_point_L93.xyz"))
domaineEtendu = createImmersibleZone(hydro_doc, "domaineEtendu", limites_domaine[0], Cloud_02, True, 2)
litMajeur = createImmersibleZone(hydro_doc, "litMajeur", lits_majeur[0], garonne_point_L93, True, 3)
limites_original = importPolylines(hydro_doc, os.path.join(tmpdir, "garonne_2_brd_FreeBorders.shp"), 'garonne_2_brd_FreeBorders', True, 4)
limites_domaine = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "extension_1_1.shp"), 'extension_1_1_PolyXY', False, 2)
-Cloud_02 = importBathymetry(hydro_doc, "Cloud_02", HYDRO_SAMPLES)
+Cloud_02 = importBathymetry(hydro_doc, os.path.join(HYDRO_SAMPLES, "Cloud_02.xyz"))
domaine_original = createImmersibleZone(hydro_doc, "domaine_original", limites_original[0], Cloud_02, False, 1)
domaine_englobant = createImmersibleZone(hydro_doc, "domaine_englobant", limites_domaine[0], Cloud_02, True, 0)
limite_extension = mergePolylines(hydro_doc, 'limite_extension', [limites_original[0], limites_domaine[0]])
-Cloud_02 = importBathymetry(hydro_doc, "Cloud_02", HYDRO_SAMPLES)
+Cloud_02 = importBathymetry(hydro_doc, os.path.join(HYDRO_SAMPLES, "Cloud_02.xyz"))
domaine_extension = createImmersibleZone(hydro_doc, "domaine_extension", limite_extension, Cloud_02, True, 0)
limite_extension = mergePolylines(hydro_doc, 'limite_extension', [limites_original[1], limites_domaine[1]])
-Cloud_02 = importBathymetry(hydro_doc, "Cloud_02", HYDRO_SAMPLES)
+Cloud_02 = importBathymetry(hydro_doc, os.path.join(HYDRO_SAMPLES, "Cloud_02.xyz"))
domaine_extension = createImmersibleZone(hydro_doc, "domaine_extension", limite_extension, Cloud_02, True, 0)
limite_extension = mergePolylines(hydro_doc, 'limite_extension', [limites_original[0], limites_domaine[0]])
-Cloud_02 = importBathymetry(hydro_doc, "Cloud_02", HYDRO_SAMPLES)
+Cloud_02 = importBathymetry(hydro_doc, os.path.join(HYDRO_SAMPLES, "Cloud_02.xyz"))
domaine_extension = createImmersibleZone(hydro_doc, "domaine_extension", limite_extension, Cloud_02, True, 0)
limite_extension = mergePolylines(hydro_doc, 'limite_extension', [limites_original[0], limites_domaine[1]])
-Cloud_02 = importBathymetry(hydro_doc, "Cloud_02", HYDRO_SAMPLES)
+Cloud_02 = importBathymetry(hydro_doc, os.path.join(HYDRO_SAMPLES, "Cloud_02.xyz"))
domaine_extension = createImmersibleZone(hydro_doc, "domaine_extension", limite_extension, Cloud_02, True, 0)
limites_amont = importPolylines(hydro_doc, os.path.join(tmpdir, "garonneAmont_brd_FreeBorders.shp"), 'garonneAmont_brd_FreeBorders', True, 5)
limites_domaine = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "raccord_4_2.shp"), 'raccord_4_2_PolyXY', False, 3)
-Cloud_02 = importBathymetry(hydro_doc, "Cloud_02", HYDRO_SAMPLES)
+Cloud_02 = importBathymetry(hydro_doc, os.path.join(HYDRO_SAMPLES, "Cloud_02.xyz"))
domaine_regroup = createImmersibleZone(hydro_doc, "domaine_regroup", limites_domaine[0], Cloud_02, True, 0)
domaine_original = createImmersibleZone(hydro_doc, "domaine_original", limites_original[0], Cloud_02, False, 1)
limites_amont = importPolylines(hydro_doc, os.path.join(tmpdir, "garonneAmont_brd_FreeBorders.shp"), 'garonneAmont_brd_FreeBorders', True, 5)
limites_domaine = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "raccord_4_2.shp"), 'raccord_4_2_PolyXY', False, 3)
-Cloud_02 = importBathymetry(hydro_doc, "Cloud_02", HYDRO_SAMPLES)
+Cloud_02 = importBathymetry(hydro_doc, os.path.join(HYDRO_SAMPLES, "Cloud_02.xyz"))
domaine_regroup = createImmersibleZone(hydro_doc, "domaine_regroup", limites_domaine[0], Cloud_02, True, 0)
domaine_original = createImmersibleZone(hydro_doc, "domaine_original", limites_original[0], Cloud_02, False, 1)
limites_amont = importPolylines(hydro_doc, os.path.join(tmpdir, "garonneAmont_brd_FreeBorders.shp"), 'garonneAmont_brd_FreeBorders', False, 5)
limites_domaine = importPolylines(hydro_doc, os.path.join(tmpdir, "raccord_4_1_adj_adj.shp"), 'raccord_4_1_adj', False, 2)
-Cloud_02 = importBathymetry(hydro_doc, "Cloud_02", HYDRO_SAMPLES)
+Cloud_02 = importBathymetry(hydro_doc, os.path.join(HYDRO_SAMPLES, "Cloud_02.xyz"))
junction = createImmersibleZone(hydro_doc, "junction", limites_domaine[0], Cloud_02, True, 0)
garonneAval = createImmersibleZone(hydro_doc, "garonneAval", limites_aval[0], Cloud_02, False, 0)
limites_original = importPolylines(hydro_doc, os.path.join(tmpdir, "garonne_2_cut_brd_FreeBorders.shp"), 'garonne_2_cut_brd_FreeBorders', False, 4)
[nouvelle_digue] = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "nouvelleDigue.shp"), 'nouvelleDigue_PolyXY', True, 4)
-Cloud_02 = importBathymetry(hydro_doc, "Cloud_02", HYDRO_SAMPLES)
+Cloud_02 = importBathymetry(hydro_doc, os.path.join(HYDRO_SAMPLES, "Cloud_02.xyz"))
domaine_nouveau = createImmersibleZone(hydro_doc, "domaine_nouveau", limites_original[2], Cloud_02, True, 0)
ile = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "ile.shp"), 'ile_PolyXY', True, 4)
domaine = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "domaine.shp"), 'domaine_PolyXY', False, 5)
-Cloud_02 = importBathymetry(hydro_doc, "Cloud_02", HYDRO_SAMPLES)
-garonne_point_L93 = importBathymetry(hydro_doc, "garonne_point_L93", HYDRO_SAMPLES)
+Cloud_02 = importBathymetry(hydro_doc, os.path.join(HYDRO_SAMPLES, "Cloud_02.xyz"))
+garonne_point_L93 = importBathymetry(hydro_doc, os.path.join(HYDRO_SAMPLES, "garonne_point_L93.xyz"))
litMineur = createImmersibleZone(hydro_doc, "litMineur", garonne[0], Cloud_02, True, 6)
litMajeur = createImmersibleZone(hydro_doc, "litMajeur", lit_majeur[0], garonne_point_L93, True, 5)
ile = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "ile.shp"), 'ile_PolyXY', True, 4)
domaine = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "domaine.shp"), 'domaine_PolyXY', False, 5)
-Cloud_02 = importBathymetry(hydro_doc, "Cloud_02", HYDRO_SAMPLES)
-garonne_point_L93 = importBathymetry(hydro_doc, "garonne_point_L93", HYDRO_SAMPLES)
+Cloud_02 = importBathymetry(hydro_doc, os.path.join(HYDRO_SAMPLES, "Cloud_02.xyz"))
+garonne_point_L93 = importBathymetry(hydro_doc, os.path.join(HYDRO_SAMPLES, "garonne_point_L93.xyz"))
litMineur = createImmersibleZone(hydro_doc, "litMineur", garonne[0], Cloud_02, True, 6)
litMajeur = createImmersibleZone(hydro_doc, "litMajeur", lit_majeur[0], garonne_point_L93, True, 5)
from PyQt5.QtCore import *
from PyQt5.QtGui import *
-from salome.hydrotools.hydroGeoMeshUtils import importPolylines, splitShapesAll
+from salome.hydrotools.hydroGeoMeshUtils import importPolylines, splitShapesAll, splitShapeTool
hydro_doc = HYDROData_Document.Document()
hydro_doc.SetLocalCS( offsetX, offsetY )
shapeList = splitShapesAll(hydro_doc, seq)
if len(shapeList) != 8:
raise ValueError("Bad nunber of shapes after splitShapesAll, found %d instead of 8"%len(shapeList))
+
seq2 = contours + lm2s
shapeList2 = splitShapesAll(hydro_doc, seq2)
if len(shapeList2) != 16:
raise ValueError("Bad nunber of shapes after splitShapesAll, found %d instead of 16"%len(shapeList2))
+
seq3 = contours + lm2s + lmajeurs + openPolys
shapeList3 = splitShapesAll(hydro_doc, seq3)
if len(shapeList3) != 89:
raise ValueError("Bad nunber of shapes after splitShapesAll, found %d instead of 89"%len(shapeList3))
+shapeList4 = splitShapeTool(hydro_doc, lmajeurs[0], contours[0])
+if len(shapeList4) != 4:
+ raise ValueError("Bad nunber of shapes after splitShapeTool, found %d instead of 4"%len(shapeList4))
+
if salome.sg.hasDesktop():
salome.sg.updateObjBrowser()
def getChildrenInStudy(obj):
"""
Given an object published in SALOME study (for instance a GEOM object), retreive its children.
- return a dictionary [name] --> object
+ parameters:
+ obj: a SALOME object published in SALOME study
+ return:
+ a dictionary [name] --> object
"""
SO = salome.myStudy.FindObjectIOR(salome.myStudy.ConvertObjectToIOR(obj))
childIterator = salome.myStudy.NewChildIterator(SO)
def loadImage(document, imageFile, imageName, displayLevel):
"""
+ load an image (photo, map...) in order to georeference it and use it as background for drawing shapes
+ parameters:
+ document: current HYDROData document
+ imageFile: full path of the image file to load
+ imageName: name to give to the object loaded in the HYDRO document
+ displayLevel: integer >=0, the higher levels are displayed on top
+ return:
+ the object image loaded
"""
image = document.CreateObject(KIND_IMAGE)
image.SetName(imageName)
def GeolocaliseImageCoords(image, a, b, c ,d):
"""
+ Geolocalize a loaded image with to sets of points: pixels coordinates <--> absolutes coordinates in the geographic reference system.
+ parameters:
+ image: loaded image to localize
+ a: first pixel coordinates QPoint(x, y) (integers)
+ b: second pixel coordinates QPoint(x, y) (integers)
+ c: first geographic point QPointF(X, Y) (floats)
+ d: second geographic point QPointF(X, Y) (floats)
"""
image.SetLocalPoints(a, b)
image.SetGlobalPoints(1, c, d)
def GeolocaliseImageReference(image, imageRef, a, b, c ,d):
"""
+ Geolocalize an image using another one already localized, with two pair of corresponding pixels on the images
+ parameters:
+ image: loaded image to localize
+ imageRef: loaded image used as a reference
+ a, b : pixel coordinates on the image to localize QPoint(x, y) (integers)
+ c, d : pixel coordinates on the reference image QPoint(x, y) (integers)
"""
image.SetLocalPoints(a, b)
image.SetGlobalPoints(3, c, d)
def importPolylines(document, shapeFile, shapeName, iSpline, displayLevel):
"""
+ Import a QGis shape (*.shp) containing one or several 2D polylines or polygons.
+ The polyline is either named from its name in the shape database if existing, or using the shapefile basename
+ with a suffix '_PolyXY'.
+ In case of several polylines, name are suffixed in sequence with '_n'.
+ parameters:
+ document: current HYDROData document
+ shapeFile: full path of the shapefile (*.shp)
+ shapeName: used to retrieve the objects in the HYDRO document: see above, name is given without the sequence suffix
+ isSpline: boolean to convert the polylines in splines
+ displayLevel: integer >=0, the higher levels are displayed on top
+ return:
+ list of shape objects
"""
HYDROData_PolylineXY.ImportShapesFromFile(shapeFile)
shapeType = 0 # polyline
shapes.append(shape)
return shapes
+def splitShapeTool(document, aShape, toolShape, tolerance=1.e-2):
+ """
+ Split the shape (2D polyline or spline) by the shape tool.
+ return a list of all the split shapes, named after their original shape name, with a sequence suffix _n
+ parameters;
+ document: current HYDROData document
+ aShape: a loaded shape (2D polyline or spline)
+ toolShape: a loaded shape (2D polyline or spline)
+ tolerance: used by the algorithm to detect intersections, default value 1.e-2
+ return:
+ a list of all the split shapes, named after their original shape name, with a sequence suffix _n
+ """
+ name = aShape.GetName()
+ existingNbSplit = {}
+ index = 1
+ found = True
+ while found:
+ nameIndex = name + "_%d"%(index)
+ shape = document.FindObjectByName(nameIndex)
+ if shape is None:
+ found = False
+ else:
+ index = index + 1
+ existingNbSplit[name] = index
+ print(existingNbSplit)
+
+ op = HYDROData_PolylineOperator()
+ op.SplitTool(document, aShape, toolShape, tolerance)
+
+ listSplit = []
+ index = existingNbSplit[name]
+ found = True
+ while found:
+ nameIndex = name + "_%d"%(index)
+ shape = document.FindObjectByName(nameIndex)
+ if shape is None:
+ found = False
+ else:
+ print("found %s"%nameIndex)
+ index = index + 1
+ listSplit.append(shape)
+ return listSplit
+
def splitShapesAll(document, shapeslist, precision=1.E-2):
"""
- Split all the shapes in the list by all the other shapes.
- return a list of all the other shapes, named after their original shape name, with a sequence suffix _n
+ Split all the shapes (2D polylines or splines) in the list by all the other shapes.
+ return a list of all the split shapes, named after their original shape name, with a sequence suffix _n
+ parameters;
+ document: current HYDROData document
+ shapeslist: a list of loaded shapes (2D polylines or splines)
+ precision: used by the algorithm to detect intersections, default value 1.e-2
+ return:
+ a list of all the split shapes, named after their original shape name, with a sequence suffix _n
"""
names = [s.GetName() for s in shapeslist]
print(existingNbSplit)
op = HYDROData_PolylineOperator()
- op.SplitAll(document, shapeslist, 1.E-2)
+ op.SplitAll(document, shapeslist, precision)
listSplit = []
for name in names:
return listSplit
-def importBathymetry(document, bathyName, bathyPath):
+def importBathymetry(document, bathyFile):
"""
+ import a bathymetry file (*.xyz or *.asc)
+ parameters:
+ document: current HYDROData document
+ bathyFile: full path of the bathymetry (*.xyz or *.shp)
+ return:
+ the bathymetry object
"""
bathy = document.CreateObject(KIND_BATHYMETRY)
+ a = os.path.splitext(bathyFile)
+ bathyName = os.path.basename(a[0])
bathy.SetName(bathyName)
bathy.SetAltitudesInverted(0)
- if not(bathy.ImportFromFile( os.path.join(bathyPath, bathyName + '.xyz' ))):
+ if not(bathy.ImportFromFile(bathyFile)):
raise ValueError('problem while loading bathymetry')
bathy.Update()
return bathy
def createImmersibleZone(document, imzName, polyLine, bathy, isImmersible, displayLevel):
"""
+ Create an immersible or unsubmersible zone with a closed polyline and a bathymetry.
+ parameters:
+ document: current HYDROData document
+ imzName: the name to give to the zone object
+ polyline: the closed 2D polyline or spline delimiting the zone
+ bathy: the bathymetry to associate to the zone
+ isImmersible: boolean
+ displayLevel: integer >=0, the higher levels are displayed on top
+ return:
+ the zone created
"""
imz = document.CreateObject(KIND_IMMERSIBLE_ZONE)
imz.SetName(imzName)
def mergePolylines(document, polyName, polyLines, isConnectedBySegment = False, tolerance = 1.E-3):
"""
+ Regroup several 2D polylines or spline in one, with several sections
+ parameters:
+ document: current HYDROData document
+ polyName: name to give to the new object
+ polyLines: a list of loaded shapes (2D polylines or splines)
+ isConnectedBySegment: boolean, to add a segment connecting the polylines, default False
+ tolerance: used by the algorithm to detect coincidences, default 1.E-3
+ return:
+ the merged polyline
"""
op=HYDROData_PolylineOperator()
op.Merge(document, polyName, polyLines, isConnectedBySegment, tolerance)
def createAxis3DDEmbankmentAltiProfile(document, axis3DName, axisXY, altiPts):
"""
+ Create a 3D polyline to be used as an axis for an embankement, using a 2D axis and a list of altitudes along the axis.
+ parameters:
document: current HYDROData_Document
axis3DName: name to give to the axis3D created
- axisXY: imported polyline, Embankment line
- altiPts: list of tuples(x, h) : parametric coordinate, altitude, along the axis
- return altiProfile, axis3D
+ axisXY: 2D polyline (spline), Embankment line
+ altiPts: list of tuples(x, h) : parametric coordinate, altitude, along the axisXY
+ return:
+ altiProfile, axis3D
"""
altiProfile = document.CreateObject(KIND_PROFILE)
altiProfile.SetName("%s_altiProfile"%axis3DName)
def createAxis3DDEmbankmentBathy(document, axis3DName, axisXY, aCloud):
"""
+ Create a 3D polyline to be used as an axis for an embankement, using a 2D axis and a bathymetry to project the axis.
+ parameters:
document: current HYDROData_Document
axis3DName: name to give to the axis3D created
axisXY: imported polyline, Embankment line
aCloud: altimetry, for projection of axisXY
- return altiProfile, axis3D
+ return:
+ altiProfile, axis3D
"""
altiProfile = document.CreateObject(KIND_PROFILE)
altiProfile.SetName("%s_altiProfile"%axis3DName)
def createEmbankmentSectionA(document, embankmentName, axis3D, sectionPoints, d, displayLevel):
"""
+ Define the section of an embankement and extrude it along a 3D axis. Section is defined with a list of points (axis distance, altitude).
+ parameters:
document: current HYDROData_Document
embankmentName: name to give to the embankment
axis3D: the 3D axis of the embankment
sectionPoints: a list of tuple (x, h) to define a half section, beginning to x=0 (center)
d calculation parameter, take 2 or 3 times the section width
displayLevel : z level for 2D representation: high values are drawn above low values
- return section, embankment
+ return:
+ section, embankment
"""
section = document.CreateObject(KIND_PROFILE)
section.SetName("%s_section"%embankmentName)
def createEmbankmentSectionB(document, embankmentName, axis3D, LC,DZ,CZ, d, displayLevel):
"""
+ Define the section of an embankement and extrude it along a 3D axis. Section is defined with a width, an height, the position of the axis.
+ parameters:
document: current HYDROData_Document
embankmentName: name to give to the embankment
axis3D: the 3D axis of the embankment
LC, DZ, CZ: width, height, height offset above axis3D
d calculation parameter, take 2 or 3 times the section width
displayLevel : z level for 2D representation: high values are drawn above low values
- return embankment
+ return:
+ embankment
"""
embankment = document.CreateObject(KIND_DIGUE)
embankment.SetName(embankmentName)