Skip to content

Commit afdf9ef

Browse files
authored
[uss_qualifier] rename and generalize VerticesResource to VolumeResource (#1138)
1 parent 3a3bebc commit afdf9ef

File tree

32 files changed

+230
-150
lines changed

32 files changed

+230
-150
lines changed

NEXT_RELEASE_NOTES.md

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,55 @@ The release notes should contain at least the following sections:
3333

3434
--------------------------------------------------------------------------------------------------------------------
3535

36-
# Release Notes for v0.18.2
36+
# Release Notes for v0.19.0
3737

3838
## Mandatory migration tasks
3939

40+
### Replacement of `resources.VerticesResource` with `resources.VolumeResource`
41+
42+
[VerticesResource](https://github.com/interuss/monitoring/blob/main/monitoring/uss_qualifier/resources/vertices.py) is being replaced with a new [VolumeResource](https://github.com/interuss/monitoring/blob/main/monitoring/uss_qualifier/resources/volume.py),
43+
which now contains a `Volume4DTemplate`, which can be used to define anything from a simple 2D polygon to a 3D volume to a full 4D spatio-temporal volume with dynamic time-bounds.
44+
45+
The old resources, defined as:
46+
47+
```yaml
48+
some_resource:
49+
$content_schema: monitoring/uss_qualifier/resources/definitions/ResourceDeclaration.json
50+
resource_type: resources.VerticesResource
51+
specification:
52+
vertices:
53+
- lat: 38
54+
lng: -81
55+
- lat: 37
56+
lng: -81
57+
- lat: 37
58+
lng: -80
59+
- lat: 38
60+
lng: -80
61+
```
62+
63+
Can be straightforwardly replaced with:
64+
65+
```yaml
66+
planning_area:
67+
$content_schema: monitoring/uss_qualifier/resources/definitions/ResourceDeclaration.json
68+
resource_type: resources.VolumeResource
69+
specification:
70+
template:
71+
outline_polygon:
72+
vertices:
73+
- lat: 38
74+
lng: -81
75+
- lat: 37
76+
lng: -81
77+
- lat: 37
78+
lng: -80
79+
- lat: 38
80+
lng: -80
81+
```
82+
83+
The optional fields of [Volume4DTemplate](https://github.com/interuss/monitoring/blob/master/monitoring/monitorlib/geotemporal.py#L21) (`altitude_lower`, `altitude_upper`, `start_time`, `start_time`, `duration`, `transformations`) can be safely omitted in all contexts that formerly depended on `VerticesResource`.
84+
4085
## Optional migration tasks
4186

4287
## Important information

monitoring/monitorlib/geo.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,18 @@ def from_f3548v21(vol: f3548v21.Volume3D | dict) -> Volume3D:
422422
def to_f3548v21(self) -> f3548v21.Volume3D:
423423
return ImplicitDict.parse(self, f3548v21.Volume3D)
424424

425+
def s2_vertices(self) -> list[s2sphere.LatLng]:
426+
"""Returns the vertices of the 2D area represented by this volume. If the underlying volume is a Polygon, its
427+
original vertices are returned. If it is a Circle, the vertices of the bounding rectangle are returned.
428+
"""
429+
if (
430+
self.outline_polygon is not None
431+
and self.outline_polygon.vertices is not None
432+
):
433+
return [v.as_s2sphere() for v in self.outline_polygon.vertices]
434+
else:
435+
return get_latlngrect_vertices(make_latlng_rect(self))
436+
425437

426438
def make_latlng_rect(area) -> s2sphere.LatLngRect:
427439
"""Make an S2 LatLngRect from the provided input.

monitoring/uss_qualifier/configurations/dev/f3548_self_contained.yaml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -221,17 +221,19 @@ v1:
221221
# An area designed to be soo big as to be refused by systems queries with it.
222222
problematically_big_area:
223223
$content_schema: monitoring/uss_qualifier/resources/definitions/ResourceDeclaration.json
224-
resource_type: resources.VerticesResource
224+
resource_type: resources.VolumeResource
225225
specification:
226-
vertices:
227-
- lat: 38
228-
lng: -81
229-
- lat: 37
230-
lng: -81
231-
- lat: 37
232-
lng: -80
233-
- lat: 38
234-
lng: -80
226+
template:
227+
outline_polygon:
228+
vertices:
229+
- lat: 38
230+
lng: -81
231+
- lat: 37
232+
lng: -81
233+
- lat: 37
234+
lng: -80
235+
- lat: 38
236+
lng: -80
235237

236238
# Details of conflicting flights (used in nominal planning scenario)
237239
conflicting_flights:

monitoring/uss_qualifier/configurations/dev/library/resources.yaml

Lines changed: 48 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -68,30 +68,34 @@ kentland_planning_area:
6868

6969
au_problematically_big_area: # A huge (as in "too big") area for checks around area sizes
7070
$content_schema: monitoring/uss_qualifier/resources/definitions/ResourceDeclaration.json
71-
resource_type: resources.VerticesResource
71+
resource_type: resources.VolumeResource
7272
specification:
73-
vertices:
74-
- lat: -23
75-
lng: 130
76-
- lat: -24
77-
lng: 130
78-
- lat: -24
79-
lng: 132
80-
- lat: -23
81-
lng: 132
73+
template:
74+
outline_polygon:
75+
vertices:
76+
- lat: -23
77+
lng: 130
78+
- lat: -24
79+
lng: 130
80+
- lat: -24
81+
lng: 132
82+
- lat: -23
83+
lng: 132
8284

8385
kentland_problematically_big_area:
84-
resource_type: resources.VerticesResource
86+
resource_type: resources.VolumeResource
8587
specification:
86-
vertices:
87-
- lat: 38
88-
lng: -81
89-
- lat: 37
90-
lng: -81
91-
- lat: 37
92-
lng: -80
93-
- lat: 38
94-
lng: -80
88+
template:
89+
outline_polygon:
90+
vertices:
91+
- lat: 38
92+
lng: -81
93+
- lat: 37
94+
lng: -81
95+
- lat: 37
96+
lng: -80
97+
- lat: 38
98+
lng: -80
9599

96100
zurich_service_area:
97101
$content_schema: monitoring/uss_qualifier/resources/definitions/ResourceDeclaration.json
@@ -152,17 +156,19 @@ zurich_planning_area:
152156

153157
zurich_problematically_big_area: # A huge (as in "too big") area for checks around area sizes
154158
$content_schema: monitoring/uss_qualifier/resources/definitions/ResourceDeclaration.json
155-
resource_type: resources.VerticesResource
159+
resource_type: resources.VolumeResource
156160
specification:
157-
vertices:
158-
- lat: 48
159-
lng: 9
160-
- lat: 47
161-
lng: 9
162-
- lat: 47
163-
lng: 8
164-
- lat: 48
165-
lng: 8
161+
template:
162+
outline_polygon:
163+
vertices:
164+
- lat: 48
165+
lng: 9
166+
- lat: 47
167+
lng: 9
168+
- lat: 47
169+
lng: 8
170+
- lat: 48
171+
lng: 8
166172

167173
# ===== NetRID flights data =====
168174

@@ -240,17 +246,19 @@ che_planning_area:
240246
units: M
241247

242248
che_problematically_big_area:
243-
resource_type: resources.VerticesResource
249+
resource_type: resources.VolumeResource
244250
specification:
245-
vertices:
246-
- lat: 45
247-
lng: 7
248-
- lat: 45
249-
lng: 8
250-
- lat: 46
251-
lng: 8
252-
- lat: 46
253-
lng: 7
251+
template:
252+
outline_polygon:
253+
vertices:
254+
- lat: 45
255+
lng: 7
256+
- lat: 45
257+
lng: 8
258+
- lat: 46
259+
lng: 8
260+
- lat: 46
261+
lng: 7
254262

255263
che_invalid_flight_auth_flights:
256264
$content_schema: monitoring/uss_qualifier/resources/definitions/ResourceDeclaration.json

monitoring/uss_qualifier/configurations/dev/utm_implementation_us/definitions/baseline_a.libsonnet

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -148,26 +148,30 @@ function(env) {
148148

149149
// An area designed to be soo big as to be refused by systems queries with it.
150150
problematically_big_area: {
151-
resource_type: 'resources.VerticesResource',
151+
resource_type: 'resources.VolumeResource',
152152
specification: {
153-
vertices: [
154-
{
155-
lat: 33,
156-
lng: -96,
157-
},
158-
{
159-
lat: 32,
160-
lng: -96,
161-
},
162-
{
163-
lat: 32,
164-
lng: -95,
165-
},
166-
{
167-
lat: 33,
168-
lng: -95,
169-
},
170-
],
153+
template: {
154+
outline_polygon: {
155+
vertices: [
156+
{
157+
lat: 33,
158+
lng: -96,
159+
},
160+
{
161+
lat: 32,
162+
lng: -96,
163+
},
164+
{
165+
lat: 32,
166+
lng: -95,
167+
},
168+
{
169+
lat: 33,
170+
lng: -95,
171+
},
172+
],
173+
}
174+
},
171175
},
172176
},
173177

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
from .planning_area import PlanningAreaResource as PlanningAreaResource
2-
from .vertices import VerticesResource as VerticesResource
2+
from .volume import VolumeResource as VolumeResource

monitoring/uss_qualifier/resources/vertices.py

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import s2sphere
2+
from implicitdict import ImplicitDict
3+
4+
from monitoring.monitorlib.geo import (
5+
LatLngPoint,
6+
)
7+
from monitoring.monitorlib.geotemporal import Volume4DTemplate
8+
from monitoring.uss_qualifier.resources.resource import Resource
9+
10+
11+
class VolumeSpecification(ImplicitDict):
12+
"""Specifies a volume in time and three-dimensional space.
13+
The time-bounds, as well as the lower and upper bounds of the Volume3D may be omitted if a timeless and altitude-free two-dimensional area is required.
14+
See monitoring.monitorlib.geotemporal.Volume4DTemplate for details.
15+
"""
16+
17+
template: Volume4DTemplate
18+
19+
def s2_vertices(self) -> list[s2sphere.LatLng]:
20+
"""Returns the vertices of the 2D area represented by this volume specification, after application of the template's transformations.
21+
Note that if the underlying volume contains a Circle, the vertices of its bounding rectangle are returned.
22+
"""
23+
return self.template.resolve({}).volume.s2_vertices()
24+
25+
def vertices(self) -> list[LatLngPoint]:
26+
"""Returns the vertices of the 2D area represented by this volume specification, after application of the template's transformations.
27+
Note that if the underlying volume contains a Circle, the vertices of its bounding rectangle are returned.
28+
"""
29+
return [LatLngPoint.from_s2(v) for v in self.s2_vertices()]
30+
31+
32+
class VolumeResource(Resource[VolumeSpecification]):
33+
specification: VolumeSpecification
34+
35+
def __init__(self, specification: VolumeSpecification, resource_origin: str):
36+
super().__init__(specification, resource_origin)
37+
self.specification = specification

monitoring/uss_qualifier/scenarios/astm/netrid/common/dss/isa_simple.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
from monitoring.monitorlib.fetch import rid as fetch
77
from monitoring.monitorlib.mutate import rid as mutate
88
from monitoring.prober.infrastructure import register_resource_type
9-
from monitoring.uss_qualifier.resources import VerticesResource
109
from monitoring.uss_qualifier.resources.astm.f3411.dss import DSSInstanceResource
1110
from monitoring.uss_qualifier.resources.interuss.id_generator import IDGeneratorResource
1211
from monitoring.uss_qualifier.resources.netrid.service_area import ServiceAreaResource
12+
from monitoring.uss_qualifier.resources.volume import VolumeResource
1313
from monitoring.uss_qualifier.scenarios.astm.netrid.common.dss.isa_validator import (
1414
ISAValidator,
1515
)
@@ -30,7 +30,7 @@ def __init__(
3030
dss: DSSInstanceResource,
3131
id_generator: IDGeneratorResource,
3232
isa: ServiceAreaResource,
33-
problematically_big_area: VerticesResource,
33+
problematically_big_area: VolumeResource,
3434
):
3535
super().__init__()
3636
self._dss = (
@@ -41,9 +41,7 @@ def __init__(
4141
self._isa_version: str | None = None
4242
self._isa = isa.specification
4343
self._isa_area = [vertex.as_s2sphere() for vertex in self._isa.footprint]
44-
self._huge_area = [
45-
v.as_s2sphere() for v in problematically_big_area.specification.vertices
46-
]
44+
self._huge_area = problematically_big_area.specification.s2_vertices()
4745

4846
def run(self, context: ExecutionContext):
4947
self._shift_isa_time_relative_to_now()

monitoring/uss_qualifier/scenarios/astm/netrid/common/dss/isa_validation.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
from monitoring.monitorlib.mutate.rid import ChangedISA
1111
from monitoring.monitorlib.rid import RIDVersion
1212
from monitoring.prober.infrastructure import register_resource_type
13-
from monitoring.uss_qualifier.resources import VerticesResource
1413
from monitoring.uss_qualifier.resources.astm.f3411.dss import DSSInstanceResource
1514
from monitoring.uss_qualifier.resources.interuss.id_generator import IDGeneratorResource
1615
from monitoring.uss_qualifier.resources.netrid.service_area import ServiceAreaResource
16+
from monitoring.uss_qualifier.resources.volume import VolumeResource
1717
from monitoring.uss_qualifier.scenarios.astm.netrid.common.dss import utils
1818
from monitoring.uss_qualifier.scenarios.astm.netrid.dss_wrapper import DSSWrapper
1919
from monitoring.uss_qualifier.scenarios.scenario import GenericTestScenario
@@ -36,7 +36,7 @@ def __init__(
3636
dss: DSSInstanceResource,
3737
id_generator: IDGeneratorResource,
3838
isa: ServiceAreaResource,
39-
problematically_big_area: VerticesResource,
39+
problematically_big_area: VolumeResource,
4040
):
4141
super().__init__()
4242
self._dss = (
@@ -49,9 +49,7 @@ def __init__(
4949

5050
self._isa_area = [vertex.as_s2sphere() for vertex in self._isa.footprint]
5151

52-
self._huge_area = [
53-
v.as_s2sphere() for v in problematically_big_area.specification.vertices
54-
]
52+
self._huge_area = problematically_big_area.specification.s2_vertices()
5553

5654
if self._dss.rid_version == RIDVersion.f3411_19:
5755
self.create_isa_path = v19.api.OPERATIONS[

0 commit comments

Comments
 (0)