public final class LocationDataRequest extends Request implements java.io.Serializable
LocationDataRequest will result in a
LocationDataResponse containing the specified
data.
Here's an example showing how to create a request for one set of data from the EGLL weather station in London, UK. The request specifies heating degree days with a base temperature of 15.5°C, broken down on a daily basis and covering the whole of July 2024:
Period period = Period.dayRange(Day.of(2024, 7, 1).to(2024, 7, 31));
DatedBreakdown breakdown = DatedBreakdown.daily(period);
Temperature baseTemp = Temperature.celsius(15.5);
Calculation calculation = Calculation.heatingDegreeDays(baseTemp);
DatedDataSpec dataSpec = DataSpec.dated(calculation, breakdown);
Location location = Location.stationId("EGLL");
LocationDataRequest request = new LocationDataRequest(
location, new DataSpecs(dataSpec));
Here's an example showing how to create a request for two sets of data from
Times Square in New York. We specify the location as a zip code (a type of
GeographicLocation), leaving it to the API to choose the most
appropriate weather station in the area. The request specifies heating degree
days with a base temperature of 55°F, and cooling degree days with a base
temperature of 65°F, both broken down on a monthly basis and covering the
last 12 months:
DatedBreakdown breakdown = DatedBreakdown.monthly(Period.latestValues(12));
DatedDataSpec hddSpec = DataSpec.dated(
Calculation.heatingDegreeDays(Temperature.fahrenheit(55)),
breakdown);
DatedDataSpec cddSpec = DataSpec.dated(
Calculation.coolingDegreeDays(Temperature.fahrenheit(65)),
breakdown);
LocationDataRequest request = new LocationDataRequest(
Location.postalCode("10036", "US"),
new DataSpecs(hddSpec, cddSpec));
See DataApi.getLocationData(LocationDataRequest) for an example of
how to submit a LocationDataRequest to the API and get a
LocationDataResponse back containing the data you requested.
DataApi.getLocationData(LocationDataRequest)Instances of this class are immutable. You can safely reuse them and call them from multiple threads at once.
| Constructor and Description |
|---|
LocationDataRequest(Location location,
DataSpecs dataSpecs)
Constructs a
LocationDataRequest object with the specified
Location and DataSpecs. |
| Modifier and Type | Method and Description |
|---|---|
DataSpecs |
dataSpecs()
Returns the non-null
DataSpecs object that specifies how the
set(s) of data should be calculated and broken down. |
boolean |
equals(java.lang.Object o)
Two
LocationDataRequest objects are equal if it can be
ascertained that they are specifying the same set(s) of data from the
same location. |
int |
hashCode()
Overridden to ensure consistency with
equals. |
Location |
location()
Returns the non-null
Location object that specifies the
location for which the data should be generated. |
java.lang.String |
toString()
Returns a non-null, non-empty string representation of this object for logging and debugging purposes.
|
public LocationDataRequest(Location location, DataSpecs dataSpecs)
LocationDataRequest object with the specified
Location and DataSpecs.location - the non-null location for which the data should be
generated.dataSpecs - the non-null specification of how the set(s) of data
should be calculated and broken down.java.lang.NullPointerException - if location or
dataSpecs is null.public Location location()
Location object that specifies the
location for which the data should be generated.public DataSpecs dataSpecs()
DataSpecs object that specifies how the
set(s) of data should be calculated and broken down.public boolean equals(java.lang.Object o)
LocationDataRequest objects are equal if it can be
ascertained that they are specifying the same set(s) of data from the
same location. In other words, they are equal if their
dataSpecs() objects are equal and their location()
objects are equal.equals in class java.lang.Objectpublic int hashCode()
equals.hashCode in class java.lang.Objectpublic java.lang.String toString()
The exact details of the representation are unspecified and subject to change.
toString in class java.lang.Object
See www.degreedays.net/api/ for more about the Degree Days.net API.
You can sign up for a Degree Days.net API account and read the integration guide that is useful and applicable whether you are using Java or not.