-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmodels.py
86 lines (71 loc) · 2 KB
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
from pydantic import BaseModel, Field
from typing import List, Optional, Literal, NamedTuple, Union
from typing_extensions import Annotated
class Variable(BaseModel):
table: str
column: str
type: Literal['min','max','sum','avg','count']
influence: Literal['low','high','ideal']
weight: int
ideal_value: float=0
class MapSuitability(BaseModel):
table: str
table_column: str
table_values: list=[]
variables: Optional[List[Variable]]=[]
return_geometry: bool=False
filter: str=""
class Point(BaseModel):
latitude: float
longitude: float
class PointSuitability(BaseModel):
points: List[Point]
buffer_in_kilometers: float
variables: Optional[List[Variable]]=[]
return_geometry: bool=False
LonField = Annotated[
Union[float, int],
Field(
title='Coordinate longitude',
gt=-180,
lt=180,
),
]
LatField = Annotated[
Union[float, int],
Field(
title='Coordinate latitude',
gt=-90,
lt=90,
),
]
class Coordinates(NamedTuple):
lon: LonField
lat: LatField
class PolygonGeometry(BaseModel):
type: Literal['Polygon']
coordinates: List[List[Coordinates]]
class LineGeometry(BaseModel):
type: Literal['LineString']
coordinates: List[Coordinates]
class PolygonGeojson(BaseModel):
type: str="Feature"
geometry: PolygonGeometry
class LineGeojson(BaseModel):
type: str="Feature"
geometry: LineGeometry
class PolygonGeojsonCollection(BaseModel):
type: str="FeatureCollection"
features: List[PolygonGeojson]
class LineGeojsonCollection(BaseModel):
type: str="FeatureCollection"
features: List[LineGeojson]
class PolygonSuitability(BaseModel):
geojson_collection: PolygonGeojsonCollection
variables: Optional[List[Variable]]=[]
return_geometry: bool=False
class LineSuitability(BaseModel):
geojson_collection: LineGeojsonCollection
buffer_in_kilometers: float
variables: Optional[List[Variable]]=[]
return_geometry: bool=False