/** * @param null|int $fileId The database ID for the time-series to load TwlData Points for. * * @throws InvalidOperationException If database credentials have not been set. */ public final function loadTwlTimeSeries($fileId = NULL) { if (is_null(self::$databaseCredentials)) { throw new InvalidOperationException('Database credentials must be set at the class level to allow this action to take place.'); } TwlFile::setDatabaseCredentials(self::$databaseCredentials); TwlTimeSeries::setDatabaseCredentials(self::$databaseCredentials); if (is_null($fileId)) { $fileData = TwlFile::getLatestFileData($this->getSiteName()); $fileId = (int) $fileData['file_id']; } $timeSeriesId = (int) TwlTimeSeries::findClosestTimeSeries($this->position); $this->timeSeries = TwlTimeSeries::loadTimeSeries($fileId, $timeSeriesId); }
<?php /** * Provides functionality to return a dune time series for graphing. * * Project: twlProject * File: loadDune.php * Created: 3/6/2016 5:19 PM * * @author Richard Snell <*****@*****.**> */ include_once '../includes/globalConfig.php'; Dune::setDatabaseCredentials($twlProjectCredentials); GeographicalFeature::setDatabaseCredentials($geonamesCredentials); TwlTimeSeries::setDatabaseCredentials($twlProjectCredentials); $DBH = call_user_func_array('DatabaseHelper::getInstance', $twlProjectCredentials); $timeSeriesId = filter_input(INPUT_GET, 'timeSeriesId', FILTER_VALIDATE_INT); $fileId = filter_input(INPUT_GET, 'fileId', FILTER_VALIDATE_INT); $duneId = filter_input(INPUT_GET, 'duneId', FILTER_VALIDATE_INT); if (empty($timeSeriesId) || empty($fileId) || empty($duneId)) { print 'empty'; exit; } $dune = Dune::loadById($duneId); $location = new GeographicalFeature($dune->getPosition()); $location->reverseGeocode(); $dune->setTimeSeries(TwlTimeSeries::loadTimeSeries($fileId, $timeSeriesId)); $returnData = $dune->exportDune(); $returnData['impEvt'] = $dune->duneImpactingEvents(); $returnData['dune']['location'] = $location->getCity(); print json_encode($returnData);