![]() |
|
|
|
Navin Johnson
Join Date: Mar 2002
Location: Wantagh, NY
Posts: 8,800
|
Code gurus
I built a little gizmo that fetches weather reports from WeatherUnderground... Used code that was available on Instructables. I re-wrote some things to streamline things.... but am having a hard time getting a good location.. I.e. I live in NY and the box is querying weather in Baltimore... (code author say something about service providers using proxies etc..)
The author of the code mentions in his notes that this section of code is where more accurate geolocations can be noted... Here is snip where things should change ... private static void InitLocation() { GeoLoactionByIP myLocation = new GeoLoactionByIP(); AskGeoService askGeo = new AskGeoService(); myLocation.queryLocation(); weatherData = new WeatherUndergroundData("d0", myLocation.latitude, myLocation.longitude);// <<< Your Key Here askGeo.queryLocation(myLocation.latitude, myLocation.longitude); int minutes = (int)(askGeo.currentOffserMS / 1000 / 60); Debug.Print("\tTimezone offset (+DST)=" + minutes + " minutes"); ntpService.SetTimeZoneOffset(minutes); } FWIW I've tried numerous iterations.... C#, VB running a netduino + FWIW 2 because of a snow day...I had plenty of time to google
__________________
Don't feed the trolls. Don't quote the trolls ![]() http://www.southshoreperformanceny.com '69 911 GT-5 '75 914 GT-3 and others Last edited by TimT; 03-03-2014 at 03:38 PM.. |
||
![]() |
|
Navin Johnson
Join Date: Mar 2002
Location: Wantagh, NY
Posts: 8,800
|
This is the authors bread crumb trail...
Maybe I am over thinking this... If your network is going through a very remote proxy, like many organizations are still using for connecting remote offices to the internet, then the location the Netduino-Plus finds is where your proxy server is. It is fairly easy to change the Netduino-Plus code to use fixed location instead of auto-detecting it, and I will let those who are interested do it themselves. Hint: All you need is use fixed longitude and latitude in function ' InitLocation' coded in the file Program.cs
__________________
Don't feed the trolls. Don't quote the trolls ![]() http://www.southshoreperformanceny.com '69 911 GT-5 '75 914 GT-3 and others |
||
![]() |
|
Navin Johnson
Join Date: Mar 2002
Location: Wantagh, NY
Posts: 8,800
|
Quote:
I've been at the code a number of times, and no joy... I emailed the author a few weeks ago... and haven't heard back
__________________
Don't feed the trolls. Don't quote the trolls ![]() http://www.southshoreperformanceny.com '69 911 GT-5 '75 914 GT-3 and others |
||
![]() |
|
Back in the saddle again
Join Date: Oct 2001
Location: Central TX west of Houston
Posts: 56,107
|
Does it have to auto locate? Can you pick a specific weather station from their page and then specifically query that station?
__________________
Steve '08 Boxster RS60 Spyder #0099/1960 - never named a car before, but this is Charlotte. '88 targa ![]() |
||
![]() |
|
Slackerous Maximus
Join Date: Apr 2005
Location: Columbus, OH
Posts: 18,179
|
Need more info about myLocation.queryLocation(); function.
Couldn't you just comment out the query and manually fill in your long/lat info?
__________________
2022 Royal Enfield Interceptor. 2012 Harley Davidson Road King 2014 Triumph Bonneville T100. 2014 Cayman S, PDK. Mercedes E350 family truckster. |
||
![]() |
|
Formerly bb80sc
Join Date: Aug 2001
Location: Hollywood Beach, CA
Posts: 4,361
|
Did you see this snippet about their API;
API | Weather Underground Looks like you need to request a "key" and insert it into the code block you referenced; Your_Key Your API key. You can request a key on the sign in page. This is used in most API calls (with the exception of the AutoComplete API).
__________________
Cheers -Brad 2015 Cayman GTS 2015 4Runner Limited |
||
![]() |
|
![]() |
Registered
Join Date: Mar 2003
Posts: 10,338
|
Determine your true lat/long (instead of using the GeoLocationByIP function) and just plug it in as the RealLatitude and RealLongitude variables
Code:
private static void InitLocation() { AskGeoService askGeo = new AskGeoService(); weatherData = new WeatherUndergroundData("d0", RealLatitude, RealLongitude); askGeo.queryLocation(RealLatitude, RealLongitude); int minutes = (int)(askGeo.currentOffserMS / 1000 / 60); Debug.Print("\tTimezone offset (+DST)=" + minutes + " minutes"); ntpService.SetTimeZoneOffset(minutes); }
__________________
“IN MY EXPERIENCE, SUSAN, WITHIN THEIR HEADS TOO MANY HUMANS SPEND A LOT OF TIME IN THE MIDDLE OF WARS THAT HAPPENED CENTURIES AGO.” |
||
![]() |
|
Navin Johnson
Join Date: Mar 2002
Location: Wantagh, NY
Posts: 8,800
|
Quote:
But still...
__________________
Don't feed the trolls. Don't quote the trolls ![]() http://www.southshoreperformanceny.com '69 911 GT-5 '75 914 GT-3 and others |
||
![]() |
|
Navin Johnson
Join Date: Mar 2002
Location: Wantagh, NY
Posts: 8,800
|
When I entered my real Lat/Long in code..
weatherData = new WeatherUndergroundData("d0", RealLatitudehere, RealLongitudehere ) Upon debugging and compiling there were many errors. tried many variations of syntax..could not get that to work...
__________________
Don't feed the trolls. Don't quote the trolls ![]() http://www.southshoreperformanceny.com '69 911 GT-5 '75 914 GT-3 and others |
||
![]() |
|
Navin Johnson
Join Date: Mar 2002
Location: Wantagh, NY
Posts: 8,800
|
Oops will try this...
after reading this code for hours,its not a surprise than I miss some nuggets.
__________________
Don't feed the trolls. Don't quote the trolls ![]() http://www.southshoreperformanceny.com '69 911 GT-5 '75 914 GT-3 and others |
||
![]() |
|
Registered
Join Date: Mar 2003
Posts: 10,338
|
Need to see the errors. If it is about data type mismatch then check the docs for the data type the GeoByIP call returns and be sure to define your lat/long variables as the same type.
__________________
“IN MY EXPERIENCE, SUSAN, WITHIN THEIR HEADS TOO MANY HUMANS SPEND A LOT OF TIME IN THE MIDDLE OF WARS THAT HAPPENED CENTURIES AGO.” |
||
![]() |
|
Registered
|
I agree, determining location by IP is unreliable. Too many variables outside of your control.
|
||
![]() |
|
![]() |
Slackerous Maximus
Join Date: Apr 2005
Location: Columbus, OH
Posts: 18,179
|
Yup. Proxy server could be a long, long way from your physical location.
__________________
2022 Royal Enfield Interceptor. 2012 Harley Davidson Road King 2014 Triumph Bonneville T100. 2014 Cayman S, PDK. Mercedes E350 family truckster. |
||
![]() |
|
Feelin' Solexy
Join Date: Oct 2003
Location: WA
Posts: 3,790
|
Or, dump the values of mylocation.lat/mylocation.long to screen... shoild be able to debug if you know what data has been retrieved using this geodatafromip() functionality. Comment out anything related to the askgeo and weatherundergrounddata functions to keep your test simple.
__________________
Grant In the stable: 1938 Buick Special model 41, 1963 Solex 2200, 1973 Vespa Primavera 125, 1974 Vespa Rally 200, 1986 VW Vanagon Syncro Westfalia, 1989 VW Doka Tristar, 2011 Pursuit 315 OS, 2022 Tesla Y Gone but not forgotten: 1973 VW Beetle, 1989 Porsche 944, 2008 R56 Mini Cooper S |
||
![]() |
|
Hell Belcho
Join Date: Sep 2006
Location: Oz
Posts: 9,249
|
I know some of those words..
__________________
Saved by the buoyancy of citrus. |
||
![]() |
|
Registered
Join Date: Mar 2003
Posts: 10,338
|
Hey, 127.0.0.1 is always where I am !
__________________
“IN MY EXPERIENCE, SUSAN, WITHIN THEIR HEADS TOO MANY HUMANS SPEND A LOT OF TIME IN THE MIDDLE OF WARS THAT HAPPENED CENTURIES AGO.” |
||
![]() |
|
Navin Johnson
Join Date: Mar 2002
Location: Wantagh, NY
Posts: 8,800
|
Corresponded with the guy who wrote the snippets.... There is now joy
//GeoLoactionByIP myLocation = new GeoLoactionByIP(); AskGeoService askGeo = new AskGeoService(); //myLocation.queryLocation(); //m_weatherData = new WeatherUndergroundData("here was your key", myLocation.latitude, myLocation.longitude); string lat = "32."; // "32.0"; string longi = "34.";// "34.7"; //askGeo.queryLocation(myLocation.latitude, myLocation.longitude); askGeo.queryLocation(lat, longi); weatherData = new WeatherUndergroundData("here place your key", lat, longi); int minutes = (int)(askGeo.currentOffserMS / 1000 / 60); Debug.Print("\tTZ offset(+DST)=" + minutes + " minutes"); ntpService.SetTimeZoneOffset(minutes); Its just a little gizmo that displays current and two day future weather... Next I am going to tackle the touch screen coding.... ![]()
__________________
Don't feed the trolls. Don't quote the trolls ![]() http://www.southshoreperformanceny.com '69 911 GT-5 '75 914 GT-3 and others Last edited by TimT; 03-11-2014 at 04:28 PM.. |
||
![]() |
|
I see you
Join Date: Nov 2002
Location: NJ
Posts: 29,917
|
Quote:
![]()
__________________
Si non potes inimicum tuum vincere, habeas eum amicum and ride a big blue trike. "'Bipartisan' usually means that a larger-than-usual deception is being carried out." |
||
![]() |
|
Navin Johnson
Join Date: Mar 2002
Location: Wantagh, NY
Posts: 8,800
|
Quote:
__________________
Don't feed the trolls. Don't quote the trolls ![]() http://www.southshoreperformanceny.com '69 911 GT-5 '75 914 GT-3 and others |
||
![]() |
|
Registered
|
I'll save you the trouble Tim......
Up to 24 inches expected here maybe less down where your place is in Bomoseen. Pack your snow shoes. ![]()
__________________
Pete 79 911SC RoW "Tornadoes come out of frikkin nowhere. One minute everything is all sunshine and puppies the next thing you know you've got flying cows".- Stomachmonkey |
||
![]() |
|