Skip to content

Commit

Permalink
[bugfix] Strictly validate polygons (interuss#446)
Browse files Browse the repository at this point in the history
* Add failing test to reproduce operation missing from query

* Add big operation test, correct missing-from-query test

* Reject invalid polygons

* Fix tests

* Fix sneaky unit test

* Fix normalization
  • Loading branch information
BenjaminPelletier committed Sep 25, 2020
1 parent b9e7b66 commit 176c36b
Show file tree
Hide file tree
Showing 18 changed files with 1,889 additions and 57 deletions.
1 change: 1 addition & 0 deletions monitoring/monitorlib/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ flask==1.1.2
google-auth==1.6.3
jwcrypto==0.7
pyjwt==1.7.1
pyyaml==5.3.1
requests==2.22.0
s2sphere==0.2.5
termcolor==1.1.0
20 changes: 19 additions & 1 deletion monitoring/monitorlib/scd.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from datetime import datetime
from datetime import datetime, timedelta
from typing import Dict, List, Optional, Tuple

import s2sphere
Expand Down Expand Up @@ -90,6 +90,24 @@ def latitude_degrees(distance_meters: float) -> float:
return 360 * distance_meters / EARTH_CIRCUMFERENCE_M


def parse_time(time: Dict) -> datetime:
t_str = time['value']
if t_str[-1] == 'Z':
t_str = t_str[0:-1]
return datetime.fromisoformat(t_str)


def start_of(vol4s: List[Dict]) -> datetime:
return min([parse_time(vol4['time_start']) for vol4 in vol4s])


def offset_time(vol4s: List[Dict], dt: timedelta) -> List[Dict]:
for vol4 in vol4s:
vol4['time_start'] = make_time(parse_time(vol4['time_start']) + dt)
vol4['time_end'] = make_time(parse_time(vol4['time_end']) + dt)
return vol4s


class Subscription(dict):
@property
def valid(self) -> bool:
Expand Down
4 changes: 0 additions & 4 deletions monitoring/prober/scd/resources/op_404_version1.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
{
"lng": 10.020054117178084,
"lat": 10.01985896200956
},
{
"lng": 9.980582850817164,
"lat": 9.98038769564864
}
]
},
Expand Down
1 change: 1 addition & 0 deletions monitoring/prober/scd/resources/op_big_operation.json

Large diffs are not rendered by default.

Loading

0 comments on commit 176c36b

Please sign in to comment.