Pelican Parts
Parts Catalog Accessories Catalog How To Articles Tech Forums
Call Pelican Parts at 888-280-7799
Shopping Cart Cart | Project List | Order Status | Help



Go Back   Pelican Parts Forums > Miscellaneous and Off Topic Forums > Off Topic Discussions


Reply
 
LinkBack Thread Tools Rate Thread
Author
Thread Post New Thread    Reply
Navin Johnson
 
TimT's Avatar
 
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..
Old 03-03-2014, 03:07 PM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #1 (permalink)
Navin Johnson
 
TimT's Avatar
 
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
Old 03-03-2014, 03:18 PM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #2 (permalink)
Navin Johnson
 
TimT's Avatar
 
Join Date: Mar 2002
Location: Wantagh, NY
Posts: 8,800
Quote:
but weather underground seems to pull the location from the ISP
This is what is driving me crazy... it used to poll and display WU from a few miles away. The one day I woke up and noticed it was displaying info from Baltimore...

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
Old 03-03-2014, 03:37 PM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #3 (permalink)
Back in the saddle again
 
masraum's Avatar
 
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 SOLD 2004 - gone but not forgotten
Old 03-03-2014, 04:14 PM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #4 (permalink)
Slackerous Maximus
 
HardDrive's Avatar
 
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.
Old 03-03-2014, 04:17 PM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #5 (permalink)
Formerly bb80sc
 
Vipergrün's Avatar
 
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
Old 03-03-2014, 04:27 PM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #6 (permalink)
 
Registered
 
id10t's Avatar
 
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);
}
I'd also wrap the whole thing up in a check, first by using the GeolocationByIP function, prompting the user to either accept that location as "close enough" or entering a more correct location and then doing the query for the actual weather data.
__________________
“IN MY EXPERIENCE, SUSAN, WITHIN THEIR HEADS TOO MANY HUMANS SPEND A LOT OF TIME IN THE MIDDLE OF WARS THAT HAPPENED CENTURIES AGO.”
Old 03-03-2014, 04:32 PM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #7 (permalink)
Navin Johnson
 
TimT's Avatar
 
Join Date: Mar 2002
Location: Wantagh, NY
Posts: 8,800
Quote:
Looks like you need to request a "key" and insert it into the code block you referenced;
I have a key.... i just obscured it in the snippet I posted....I mean people on Pelican are genuinely solid folks....

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
Old 03-03-2014, 04:36 PM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #8 (permalink)
Navin Johnson
 
TimT's Avatar
 
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
Old 03-03-2014, 04:42 PM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #9 (permalink)
Navin Johnson
 
TimT's Avatar
 
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
Old 03-03-2014, 04:44 PM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #10 (permalink)
Registered
 
id10t's Avatar
 
Join Date: Mar 2003
Posts: 10,338
Quote:
Originally Posted by TimT View Post
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...
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.”
Old 03-03-2014, 05:13 PM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #11 (permalink)
Registered
 
Head416's Avatar
 
Join Date: Oct 2006
Location: Los Angeles, CA
Posts: 1,881
Garage
I agree, determining location by IP is unreliable. Too many variables outside of your control.
Old 03-03-2014, 07:02 PM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #12 (permalink)
 
Slackerous Maximus
 
HardDrive's Avatar
 
Join Date: Apr 2005
Location: Columbus, OH
Posts: 18,179
Quote:
Originally Posted by Head416 View Post
I agree, determining location by IP is unreliable. Too many variables outside of your control.
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.
Old 03-03-2014, 07:35 PM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #13 (permalink)
Feelin' Solexy
 
Tishabet's Avatar
 
Join Date: Oct 2003
Location: WA
Posts: 3,790
Quote:
Originally Posted by HardDrive View Post
Need more info about myLocation.queryLocation(); function.

Couldn't you just comment out the query and manually fill in your long/lat info?
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
Old 03-03-2014, 11:12 PM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #14 (permalink)
Hell Belcho
 
Nostril Cheese's Avatar
 
Join Date: Sep 2006
Location: Oz
Posts: 9,249
I know some of those words..
__________________
Saved by the buoyancy of citrus.
Old 03-04-2014, 12:33 AM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #15 (permalink)
Registered
 
id10t's Avatar
 
Join Date: Mar 2003
Posts: 10,338
Quote:
Originally Posted by Head416 View Post
I agree, determining location by IP is unreliable. Too many variables outside of your control.
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.”
Old 03-04-2014, 03:47 AM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #16 (permalink)
Navin Johnson
 
TimT's Avatar
 
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..
Old 03-11-2014, 04:25 PM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #17 (permalink)
I see you
 
flatbutt's Avatar
 
Join Date: Nov 2002
Location: NJ
Posts: 29,917
Quote:
Originally Posted by TimT View Post
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....

you need a girlfriend.
__________________
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."
Old 03-11-2014, 04:45 PM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #18 (permalink)
Navin Johnson
 
TimT's Avatar
 
Join Date: Mar 2002
Location: Wantagh, NY
Posts: 8,800
Quote:
you need a girlfriend.
In addition to my wife? I'll tell her you said so.
__________________
Don't feed the trolls. Don't quote the trolls
http://www.southshoreperformanceny.com
'69 911 GT-5
'75 914 GT-3
and others
Old 03-11-2014, 04:54 PM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #19 (permalink)
Registered
 
pete3799's Avatar
 
Join Date: Nov 2008
Location: Vermont
Posts: 7,431
Garage
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
Old 03-11-2014, 06:15 PM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #20 (permalink)
Reply


 


All times are GMT -8. The time now is 08:38 AM.


 
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 -    DMCA Registered Agent Contact Page
 

DTO Garage Plus vBulletin Plugins by Drive Thru Online, Inc.