Code Coverage
 
Lines
Branches
Paths
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
28 / 28
66.67% covered (warning)
66.67%
10 / 15
50.00% covered (danger)
50.00%
5 / 10
0.00% covered (danger)
0.00%
0 / 5
CRAP
0.00% covered (danger)
0.00%
0 / 1
MultiInstance
100.00% covered (success)
100.00%
28 / 28
66.67% covered (warning)
66.67%
10 / 15
50.00% covered (danger)
50.00%
5 / 10
100.00% covered (success)
100.00%
5 / 5
22.50
100.00% covered (success)
100.00%
1 / 1
 addFilterByDateTimeRange
100.00% covered (success)
100.00%
5 / 5
66.67% covered (warning)
66.67%
2 / 3
50.00% covered (danger)
50.00%
1 / 2
100.00% covered (success)
100.00%
1 / 1
2.50
 addFilterByBoundingBox
100.00% covered (success)
100.00%
7 / 7
66.67% covered (warning)
66.67%
2 / 3
50.00% covered (danger)
50.00%
1 / 2
100.00% covered (success)
100.00%
1 / 1
2.50
 addFilterByMagnitudeRange
100.00% covered (success)
100.00%
5 / 5
66.67% covered (warning)
66.67%
2 / 3
50.00% covered (danger)
50.00%
1 / 2
100.00% covered (success)
100.00%
1 / 1
2.50
 addFilterByDepthRange
100.00% covered (success)
100.00%
5 / 5
66.67% covered (warning)
66.67%
2 / 3
50.00% covered (danger)
50.00%
1 / 2
100.00% covered (success)
100.00%
1 / 1
2.50
 addFilterByRadiusRange
