Data |
Exception | Condition |
---|---|
LocationException | The request failed because of problems relating to the specified Location. |
ServiceException | The request failed because of a problem with the API service (sorry!). |
RateLimitException | You hit the RateLimit for your account's plan, and need to wait a little while before it's reset. |
InvalidRequestException | The request that is sent to the API servers is invalid (e.g. it is authenticated with invalid API access keys). |
TransportException | A problem sending the request to the API servers, or a problem getting the API's response back. |
DegreeDaysApiException | The superclass of all the exceptions listed above. |
ArgumentNullException | request is null. |
Typically you would specify a GeographicLocation in the LocationInfoRequest, using this GetLocationInfo(LocationInfoRequest) method to map postal/zip codes or longitude/latitude positions to station IDs.
This GetLocationInfo(LocationInfoRequest) method can be useful if you have a database of data stored by station ID, but are using geographic locations (postal/zip codes or longitude/latitude positions) to determine which station ID to use for each of your real-world locations. A call to this GetLocationInfo(LocationInfoRequest) method will only ever take one request unit, whilst a call to GetLocationData(LocationDataRequest) can take many more (depending on how much data it fetches), so it often makes sense to use this method to avoid the overhead of re-fetching data that you already have stored. We call this "two-stage data fetching", and you can read more about it in the remarks for the GeographicLocation class.
Note, however, that this returns nothing that isn't also returned by a call to GetLocationData(LocationDataRequest). So, if you know you'll be fetching data anyway, you might as well use GetLocationData(LocationDataRequest) from the start.
DegreeDaysApi api = new DegreeDaysApi( new AccountKey("test-test-test"), new SecurityKey("test-test-test-test-test-test-test-test-test-test-test-test-test")); DatedDataSpec hddSpec = DataSpec.Dated( Calculation.HeatingDegreeDays(Temperature.Fahrenheit(65)), DatedBreakdown.Yearly(Period.LatestValues(10))); LocationInfoRequest request = new LocationInfoRequest( Location.PostalCode("02532", "US"), new DataSpecs(hddSpec)); LocationInfoResponse response = api.DataApi.GetLocationInfo(request); Console.Out.WriteLine("Station ID: " + response.StationId);
The exceptions thrown by this GetLocationInfo(LocationInfoRequest) method are the same as those thrown by GetLocationData(LocationDataRequest), and they are thrown under exactly the same circumstances.
However, because the LocationInfoResponse returned by this method does not contain any data (i.e. no DataSets), there's no way to tell from this whether an equivalent LocationDataResponse would actually contain any or all of the data you want. So, although you can use this method to determine what station ID the API would use for an equivalent call to GetLocationData(LocationDataRequest), you would have to actually make that call to be sure that you could get all the data you wanted.
Version | Description |
---|---|
1.1 | This was added in version 1.1. |