![]() |
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 |
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 |
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 |
Does it have to auto locate? Can you pick a specific weather station from their page and then specifically query that station?
|
Need more info about myLocation.queryLocation(); function.
Couldn't you just comment out the query and manually fill in your long/lat info? |
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). |
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() |
Quote:
But still... |
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... |
Oops will try this...
after reading this code for hours,its not a surprise than I miss some nuggets. |
Quote:
|
I agree, determining location by IP is unreliable. Too many variables outside of your control.
|
Quote:
|
Quote:
|
I know some of those words..
|
Quote:
|
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.... http://forums.pelicanparts.com/uploa...1394583929.jpg |
Quote:
|
Quote:
|
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.:D |
All times are GMT -8. The time now is 05:40 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0
Copyright 2025 Pelican Parts, LLC - Posts may be archived for display on the Pelican Parts Website