Giter Club home page Giter Club logo

goseismic's Introduction

goseismic

Travis CI Build Status

goseismic is library for receiving (near) realtime notifications about earthquakes using websockets from SeismicPortal. Using goseismic, received JSON message is parsed to goseismic.Event and sent to channel when an event is inserted or updated. Depending on the event, you can use bots, push notification etc. to further process the information.

Installation

go get -u github.com/h00s/goseismic

Usage

Information about earthquake events are sent in JSON thru websockets. This is example of one received event:

{
  "action":"create",
  "data":{
    "geometry":{
      "type":"Point",
      "coordinates":[
        -121.2,
        36.6,
        -4.0
      ]
    },
    "type":"Feature",
    "id":"20201230_0000082",
    "properties":{
      "lastupdate":"2020-12-30T08:47:00.0Z",
      "magtype":"md",
      "evtype":"ke",
      "lon":-121.2,
      "auth":"NC",
      "lat":36.6,
      "depth":4.0,
      "unid":"20201230_0000082",
      "mag":2.4,
      "time":"2020-12-30T08:45:29.9Z",
      "source_id":"934165",
      "source_catalog":"EMSC-RTS",
      "flynn_region":"CENTRAL CALIFORNIA"
    }
  }
}

Possible values for action are created or updated depending if it's new event or update on one of the previous events.

Received events are parsed and sent to Seismic.Events channel which you can read and further process. This is simple example how to receive events and display them (check example/main.go for comments):

package main

import (
	"log"
	"os"
	"os/signal"

	"github.com/h00s/goseismic"
)

func main() {
	s := goseismic.NewSeismic()
	s.Connect()
	defer s.Disconnect()

	interrupt := make(chan os.Signal, 1)
	signal.Notify(interrupt, os.Interrupt)

	for {
		select {
		case e := <-s.Events:
			log.Println(e)
		case <-interrupt:
			return
		}
	}
}

goseismic's People

Contributors

h00s avatar

Stargazers

 avatar Petar Cvetko Voćanec avatar Ilija Leko avatar Dinko Korunic avatar Sara avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar Nikolina avatar Erik Birt avatar Alen Kreuzer avatar  avatar Rubber Duck avatar Gonzalo Lagos avatar  avatar Neville Mascarenhas avatar Emanuel Quimper avatar Brandon Catubig avatar Giorgio Previtera avatar Mahim M S avatar Can Evgin avatar  avatar Chris avatar  avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.