Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
100.00% |
28 / 28 |
|
66.67% |
10 / 15 |
|
50.00% |
5 / 10 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 1 |
| MultiInstance | |
100.00% |
28 / 28 |
|
66.67% |
10 / 15 |
|
50.00% |
5 / 10 |
|
100.00% |
5 / 5 |
22.50 | |
100.00% |
1 / 1 |
| addFilterByDateTimeRange | |
100.00% |
5 / 5 |
|
66.67% |
2 / 3 |
|
50.00% |
1 / 2 |
|
100.00% |
1 / 1 |
2.50 | |||
| addFilterByBoundingBox | |
100.00% |
7 / 7 |
|
66.67% |
2 / 3 |
|
50.00% |
1 / 2 |
|
100.00% |
1 / 1 |
2.50 | |||
| addFilterByMagnitudeRange | |
100.00% |
5 / 5 |
|
66.67% |
2 / 3 |
|
50.00% |
1 / 2 |
|
100.00% |
1 / 1 |
2.50 | |||
| addFilterByDepthRange | |
100.00% |
5 / 5 |
|
66.67% |
2 / 3 |
|
50.00% |
1 / 2 |
|
100.00% |
1 / 1 |
2.50 | |||
| addFilterByRadiusRange | |
100.00% |
6 / 6 |
|
66.67% |
2 / 3 |
|
50.00% |
1 / 2 |
|
100.00% |
1 / 1 |
2.50 | |||
| 1 | <?php |
| 2 | namespace Fdsn\Webservices\Event; |
| 3 | |
| 4 | use ArrayIterator; |
| 5 | use IteratorAggregate; |
| 6 | use Traversable; |
| 7 | |
| 8 | use Fdsn\Webservices\Event\Event as Fdsnws_Webservice_Event; |
| 9 | |
| 10 | use Fdsn\Webservices\Event\Structs\Author as DS_Author; |
| 11 | use Fdsn\Webservices\Event\Structs\DateTimeRange as DS_DateTimeRange; |
| 12 | use Fdsn\Webservices\Event\Structs\Depth as DS_Depth; |
| 13 | use Fdsn\Webservices\Event\Structs\DepthRange as DS_DepthRange; |
| 14 | use Fdsn\Webservices\Event\Structs\Epicenter as DS_Epicenter; |
| 15 | use Fdsn\Webservices\Event\Structs\Id as DS_Id; |
| 16 | use Fdsn\Webservices\Event\Structs\LatLon as DS_LatLon; |
| 17 | use Fdsn\Webservices\Event\Structs\LatLonRange as DS_LatLonRange; |
| 18 | use Fdsn\Webservices\Event\Structs\Location as DS_Location; |
| 19 | use Fdsn\Webservices\Event\Structs\Magnitude as DS_Magnitude; |
| 20 | use Fdsn\Webservices\Event\Structs\MagnitudeRange as DS_MagnitudeRange; |
| 21 | use Fdsn\Webservices\Event\Structs\Quake as DS_Quake; |
| 22 | use Fdsn\Webservices\Event\Structs\Radius as DS_Radius; |
| 23 | use 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 | */ |
| 33 | class 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 | if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); |
| 59 | $this->dateTimeRange = $dateTimeRange; |
| 60 | $this->parameters['datatimerange'] = sprintf("starttime=%s&endtime=%s", |
| 61 | $this->dateTimeRange->startDateTime(), |
| 62 | $this->dateTimeRange->endDateTime()); |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Add filter based on geographical selection |
| 67 | * @param \Fdsn\DataStructure\LatLonRange $square Lat/Lon min -> Lat/Lon max |
| 68 | */ |
| 69 | public function addFilterByBoundingBox(DS_LatLonRange $square):void { |
| 70 | if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); |
| 71 | |
| 72 | $this->square = $square; |
| 73 | |
| 74 | $this->parameters['boundingbox'] = sprintf("minlat=%.2f&maxlat=%.2f&minlon=%.2f&maxlon=%.2f", |
| 75 | $this->square->min()->lat(), |
| 76 | $this->square->max()->lat(), |
| 77 | $this->square->min()->lon(), |
| 78 | $this->square->max()->lon()); |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * Add filter based on magnitude range |
| 83 | * @param \Fdsn\DataStructure\MagnitudeRange $magnitudeRange Magnitude min -> Magnitude max |
| 84 | */ |
| 85 | public function addFilterByMagnitudeRange(DS_MagnitudeRange $magnitudeRange):void { |
| 86 | if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); |
| 87 | |
| 88 | $this->magnitudeRange = $magnitudeRange; |
| 89 | $this->parameters['magnituderange'] = sprintf("minmag=%.2f&maxmag=%.2f", |
| 90 | $this->magnitudeRange->min()->value(), |
| 91 | $this->magnitudeRange->max()->value()); |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * Add filter based on depth range |
| 96 | * @param \Fdsn\DataStructure\DepthRange $depthRange Depth min -> Depth max |
| 97 | */ |
| 98 | public function addFilterByDepthRange(DS_DepthRange $depthRange):void { |
| 99 | if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); |
| 100 | |
| 101 | $this->depthRange = $depthRange; |
| 102 | $this->parameters['depthrange'] = sprintf("mindepth=%.2f&maxdepth=%.2f", |
| 103 | $this->depthRange->min()->value(), |
| 104 | $this->depthRange->max()->value()); |
| 105 | } |
| 106 | |
| 107 | /** |
| 108 | * Add filter based on latlon->radius |
| 109 | * @param \Fdsn\DataStructure\LatLon $latlon lat/lon as coordinate to start search |
| 110 | * @param \Fdsn\DataStructure\RadiusRange $radiusRange radius min->max to search ( valid range [0:180] for both radius ) |
| 111 | */ |
| 112 | public function addFilterByRadiusRange(DS_LatLon $latlon, DS_RadiusRange $radiusRange ):void { |
| 113 | if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); |
| 114 | |
| 115 | $this->latlon = $latlon; |
| 116 | $this->radiusRange = $radiusRange; |
| 117 | |
| 118 | $this->parameters['radiusrange'] = sprintf("latitude=%.3f&longitude=%.3f&minradius=%.2f&maxradius=%.2f", |
| 119 | $this->latlon->lat(), $this->latlon->lon(), |
| 120 | $this->radiusRange->min()->value(), $this->radiusRange->max()->value()); |
| 121 | } |
| 122 | |
| 123 | } |