add constructors

This commit is contained in:
KatKatKateryna
2024-10-22 17:02:24 +01:00
parent 25f16c700d
commit 2e0743d626
3 changed files with 63 additions and 9 deletions
+2
View File
@@ -12,6 +12,7 @@ from specklepy.objects.GIS.geometry import (
GisLineElement,
GisPointElement,
GisPolygonElement,
GisPolygonGeometry,
GisRasterElement,
PolygonGeometry,
PolygonGeometry3d,
@@ -21,6 +22,7 @@ from specklepy.objects.GIS.layers import RasterLayer, VectorLayer
__all__ = [
"VectorLayer",
"RasterLayer",
"GisPolygonGeometry",
"PolygonGeometry",
"PolygonGeometry3d",
"GisPolygonElement",
+43 -1
View File
@@ -1,4 +1,4 @@
from typing import List
from typing import List, Optional
from specklepy.objects.base import Base
from specklepy.objects.geometry import Mesh, Point, Polyline
@@ -10,6 +10,12 @@ class GisNonGeometricFeature(Base, speckle_type="Objects.GIS.GisNonGeometricFeat
attributes: Base
def __init__(
self,
attributes: Optional[Base] = None,
) -> None:
self.attributes = attributes or Base()
class GisPointFeature(
Base,
@@ -25,6 +31,14 @@ class GisPointFeature(
def geometry(self) -> List[Point]:
return self.displayValue
def __init__(
self,
attributes: Optional[Base] = None,
displayValue: Optional[List[Point]] = None,
) -> None:
self.attributes = attributes or Base()
displayValue = displayValue or []
class GisPolylineFeature(
Base,
@@ -40,6 +54,14 @@ class GisPolylineFeature(
def geometry(self) -> List[Polyline]:
return self.displayValue
def __init__(
self,
attributes: Optional[Base] = None,
displayValue: Optional[List[Point]] = None,
) -> None:
self.attributes = attributes or Base()
displayValue = displayValue or []
class GisPolygonFeature(
Base,
@@ -52,6 +74,16 @@ class GisPolygonFeature(
displayValue: List[Mesh]
geometry: List[PolygonGeometry]
def __init__(
self,
geometry: List[PolygonGeometry],
attributes: Optional[Base] = None,
displayValue: Optional[List[Point]] = None,
) -> None:
self.geometry = geometry
self.attributes = attributes or Base()
displayValue = displayValue or []
class GisMultipatchFeature(
Base,
@@ -63,3 +95,13 @@ class GisMultipatchFeature(
attributes: Base
displayValue: List[Mesh]
geometry: List[Base] # GisMultipatchGeometry or PolygonGeometry3d
def __init__(
self,
geometry: List[Base],
attributes: Optional[Base] = None,
displayValue: Optional[List[Point]] = None,
) -> None:
self.geometry = geometry
self.attributes = attributes or Base()
displayValue = displayValue or []
+18 -8
View File
@@ -14,26 +14,36 @@ from specklepy.objects.geometry import (
)
class PolygonGeometry(
Base, speckle_type="Objects.GIS.PolygonGeometry", detachable={"displayValue"}
):
class PolygonGeometry(Base, speckle_type="Objects.GIS.PolygonGeometry"):
"""GIS Polygon Geometry"""
boundary: Polyline
voids: List[Polyline]
displayValue: List[Mesh]
def __init__(
self,
boundary: Polyline,
voids: Optional[List[Polyline]] = None,
) -> None:
self.boundary = boundary
self.voids = voids or []
GisPolygonGeometry = PolygonGeometry
class PolygonGeometry3d(
PolygonGeometry,
speckle_type="Objects.GIS.PolygonGeometry3d",
detachable={"displayValue"},
):
"""GIS Polygon3d Geometry"""
boundary: Polyline
voids: List[Polyline]
displayValue: List[Mesh]
def __init__(
self,
boundary: Polyline,
voids: Optional[List[Polyline]] = None,
) -> None:
super().__init__(boundary=boundary, voids=voids)
@deprecated(version="2.20", reason="Replaced with GisPolygonFeature")