Documentation
¶
Overview ¶
Package usgsquake exposes the USGS Earthquake catalog as a kit Domain driver.
A multi-domain host (ant) enables it with a single blank import:
import _ "github.com/tamnd/usgsquake-cli/usgsquake"
The same Domain also builds the standalone quake binary (see cli.NewApp).
Package usgsquake is the library behind the quake command line: the HTTP client, request shaping, and typed data models for the USGS FDSNWS Earthquake Event Web Service (earthquake.usgs.gov/fdsnws/event/1).
The USGS API is free and requires no API key. It returns seismic events worldwide in GeoJSON format with magnitude, location, depth, and metadata.
Index ¶
- Constants
- type Client
- func (c *Client) Count(ctx context.Context, p CountParams) (*Count, error)
- func (c *Client) Get(ctx context.Context, eventID string) (*Earthquake, error)
- func (c *Client) List(ctx context.Context, p ListParams) ([]Earthquake, error)
- func (c *Client) Nearby(ctx context.Context, lat, lon, radiusKm, minMag float64, limit int) ([]Earthquake, error)
- type Config
- type Count
- type CountParams
- type Domain
- type Earthquake
- type ListParams
Constants ¶
const Host = "earthquake.usgs.gov"
Host is the API host this client talks to.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to the USGS earthquake API over HTTP.
func (*Client) List ¶
func (c *Client) List(ctx context.Context, p ListParams) ([]Earthquake, error)
List queries /query for earthquakes matching the given params.
type Config ¶
type Config struct {
BaseURL string
UserAgent string
Rate time.Duration
Timeout time.Duration
Retries int
}
Config holds all tunable parameters for the Client.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a Config with sensible defaults.
type CountParams ¶
CountParams holds filters for a count query.
type Domain ¶
type Domain struct{}
Domain is the usgsquake driver.
func (Domain) Info ¶
func (Domain) Info() kit.DomainInfo
Info describes the scheme, the hostnames a pasted link is matched against, and the identity reused for the binary's help and version.
type Earthquake ¶
type Earthquake struct {
ID string `json:"id"`
Place string `json:"place"`
Title string `json:"title"`
Status string `json:"status"`
Type string `json:"type"`
Magnitude float64 `json:"magnitude"`
Time int64 `json:"time"` // Unix milliseconds
Updated int64 `json:"updated"` // Unix milliseconds
Lat float64 `json:"lat"`
Lon float64 `json:"lon"`
Depth float64 `json:"depth_km"`
Tsunami int `json:"tsunami"`
Significance int `json:"significance"`
URL string `json:"url"`
}
Earthquake is one seismic event from the USGS catalog.