OpenWeatherMap Api give false data - java

I use this tutorial : Using OpenWeatherMap API Key
When I use this url with the city name the name is correct. So if I put "Paris" I have the word "Paris" on my application:
URL url = new URL("http://api.openweathermap.org/data/2.5/weather?q="+city+"&APPID=ea574594b9d36ab688642d5fbeab847e");
But when I try to do the same thing with latitude and longitude instead of the name of the city. The data of temperature, wind, pressure, ... are right. There is just the name of the city that is not right. Instead of having "Paris" I have something else.
URL url = new URL("http://api.openweathermap.org/data/2.5/weather?lat=%s&lon=%s&APPID=ea574594b9d36ab688642d5fbeab847e");
Example, by entering this into the browser. The numbers are reduced to two digits after the decimal point.

Related

GeoPoint - how to pass accuracy?

I have such information for saving to ES in my json:
{
"geolocation": {
"latitude": 50.443278299999996,
"longitude": 30.5075698,
"accuracy": 3966
}
}
geolocation in my Java object is GeoPoint (private GeoPoint geolocation). How I can pass an accuracy to GeoPoint? Or maybe there is another type for saving location with lat, lon and accuracy?
P.S. For parsing I use:
public GenericResponse<?> addUserInfo(#RequestBody UserInformation userInformation) {
}
And geolocation is one of the fields in UserInformation class.
I believe you are missing something. Accuracy or distance, it's something that you specify when querying, not when saving something. For example:
You have one entry in your elasticsearch. This entry has a geo_point field that includes lat and lon.
When you search for this profile you have a geo point, which represents a location and you want, based on this location (let's name it query location) to find all entries in elasticsearch that have a distance of X meters from you.
Basically there is no distance/accuracy to save. Given a geo query, elasticsearch will calculate the distance between these two points and it will check if it is smaller than the distance/accuracy you provided (during query), if it is, it will include the entry.

Android - Get id from Geocoder location

UPDATED: If I try to use ZIP CODE I'll get neighborhood code. And I want something to identify NEW YORK not the neighborhood.
I'm using geolocation (geocoder) in my app, and I compare the city name that geocode gives me with a name I already have in my database.
For example, if the user has phone language in English the result would be something like this:
DATABASE: New York
APP RESULT: New York (MATCH)
But if user has phone language in Spanish the result won`t match:
DATABASE: New York
APP RESULT: Nueva York (NO MATCH)
Is there any way to obtain a UNIQUE ID for every CITY instead of names, something like "CITYNAME = 0001q5"?

Firebase search on longitude and latitude

Hi was going to use Geofire for this but as its not compatiable with the latest version of Firebase yet I will hold off using it for now.
I have a simple database entry that looks like this...
author: "Aidan Mack"
lat: 58.9551641
long: -1.1091357
title: "hello"
userID: "userid"
I want to send a lat/long and distance radius and get back db entrys like the above within the given radius... any ideas how I would go about it with out using geofire?
Thanks
Aidan

Does google libphonenumber API provide CITY name based on the area code?

I am working on google libphonenumber to get the phone number's information. I was able to pull the State & country name. But I am unable to get the CITY name. Does the google API provide CITY name as well ?
Please advice thanks in advance.
Does Google's libphonenumber API provide city names based on the area code?
Yes - but only if its internal geocoding database contains that information. Some US phone numbers are entirely non-geographic (like 1-800 numbers) and for many others the database just doesn't have that information.
Also, libphonenumber's geo lookup only returns single string values: it does not return structured data, like a class with city, state, county, and zip code fields. And the format of the returned string value varies considerably - limiting its uses in any automated system as it necessarily requires a human user to interpret the data.
For example, using the current libphonenumber (as of December 2021, that's version 8.12.38), I get the following results for these fictitious, but valid, numbers:
1-800-333-4567
This is a non-geographic "1-800" (toll-free) number.
libphonenumber's lookup returns the string "United States".
1-201-200-0000
The is is a US phone number in area code 201 for New Jersey.
libphonenumber's lookup returns the string "Jersey City, NJ".
It resolved it to a city and state, giving the state's abbreviation.
1-425-666-9999
This is (almost) my own personal phone number which I got from a T-Mobile store in Redmond, WA.
But libphonenumber's lookup returns only the imprecise string "Washington State" with no city name or similar. It's curious that it returned the full US state name instead of the "WA" abbreviation.
Remember, as with any in-proc "offline" geolocation database, data will inevitably go stale and inaccurate. Also, in the US at least, it's impossible to differentiate between mobile-phone numbers and landline numbers, and the area-code of someone's mobile-phone number is completely detached from the phone subscriber's actual physical location (it's usually the area-code of the AT&T / T-Mobile / Sprint store where they initially signed-up for service, even if they subsequently move across the country).
Anyway, here's how you use the PhoneNumberOfflineGeocoder class:
Java:
static string lookupNumber( string phoneNumber ) {
PhoneNumber parsed = PhoneNumberUtil.getInstance().parse( phoneNumber, /*defaultRegion:*/ "US" );
return PhoneNumberOfflineGeocoder.getInstance().getDescriptionForNumber( parsed, Locale.ENGLISH );
}
lookupNumber( "1-800-333-4567" ) // "United States"
lookupNumber( "+12012000000" ) // "Jersey City, NJ"
lookupNumber( "+14256669999" ) // "Washington State"
C#
static String LookupNumber( string phoneNumber ) {
PhoneNumber parsed = PhoneNumberUtil.GetInstance().Parse( phoneNumber, defaultRegion: "US" );
return PhoneNumberOfflineGeocoder.GetInstance().GetDescriptionForNumber( parsed, Locale.English );
}
LookupNumber( "1-800-333-4567" ) // "United States"
LookupNumber( "+12012000000" ) // "Jersey City, NJ"
LookupNumber( "+14256669999" ) // "Washington State"

Google GeoCoding Query

I am doing "Address Validation". My Address table has "Street Address", "City", "State", "Postal Code", "Country". I am using Google MAP API to validate my address.
I gave my address like
Street Address -- "kajhfkjdhfkjdsh"
City -- ksjfdlsjflsdjflk
State -- AP
PostalCode -- 500087
Country -- India
In this example only State, PostalCode, Country are valid and the remaining fields are invalid. But when I use the Google Map's API its saying its a valid address. But the street address and city are invalid.
So as per my observation the address validation is done only based on 3 fields those are (State, Postal Code, Country). So How can I validate Street and city along with the remaining fields with GOOGLE MAPS API?
Or is there any way/other (API) to validate all the fields in my address table.
Can anyone help me on this. I am stuck over here.
When trying this address with the google geocoding service http://maps.googleapis.com/maps/api/geocode/xml?sensor=false&address=kajhfkjdhfkjdsh,ksjfdlsjflsdjflk,AP,500087,India I see the result is of type postal_code and partial_match is set to true.
Trying real address I get the result type as street_address and the partial_match flag is missing.
I suggest you make some tests and check the content of the service result. This is a geocoding service, so it aims to give you a location to point your map to, not to validate addresses.

Categories

Resources