Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize Longitude and Latitude coordinate Correction by Qt

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to realize longitude and latitude coordinate correction by Qt". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "Qt how to achieve longitude and latitude coordinates correction" bar!

I. Preface

A problem involved in map applications is the problem of coordinate correction. This problem is because map manufacturers are not allowed to use standard GPS coordinates according to the confidentiality requirements of local rules, but to use national defined offset standards, or to do algorithm operations on this basis, so there are three conventional coordinate standards: GPS coordinates (WGS-84, international standards, Google Earth software). Hardware GPS module, etc.), Chinese coordinate offset standard (GCJ-02, Google Maps, Tencent Map, Amap, etc.), Baidu coordinate offset standard (BD-09, only used by Baidu Maps). As other coordinates are not allowed to be converted into GPS coordinates, there are only four commonly used conversions: GPS to Baidu, GPS to other, Baidu to other, other to Baidu, and the other is the Chinese coordinate offset standard, which is currently adopted by Google Maps, Tencent Map and Amap.

Online Baidu Maps provides a Convertor class specifically responsible for this conversion. You only need to call the corresponding translate method to pass in parameters. The result of this conversion is ideal, but the disadvantage is that it must be used online. After all, the algorithm is confidential stored on the server, but many application scenarios are used offline, so it is necessary to find a more accurate algorithm to do this conversion. The versions of java, c #, python and other languages are circulating on the Internet, so they are specially rewritten into the version of C++ Qt. The results of the personal test and the online version are basically the same. It is said that there may be a big deviation near the equator, but the deviation is very small on the map of China.

II. Functional features

1 functional characteristics of regional map encapsulation of provinces and cities

At the same time, support flicker point map, migration map, area map, world map, dashboard and so on.

You can set various colors such as title, prompt, background color, text color, line color, area color, and so on.

You can set the name, value, longitude and latitude collection of the city.

You can set the magnification of the map and whether the mouse wheel is allowed to zoom.

Built-in world map, national map, provincial map, regional map, can be accurate to the county, all maps are used offline.

Built-in provincial and municipal json data file to js file function, if there is a data update self-conversion, support a single file conversion and one-click conversion of all files.

Built-in function to obtain all the names and longitude and latitude information sets of the region from json files or js files, which can be used to display the information obtained by this method.

Depending on the browser component to display the map, the demo provided supports webkit/webengine/miniblink/ie to load web pages in many ways.

Using miniblink browser kernel to get through the regret of lack of browser module in Qt5.6 and subsequent versions of + mingw compiler, so that the whole project supports all Qt versions, such as any version from 4.7 to 6.2.

The points set by the flicker point migration chart and so on support setting the color separately.

Provides an interface to directly obtain the point-related information of the click, which is convenient for program linkage processing.

Strong expansibility, you can add a variety of exquisite echarts components according to the gourd painting ladle to make a great effect.

The built-in dashboard components provide interactive functionality, and the corresponding code is included in the demo demo.

The function interface is friendly and unified, and it is easy to use, just one class.

Support any Qt version, any system, any compiler.

2 functional features of Baidu map encapsulation class

Both online map and offline map modes are supported.

It also supports webkit kernel, webengine kernel, miniblink kernel and IE kernel.

Multiple dimension points can be set, including name, address, longitude and latitude.

You can set whether the map can be clicked, dragged, or scrolled.

You can set the protocol version, secret key, theme style, central coordinates, central city, geocoding location, and so on.

Can set the map zoom scale and level, thumbnails, scale, road information and other controls visible.

Support map interaction, such as mouse press to get the latitude and longitude of the corresponding location.

Support to query the route, you can set the starting point, end point, route mode, route mode, route scheme (minimum time, least transfer, least walk, do not take the subway, shortest distance, avoid highway).

Can display dots, lines and surfaces tools, and can draw lines, points, rectangles, circles and so on directly on the map.

Administrative divisions can be set up, a certain urban area drawing layer can be specified, and the online map automatically outputs the administrative division boundary points to the js file for offline map use.

Multiple coverings can be added statically or dynamically. Support points, broken lines, polygons, rectangles, circles, arcs, point aggregations, etc.

Provides a function interface to handle latitude and longitude resolution to address and address resolution to latitude and longitude coordinates.

The demo provided can be directly selected to perform corresponding processing such as route query.

You can get the collection of point coordinate information queried by the route, such as for robot coordinate navigation.

Encapsulates a wealth of functions such as deleting specified points and all points, deleting specified coverings and all coverings, etc.

Callout point pop-up box information can be customized in standard html format.

Dimension point click event optional 0-do not process 1-own pop-up box 2-send a signal.

Dimension points can be animated 0-do not process 1-Jump 2-fall

Dimension points can be set up local picture files and so on.

The function interface is friendly and unified, and it is easy to use, just one class.

Support js dynamic interaction to add points, delete points, clear points, reset points, no need to refresh the page.

Support any Qt version, any system, any compiler.

3 functional features of offline map download

Multi-thread synchronous download multi-level tile map, non-card interface.

Built-in multiple offline map download request addresses, automatically randomly select a send request.

The download map type supports both street maps and satellite maps.

Automatically calculate the number of downloaded tiles in the visual area or administrative area.

The level of download can be customized and selected.

A signal notification is sent to each tile when the download is completed, and the parameters include the download time.

You can set the maximum download timeout, after which you will discard the jump to the next download task.

Displays the download progress in real time, as well as the number of tiles and total tiles that have been downloaded at the current level.

The download can be stopped during the download process, and the download completes the automatic statistics of the total time.

Built-in longitude and latitude and screen coordinates conversion function.

Baidu Maps is currently supported, and other maps such as Google Maps, Tencent Map and Amap can be customized.

The function interface is friendly and unified, and it is easy to use, just one class.

Support any Qt version, any system, any compiler.

4 functional features of contours download of provinces and cities

The timer queues to download the provincial and municipal outline map point coordinate set and stores it to the JS file.

Support multiple irregular area downloads in one administrative area.

Automatically calculate the number of download profiles in the administrative area.

Can accurately select provinces, urban areas, county towns, can also directly enter the name of the administrative region.

You can set the download interval, start the download at any time, and stop the download.

Provide editing boundary function, you can directly edit the collection of points in irregular areas on the map, and then obtain the boundary point set data, which can be used to draw the area to get the data, such as the administrative data of a township or even a community. Impressive.

Third, experience address

Experience address: https://pan.baidu.com/s/15ZKAlptW-rDcNq8zlzdYLg extraction code: uyes file name: bin_map.zip

Domestic site: https://gitee.com/feiyangqingyun

International site: https://github.com/feiyangqingyun

4. Effect picture

5. There are four common conversion codes: GPS to Baidu, GPS to other, Baidu to other, other to Baidu / / WGS-84: international standard, GPS coordinates (Google Earth use, or GPS module) / / GCJ-02: Chinese coordinate offset standard, Google Map, Gaud, Tencent use / / BD-09: Baidu coordinate offset standard, Baidu Map uses static QPointF gcj2bd (const QPointF & point); static QPointF bd2gcj (const QPointF & point) Static double transformLng (double lng, double lat); static double transformLat (double lng, double lat); static QPointF wgs2gcj (const QPointF & point); static QPointF wgs2bd (const QPointF & point); / / pi conversion double x_pi = M_PI * 3000.0 / 180.0X QPointF MapHelper::gcj2bd (const QPointF & point) {double x = point.x (); double y = point.y (); double z = qSqrt (x * x + y * y) + 0.00002 * qSin (y * x_pi) Double theta = qAtan2 (y, x) + 0.000003 * qCos (x * x_pi); double lng = z * qCos (theta) + 0.0065; double lat = z * qSin (theta) + 0.006; return QPointF (lng, lat);} QPointF MapHelper::bd2gcj (const QPointF & point) {double x = point.x ()-0.0065; double y = point.y ()-0.006 Double z = qSqrt (x * x + y * y)-0.00002 * qSin (y * x_pi); double theta = qAtan2 (y, x)-0.000003 * qCos (x * x_pi); double lng = z * qCos (theta); double lat = z * qSin (theta); return QPointF (lng, lat) } double MapHelper::transformLng (double lng, double lat) {double ret = 300.0 + lat + 2.0 * lng + 0.1 * lat * lat + 0.1 * lat * lng + 0.1 * qSqrt (qAbs (lat)); ret + = (20.0 * qSin (6.0 * lat * M_PI) + 20.0 * qSin (2.0 * lat * M_PI)) * 2.0 / 3.0 Ret + = (20.0 * qSin (lat * M_PI) + 40.0 * qSin (lat / 3.0 * M_PI)) * 2.0 / 3.0; ret + = (150.0 * qSin (lat / 12.0 * M_PI) + 300.0 * qSin (lat / 30.0 * M_PI)) * 2.0 / 3.0; return ret } double MapHelper::transformLat (double lng, double lat) {double ret =-100.0 + 2.0 * lat + 3.0 * lng + 0.2 * lng * lng + 0.1 * lat * lng + 0.2 * qSqrt (qAbs (lat)); ret + = (20.0 * qSin (6.0 * lat * M_PI) + 20.0 * qSin (2.0 * lat * M_PI)) * 2.0 / 3.0 Ret + = (20.0 * qSin (lng * M_PI) + 40.0 * qSin (lng / 3.0 * M_PI)) * 2.0 / 3.0; ret + = (160.0 * qSin (lng / 12.0 * M_PI) + 320 * qSin (lng * M_PI / 30.0)) * 2.0 / 3.0; return ret;} / / projection factor double a = 6378245.0 projected from satellite ellipsoid coordinates to plane map coordinate system / / eccentricity of the ellipsoid double ee = 0.00669342162296594323 transformLng QPointF MapHelper::wgs2gcj (const QPointF & point) {double x = point.x (); double y = point.y (); double lng = transformLng (y-35.0, x-105.0); double lat = transformLat (y-35.0, x-105.0); double rad = y / 180.0 * mi Pi; double magic = qSin (rad); magic = 1-ee * magic * magic Double sqrtMagic = qSqrt (magic); lng = x + (lng * 180.0) / (a / sqrtMagic * qCos (rad) * M_PI); lat = y + (lat * 180.0) / (a * (1-ee)) / (magic * sqrtMagic) * M_PI); return QPointF (lng, lat) } QPointF MapHelper::wgs2bd (const QPointF & point) {/ / GPS to Baidu has to go through double conversion return gcj2bd (wgs2gcj (point));} so far, I believe you have a deeper understanding of "how to achieve longitude and latitude coordinate correction by Qt". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 230

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report