Falscher Rückgabetyp für Klasse
Verfasst: Freitag 12. Juni 2020, 10:47
Hallo zusammen,
ich versuche gerade meine Skript schöner zu machen. Hierfür habe ich eine Klasse geschrieben.
Die Methode create_bounding_geom() wird über object.create_bounding_geom() aufgerufen und lierfert ein shapely Poygon als Rückgabewert.
Als nächstes möchte ich die Methode filter_for_points() über object.filter_for_points() aufrufen und erhalte folgende Fehlermeldung:
Ich verstehe warum das nicht geht. Ich möchte gern das der Rückgabewert ein Klassen-Objekt ist und habe deshalb folgendes probiert:
Meine Frage: Wie erhalte ich als Rückgabewert ein PointCloudPreprocessing-Object.
Wäre super wenn mir jeamnd da weiterhelfen könnte.
Gruß
ich versuche gerade meine Skript schöner zu machen. Hierfür habe ich eine Klasse geschrieben.
Die Methode create_bounding_geom() wird über object.create_bounding_geom() aufgerufen und lierfert ein shapely Poygon als Rückgabewert.
Als nächstes möchte ich die Methode filter_for_points() über object.filter_for_points() aufrufen und erhalte folgende Fehlermeldung:
Code: Alles auswählen
class PointCloudPreprocessing:
def __init__(self, angle_against_true_north,rotation_direction,offset_XY,bbox_rotate=None):
self.__angle_against_true_north = angle_against_true_north
self.__rotation_direction= rotation_direction
self.__offset_XY = offset_XY
self.__bbox_rotate = bbox_rotate
Code: Alles auswählen
AttributeError: 'Polygon' object has no attribute 'filter_for_points'
Code: Alles auswählen
def create_bounding_geom(self,df,index,bauteil):
x_max,x_min = df["Max_X"][index],df["Min_X"][index]
#print(x_max,x_min)
y_max,y_min = df["Max_Y"][index],df["Min_Y"][index]
#print(y_max,y_min)
#create Point()
p_max = Point(x_max,y_max)
p_min = Point(x_min,y_min)
#create Polygon and rotate
poly = Polygon([p_max,p_min,p_max])
poly_rotate = affinity.rotate(poly,self.__angle_against_true_north*(-1),"center",use_radians=False)
#create box from rotated geometry
p1 = Point(poly_rotate.bounds[0],poly_rotate.bounds[1])
p2 = Point(poly_rotate.bounds[2],poly_rotate.bounds[3])
#print(p1.distance(p2))
if bauteil == "Stützen":
bbox = box(minx=p1.x-offsetXY_Stütze[0],miny=p1.y-offsetXY_Stütze[1],maxx=p2.x+offsetXY_Stütze[0],maxy=p2.y+offsetXY_Stütze[1])
print("Stütze")
else:
bbox = box(minx=p1.x,miny=p1.y,maxx=p2.x,maxy=p2.y)
print("Cropping Baufeld without Offset")
#rotate back the geometry to crop oriented PointCloud
self.__bbox_rotate = affinity.rotate(bbox,angle_against_true_north,"center")
return self.__bbox_rotate
Wäre super wenn mir jeamnd da weiterhelfen könnte.
Gruß