algorithm for getting time zone from geo coordinates

前端 未结 4 1427
春和景丽
春和景丽 2021-01-02 03:15

I want to write app where user can point any place on map (not only cities) and get timezone in that place.

What data structure (app will not have Internet connectiv

4条回答
  •  渐次进展
    2021-01-02 03:41

    There are a number of web services that can do this for you (for example GeoNames has a great API). But if you don't have an Internet connection, then that's not something you're going to find directly in Java ME's standard libraries.

    You could do something close, though: Store the coordinates of the cities corresponding to each time zone, then do a Voronoi tessellation so that you have the areas which are closest to each city. Then, when your users click on a particular geographic area, you simply map that point to the right section of the tessellation, and presto -- you've got the nearest city, which in turn determines the right time zone.

    More sophisticated approaches are possible, but they also require significantly larger memory structures, which I assume is a constraint if you are running Java ME. This is a good compromise between space and speed.

提交回复
热议问题