From d3c781484d7cdd89334cb5d447bdbe818668abec Mon Sep 17 00:00:00 2001
From: Jeremy Fee <jmfee@usgs.gov>
Date: Fri, 10 Apr 2020 13:01:01 -0600
Subject: [PATCH] Revert httpx dependency version, add lat/lon validator for
 observatory and fix values

---
 Pipfile                        |  2 +-
 Pipfile.lock                   | 12 ++++++------
 geomagio/api/ws/Observatory.py | 20 ++++++++++++++++----
 3 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/Pipfile b/Pipfile
index 67665fece..921318cd0 100644
--- a/Pipfile
+++ b/Pipfile
@@ -20,7 +20,7 @@ authlib = "*"
 cryptography = "*"
 databases = {extras = ["postgresql", "sqlite"],version = "*"}
 fastapi = "*"
-httpx = "==0.12.1"
+httpx = "==0.11.1"
 openpyxl = "*"
 orm = "==0.1.5"
 pydantic = "==1.4"
diff --git a/Pipfile.lock b/Pipfile.lock
index 32f1ee328..6f8dbed1b 100644
--- a/Pipfile.lock
+++ b/Pipfile.lock
@@ -1,7 +1,7 @@
 {
     "_meta": {
         "hash": {
-            "sha256": "0080c46fcd35a3d58478fb313c8c91b5c2f52f155c3da9fe2ea7bfdc0a06d109"
+            "sha256": "9d11130b39f605d10cd4d32c8b721e21b38cdbae4b5eaf19f794d6181184a08c"
         },
         "pipfile-spec": 6,
         "requires": {},
@@ -226,11 +226,11 @@
         },
         "httpx": {
             "hashes": [
-                "sha256:405b4749f597b1f45cae5bffc17b23dc251cce30a0c4c8126f1007b9e728a615",
-                "sha256:ce51c8e8ed2834447fde5a94650299fd74017b7da69cc786b6421fefda09a393"
+                "sha256:1d3893d3e4244c569764a6bae5c5a9fbbc4a6ec3825450b5696602af7a275576",
+                "sha256:7d2bfb726eeed717953d15dddb22da9c2fcf48a4d70ba1456aa0a7faeda33cf7"
             ],
             "index": "pypi",
-            "version": "==0.12.1"
+            "version": "==0.11.1"
         },
         "hyperframe": {
             "hashes": [
@@ -378,10 +378,10 @@
         },
         "orm": {
             "hashes": [
-                "sha256:e415e8ad6e638ab902a562a7bf03a190c20faf38d6e8f64d86cefcc4d56e309d"
+                "sha256:37cb4757b670c1713f4e0d65874c5afe819acbd712abb9743c97e1d4b00d511c"
             ],
             "index": "pypi",
-            "version": "==0.2.0.dev0"
+            "version": "==0.1.5"
         },
         "psycopg2-binary": {
             "hashes": [
diff --git a/geomagio/api/ws/Observatory.py b/geomagio/api/ws/Observatory.py
index c345ed179..ebd10da2f 100644
--- a/geomagio/api/ws/Observatory.py
+++ b/geomagio/api/ws/Observatory.py
@@ -29,6 +29,18 @@ class Observatory(BaseModel):
                 agency_name = "Japan Meteorological Agency (JMA)"
         return agency_name
 
+    @validator("latitude")
+    def validate_latitude(cls, latitude: float) -> float:
+        if latitude > 90 or latitude < -90:
+            raise ValueError(f"latitude ({latitude}) out of range [-90, 90]")
+        return latitude
+
+    @validator("longitude")
+    def validate_longitude(cls, longitude: float) -> float:
+        if longitude > 360 or longitude < -360:
+            raise ValueError(f"longitude ({longitude}) out of range [-360, 360]")
+        return longitude
+
     @validator("sensor_orientation", always=True)
     def validate_sensor_orientation(cls, sensor_orientation: str, values: Dict) -> str:
         agency = values.get("agency")
@@ -71,8 +83,8 @@ OBSERVATORIES = [
     Observatory(
         id="BRW",
         elevation=10,
-        latitude=203.378,
-        longitude=71.322,
+        latitude=71.322,
+        longitude=203.378,
         name="Barrow",
         agency="USGS",
         declination_base=10589,
@@ -80,8 +92,8 @@ OBSERVATORIES = [
     Observatory(
         id="BRT",
         elevation=10,
-        latitude=203.378,
-        longitude=71.322,
+        latitude=71.322,
+        longitude=203.378,
         name="Barrow Test (ObsRIO)",
         agency="USGS",
         declination_base=10589,
-- 
GitLab