100.00% covered (success)
100.00%
6 / 6
66.67% covered (warning)
66.67%
2 / 3
50.00% covered (danger)
50.00%
1 / 2
100.00% covered (success)
100.00%
1 / 1
2.50
1<?php
2namespace Fdsn\Webservices\Event;
3
4use ArrayIterator;
5use IteratorAggregate;
6use Traversable;
7
8use Fdsn\Webservices\Event\Event as Fdsnws_Webservice_Event;
9
10use Fdsn\Webservices\Event\Structs\Author as DS_Author;
11use Fdsn\Webservices\Event\Structs\DateTimeRange as DS_DateTimeRange;
12use Fdsn\Webservices\Event\Structs\Depth as DS_Depth;
13use Fdsn\Webservices\Event\Structs\DepthRange as DS_DepthRange;
14use Fdsn\Webservices\Event\Structs\Epicenter as DS_Epicenter;
15use Fdsn\Webservices\Event\Structs\Id as DS_Id;
16use Fdsn\Webservices\Event\Structs\LatLon as DS_LatLon;
17use Fdsn\Webservices\Event\Structs\LatLonRange as DS_LatLonRange;
18use Fdsn\Webservices\Event\Structs\Location as DS_Location;
19use Fdsn\Webservices\Event\Structs\Magnitude as DS_Magnitude;
20use Fdsn\Webservices\Event\Structs\MagnitudeRange as DS_MagnitudeRange;
21use Fdsn\Webservices\Event\Structs\Quake as DS_Quake;
22use Fdsn\Webservices\Event\Structs\Radius as DS_Radius;
23use Fdsn\Webservices\Event\Structs\RadiusRange as DS_RadiusRange;
24
25/**
26 * PHP library to access FDSN Webservices and request Event (earthquake) information in text format
27 * @see    https://www.fdsn.org/webservices/fdsnws-event-1.2.pdf FDSN official documentation
28 *
29 * @param string     $format     Accepted output kind format
30 * @param string     $user        Set your app name
31 * @param string     $fdns_server    Fdns webservice domain name (default: webservices.ms.ingv.it)
32 */
33class MultiInstance extends Fdsnws_Webservice_Event implements IteratorAggregate {
34
35    /* Search by bounding box */    
36    private DS_LatLonRange     $square;
37
38    /* Search by magnitude */    
39    private DS_MagnitudeRange     $magnitudeRange;
40
41    /* Search by datetime */    
42    private DS_DateTimeRange    $dateTimeRange;
43
44    /* Search by depth */    
45    private DS_DepthRange     $depthRange;
46
47    /* Search by radius */    
48    private DS_LatLon    $latlon;
49    private DS_RadiusRange $radiusRange;
50    
51    protected string $eventList;
52
53    protected DS_Quake $event;
54    
55    /**
56     * Add filter based on datetime range
57     * @param \Fdsn\DataStructure\DateTimeRange $dateTimeRange     Datetime min -> Datetime max (default value is TODAY)
58     */
59    public function addFilterByDateTimeRange(DS_DateTimeRange  $dateTimeRange):void { 
60        if( self::debug ) printf("[%s] %d \n", __METHOD__, time());
61        $this->dateTimeRange = $dateTimeRange; 
62        $this->parameters['datatimerange'] = sprintf("starttime=%s&endtime=%s", 
63                    $this->dateTimeRange->startDateTime(),
64                    $this->dateTimeRange->endDateTime());
65    }
66
67    /**
68     * Add filter based on geographical selection
69     * @param \Fdsn\DataStructure\LatLonRange $square     Lat/Lon min -> Lat/Lon max
70     */
71    public function addFilterByBoundingBox(DS_LatLonRange $square):void { 
72        if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); 
73
74        $this->square = $square; 
75
76        $this->parameters['boundingbox'] = sprintf("minlat=%.2f&maxlat=%.2f&minlon=%.2f&maxlon=%.2f",
77            $this->square->min()->lat(),
78            $this->square->max()->lat(),
79            $this->square->min()->lon(),
80            $this->square->max()->lon());
81    }
82
83    /**
84     * Add filter based on magnitude range
85     * @param \Fdsn\DataStructure\MagnitudeRange     $magnitudeRange     Magnitude min -> Magnitude max
86     */
87    public function addFilterByMagnitudeRange(DS_MagnitudeRange $magnitudeRange):void { 
88        if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); 
89
90        $this->magnitudeRange = $magnitudeRange; 
91        $this->parameters['magnituderange'] = sprintf("minmag=%.2f&maxmag=%.2f",
92            $this->magnitudeRange->min()->value(),
93            $this->magnitudeRange->max()->value());
94    }
95
96    /**
97     * Add filter based on depth range
98     * @param \Fdsn\DataStructure\DepthRange $depthRange     Depth min -> Depth max
99     */
100    public function addFilterByDepthRange(DS_DepthRange  $depthRange):void { 
101        if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); 
102
103        $this->depthRange  = $depthRange; 
104        $this->parameters['depthrange'] = sprintf("mindepth=%.2f&maxdepth=%.2f",
105            $this->depthRange->min()->value(),
106            $this->depthRange->max()->value());
107    }
108
109    /**
110     * Add filter based on latlon->radius
111     * @param \Fdsn\DataStructure\LatLon        $latlon        lat/lon as coordinate to start search
112     * @param \Fdsn\DataStructure\RadiusRange     $radiusRange    radius min->max to search ( valid range [0:180] for both radius )
113     */
114    public function addFilterByRadiusRange(DS_LatLon $latlon, DS_RadiusRange $radiusRange ):void { 
115        if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); 
116
117        $this->latlon = $latlon;  
118        $this->radiusRange = $radiusRange; 
119
120        $this->parameters['radiusrange'] = sprintf("latitude=%.3f&longitude=%.3f&minradius=%.2f&maxradius=%.2f",
121            $this->latlon->lat(), $this->latlon->lon(),
122            $this->radiusRange->min()->value(), $this->radiusRange->max()->value());
123    }
124
125}