Time zone itch-is it really Beijing time to get the GPS module from the phone?

Source: Internet
Author: User
Tags time zones sunrise time


Last year, the Internet map industry began to introduce crowdsourcing model, the domestic relatively large map vendors, such as four-dimensional map, high-gold maps, Baidu Map began to launch the application of UGC, crowdsourcing to users to collect the door address, bus station and other information, and in accordance with the workload to the collector a certain return. I have played a German launched "Road Treasure" app, the application of internal integration of road Pat, door collection, public transport, POI task. The application has the following limitations: (1) in order to prevent cheating, the collector must turn on the GPS to take the number. (2) In order to ensure that the picture is clear, the collection work only half an hour after sunrise and half an hour before sunset. The problem is that the app simply reads the time of the phone to determine the sunrise and sunset time. In a user online meeting, far away in Xinjiang users complain, often the scorching sun collection is forced to end. PS: In fact, there is a bug he did not find: The sun rises before the collection has been released, and if you are located in the east of three northeastern provinces users, can still be collected after sunset ~

So where does the problem really be? Start with the time zone.

Theoretical time zones

It is well known that the Sunrise Day is different around the world due to the problem of time difference. However, each country or region, like to set the sunrise time around 5-7, the sunset at 16-19 points to the left, and even some areas in order to accommodate such a folk habit, but also sets the concept of daylight saving time. In this way, the use of the world's unified Greenwich Mean Time, can only stay in the professional field, and in the civil domain, we have to use the time appropriate to their own. This creates the time zone. Based on the Prime Meridian of Greenwich, London, 12 time zones were set for east to west, and the "time" values for each time zone differed by one hours.

The theoretical time zone is centered on a meridian that is divisible by 15, extending 7.5 degrees to the east and west sides, i.e. dividing a time zone every 15 °, which is the theoretical time zone. When the time zone of the theory takes place in its central meridian (or Standard meridian). Therefore, each time zone, the area is one hours apart, the difference in how many time zones, the difference is how many hours. The time zone in the east is earlier than the West time zone. The 0-degree meridian of Greenwich, extending 7.5 degrees to the east and west, constitutes a time zone of 15-degree range, which is the GMT period, which is also used as the international standard Time measurement. Longitude 7.5-22.5 degrees east of the region, and so on, the Western Hemisphere also adopted the same analogy. The East 12 and West 12 districts are coincident (172.5e-172.5w), and the International Date Line (180E/W) crosses from the middle. Crossing from east to west, date plus 1 days, west to east Crossing, date minus 1 days.

Legal time Zone

But the boundaries of the country are not as straight as the warp parallels. In order to avoid the boundaries of the country, some time zones are irregular in shape, and the country's internal administrative dividing line is the time zone, which is the actual time zone, that is, the legal time zone. So, the theoretical time zone symmetry, perfect division, it becomes this: (Image from Wikipedia)

As you can see, China spans 5 theoretical time zones (from East five to East nine), but all of them are in the legal time zone utc+8. The U.S. legal time zone is as close as possible to the theoretical time zone, so there is the United States East, the United States and West, the Pacific. The difference between equal time. In order to make the best use of sunlight, daylight saving time is used in some areas. China has adopted a 6-year daylight saving time, but because China will be a number of theoretical zones unified for the East eight, so the late dawn of Xinjiang and other regions can not play a role in saving energy, coupled with the general scientific literacy of our people is not high, resulting in more confusion. So a hasty ending.

GMT

Which legal time zone is used in a particular country depends on the theoretical time zone in which the capital is located. Beijing is located in the East eight district, so the East Eight region Center Meridian (120E) where the location of the Sun ( theoretical Time ) as the legal time , rather than Beijing's place in the sun (Beijing is roughly located near 116e,40w).

How is the time of the mobile device and computer calibrated?

As we all know, there are a large number of Internet timing services, such as the United States Naval Observatory Time Service Center, China National Institute of Chinese Academy of Sciences. These timing services provide a variety of data formats, such as the number of seconds from January 1, 1970 to the present integer, and then the time of the floating-point format, but the time base is GMT, that is Greenwich International Standard Time. Our new computer installation system, or mobile phone, tablet first enabled, there will generally be regional settings: "Utc+8, Beijing, Hong Kong, Taipei, Singapore." This allows the device to be converted to local time.

GPS Time

It is believed that a lot of people are aware of this. The GPS module (in the case of Android phones, called Location.gettime ()) obtains time, which is the local theoretical time calculated based on the theoretical time zone. The GPS satellite broadcasts the current world standard Time, then calculates the theoretical time zone based on latitude and longitude, and calculates the local time of the theoretical time zone in linear time. For example, you are in Kashi, Xinjiang, located in the theory of the East Five district, when Beijing time is 10 o'clock in the morning, then your mobile phone time is 10 points, but the GPS acquisition time is 7 points (East eight-east five = 3 hours of slack).

Can I obtain local legal time only through latitude and longitude?

Theoretically feasible. But in fact it is very difficult: because of the irregular nature of the border line, to store a certain point on the Earth (assuming that the size of 10 m * 10 meters) in the country or legal time zone, the amount of data is very large, the actual significance is not big. The current solution, therefore, is to require the user to manually set the regional options (and most of them are mandatory in the initialization wizard). Daylight saving Time mapping rules are much simpler, so the general will have the device to determine their own.

Solutions for "Road treasure Hunt" bugs

First, the time acquisition mode is changed by GPS access, you can make a real sunrise and sunset judgment. If the time zone is the granularity, theoretically 6 o'clock in the morning sunrise, 18 point sunset, this moment is also the local theoretical time.

Second, some Android phone manufacturers to develop the driver is really rotten, through the gettime may not get local theoretical time, then only through the GPS read longitude code switch-case condition judgment:

Switch (longitude)

{

Case 67.5e-82.5e (theory East Five): the use of local theoretical time is "mobile phone time (Beijing time)-3 hours" judgment;

Case 82.5e-97.5e (theory East six): The use of local theoretical time is "mobile phone time (Beijing time)-2 hours" judgment;

..... ;

Case 127.5E-142.5E (theory East Nine): The use of local theoretical time is "mobile phone time (Beijing time) + 1 hours" judgment;//Heilongjiang Jiamusi Fuyuan County Black Blind Island is almost 134E, this is the east end of China

}

Thirdly, a better approach is to calculate the sunrise and sunset of the point directly through the GPS latitude and longitude. Because the method is accurate to the point, so the error is only a few seconds, and "6 Point Sunrise 18 Sunset", the error within half an hour. This requires complex scientific calculations, which can be implemented in a code base.

More

The principle behind the map application is much more than that. China's unique coordinate distortions and offsets are also a big problem, compared with the international standard WGS84 coordinate system, domestic map dealers to pay the use of confidential conversion plug-ins.

Time zone itch-is it really Beijing time to get the GPS module from the phone?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.