|
| 1 | +from __future__ import annotations |
| 2 | + |
| 3 | +from enum import Enum |
| 4 | +from typing import List, Optional, Union |
| 5 | + |
| 6 | +from pydantic import ( |
| 7 | + AnyUrl, |
| 8 | + AwareDatetime, |
| 9 | + BaseModel, |
| 10 | + Field, |
| 11 | + RootModel, |
| 12 | + confloat, |
| 13 | + constr, |
| 14 | +) |
| 15 | + |
| 16 | + |
| 17 | +class Address(BaseModel): |
| 18 | + addressCountry: Optional[str] = Field( |
| 19 | + None, description='The country. For example, Spain' |
| 20 | + ) |
| 21 | + addressLocality: Optional[str] = Field( |
| 22 | + None, |
| 23 | + description='The locality in which the street address is, and which is in the region', |
| 24 | + ) |
| 25 | + addressRegion: Optional[str] = Field( |
| 26 | + None, |
| 27 | + description='The region in which the locality is, and which is in the country', |
| 28 | + ) |
| 29 | + district: Optional[str] = Field( |
| 30 | + None, |
| 31 | + description='A district is a type of administrative division that, in some countries, is managed by the local government', |
| 32 | + ) |
| 33 | + postOfficeBoxNumber: Optional[str] = Field( |
| 34 | + None, |
| 35 | + description='The post office box number for PO box addresses. For example, 03578', |
| 36 | + ) |
| 37 | + postalCode: Optional[str] = Field( |
| 38 | + None, description='The postal code. For example, 24004' |
| 39 | + ) |
| 40 | + streetAddress: Optional[str] = Field(None, description='The street address') |
| 41 | + streetNr: Optional[str] = Field( |
| 42 | + None, description='Number identifying a specific property on a public street' |
| 43 | + ) |
| 44 | + |
| 45 | + |
| 46 | +class CategoryEnum(Enum): |
| 47 | + apartments = 'apartments' |
| 48 | + bakehouse = 'bakehouse' |
| 49 | + barn = 'barn' |
| 50 | + bridge = 'bridge' |
| 51 | + bungalow = 'bungalow' |
| 52 | + bunker = 'bunker' |
| 53 | + cathedral = 'cathedral' |
| 54 | + cabin = 'cabin' |
| 55 | + carport = 'carport' |
| 56 | + cemetery = 'cemetery' |
| 57 | + chapel = 'chapel' |
| 58 | + church = 'church' |
| 59 | + civic = 'civic' |
| 60 | + commercial = 'commercial' |
| 61 | + conservatory = 'conservatory' |
| 62 | + construction = 'construction' |
| 63 | + cowshed = 'cowshed' |
| 64 | + detached = 'detached' |
| 65 | + digester = 'digester' |
| 66 | + dormitory = 'dormitory' |
| 67 | + farm = 'farm' |
| 68 | + farm_auxiliary = 'farm_auxiliary' |
| 69 | + garage = 'garage' |
| 70 | + garages = 'garages' |
| 71 | + garbage_shed = 'garbage_shed' |
| 72 | + grandstand = 'grandstand' |
| 73 | + greenhouse = 'greenhouse' |
| 74 | + hangar = 'hangar' |
| 75 | + hospital = 'hospital' |
| 76 | + hotel = 'hotel' |
| 77 | + house = 'house' |
| 78 | + houseboat = 'houseboat' |
| 79 | + hut = 'hut' |
| 80 | + industrial = 'industrial' |
| 81 | + kindergarten = 'kindergarten' |
| 82 | + kiosk = 'kiosk' |
| 83 | + mosque = 'mosque' |
| 84 | + office = 'office' |
| 85 | + parking = 'parking' |
| 86 | + pavilion = 'pavilion' |
| 87 | + public = 'public' |
| 88 | + residential = 'residential' |
| 89 | + retail = 'retail' |
| 90 | + riding_hall = 'riding_hall' |
| 91 | + roof = 'roof' |
| 92 | + ruins = 'ruins' |
| 93 | + school = 'school' |
| 94 | + service = 'service' |
| 95 | + shed = 'shed' |
| 96 | + shrine = 'shrine' |
| 97 | + stable = 'stable' |
| 98 | + stadium = 'stadium' |
| 99 | + static_caravan = 'static_caravan' |
| 100 | + sty = 'sty' |
| 101 | + synagogue = 'synagogue' |
| 102 | + temple = 'temple' |
| 103 | + terrace = 'terrace' |
| 104 | + train_station = 'train_station' |
| 105 | + transformer_tower = 'transformer_tower' |
| 106 | + transportation = 'transportation' |
| 107 | + university = 'university' |
| 108 | + warehouse = 'warehouse' |
| 109 | + water_tower = 'water_tower' |
| 110 | + |
| 111 | + |
| 112 | +class Type(Enum): |
| 113 | + Point = 'Point' |
| 114 | + |
| 115 | + |
| 116 | +class ContainedInPlace(BaseModel): |
| 117 | + bbox: Optional[List[float]] = Field(None, min_length=4) |
| 118 | + coordinates: List[float] = Field(..., min_length=2) |
| 119 | + type: Type |
| 120 | + |
| 121 | + |
| 122 | +class Coordinate(RootModel[List[float]]): |
| 123 | + root: List[float] |
| 124 | + |
| 125 | + |
| 126 | +class Type1(Enum): |
| 127 | + LineString = 'LineString' |
| 128 | + |
| 129 | + |
| 130 | +class ContainedInPlace1(BaseModel): |
| 131 | + bbox: Optional[List[float]] = Field(None, min_length=4) |
| 132 | + coordinates: List[Coordinate] = Field(..., min_length=2) |
| 133 | + type: Type1 |
| 134 | + |
| 135 | + |
| 136 | +class Type2(Enum): |
| 137 | + Polygon = 'Polygon' |
| 138 | + |
| 139 | + |
| 140 | +class ContainedInPlace2(BaseModel): |
| 141 | + bbox: Optional[List[float]] = Field(None, min_length=4) |
| 142 | + coordinates: List[List[Coordinate]] |
| 143 | + type: Type2 |
| 144 | + |
| 145 | + |
| 146 | +class Type3(Enum): |
| 147 | + MultiPoint = 'MultiPoint' |
| 148 | + |
| 149 | + |
| 150 | +class ContainedInPlace3(BaseModel): |
| 151 | + bbox: Optional[List[float]] = Field(None, min_length=4) |
| 152 | + coordinates: List[List[float]] |
| 153 | + type: Type3 |
| 154 | + |
| 155 | + |
| 156 | +class Type4(Enum): |
| 157 | + MultiLineString = 'MultiLineString' |
| 158 | + |
| 159 | + |
| 160 | +class ContainedInPlace4(BaseModel): |
| 161 | + bbox: Optional[List[float]] = Field(None, min_length=4) |
| 162 | + coordinates: List[List[Coordinate]] |
| 163 | + type: Type4 |
| 164 | + |
| 165 | + |
| 166 | +class Type5(Enum): |
| 167 | + MultiPolygon = 'MultiPolygon' |
| 168 | + |
| 169 | + |
| 170 | +class ContainedInPlace5(BaseModel): |
| 171 | + bbox: Optional[List[float]] = Field(None, min_length=4) |
| 172 | + coordinates: List[List[List[Coordinate]]] |
| 173 | + type: Type5 |
| 174 | + |
| 175 | + |
| 176 | +class Type6(Enum): |
| 177 | + Point = 'Point' |
| 178 | + |
| 179 | + |
| 180 | +class Location(BaseModel): |
| 181 | + bbox: Optional[List[float]] = Field(None, min_length=4) |
| 182 | + coordinates: List[float] = Field(..., min_length=2) |
| 183 | + type: Type6 |
| 184 | + |
| 185 | + |
| 186 | +class Type7(Enum): |
| 187 | + LineString = 'LineString' |
| 188 | + |
| 189 | + |
| 190 | +class Location1(BaseModel): |
| 191 | + bbox: Optional[List[float]] = Field(None, min_length=4) |
| 192 | + coordinates: List[Coordinate] = Field(..., min_length=2) |
| 193 | + type: Type7 |
| 194 | + |
| 195 | + |
| 196 | +class Type8(Enum): |
| 197 | + Polygon = 'Polygon' |
| 198 | + |
| 199 | + |
| 200 | +class Location2(BaseModel): |
| 201 | + bbox: Optional[List[float]] = Field(None, min_length=4) |
| 202 | + coordinates: List[List[Coordinate]] |
| 203 | + type: Type8 |
| 204 | + |
| 205 | + |
| 206 | +class Type9(Enum): |
| 207 | + MultiPoint = 'MultiPoint' |
| 208 | + |
| 209 | + |
| 210 | +class Location3(BaseModel): |
| 211 | + bbox: Optional[List[float]] = Field(None, min_length=4) |
| 212 | + coordinates: List[List[float]] |
| 213 | + type: Type9 |
| 214 | + |
| 215 | + |
| 216 | +class Type10(Enum): |
| 217 | + MultiLineString = 'MultiLineString' |
| 218 | + |
| 219 | + |
| 220 | +class Location4(BaseModel): |
| 221 | + bbox: Optional[List[float]] = Field(None, min_length=4) |
| 222 | + coordinates: List[List[Coordinate]] |
| 223 | + type: Type10 |
| 224 | + |
| 225 | + |
| 226 | +class Type11(Enum): |
| 227 | + MultiPolygon = 'MultiPolygon' |
| 228 | + |
| 229 | + |
| 230 | +class Location5(BaseModel): |
| 231 | + bbox: Optional[List[float]] = Field(None, min_length=4) |
| 232 | + coordinates: List[List[List[Coordinate]]] |
| 233 | + type: Type11 |
| 234 | + |
| 235 | + |
| 236 | +class Type12(Enum): |
| 237 | + Building = 'Building' |
| 238 | + |
| 239 | + |
| 240 | +class Building(BaseModel): |
| 241 | + address: Optional[Address] = Field(None, description='The mailing address') |
| 242 | + alternateName: Optional[str] = Field( |
| 243 | + None, description='An alternative name for this item' |
| 244 | + ) |
| 245 | + areaServed: Optional[str] = Field( |
| 246 | + None, |
| 247 | + description='The geographic area where a service or offered item is provided', |
| 248 | + ) |
| 249 | + category: Optional[List[CategoryEnum]] = Field( |
| 250 | + None, |
| 251 | + description="Category of the building. Enum:'apartments, bakehouse, barn, bridge, bungalow, bunker, cathedral, cabin, carport, chapel, church, civic, commercial, conservatory, construction, cowshed, detached, digester, dormitory, farm, farm_auxiliary, garage, garages, garbage_shed, grandstand, greenhouse, hangar, hospital, hotel, house, houseboat, hut, industrial, kindergarten, kiosk, mosque, office, parking, pavilion, public, residential, retail, riding_hall, roof, ruins, school, service, shed, shrine, stable, stadium, static_caravan, sty, synagogue, temple, terrace, train_station, transformer_tower, transportation, university, warehouse, water_tower'", |
| 252 | + ) |
| 253 | + collapseRisk: Optional[confloat(ge=0.0, le=1.0)] = Field( |
| 254 | + None, description='Probability of total collapse of the building' |
| 255 | + ) |
| 256 | + containedInPlace: Optional[ |
| 257 | + Union[ |
| 258 | + ContainedInPlace, |
| 259 | + ContainedInPlace1, |
| 260 | + ContainedInPlace2, |
| 261 | + ContainedInPlace3, |
| 262 | + ContainedInPlace4, |
| 263 | + ContainedInPlace5, |
| 264 | + ] |
| 265 | + ] = Field( |
| 266 | + None, |
| 267 | + description='Geojson reference to the item. It can be Point, LineString, Polygon, MultiPoint, MultiLineString or MultiPolygon', |
| 268 | + ) |
| 269 | + dataProvider: Optional[str] = Field( |
| 270 | + None, |
| 271 | + description='A sequence of characters identifying the provider of the harmonised data entity', |
| 272 | + ) |
| 273 | + dateCreated: Optional[AwareDatetime] = Field( |
| 274 | + None, |
| 275 | + description='Entity creation timestamp. This will usually be allocated by the storage platform', |
| 276 | + ) |
| 277 | + dateModified: Optional[AwareDatetime] = Field( |
| 278 | + None, |
| 279 | + description='Timestamp of the last modification of the entity. This will usually be allocated by the storage platform', |
| 280 | + ) |
| 281 | + description: Optional[str] = Field(None, description='A description of this item') |
| 282 | + floorsAboveGround: Optional[float] = Field( |
| 283 | + None, description='Floors above the ground level' |
| 284 | + ) |
| 285 | + floorsBelowGround: Optional[float] = Field( |
| 286 | + None, description='Floors below the ground level' |
| 287 | + ) |
| 288 | + id: Optional[ |
| 289 | + Union[ |
| 290 | + constr( |
| 291 | + pattern=r'^[\\w\\-\\.\\{\\}\\$\\+\\*\\[\\]`|~^@!, :\\\\]+$', |
| 292 | + min_length=1, |
| 293 | + max_length=256, |
| 294 | + ), |
| 295 | + AnyUrl, |
| 296 | + ] |
| 297 | + ] = Field(None, description='Unique identifier of the entity') |
| 298 | + location: Optional[ |
| 299 | + Union[Location, Location1, Location2, Location3, Location4, Location5] |
| 300 | + ] = Field( |
| 301 | + None, |
| 302 | + description='Geojson reference to the item. It can be Point, LineString, Polygon, MultiPoint, MultiLineString or MultiPolygon', |
| 303 | + ) |
| 304 | + mapUrl: Optional[ |
| 305 | + Union[ |
| 306 | + constr( |
| 307 | + pattern=r'^[\\w\\-\\.\\{\\}\\$\\+\\*\\[\\]`|~^@!, :\\\\]+$', |
| 308 | + min_length=1, |
| 309 | + max_length=256, |
| 310 | + ), |
| 311 | + AnyUrl, |
| 312 | + ] |
| 313 | + ] = Field(None, description='Reference to the map containing the building') |
| 314 | + name: Optional[str] = Field(None, description='The name of this item') |
| 315 | + occupier: Optional[ |
| 316 | + List[ |
| 317 | + Union[ |
| 318 | + constr( |
| 319 | + pattern=r'^[\\w\\-\\.\\{\\}\\$\\+\\*\\[\\]`|~^@!,:\\\\]+$', |
| 320 | + min_length=1, |
| 321 | + max_length=256, |
| 322 | + ), |
| 323 | + AnyUrl, |
| 324 | + ] |
| 325 | + ] |
| 326 | + ] = Field(None, description='Person or entity using the building') |
| 327 | + openingHours: Optional[List[str]] = Field( |
| 328 | + None, description='Opening hours of this building' |
| 329 | + ) |
| 330 | + owner: Optional[ |
| 331 | + List[ |
| 332 | + Union[ |
| 333 | + constr( |
| 334 | + pattern=r'^[\\w\\-\\.\\{\\}\\$\\+\\*\\[\\]`|~^@!,:\\\\]+$', |
| 335 | + min_length=1, |
| 336 | + max_length=256, |
| 337 | + ), |
| 338 | + AnyUrl, |
| 339 | + ] |
| 340 | + ] |
| 341 | + ] = Field( |
| 342 | + None, |
| 343 | + description='A List containing a JSON encoded sequence of characters referencing the unique Ids of the owner(s)', |
| 344 | + ) |
| 345 | + peopleCapacity: Optional[confloat(ge=0.0)] = Field( |
| 346 | + None, description='Allowed people present at the building' |
| 347 | + ) |
| 348 | + peopleOccupancy: Optional[confloat(ge=0.0)] = Field( |
| 349 | + None, description='People present at the building' |
| 350 | + ) |
| 351 | + seeAlso: Optional[Union[List[AnyUrl], AnyUrl]] = Field( |
| 352 | + None, description='list of uri pointing to additional resources about the item' |
| 353 | + ) |
| 354 | + source: Optional[str] = Field( |
| 355 | + None, |
| 356 | + description='A sequence of characters giving the original source of the entity data as a URL. Recommended to be the fully qualified domain name of the source provider, or the URL to the source object', |
| 357 | + ) |
| 358 | + type: Optional[Type12] = Field(None, description='NGSI Entity type') |
0 commit comments