server = 'https://awdn1.unl.edu/productdata/get?'; } else { $this->server = 'https://awdn2.unl.edu/productdata/get?'; } $this->ch = curl_init(); curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, 1); } function getList(string $product='scqc1440',string $network=null) { /* List Stations Generates a list of all stations in the database for the passed product ID. This call does not require any other parameters. :param str product: Product ID :param str network: Limit Request by Network :return: JSON containing: * Stationid * Name * Latitude * Longitude * Elevation * Network * Startup * Closedown * Climate Division Name * Climate Division Code :rtype: dict Networks ID are: * coagmet - Colorado * kstate - Kansas * iem - Iowa * ndawn - North Dakota, Minnesota, Montana * nemesonet - Nebraska * wacnet - Wyoming */ $this->server .= 'list='.$product; if (!is_null($network)) { $this->server .= '&network='.$network; } curl_setopt($this->ch, CURLOPT_URL, $this->server); return curl_exec($this->ch); } function getActive(string $product='scqc1440',string $network=null) { /* Active Stations Generates a list of active stations in the database for the passed product ID. This call does not require any other parameters. :param str product: Product ID :param str network: Limit Request by Network :return: JSON containing: * Stationid * Name * Latitude * Longitude * Elevation * Network * Startup * Received * Climate Division Name * Climate Division Code :rtype: dict Networks ID are: * coagmet - Colorado * kstate - Kansas * iem - Iowa * ndawn - North Dakota, Minnesota, Montana * nemesonet - Nebraska * wacnet - Wyoming */ $this->server .= 'active='.$product; if (!is_null($network)) { $this->server .= '&network='.$network; } curl_setopt($this->ch, CURLOPT_URL, $this->server); return curl_exec($this->ch); } function getData(string $name,string $begin,string $end,string $product='scqc1440',string $format="json",string $units='si',string $tz='CST',string $network=null,string $sensor=null) { /* Data Request Gets data for the requested parameters. :param str name: The name, state ID or station ID :param str productid: The product to read from :param str network: The network abbreviation. Optional and if omitted the name parameter is used alone. :param str begin: timestamp to start data retrieval on in the form YYYYmmddHH where: Y = year, m = month, d = day, H = hour. The hour can be omitted to get the full day :param str end: timestamp to end data retrieval on in the form YYYYmmddHH where: Y = year, m = month, d = day, H = hour. The hour can be omitted to get the full day :param str format: Output format. This is optional and defaults to json. * json = Javascript Object Notation * geojson = Geographical Javascript Object Notation * csv = Comma Spaced Values :param str tz: Timezone abbreviation to grab the data with. This is optional and defaults to Central Standard Time :param str sensor: Retrieve data for a specific sensor. This is optional. :param str units: Return data in United States (us) or International System (si) units. The default is International System. :return: Returns data from Web Services and Contains: * Name * State * County * Sensors * units * data * Latitude * Longitude :rtype: dict Networks ID are: * coagmet - Colorado * kstate - Kansas * iem - Iowa * ndawn - North Dakota, Minnesota, Montana * nemesonet - Nebraska * wacnet - Wyoming */ $this->server .= "name=".$name."&productid=".$product."&begin=".$begin."&end=".$end."&format=".$format; if (!is_null($network)) { $this->server .= '&network='.$network; } if (!is_null($units)) { $this->server .= '&units='.$units; } if (!is_null($tz)) { $this->server .= '&tz='.$tz; } if (!is_null($sensor)) { $this->server .= '&sensor='.$sensor; } curl_setopt($this->ch, CURLOPT_URL, $this->server); return curl_exec($this->ch); } function getGrid(string $date,string $product='scqc1440') { /* Grid Data Request Gets grid data for the requested parameters. :param str productid: The product to read. This can be hourly (scqc60), daily (scqc1440) or ET (penet) :param str date: timestamp to get data retrieval on in the form YYYYmmddHH where: Y = year, m = month, d = day, H = hour. The hour is omitted when getting daily grids. Yesterdays data can be reteived by using a 'y' instead of the timestamp. :return: Returns gridded data from Web Services in geojson format. :rtype: dict */ $this->server .= "grid=".$product."&date=".$date; curl_setopt($this->ch, CURLOPT_URL, $this->server); return curl_exec($this->ch); } } ?>