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 compile maps in Qt to download contours of provinces and cities

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article mainly introduces "how Qt compiles maps to download provincial and municipal contours". In daily operation, I believe many people have doubts about how Qt compiles maps to download provincial and municipal contours. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the doubts of "how Qt compiles maps to download provincial and municipal contours". Next, please follow the editor to study!

I. Preface

In the past, when we obtained the boundary points, we mainly used the method of online map, because the function directly built in the online map can automatically obtain the boundary according to the name of the administrative area. in fact, these boundaries are smooth lines connected by a set of point coordinates, and then form an outline map. The disadvantage of this method is that it can only be used online, and most of our application scenarios should be offline. Even if many devices are always offline, it is impossible to get information on the Internet, but what to do if you want the outline map of each provincial and municipal region? you can only download these required outline files in advance. These files store the set of longitude and latitude coordinates, and you only need to define irregular lines and draw them into these sets of longitude and latitude coordinates in the offline map.

The interactive mechanism of Qt browser controls is very convenient, so when you map online, you can send Qt programs to store the longitude and latitude coordinates of each area. In the actual testing process, it is found that some maps have multiple closed curves, such as scattered islands and enclaves, which can not be omitted, so store latitude and longitude coordinate information in the form of an array. At the beginning, it is stored according to a set of strings, but later it is found that some places are less or even irregular. It turns out that there are multiple sets of curves. When parsing, you can instantiate the class of irregular lines according to the array.

By default, the on-line map can only be accurate to the county seat. If you want to be more accurate, you need to manually adjust the boundary point and pull it, and then take the initiative to obtain the longitude and latitude coordinate set of the current boundary point and store it. This requires setting the shape of a basic boundary point at the beginning, opening the allowed editing attributes, and then adjusting the position by yourself. Finally, click to get the boundary point coordinates and save the file. If you need a lot of outline maps of villages and towns, it can only be patiently adjusted and obtained slowly, of course, this boring and unskilled thing can also be left to the little girl to do.

II. Functional features

Both online map and offline map modes are supported.

Support webkit kernel, webengine kernel and IE kernel at the same time.

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.

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.

Third, effect picture

4. Related codes QStringList MapBoundary::getResult (const QByteArray & data, quint8 type, const QString & provinceName, const QString & cityName) {/ / processing data QStringList result; if (type = = 1 & & provinceName.isEmpty ()) {return result;} else if (type = = 2 & & (provinceName.isEmpty () | | cityName.isEmpty () {return result } # if (QT_VERSION > QT_VERSION_CHECK) / / parse QJsonParseError error; QJsonDocument jsonDoc = QJsonDocument::fromJson (data, & error) using qt's built-in json method; if (error.error = = QJsonParseError::NoError) {QJsonObject rootObj = jsonDoc.object (); / / qDebug ()

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: 0

*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

Internet Technology

Wechat

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

12
Report