ingv

package module
v0.0.0-...-eb37bae Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 7, 2024 License: MIT Imports: 11 Imported by: 0

README

ingv

Go library and CLI to fetch earthquake information from the Italian INGV.

The INGV Earthquake Event API is documented at https://webservices.ingv.it/swagger-ui/dist/?url=https://ingv.github.io/openapi/fdsnws/event/0.0.1/event.yaml , which is the API equivalent of visiting the web page http://terremoti.ingv.it/ .

Command line interface

Located at cmd/quakes. Just run go build, then ./quakes --help.

Documentation

Index

Constants

View Source
const TimeFormat = "2006-01-02T15:04:05.999999"

time format used by the INGV API

Variables

View Source
var TimeLocation = time.UTC

Functions

func DistanceInKm

func DistanceInKm(origin, dest Loc) float64

DistanceInKm computes the distance in KM between two sets of coordinates using the haversine formula, that is, assuming a spherical Earth (the error margin is ~0.3%). This function works around what appears to be a broken min/max radius computation in the API.

Warning: using this function is different than using With{Min,Max}RadiusKm, because the filtering happens after the search, so you have to handle that manually.

Types

type Loc

type Loc struct {
	Lat float64
	Lon float64
}

type Param

type Param func(r *Request)

func WithEndTime

func WithEndTime(t time.Time) Param

func WithEventID

func WithEventID(id int) Param

func WithFocalMechanismID

func WithFocalMechanismID(id int) Param

func WithFormat

func WithFormat(f string) Param

func WithIncludeAllMagnitude

func WithIncludeAllMagnitude(i bool) Param

func WithIncludeAllOrigins

func WithIncludeAllOrigins(i bool) Param

func WithIncludeAllStationMagnitudes

func WithIncludeAllStationMagnitudes(i bool) Param

func WithIncludeArrivals

func WithIncludeArrivals(i bool) Param

func WithLat

func WithLat(l float64) Param

func WithLimit

func WithLimit(l int) Param

func WithLon

func WithLon(l float64) Param

func WithMagnitudeID

func WithMagnitudeID(id int) Param

func WithMagnitudeType

func WithMagnitudeType(m int) Param

func WithMaxDepth

func WithMaxDepth(d float64) Param

func WithMaxLat

func WithMaxLat(l float64) Param

func WithMaxLon

func WithMaxLon(l float64) Param

func WithMaxMag

func WithMaxMag(m float64) Param

func WithMaxRadius

func WithMaxRadius(rad float64) Param

func WithMaxRadiusKm

func WithMaxRadiusKm(rad float64) Param

func WithMinDepth

func WithMinDepth(d float64) Param

func WithMinLat

func WithMinLat(l float64) Param

func WithMinLon

func WithMinLon(l float64) Param

func WithMinMag

func WithMinMag(m float64) Param

func WithMinRadius

func WithMinRadius(rad float64) Param

func WithMinRadiusKm

func WithMinRadiusKm(rad float64) Param

func WithOffset

func WithOffset(o int) Param

func WithOrderBy

func WithOrderBy(o string) Param

func WithOriginID

func WithOriginID(id int) Param

func WithStartTime

func WithStartTime(t time.Time) Param

type QuakeInfo

type QuakeInfo struct {
	EventID           int
	Time              time.Time
	Latitude          float64
	Longitude         float64
	DepthInKm         float64
	Author            string
	Catalog           string
	Contributor       string
	ContributorID     int
	MagType           string
	Magnitude         float64
	MagAuthor         string
	EventLocationName string
	EventType         string
}

func Get

func Get(params ...Param) ([]QuakeInfo, error)

type Request

type Request struct {
	EventID                     *int       `name:"eventid"`
	OriginID                    *int       `name:"originid"`
	MagnitudeID                 *int       `name:"magnitudeid"`
	FocalMechanismID            *int       `name:"focalmechanismid"`
	MinLat                      *float64   `name:"minlat"`
	MaxLat                      *float64   `name:"maxlat"`
	MinLon                      *float64   `name:"minlon"`
	MaxLon                      *float64   `name:"maxlon"`
	Lat                         *float64   `name:"lat"`
	Lon                         *float64   `name:"lon"`
	MaxRadius                   *float64   `name:"maxradius"`
	MaxRadiusKm                 *float64   `name:"maxradiuskm"`
	MinRadius                   *float64   `name:"minradius"`
	MinRadiusKm                 *float64   `name:"minradiuskm"`
	MinDepth                    *float64   `name:"mindepth"`
	MaxDepth                    *float64   `name:"maxdepth"`
	StartTime                   *time.Time `name:"start_time"`
	EndTime                     *time.Time `name:"end_time"`
	MinMag                      *float64   `name:"minmag"`
	MaxMag                      *float64   `name:"maxmag"`
	MagnitudeType               *int       `name:"magnitudetype"`
	Limit                       *int       `name:"limit"`
	Offset                      *int       `name:"offset"`
	OrderBy                     *string    `name:"orderby"`
	IncludeAllMagnitude         *bool      `name:"includeallmagnitude"`
	IncludeArrivals             *bool      `name:"includearrivals"`
	IncludeAllOrigins           *bool      `name:"includeallorigins"`
	IncludeAllStationMagnitudes *bool      `name:"includeallstationmagnitudes"`
	Format                      *string    `name:"format"`
}

func (*Request) ToValues

func (r *Request) ToValues() url.Values

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL