Android has official GPS positioning API, why use Baidu/GPS positioning SDK?

1. Background

In a Demoproject, the team is ready to use the official GPSpositioning to save trouble API.
But in my impression, the official positioning APIis not easy to use, and the positioning is generally 高德地图/百度地图used SDK.
If you use the official location APIto obtain the location, you may not be able to get it indoors when you are debugging in the office.
But after trying it out 感到惊讶, I was able to locate it indoors. What’s going on? It’s different from what I thought
.

Through this article, these issues will be clarified

  • What kinds of active positioning methods are there?
  • Why is it almost impossible to receive GPS signals indoors?
  • Why can positioning be performed indoors?
  • Should I use the official positioning API or the Baidu/AutoNavi positioning SDK?

2. Android official positioning API

Let’s first look at the Android official positioning API , there are several positioning methods

  • GPS_PROVIDER: Obtain the latitude and longitude information of the geographic location through GPS
  • NETWORK_PROVIDER: Obtain the geographic location through the base station of the mobile network or Wi-Fi
  • PASSIVE_PROVIDER: Passive positioning. Other applications such as Baidu and AutoNavi use positioning. The system will update the positioning information and save it. In this way, the latest location information can be obtained. You can query getProvider()the method to determine the origin of the location update, which requires ACCESS_FINE_LOCATIONthe permission, but if not enabled GPS, this providermay only return a rough location match;

3. Check the statements of online articles

I searched the descriptions in the online articles, and it is similar to my impression. There are
two ways of active positioning in the official high-level API, but they are not very easy to use.

  • GPS positioning : When developing indoors, mobile phones can hardly obtain location information at all
  • Network positioning : due to network problems in mainland China, google services cannot be accessed

insert image description here

Articles with similar views also
solve the problem of high power consumption in Android's native positioning
? Poor positioning accuracy? How to optimize Android native positioning
Android native positioning service LocationManager
android mobile phone positioning onLocationChanged does not return for a long time

4. Why can't GPS receive signal indoors?

After consulting relevant information, it can be concluded that since the space satellite is too far away from the ground, there must be no obstruction between the antenna and the sky.
Today's houses are made of reinforced concrete, so the GPS signal will be blocked or reflected and cannot be received.

insert image description here
insert image description here

5. Why can positioning be performed indoors?

I looked at the source code of the positioning Demo I found on Github , and found that the positioning can be obtained on the tablet because the positioning I found Demowas optimized internally: if the GPS cannot be obtained, then the positioning can be obtained through the network.
It should be 国内高版本的Androidan optimized, unused Googlenetwork (cannot be accessed in China google), and the network positioning of the domestic high-version mobile phone system is specially optimized for the domestic network environment, so the positioning can be obtained.
However, the positioning obtained in this way is an approximate position, and the accuracy is not high.
If you simply obtain GPS positioning , I tried it, and it is almost impossible to obtain it indoors. You can only get GPSthe positioning by putting the phone outside the window.

If the Android version is too low, or a mobile phone with a native Android system, it may be in China, and indoor positioning cannot be performed (due to lack of equipment, this conclusion has not been verified)

6. Will the Baidu/AutoNavi positioning SDK be more reliable?

6.1 Introduction of Amap Positioning SDK

Baidu/AutoNavi's specialized positioning SDK integrates multiple positioning data (GPS, base station, Wifi, Bluetooth, etc.), and the obtained positioning information will be more reliable than Android's native positioning, and it is free.

Here we take the Gaode positioning SDK as an example, and intercept some official introductions to it

insert image description here
insert image description here

6.2 Principles of various mobile phone positioning methods

Mobile phone positioning methods mainly include: GPS positioning and network positioning (base station, WiFi, Bluetooth, etc.)

6.2.1 GPS positioning

