Git Product home page Git Product logo

Comments (22)

ab1jx avatar ab1jx commented on August 20, 2024 1

I replied to the email because I attached some images. OK, it's picking it up here too. Except not the images.

See the end of https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=227884&p=1403190#p1403190 where the images are working. Matching while typing coordinates is maybe a bad idea.

I thought close referred to the dialog box not the issue. It's workable.

from meteo-qt.

dglent avatar dglent commented on August 20, 2024

Hello

Maybe the zip code could help more for this case as the coordinates needs to click and go to the map to check.

from meteo-qt.

ab1jx avatar ab1jx commented on August 20, 2024

https://developers.google.com/maps/documentation/geolocation/intro#responses

Using geolocation might work, if you can jump to the nearest weather station from that (lat & long). Not sure about zips, maybe there's a lookup table somewhere that crosses them to lat & long. I normally get a full weather forecast from NWS at
http://forecast.weather.gov/MapClick.php?lat=42.65050&lon=-72.8298&unit=0&lg=english&FcstType=text&TextType=1

That is my exact GPS lat & long, I let NWS match it to a forecast.

What are the numbers? My station is (maybe) 4830099 or 4950747 or 5157262. That's not the Yahoo woeid is it? My woeid is 12758427

from meteo-qt.

ab1jx avatar ab1jx commented on August 20, 2024

OK, user inputs a lat & long or it comes from geolocation (hopefully not geoip: terrible). Some server has all the known weather stations in some big table. 2 binary searches among lat & long data and you've got the 4 nearest weather stations. Present those to the user or use the geometrical distance formula to pick the closest one. It won't need to be done often.

from meteo-qt.

dglent avatar dglent commented on August 20, 2024

Great i will add this feature to search by geographic coordinates

from meteo-qt.

ab1jx avatar ab1jx commented on August 20, 2024

Good geolocation test page (look at the page source). https://benwerd.com/lab/geo.php The API is mostly used by phones with internal GPSes, but at least with Firefox it's possible to set up a file on fixed computers with no GPS that emulates it. And just a pair of edit boxes to input lat & long manually would be useful for when all that's not working or isn't set up.

Good app, I'm recommending it on a Raspberry Pi page at https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=227884&p=1397877#p1397877

from meteo-qt.

dglent avatar dglent commented on August 20, 2024

The above page is very usefull in order to get the geolocation, i will check it .
The above commit shows the coordinates in the results.

from meteo-qt.

dglent avatar dglent commented on August 20, 2024

Could you test the commit below ?

Search city by geographic coordinates:
f05b6da

from meteo-qt.

ab1jx avatar ab1jx commented on August 20, 2024

from meteo-qt.

ab1jx avatar ab1jx commented on August 20, 2024

That doesn't quite work either. Doing any ASCII search probably won't. Latitude and longitude are originally expressed in degrees, minute and seconds. Computers (mostly) use a decimal number like 42.650515. Each degree is broken into 60 minutes, each of those is 60 seconds. So the decimal is latitude + (minutes/60) + (seconds/3600) (roughly). If you express the coordinates as 2 doubles that's probably close enough, but they need to be numbers, not ASCII. The best discussion I could find quickly is at https://www.wikihow.com/Read-Latitude-and-Longitude-on-a-Map Decimal lat and long: https://www.wikihow.com/Write-Latitude-and-Longitude

Trying to use your geolocation interface landed me in New York because it's trying to match latitude first and assumes longitude is less significant. It's 2-dimensional, you can't do that.

from meteo-qt.

dglent avatar dglent commented on August 20, 2024

All tests i do work here.
Could you give me an example ?
In the example of the above link, you search for 38.53,-77

I don't understand for the "ascii" part of the question:
You add the coordinates and then it is created an url to request the place to openweathermap.com:
http://api.openweathermap.org/data/2.5/find?lat=38.53&lon=-77.0&type=like&mode=xml&APPID=xxxxxxxxxxx
You cannot specify anything else
Example of city name search results with coordinates: https://openweathermap.org/find?q=london
And the API of the url with coordinates request: https://openweathermap.org/current#geo

from meteo-qt.

dglent avatar dglent commented on August 20, 2024

The automatic geolocation doesn't work for you ?

from meteo-qt.

ab1jx avatar ab1jx commented on August 20, 2024

The "Find my location" icon doesn't work, it says N/A in the top window, "No results" at the bottom. Yet this geolocation test page works https://benwerd.com/lab/geo.php

By ASCII I mean letters, words as opposed to numbers. Coordinates are 2 numbers. Trying to "match as typed" can at best match the first one. And my coordinates don't exactly match any weather station's so trying to match characters won't work. You need to treat them as numbers and find the closest ones. It's like X and Y in Cartesian coordinates in math. Matching as text lands me in New York because I'm north of New York by 300 km and it only looks at the first number.

Pictures would be easier, but clicking the left icon in that dialog, the one with the magnifying glass and entering my coords as 42.65,-72.83
gets me the list
4932757 - Charlemont - - 42.6279 - -72.8699
4931627 - Buckland 42.5923 --72.7918
etc.

