Skip to content

Commit 9e5c16a

Browse files
author
Stefan Kuethe
committed
Refactor inheritance
1 parent 3681242 commit 9e5c16a

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

src/openlayers/layers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
WebGLTileLayer,
1010
WebGLVectorLayer,
1111
VectorTileLayer,
12-
WebGLVectorTileLayer
12+
WebGLVectorTileLayer,
1313
)
1414

1515
__all__ = [
@@ -19,5 +19,5 @@
1919
"WebGLVectorLayer",
2020
"BasemapLayer",
2121
"VectorTileLayer",
22-
"WebGLVectorTileLayer"
22+
"WebGLVectorTileLayer",
2323
]

src/openlayers/models/layers.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
# --- Base layer
1414
class Layer(OLBaseModel):
15+
"""A base class for creating OL layers"""
1516
id: str | None = None
1617
source: dict | SourceT
1718
background: str | None = None
@@ -31,10 +32,8 @@ def validate_id(cls, v) -> str:
3132
class TileLayer(Layer): ...
3233

3334

34-
# TODO: Inherit from `VectorTileLayer`
35-
class VectorLayer(Layer):
35+
class VectorTileLayer(Layer):
3636
style: dict | FlatStyle | None = default_style()
37-
fit_bounds: bool = Field(False, serialization_alias="fitBounds")
3837

3938
@field_validator("style")
4039
def validate_style(cls, v):
@@ -43,19 +42,24 @@ def validate_style(cls, v):
4342

4443
return v
4544

45+
# TODO: Inherit from `VectorTileLayer`
46+
class VectorLayer(VectorTileLayer):
47+
"""A layer for rendering vector sources"""
48+
#style: dict | FlatStyle | None = default_style()
49+
fit_bounds: bool = Field(False, serialization_alias="fitBounds")
4650

47-
class WebGLVectorLayer(VectorLayer): ...
48-
49-
50-
class VectorTileLayer(Layer):
51-
style: dict | FlatStyle | None = None
52-
51+
"""
5352
@field_validator("style")
5453
def validate_style(cls, v):
5554
if isinstance(v, FlatStyle):
5655
return v.model_dump()
5756
5857
return v
58+
"""
59+
60+
class WebGLVectorLayer(VectorLayer):
61+
"""A layer for rendering vector sources using WebGL"""
62+
...
5963

6064

6165
class WebGLVectorTileLayer(VectorTileLayer): ...

0 commit comments

Comments
 (0)