Receive satellite broadcasts through a GPS receiver, and obtain your own position information by analyzing the position, distance and other information of multiple visible satellites and corresponding algorithms.
advantage:

  • High positioning accuracy, GPS positioning is divided into military and civilian use, the accuracy of the civilian field can basically be within 10 meters
  • Use GPS positioning, no SIM card, no network

shortcoming :

  • Slow positioning (slower than network positioning)
  • High power consumption (more power consumption than network positioning)
  • Unable to locate indoors or in the basement (Because the satellite signal penetration ability is weak, indoor positioning cannot be performed, even outdoors, where the cloud cover is thick, the positioning will be affected)
  • The vast majority of mobile phone end users do not enable the GPS function by default

6.2.2 Network Positioning

Network positioning is to send the signal (mainly base station, Wifi, Bluetooth) received by the mobile device to the network server to obtain the location. The reason why signal data is sent to the network is that network positioning uses signal fingerprints for positioning, which requires a huge and continuously updated fingerprint database, which is difficult to synchronize to mobile devices. In order to locate, it is necessary to establish the fingerprint characteristics of each location in advance, and then compare the historical fingerprints of each location with real-time fingerprints during positioning to determine the location.

Positioning SDKs such as AutoNavi and Baidu maintain a huge set of fingerprint databases and use domestic networks, so they can use network positioning well in China.

6.1.2.1 Base Station Positioning

According to the relationship between the mobile terminal and multiple base station locations, signal strength, etc., calculate your own location information.

advantage:

  • fast positioning
  • less power consumption
  • available indoors

shortcoming:

  • The positioning error is large, and the positioning accuracy is tens of meters to several thousand meters. The accuracy depends on the distribution of base stations and the size of the coverage area. Usually, the accuracy is 150 meters.
  • Base station coverage is relatively high in cities, and it is recommended to use base station positioning. If it is in the suburbs, the base station is far away, the coverage of the base station is not as good as in the city, and the positioning error is relatively large
6.2.2.2 WiFi / Bluetooth Positioning

Use the wireless hotspot signal and signal strength searched by the mobile phone to match the hotspot location server data and return the mobile phone location information.

Bluetooth is similar.

Principle :

  1. Each wireless hotspot has a unique address BSSID(that is, macthe address), and the location of the wireless hotspot is relatively fixed within a certain period of time.
  2. When the mobile phone turns on WiFi, you can search for nearby wireless hotspots and the signal strength of the hotspots
  3. The mobile phone uploads the searched wireless hotspot list information to the location server; the location server can return the location information of the mobile phone through calculation

advantage:

  • High positioning accuracy, especially in places with many wireless network hotspots;
  • Fast positioning speed;

shortcoming:

  • Rely on WiFi signal;

6.2 Partially refer to the evolution of mobile phone positioning methods
based on the Gaode network positioning algorithm Summary of several positioning methods in android

7. Summary

Through this article, we can answer the question at the beginning of this article

  • What kinds of active positioning methods are there?
    • There are two kinds of GPS positioning and network positioning
  • Why is it almost impossible to receive GPS signals indoors?
    • Because the space satellite is too far from the ground, once there is an obstruction between the antenna and the sky, the GPS positioning signal will be interfered
  • Why can positioning be performed indoors?
    • Because the old version of the domestic Android system has not optimized the network positioning, and the Google network used, naturally cannot be accessed in China
    • The higher version of the domestic Android mobile phone system has been optimized for the domestic network environment, so you can use the network positioning
  • Should I use the official positioning API or the Baidu/AutoNavi positioning SDK?
    • Professional positioning SDKs such as Baidu/Gaode will be more reliable, and it is recommended to use professional positioning SDKs for development of production projects
    • If it is a demo project, it is only installed on a few new mobile phones. For convenience, you can use the official Android native positioning, and the positioning can also be successful. You can see this positioning demo

This article is exclusively published by Helium on CSDN
Address: https://blog.csdn.net/EthanCo

Guess you like

Origin blog.csdn.net/EthanCo/article/details/130153809