Those are close but what I use is:
Heath_US- lat: N S 42.6734°- lon: E W -72.8218°_4950747 (same #, hmm)

Hmm, I made a little HTML file with the http://api.openweathermap.org/data/2.5/find?lat=38.53&lon=-77.0&type=like&mode=xml&APPID=xxxxxxxxxxx URL copied from above and put in my coords and API key. When I click the link in my browser it brings up weather data from 5 cities all on one page: Charlemont, Buckland, Shelburne Falls, Colrain, Shelburne. So if you're using OWM's matching that part works I guess.

The geolocation button doesn't work, maybe because it's looking for an exact match and there isn't one. Those 5 cities are all within 15 km or so. But if I type the "lat: N S 42.6734°- lon: E W -72.8218°" coords from above into Google Maps it's under 3 km away and there is a weather station there because that's the one that WeatherBug uses. Town hall, town weather station.

Maybe some confusion comes from the fact that I live in a village of 800 people, not a city. OWM may be lumping them all together. But there's a big difference in altitude, I'm 487 meters above sea level, so the weather's different up here.

In what I get back in my browser I see that 4950747 is a "city id" by OWM: Shelburne at coord lon="-72.6885" lat="42.5898". So they're grouping Heath into the same city id even though it's 17 km away. That's a problem with Open Weather Maps, not with your program.

http://api.openweathermap.org/data/2.5/find?lat=42.650515&lon=-72.829819&type=like&mode=xml&APPID=296b517eddb0adaeb7226b3048de5b60

from meteo-qt.

dglent avatar dglent commented on August 20, 2024

Ok i see
For the coordinates, the resolution is done in OWM side. The only thing meteo-qt does is to send an url with the entered latitude and longitude.
So it seems that they don't provide your city when searching by coordinates

For the automatic geolocation i didn't use your site because it needs a click from the web browser (accept geolocation). Probably programmatically i need to make a webbrowser call and simulate the click to accept the geolocation.
I found this site http://ipinfo.io/json which provides the geolocation without click. If you open this site in the web browser, it works ?

from meteo-qt.

ab1jx avatar ab1jx commented on August 20, 2024

Well I shouldn't need a city, weather came before cities. I like my NWS URL of https://forecast.weather.gov/MapClick.php?lat=42.65050&lon=-72.8298&unit=0&lg=english&FcstType=text&TextType=1 You can edit your (US) coordinates into it and save it, email it, put it in your bookmarks toolbar, etc.

Accept geolocation is part of HTML 5 I think. Without that phones could send their locations without the owner's permission, making it possible (easier) to track them. Mine is just the first site I found a few years ago that worked for testing my local json file and Firefox setup so I kept using it. Yours, twice now says "Rate limit exceeded. Upgrade to increase your usage limits at https://ipinfo.io/pricing, or contact us via https://ipinfo.io/contact". Do you need an API key or something? Cookie? Oh well.

You don't have a Bitcoin ticker that sits in the tray up your sleeve by any chance? :)

ipinfo.io seems to be owned by Google. I was curious to see where it was that such a thing would work. nslookup on ipinfo.io comes back to 216.239.32.21 (and 3 others), then whois on 216.239.32.21 comes back to Google LLC.

from meteo-qt.

dglent avatar dglent commented on August 20, 2024

Ok so it is not a good solution this site. I thought that they allow a minimum number of lookups for free. I tested multiple times though without any problem. It may have region or other restrictions (?)
I will try to find another solution

Sorry nothing for bitcoin here :(

from meteo-qt.

ab1jx avatar ab1jx commented on August 20, 2024

It's Google, they're trying to make money off it. There's nothing in the URL to identify a user, maybe they only want to charge people with US IP addresses. Maybe it's because I use ad-blockers so their advertising doesn't load.

Anyway it's not rocket science but it does need to run on some server. I wrote this 11 months ago. If I open it as file:/// it doesn't work, but I'm running Apache (and nginx) on this Raspberry Pi. If I open it as http://127.0.0.1/geodemo.html it works. You could put something like it on any server, customize it however you want. It's only a first-time thing anyway, you don't need it often. Hmm, you're using Qt right, do you have a /usr/include/QtLocation directory? I'm not sure what mine came with, I do have QtCreator on here. I've only played with it a couple times. On Linux I wouldn't be sure there isn't something in /proc but only Firefox is looking at my json file, I don't have a real GPS on this. Anyway the HTML, which will probably get mangled by this form. I could email it as an attachment.

It tells me:
Latitude is 42.650515°
Longitude is -72.829819°

<!doctype html>

from meteo-qt.

ab1jx avatar ab1jx commented on August 20, 2024

https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/Using_geolocation and
https://www.mozilla.org/en-US/firefox/geolocation/

It works by doing
navigator.geolocation.getCurrentPosition(success, error);
then you can get to position.coords.latitude and position.coords.longitude

In Javascript, I don't know about Qt. In the above I don't see anything past the doctype line, that's the first of 53 lines.

In Qt look at QGeoLocation QPlace::location() const and GPSLatitude. Qt seems to treat GPS stuff like media stuff. How you fake it if you don't have a GPS connected I don't know. A couple of edit/text boxes or an ini/rc file would work.

http://doc.qt.io/qt-5/qtpositioning-index.html

from meteo-qt.

dglent avatar dglent commented on August 20, 2024

Thanks for the hints
I will try to find out the best method to improve the geolocation accuracy
Try please the above commit

from meteo-qt.

dglent avatar dglent commented on August 20, 2024

It seems that this site has also a good detection: https://iplocation.com/

from meteo-qt.

ab1jx avatar ab1jx commented on August 20, 2024

from meteo-qt.

dglent avatar dglent commented on August 20, 2024

After having added these 2 features:

  • Show the geolocation coordinates when searching a city
  • Detect automatically the geolocation by ip (from providers sites)

the basic need has been covered

from meteo-qt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.