|
1 | 1 | from typing import List, Dict, TypedDict, Any, Optional, Literal |
2 | 2 | from pydantic import BaseModel, field_validator, Field |
3 | 3 | import json |
4 | | - |
5 | | -# class CreateCamera(BaseModel): |
6 | | -# title: str |
7 | | -# source: str |
8 | | -# image_width: int |
9 | | -# image_height: int |
10 | | -# calib: Any |
11 | | -# latitude: float |
12 | | -# longitude: float |
13 | | - |
14 | | -# @field_validator('title') |
15 | | -# @classmethod |
16 | | -# def validate_title(cls, title): |
17 | | -# if len(title) < 1 or len(title) > 200: |
18 | | -# raise ValueError(f"Invalid camera title: {title}") |
19 | | -# return title |
20 | | - |
21 | | -# @field_validator('source') |
22 | | -# @classmethod |
23 | | -# def validate_source(cls, source): |
24 | | -# return source |
25 | | - |
26 | | -# @field_validator('latitude') |
27 | | -# @classmethod |
28 | | -# def validate_latitude(cls, latitude): |
29 | | -# if latitude > 90 or latitude < -90: |
30 | | -# raise ValueError(f"Invalid latitude value: {latitude}") |
31 | | -# return latitude |
32 | | - |
33 | | -# @field_validator('longitude') |
34 | | -# @classmethod |
35 | | -# def validate_longitude(cls, longitude): |
36 | | -# if longitude > 180 or longitude < -180: |
37 | | -# raise ValueError(f"Invalid longitude value: {longitude}") |
38 | | -# return longitude |
39 | | - |
40 | | -# @field_validator('image_width') |
41 | | -# @classmethod |
42 | | -# def validate_image_width(cls, image_width): |
43 | | -# if image_width <= 0: |
44 | | -# raise ValueError(f"Invalid image_width value: {image_width}") |
45 | | -# return image_width |
46 | | - |
47 | | -# @field_validator('image_height') |
48 | | -# @classmethod |
49 | | -# def validate_image_height(cls, image_height): |
50 | | -# if image_height <= 0: |
51 | | -# raise ValueError(f"Invalid image_height value: {image_height}") |
52 | | -# return image_height |
53 | | - |
54 | | -# @field_validator('calib') |
55 | | -# @classmethod |
56 | | -# def validate_calib(cls, calib): |
57 | | -# if calib is not None: |
58 | | -# try: |
59 | | -# json.dumps(calib) |
60 | | -# except: |
61 | | -# raise ValueError(f"Invalid calibration data") |
62 | | -# return calib |
63 | 4 |
|
64 | 5 | class CameraBase(BaseModel): |
65 | 6 | title: Optional[str] = Field(None, min_length=3, max_length=120) |
66 | 7 | source: Optional[str] = Field(None, max_length=250) |
67 | 8 | image_width: Optional[int] = Field(None, gt=0) |
68 | 9 | image_height: Optional[int] = Field(None, gt=0) |
69 | | - calib: Any |
| 10 | + calib: Optional[Any] = None |
70 | 11 | latitude: Optional[float] = Field(None, ge=-90, le=90) |
71 | 12 | longitude: Optional[float] = Field(None, ge=-180, le=180) |
72 | 13 |
|
|
0 commit comments