import { toArray } from './to-array' ; import { QuakemlEvent } from './quakeml-event' ; param data param eventElementName export class Quakeml { param waveformID static formatWaveformID ( waveformID ) { if ( ! waveformID ) { return null ; } return ( waveformID . networkCode + ' ' + waveformID . stationCode + ( waveformID . channelCode ? ' ' + waveformID . channelCode : '' ) + ( waveformID . locationCode ? ' ' + waveformID . locationCode : '' ) ) ; } param time static parseTime ( time ) { if ( ! time ) { return null ; } if ( ! time . endsWith ( 'Z' ) ) { time = time + 'Z' ; } return new Date ( time ) ; } creationInfo : any ; events : Array < QuakemlEvent > = [ ] ; namespaces : any = { } ; publicID : string ; constructor ( data ) { const quakeml = data [ 'q:quakeml' ] ; for ( const key in quakeml ) { if ( key . startsWith ( 'xmlns' ) ) { this . namespaces [ quakeml [ key ] ] = key . substring ( 'xmlns:' . length ) ; } } const eventParameters = quakeml . eventParameters ; this . publicID = eventParameters . publicID ; this . creationInfo = eventParameters . creationInfo ; this . events = toArray ( eventParameters . event ) . map ( e => { return new QuakemlEvent ( e ) ; } ) ; } }