Skip to content

Commit b32ae8d

Browse files
committed
implement angle alignment for fmv
1 parent 09706a7 commit b32ae8d

File tree

3 files changed

+40
-10
lines changed

3 files changed

+40
-10
lines changed

sample_data/fmv.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"type": "fmv",
2121
"action": "replace",
2222
"metadata": {
23+
"name": "FMV Testing Layer"
2324
}
2425
}
2526
]
@@ -35,8 +36,8 @@
3536
"url": "https://data.kitware.com/api/v1/file/604a547c2fa25629b93176d2/download",
3637
"name": "FMV Large Video",
3738
"type": "fmv",
38-
"action": "replace",
3939
"metadata": {
40+
"name":"FMV Large Video Layer"
4041
}
4142
}
4243
]

scripts/fmv/kwiver-klv.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,28 @@ def create_geojson_and_bbox(
109109
center_lat = float(frame["Geodetic Frame Center Latitude (EPSG:4326)"])
110110
center_lon = float(frame["Geodetic Frame Center Longitude (EPSG:4326)"])
111111
width = float(frame["Target Width (meters)"])
112-
113-
# Compute bounding box corners around center
112+
platform_heading = float(frame['Platform Heading Angle (degrees)'])
113+
sensor_heading = float(frame['Sensor Relative Azimuth Angle (degrees)'])
114+
heading = platform_heading + sensor_heading
115+
# Build a rectangular footprint centered at the center point, rotated by heading
116+
# Assume the footprint is square for now (or width x width)
117+
half = width / 2
118+
119+
# Define rectangle in heading-relative azimuths (clockwise from north)
120+
rotation_offset = 0 # degrees (CCW)
121+
rotated_heading = (heading + rotation_offset) % 360
122+
123+
angles = [
124+
rotated_heading - 45, # Top-left
125+
rotated_heading + 45, # Top-right
126+
rotated_heading + 135, # Bottom-right
127+
rotated_heading - 135, # Bottom-left
128+
]
114129
corners = []
115-
for az in (0, 90, 180, 270):
116-
lon, lat, _ = geod.fwd(center_lon, center_lat, az, width / 2)
130+
for az in angles:
131+
lon, lat, _ = geod.fwd(center_lon, center_lat, az % 360, half * (2 ** 0.5))
117132
corners.append((lon, lat))
118133
corners.append(corners[0]) # close the polygon
119-
120134
polygon = Polygon(corners)
121135
polygons.append(polygon)
122136
frame_polygons.append((frame_id, polygon))

uvdat/core/tasks/fmv.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,26 @@ def create_geojson_and_bbox(
186186
center_lat = float(frame['Geodetic Frame Center Latitude (EPSG:4326)'])
187187
center_lon = float(frame['Geodetic Frame Center Longitude (EPSG:4326)'])
188188
width = float(frame['Target Width (meters)'])
189-
190-
# Compute bounding box corners around center
189+
platform_heading = float(frame['Platform Heading Angle (degrees)'])
190+
sensor_heading = float(frame['Sensor Relative Azimuth Angle (degrees)'])
191+
heading = platform_heading + sensor_heading
192+
# Build a rectangular footprint centered at the center point, rotated by heading
193+
# Assume the footprint is square for now (or width x width)
194+
half = width / 2
195+
196+
# Define rectangle in heading-relative azimuths (clockwise from north)
197+
rotation_offset = 0 # degrees (CCW)
198+
rotated_heading = (heading + rotation_offset) % 360
199+
200+
angles = [
201+
rotated_heading - 45, # Top-left
202+
rotated_heading + 45, # Top-right
203+
rotated_heading + 135, # Bottom-right
204+
rotated_heading - 135, # Bottom-left
205+
]
191206
corners = []
192-
for az in (0, 90, 180, 270):
193-
lon, lat, _ = geod.fwd(center_lon, center_lat, az, width / 2)
207+
for az in angles:
208+
lon, lat, _ = geod.fwd(center_lon, center_lat, az % 360, half * (2 ** 0.5))
194209
corners.append((lon, lat))
195210
corners.append(corners[0]) # close the polygon
196211

0 commit comments

Comments
 (0)