Coordinate time zone

As a title, I need to find the time zone (or maybe just the UTC offset) based on a pair of coordinates. I have been looking for different solutions and there are several web services, but I need to have access to the application offline. Since time intervals are not entirely based on longitude, this does not seem so easy ...

Although I’m talking about requesting an ESRI shapefile, I have all the countries of the world and their time zones, but it seems complicated. If this should be the solution, do you know of any .NET library that provides this functionality?

+8
timezone c # shapefile esri
source share
5 answers

See: How to get the time zone from a location using latitude and longitude coordinates?

0
source share

I solved this with a client application. The technique was to create a color cylindrical map of the world, each time zone has a unique color. Lat-Lons are converted to image coordinates, and the color of the coordinate is read, and then cross-linked to the time zone of that color.

This short explanation is not exactly what I did, but he moved on to the idea. I actually filled out a couple of dictionaries and looked for them. The first execution required a 2M resource file to fill out (after I processed my card and turned it into binary data). The theoretical maximum error (for latitudes near the equator) should be +/- about 15 miles. Unfortunately, my initial map accuracy was more like +/- 100 miles.

So I'm redoing the project. I have been doing this for several days, creating both a more accurate and a higher map for a crunch. A couple more days, and this needs to be done. The resource file will be about 20 M, unless I select only the resources of the β€œstupid area” and mathematically calculate 90% of the world that can be calculated directly (most of the world can be mathematically derived from longitude). I'm not sure that many will make sure that the resource file is 20 M, but some could. In any case, if there is any interest, I will try to publish the code necessary to run it, and the resource file is one of the common code sites. If there seems to be no interest, I will not worry.

Just to re-iterate the code needed in your application, there are only a few lines, but the resource file is large (without compression, my new one works at 22 MB). It is also fast (the first performance was 100 M / s). This requires a file download, and it takes a little time. The 2M version did not have a noticeable delay, but the 22M may (not yet).

+6
source share

Check tz database. I know that it associates names with time zones (e.g., city, countries, EST, etc.). But I believe that somewhere there is an extension of coordinates.

+2
source share

I tried to export the table, but it is not possible to export geometry types to text. However, in any case, it was not so difficult. You need to create a google shapefile Manifold several years ago, which displays all the continents in the world and their time zones. Then you need to export this data to SQL Server 2008 using some kind of program. I used Manifold (don't forget to use Enterprise Edition or higher). Then I request data using the following stored procedure:

 USE [MyDb] GO /****** Object: StoredProcedure [dbo].[GetTimeZone] Script Date: 11/18/2009 21:23:52 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[GetTimeZone] @Latitude float, @Longitude float AS /* SET NOCOUNT ON */ DECLARE @g geometry /* Validation */ IF @Latitude > 90 OR @Latitude < -90 OR @Longitude > 180 OR @Longitude < -180 RAISERROR('Latitude or longitude out of range', 16, 1) IF @Latitude IS NULL OR @Longitude IS NULL RAISERROR('Latitude or longitude cannot be null', 16, 1) SET @g = geometry::Point(@Longitude, @Latitude, 4326); IF EXISTS(SELECT * From TimeZones WHERE Shape.STContains(@g) = 1) /* Point exists on map, get the info */ SELECT Name, LocalSumme, Offset, AreaI FROM TimeZones WHERE Shape.STContains(@g) = 1 ELSE /* Point is an international water */ IF(@Longitude >= 0) SELECT NULL AS Name, NULL AS LocalSumme, FLOOR((@Longitude + 7.5) / 15) AS Offset, NULL AS AreaI ELSE SELECT NULL AS Name, NULL AS LocalSumme, -FLOOR(( -@Longitude + 7.5) / 15) AS Offset, NULL AS AreaI 

There is a problem in the shapefile because national waters are not displayed. I may have used @ g.STBuffer () to solve this problem.

+1
source share

The solution was to export the ESRI shapefile to SQL Server 2008 using the new spatial data types.

If anyone has a better solution, feel free to post!

0
source share

All Articles