heeeeeeelp meee

  • 1
  • Question
  • Updated 5 years ago
/ create a instance of a wunderground data reader
HttpDataReaderService dataReader = new HttpDataReaderService();

// select a wunderground weather station (ID "INORDRHE72" = Dortmund-Mengede)
WeatherStation weatherStation = WeatherStations.ALL.get("INORDRHE72");

// set selected weather station to data reader
dataReader.setWeatherStation(weatherStation);

// get current (last) weather data set from selected station
DataSet current = dataReader.getCurrentData();

// print selected weather station ID
System.out.println(weatherStation.getStationId());

// print city, state and country of weather station
System.out.println(weatherStation.getCity() + " " + weatherStation.getState() + " " + weatherStation.getCountry());

// print datetime of measure and temperature ...
System.out.println(current.getDateTime() + " " + current.getTemperature());

that is not work for other station , please help me
Photo of elmottaki

elmottaki

  • 8 Posts
  • 0 Reply Likes
  • sad

Posted 5 years ago

  • 1
Photo of elmottaki

elmottaki

  • 8 Posts
  • 0 Reply Likes
heeeeeeeeeeeeelp please
Photo of afelicioni

afelicioni

  • 227 Posts
  • 43 Reply Likes
Can you reveal the other station id that doesn't work?

Extra: is this code using a custom java class or something?
Photo of elmottaki

elmottaki

  • 8 Posts
  • 0 Reply Likes
yes java but other station doesn't work with other station as
ITHRINGE25 Hasenthal Germany
ITHRINGE27 Kleinobringen Germany
ITHRINGE28 Saalfeld Germany
ITHRINGE26 Sitzendorf Germany
ITHRINGE21 Steinbach Germany
ITHRINGE33 Suhl Germany
ITHRINGE32 Tanna Germany
IURBACH71 73660 Germany
IVOGTLAN2 Bad Elster Germany
IVORPOMM2 Helpt Germany
IWATBOCH2 Bochum Germany
Photo of afelicioni

afelicioni

  • 227 Posts
  • 43 Reply Likes
I think I've spotted the class you're using ( https://code.google.com/p/wundergroun... ), but my java skills are poor so I am not able to give best advices.

There is a sort of hashmap, dictionary or whatever in wunderground/api/domain/WeatherStations.java class that you may need to customize, if you want to get this class working with the above stations IDs.

But I feel confused, because it seems that data gets scraped from regular website area, not coming from WU API ecosystem; just reading at resources/wunderground-core.properties there are strings like
wunderground.core.http.url=http\://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID\={1}&format\=1
wunderground.core.http.stations.url=http\://www.wunderground.com/weatherstation/ListStations.asp?selectedCountry\=
that the class uses to read and filtering as input to perform weather parameters reading requests... So, it's itself a sort of replica of Weather Underground API! It would be unfair to look for support here
Photo of elmottaki

elmottaki

  • 8 Posts
  • 0 Reply Likes
but how to modify this class
Photo of afelicioni

afelicioni

  • 227 Posts
  • 43 Reply Likes
editing wunderground/api/domain/WeatherStations.java with your favourite IDE or editor could be a start point, studying what the class asks for a station to be inlcuded.

if in trouble, try considering to get in touch with class developer
Photo of Martin

Martin

  • 0 Posts
  • 0 Reply Likes
WeatherStations class contains only some static weather stations objects.
To getting data from e.g "ITHRINGE33" do something like this:

WeatherStation weatherStation = new WeatherStation("ITHRINGE33");
weatherStation.setCity("Suhl");

httpDataReaderService.setWeatherStation(weatherStation);
DataSet weatherData = httpDataReaderService.getCurrentData();

System.out.println(weatherData.getTemperature());

this print actual 29.8 degree celsius to stdout.
Very hot currently!