forked from AG_QGIS/Plugin_SN_Basis
Wrappe modular aufgebaut, Tests erfolgreich, Menüleiste und Werzeugleiste werden eingetragen (QT6 und QT5)- (Es fehlen noch Fachplugins, um zu prüfen, ob es auch wirklich in QGIS geht)
This commit is contained in:
57
functions/ly_geometry_wrapper.py
Normal file
57
functions/ly_geometry_wrapper.py
Normal file
@@ -0,0 +1,57 @@
|
||||
# sn_basis/functions/ly_geometry_wrapper.py
|
||||
|
||||
def get_layer_geometry_type(layer) -> str:
|
||||
if layer is None:
|
||||
return "None"
|
||||
|
||||
geometry_type = getattr(layer, "geometry_type", None)
|
||||
if geometry_type is not None:
|
||||
return str(geometry_type)
|
||||
|
||||
try:
|
||||
if callable(getattr(layer, "isSpatial", None)) and not layer.isSpatial():
|
||||
return "None"
|
||||
|
||||
gtype = getattr(layer, "geometryType", None)
|
||||
if callable(gtype):
|
||||
value = gtype()
|
||||
if not isinstance(value, int):
|
||||
return "None"
|
||||
|
||||
return {
|
||||
0: "Point",
|
||||
1: "LineString",
|
||||
2: "Polygon",
|
||||
}.get(value, "None")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return "None"
|
||||
|
||||
|
||||
|
||||
|
||||
def get_layer_feature_count(layer) -> int:
|
||||
if layer is None:
|
||||
return 0
|
||||
|
||||
count = getattr(layer, "feature_count", None)
|
||||
if count is not None:
|
||||
if isinstance(count, int):
|
||||
return count
|
||||
return 0
|
||||
|
||||
try:
|
||||
if callable(getattr(layer, "isSpatial", None)) and not layer.isSpatial():
|
||||
return 0
|
||||
|
||||
fc = getattr(layer, "featureCount", None)
|
||||
if callable(fc):
|
||||
value = fc()
|
||||
if isinstance(value, int):
|
||||
return value
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return 0
|
||||
|
||||
Reference in New Issue
Block a user