B4J Question Best practices to get city name over Server Handler

Alexander Stolte

Expert
Licensed User
Longtime User
Hello,

to save a lot of money i have a good idea, but first my current situation:

in my Android and IOS App i use the current location (lat, lon) to post local content between the users. Currently i use the google geocode api to get the city name on the client side, but to access such a api is expensive if i have a lot of user. And users are often on the same lat lon coordinates.

My idea:
save the city name togehter with the lat lon coordinates and check in a range of 250 meters if there is already a city in this range in the database, IF NOT then i would call a B4J Server handler to call the geocode api to get the cityname.

Is this a good idea? I expect at the beginning high traffic, on this method maybe 20 request per second.
Does anyone already have experience using a server to call the city names via an api?

Greetings
 

MarkusR

Well-Known Member
Licensed User
Longtime User
Germany ~ (1000 x 1000 km) have ~2100 citys, not much.
if you would collect the data by click around the borders each one minute u need 35 hours :)
maybe u can extract the borders (geofence) from a web api request at open street map? (steal)
or u can live with a nearest city, just the middle of the city in lat,lon.
its really necessary to have the exact city from user?
the best solution is to be independent. (not addicted from google,apple,ms,amazon)
i think a small sqlite database can store all that u do not need a web request.
 
Last edited:
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
Germany ~ (1000 x 1000 km) have ~2100 citys, not much.
I have at my Database a dump from the city names from GeoNames. But i cant live with near by, because if a user live in Halle (Saale) for example i dont want to show him in Kabelsketal, because the nearest lat lon in the database are in Kabelsketal.

Yes it is necessary to have the exact (~250 meters) city.

the best solution is to be independent. (not addicted from google,apple,ms,amazon)
i think so too, but i dont think it is possible without it.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

MarkusR

Well-Known Member
Licensed User
Longtime User
hmm, 1000 km / 0,250 km = 4000 x 4000 = 16.000.000 Datas.

if the city is bigger maybe it helped if u add more points to get the best nearest.

its better to have a sub that check intersection point in polygon, but i thinks its complicated to solve.
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
I have now my own Openstreetmap-Server, setting up with Nominatim and with the latest database from Geofabrik.de.

So i can build my own B4J API to get the results I want. The Documentation from Nominatim is very good, that you can install everything without problems.
 
Upvote 0
Top