Skip to content

Commit f1214ba

Browse files
authored
Merge pull request #8 from micrictor/add-cot-detail-properties
Add Image/Track classes to Detail schema
2 parents ed58867 + b4866f3 commit f1214ba

File tree

1 file changed

+71
-4
lines changed

1 file changed

+71
-4
lines changed

CoT/models/core.py

Lines changed: 71 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import datetime
22
import re
33
from datetime import datetime
4-
from typing import Optional, Any
4+
from typing import Optional, Any, Union, Literal
55

66
from pydantic import ConfigDict, Field, GetCoreSchemaHandler, computed_field, constr
77
from pydantic_core import CoreSchema, core_schema
@@ -13,11 +13,78 @@
1313

1414
class Remarks(BaseModel):
1515
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+
1781
# MITRE Definition does not have addition subschema
1882
class Detail(CustomModel):
1983
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+
2188

2289
class Point(CustomModel):
2390
lat: float = Field(ge=-90, le=90)
@@ -99,5 +166,5 @@ def xml(self):
99166
'<?xml version="1.0" encoding="utf-8"?>',
100167
'<?xml version="1.0"?>',
101168
)
102-
169+
103170

0 commit comments

Comments
 (0)