Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
geomag-algorithms
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ghsc
National Geomagnetism Program
geomag-algorithms
Commits
f2be5eac
Commit
f2be5eac
authored
4 years ago
by
Rivers, Travis (Contractor) Creighton
Browse files
Options
Downloads
Patches
Plain Diff
refactor observatories endpoints, add to_json method to class
parent
a0f17598
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!146
Release CMO metadata to production
,
!32
Observatories endpoint
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
geomagio/api/ws/Observatory.py
+18
-0
18 additions, 0 deletions
geomagio/api/ws/Observatory.py
geomagio/api/ws/observatories.py
+4
-38
4 additions, 38 deletions
geomagio/api/ws/observatories.py
with
22 additions
and
38 deletions
geomagio/api/ws/Observatory.py
+
18
−
0
View file @
f2be5eac
...
...
@@ -51,6 +51,24 @@ class Observatory(BaseModel):
sensor_orientation
=
"
HDZF
"
return
sensor_orientation
def
to_json
(
self
)
->
str
:
return
{
"
type
"
:
"
Feature
"
,
"
id
"
:
self
.
id
,
"
properties
"
:
{
"
name
"
:
self
.
name
,
"
agency
"
:
self
.
agency
,
"
agency_name
"
:
self
.
agency_name
,
"
sensor_orientation
"
:
self
.
sensor_orientation
,
"
sensor_sampling_rate
"
:
0.01
,
"
declination_base
"
:
self
.
declination_base
,
},
"
geometry
"
:
{
"
type
"
:
"
Point
"
,
"
coordinates
"
:
[
self
.
longitude
,
self
.
latitude
,
self
.
elevation
],
},
}
OBSERVATORIES
=
[
Observatory
(
...
...
This diff is collapsed.
Click to expand it.
geomagio/api/ws/observatories.py
+
4
−
38
View file @
f2be5eac
...
...
@@ -2,54 +2,20 @@ from typing import Dict
from
fastapi
import
APIRouter
from
.Observatory
import
OBSERVATORIES
from
.Observatory
import
OBSERVATORIES
,
OBSERVATORY_INDEX
router
=
APIRouter
()
@router.get
(
"
/observatories
"
)
@router.get
(
"
/observatories
/
"
)
def
get_observatories
()
->
Dict
:
return
{
"
type
"
:
"
FeatureCollection
"
,
"
features
"
:
[
{
"
type
"
:
"
Feature
"
,
"
id
"
:
o
.
id
,
"
properties
"
:
{
"
name
"
:
o
.
name
,
"
agency
"
:
o
.
agency
,
"
agency_name
"
:
o
.
agency_name
,
"
sensor_orientation
"
:
o
.
sensor_orientation
,
"
sensor_sampling_rate
"
:
0.01
,
"
declination_base
"
:
o
.
declination_base
,
},
"
geometry
"
:
{
"
type
"
:
"
Point
"
,
"
coordinates
"
:
[
o
.
longitude
,
o
.
latitude
,
o
.
elevation
],
},
}
for
o
in
OBSERVATORIES
],
"
features
"
:
[
o
.
to_json
()
for
o
in
OBSERVATORIES
],
}
@router.get
(
"
/observatories/{id}
"
)
async
def
get_observatory_by_id
(
id
:
str
)
->
Dict
:
for
o
in
OBSERVATORIES
:
if
o
.
id
==
id
:
return
{
"
id
"
:
o
.
id
,
"
properties
"
:
{
"
name
"
:
o
.
name
,
"
agency
"
:
o
.
agency
,
"
agency_name
"
:
o
.
agency_name
,
"
sensor_orientation
"
:
o
.
sensor_orientation
,
"
sensor_sampling_rate
"
:
0.01
,
"
declination_base
"
:
o
.
declination_base
,
},
"
geometry
"
:
{
"
type
"
:
"
Point
"
,
"
coordinates
"
:
[
o
.
longitude
,
o
.
latitude
,
o
.
elevation
],
},
}
return
OBSERVATORY_INDEX
[
id
].
to_json
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment