|
1 | 1 | import datetime |
2 | 2 | import re |
3 | 3 | from datetime import datetime |
4 | | -from typing import Optional, Any |
| 4 | +from typing import Optional, Any, Union, Literal |
5 | 5 |
|
6 | 6 | from pydantic import ConfigDict, Field, GetCoreSchemaHandler, computed_field, constr |
7 | 7 | from pydantic_core import CoreSchema, core_schema |
|
13 | 13 |
|
14 | 14 | class Remarks(BaseModel): |
15 | 15 | text: str |
16 | | - |
| 16 | + |
| 17 | +# https://github.com/deptofdefense/AndroidTacticalAssaultKit-CIV/blob/889eee292c43d3d2eafdd1f2fbf378ad5cd89ecc/takcot/mitre/CoT%20Image%20Schema%20%20(PUBLIC%20RELEASE).xsd |
| 18 | +class Image(CustomModel): |
| 19 | + """ |
| 20 | + Image metadata for Cursor On Target messages, based on MITRE schema. |
| 21 | + Specifically limited to geographically located (though not necessarily |
| 22 | + geographically registered) image products. |
| 23 | + """ |
| 24 | + # Fields required for image to display in TAK clients |
| 25 | + |
| 26 | + content: Optional[str] = None # For base64 encoded image data |
| 27 | + url: Optional[str] = None # URL link if image is not embedded |
| 28 | + source: Optional[str] = None # CoT UID of the producer |
| 29 | + mime: str # Required mime type for the image |
| 30 | + |
| 31 | + # Metadata for image display and postprocessing |
| 32 | + |
| 33 | + # Image type from NITF spec (MIL-STD-2500C APPENDIX A) |
| 34 | + type: Optional[Literal[ |
| 35 | + "BP", # Black and White Picture |
| 36 | + "CP", # Color Picture |
| 37 | + "BARO", # Barometric pressure |
| 38 | + "CAT", # Computerized Axial Tomography scan |
| 39 | + "EO", # Electro-optical |
| 40 | + "FL", # Forward Looking Infrared |
| 41 | + "FP", # Fingerprints |
| 42 | + "HR", # High Resolution Radar |
| 43 | + "HS", # Hyperspectral |
| 44 | + "IR", # Infrared |
| 45 | + "MRI", # Magnetic Resonance Imaging |
| 46 | + "MS", # Multispectral |
| 47 | + "OP", # Optical |
| 48 | + "RD", # Radar |
| 49 | + "SAR", # Synthetic Aperture Radar |
| 50 | + "SARIQ", # Synthetic Aperture Radar Radio Hologram |
| 51 | + "SL", # Side Looking Radar |
| 52 | + "TI", # Thermal Infrared |
| 53 | + ]] = None # Image type from NITF spec |
| 54 | + resolution: Optional[float] = None # Meters per pixel |
| 55 | + size: Optional[int] = Field(None, ge=0) # Approximate file size in bytes |
| 56 | + width: Optional[int] = Field(None, ge=0) # Width in pixels |
| 57 | + height: Optional[int] = Field(None, ge=0) # Height in pixels |
| 58 | + quality: Optional[str] = None # Image quality vs compression trade-off. Floating point value between 0.0 and 1.0, where 1.0 is best quality. |
| 59 | + fov: Optional[float] = Field(None, ge=0, lt=360) # Angular field of view in degrees |
| 60 | + version: Optional[float] = None # Schema version |
| 61 | + reason: Optional[str] = None # Reason image was produced |
| 62 | + bands: Optional[int] = Field(None, ge=0) # Number of data bands within the image |
| 63 | + mimecsv: Optional[str] = None # Supplementary mime types for container formats |
| 64 | + north: Optional[float] = Field(None, ge=0, lt=360) # Orientation of north in degrees |
| 65 | + |
| 66 | + |
| 67 | +class Track(CustomModel): |
| 68 | + """ |
| 69 | + Track information for Cursor On Target messages, based on MITRE schema. |
| 70 | + Represents motion information including course, speed, and slope. |
| 71 | + """ |
| 72 | + course: float = Field(ge=0, lt=360, description="Direction of motion with respect to true north. Measured in degrees.") |
| 73 | + speed: float = Field(ge=0.0, description="Magnitude of motion measured in meters per second") |
| 74 | + slope: Optional[float] = Field(None, ge=-90.0, le=90.0, description="Vertical component of motion vector. Measured in degrees. Negative indicates downward motion.") |
| 75 | + eCourse: Optional[float] = Field(None, description="1-sigma error on a Gaussian distribution associated with the course attribute") |
| 76 | + eSpeed: Optional[float] = Field(None, description="1-sigma error on a Gaussian distribution associated with the speed attribute") |
| 77 | + eSlope: Optional[float] = Field(None, description="1-sigma error on a Gaussian distribution associated with the slope attribute") |
| 78 | + version: Optional[float] = None |
| 79 | + |
| 80 | + |
17 | 81 | # MITRE Definition does not have addition subschema |
18 | 82 | class Detail(CustomModel): |
19 | 83 | model_config = ConfigDict(extras=True, populate_by_name=True) |
20 | | - remarks: Remarks = Optional[Remarks] |
| 84 | + remarks: Optional[Remarks] = None |
| 85 | + image: Optional[Image] = None |
| 86 | + track: Optional[Track] = None |
| 87 | + |
21 | 88 |
|
22 | 89 | class Point(CustomModel): |
23 | 90 | lat: float = Field(ge=-90, le=90) |
@@ -99,5 +166,5 @@ def xml(self): |
99 | 166 | '<?xml version="1.0" encoding="utf-8"?>', |
100 | 167 | '<?xml version="1.0"?>', |
101 | 168 | ) |
102 | | - |
| 169 | + |
103 | 170 |
|
0 commit comments