Code Coverage
 
Lines
Branches
Paths
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
23 / 23
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
5 / 5
CRAP
100.00% covered (success)
100.00%
1 / 1
MultiInstance
100.00% covered (success)
100.00%
23 / 23
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
5 / 5
5
100.00% covered (success)
100.00%
1 / 1
 addFilterByDateTimeRange
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 addFilterByBoundingBox
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 addFilterByMagnitudeRange
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 addFilterByDepthRange
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 addFilterByRadiusRange
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
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    /**
54     * Add filter based on datetime range
55     * @param \Fdsn\DataStructure\DateTimeRange $dateTimeRange     Datetime min -> Datetime max (default value is TODAY)
56     */
57    public function addFilterByDateTimeRange(DS_DateTimeRange  $dateTimeRange):void { 
58        $this->dateTimeRange = $dateTimeRange; 
59        $this->parameters['datatimerange'] = sprintf("starttime=%s&endtime=%s", 
60                    $this->dateTimeRange->startDateTime(),
61                    $this->dateTimeRange->endDateTime());
62    }
63
64    /**
65     * Add filter based on geographical selection
66     * @param \Fdsn\DataStructure\LatLonRange $square     Lat/Lon min -> Lat/Lon max
67     */
68    public function addFilterByBoundingBox(DS_LatLonRange $square):void { 
69        $this->square = $square; 
70
71        $this->parameters['boundingbox'] = sprintf("minlat=%f&maxlat=%f&minlon=%f&maxlon=%f",
72            $this->square->min()->lat(),
73            $this->square->max()->lat(),
74            $this->square->min()->lon(),
75            $this->square->max()->lon());
76    }
77
78    /**
79     * Add filter based on magnitude range
80     * @param \Fdsn\DataStructure\MagnitudeRange     $magnitudeRange     Magnitude min -> Magnitude max
81     */
82    public function addFilterByMagnitudeRange(DS_MagnitudeRange $magnitudeRange):void { 
83        $this->magnitudeRange = $magnitudeRange; 
84        $this->parameters['magnituderange'] = sprintf("minmag=%f&maxmag=%f",
85            $this->magnitudeRange->min()->value(),
86            $this->magnitudeRange->max()->value());
87    }
88
89    /**
90     * Add filter based on depth range
91     * @param \Fdsn\DataStructure\DepthRange $depthRange     Depth min -> Depth max
92     */
93    public function addFilterByDepthRange(DS_DepthRange  $depthRange):void { 
94        $this->depthRange  = $depthRange; 
95        $this->parameters['depthrange'] = sprintf("mindepth=%f&maxdepth=%f",
96            $this->depthRange->min()->value(),
97            $this->depthRange->max()->value());
98    }
99
100    /**
101     * Add filter based on latlon->radius
102     * @param \Fdsn\DataStructure\LatLon        $latlon        lat/lon as coordinate to start search
103     * @param \Fdsn\DataStructure\RadiusRange     $radiusRange    radius min->max to search ( valid range [0:180] for both radius )
104     */
105    public function addFilterByRadiusRange(DS_LatLon $latlon, DS_RadiusRange $radiusRange ):void { 
106        $this->latlon = $latlon;  
107        $this->radiusRange = $radiusRange; 
108
109        $this->parameters['radiusrange'] = sprintf("latitude=%f&longitude=%f&minradius=%.2f&maxradius=%.2f",
110            $this->latlon->lat(), $this->latlon->lon(),
111            $this->radiusRange->min()->value(), $this->radiusRange->max()->value());
112    }
113
114}