-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfelt_reports.go
45 lines (36 loc) · 1.03 KB
/
felt_reports.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package geonet
type intensityAPIResponse struct {
Type string `json:"type"`
Features []intensityFeature `json:"features"`
}
func (res intensityAPIResponse) Reports() []FeltReport {
reports := []FeltReport{}
for _, f := range res.Features {
r := FeltReport{f.Properties, f.Geometry.Coordinates}
reports = append(reports, r)
}
return reports
}
type intensityFeature struct {
feature
Properties intensityProperties `json:"properties"`
}
type intensityProperties struct {
MMI int `json:"mmi"`
Count int `json:"count"`
}
// FeltReport represents a report from a user who felt shaking
type FeltReport struct {
intensityProperties
Coordinates []float64 `json:"coordinates"`
}
// FeltReports will return reports from people who felt the quake
// using the given API client
func (q Quake) FeltReports(c *Client) ([]FeltReport, error) {
resp := intensityAPIResponse{}
err := c.Get("/intensity?type=reported&publicID="+q.PublicID, &resp)
if err != nil {
return []FeltReport{}, err
}
return resp.Reports(), nil
}