Integrated two development of MAPX embedded in VC + +

Source: Internet
Author: User

http://www.gissky.com/GIS/ShowArticle.asp?SID=12&ID=1178

Combining GIS tool software with today's visual development language integration two times development method is the mainstream of GIS application development. Its advantage is that can make full use of the GIS tool software to the spatial database management, the analysis function, but also may use other visual development language to have the high efficiency, the convenience and so on programming merit, sets both the director ...

MAPX is the MapInfo company to provide users with a powerful map analysis of the function of ActiveX control products. Because it is a standard control based on Windows operating system, it supports most standard visual development environments such as Visual C + +, visual Basic, Delphi, PowerBuilder, and so on. Programmers in the development process can choose their most familiar development language, easily embed map functions in the application, and can be separated from the MapInfo software platform to run. Here talked about VC + + embedded MAPX for two development can be divided into the following steps to achieve:

1 Pre-Setup for application engineering

Before you create the MAPX control, you must add the MapX.h and MapX.cpp files to the project. For visual c++5.0 and above, select the Add to Project-> files command from the Project menu to open the Insertfiles into Project dialog box, Select MapX.cpp and MapX.h files to be added to the project (there are two files in the C + + example of mapx).

Note: Do not select the add to project->components and Controls command in the Project menu. If you select this command to join the MAPX control, a new. cpp file is created, but the text does not include all the MAPX objects.

2 operation of the Mapx property

For C + + programs, each MapX object (Objects) is implemented in MapX.h and MapX.cpp with a class name that is the same as the name of the Mapx object and has been defined in CMAPX.

For example, a DataSet object is implemented with a class cmapxdataset. This is consistent with the definition of C + + classes. The attributes of each Mapx object (properties) are implemented using the member functions of the class. For example, the name of the DataSet object (name) is implemented with the name () function, but there are two ways to use the name (), that is, get and set. Such as:

CString GetName ()//Get Object name

void SetName (LPCTSTR);//Set object name

Application of 3-part MAPX tool

(1) Improvement of the "whole diagram" tool

The code for the General map tool is:

M_ctrlmapx.setzoom (M_ctrlmapx.getgeosetwidth ());

The disadvantage of this method is that after the whole diagram is displayed again, the center of the view is actually displayed as the center of the screen, and if the previous view is at the edge of the entire diagram, clicking on the full Diagram tool is not actually the entire diagram of the initial setting. You can therefore implement the following code:

CString Mapname=m_ctrlmapx.getgeoset ()//Get the name of the current map

M_ctrlmapx.setgeoset (mapname)//Set the map as the main viewport display chart

(2) Create "information" tool

MAPX does not provide an information tool, which is a customized tool. There are two methods of implementation, the basic idea is:

(1) Create the tool's mouse pointer type (typically "+"), when you select this tool on the toolbar, set as the current tool, then track where the mouse clicks on the map, trigger the Toolused event, determine the corresponding object based on the location information, and then read the object properties or bound database, pop-up dialog box, Implementation information display. This method is only suitable for displaying the topmost object of the map (the specific implementation code in the C + + example "Buffer" with MAPX).

(2) Use the selection tool to select the object on the map to display the information, and then click on the toolbar Information tool, pop-up dialog box, to achieve information display. The implementation code for this information tool is different from (1), with no mouse pointer, which actually reads the properties of the selected object or the bound database. This method is suitable for displaying any layer on the map.

Both methods have their own characteristics, the first method is direct, but it is easy to appear in the actual application of the exception, the second method to click once more, but the application of stability, but also applicable to any layer on the map.

(3) The use of "ranging" tool considerations

The distance () function of MAPX is for the map of the Earth, the use of the non-Earth map to pay attention to numerical conversion. Otherwise, the measured data is far from the actual difference.

4 GIS Two-times development with MAPX

(1) Create a database

A spatial database can be created in two ways, one through the layer build feature of MAPX. Each layer generated by MAPX corresponds to a table (table) that contains other property fields in addition to the location coordinates of the geographical objects, and another method is generated by importing other databases with geographic information. MAPX can map the geographic information in these databases to map layers through data binding, and MAPX supports access to a variety of common databases.

(2) Set layer control and map projection

Before adding the map to MAPX, we can use the Layer management tool included with MAPX Geoset manager to match the layers to be added, and build a layer group that sets the name, content, attributes, and the order of display between each layer of the layers. MAPX can be set to the layer four kinds of properties: can be displayed, selectable, editable and automatic annotation. The properties of a generic layer are visible, the layers that need to be queried are set to be selectable, the layers that need to be modified are set to editable, and automatic annotations automatically display the labels for the geographical objects in the layer. The proper setting of these properties will help the system to realize the function of geographic information maintenance and querying. When matching each layer, you should pay attention to the settings for each layer projection. All layers must use a consistent projection method to match exactly. The map of MAPX is divided into the Earth map and non-earth map, the coordinates of the objects in the Earth map are expressed by latitude and longitude, and the coordinates of the objects in the non-earth map are usually relative coordinates, which are set up relative to a datum point in the graph. If the coordinates of the layers are inconsistent, you must convert the coordinates before you can match them.

(3) Design editing function

The MAPX provides the standard geographical object type definition, can conveniently select the geographical object type in the point, the line, the Surface Type selection dialog box which the MAPX provides, including the symbol which uses the shape, the color, the size and so on the attribute. Using the drawing tools provided by MAPX, we can design a variety of geographic object generation tools for users. Using the selection tools of various geo-information objects provided by MAPX (such as rectangle, circle Selection Tool), users can call these selection tools and combine the editing (deletion, modification, etc.) function of the site of MAPX to complete the editing of geographical objects in geographic information system. Note, however, that both geographical and geo-data are treated separately.

(4) Design query function and analysis statistic function

For geographic information query function and analysis statistic function required in GIS, MAPX provides a certain number of inquiries and analysis means, such as MAPX can be based on the field values in the Layer table to query the corresponding geographical objects, you can provide corresponding to a layer table or a few fields of the analysis pie and so on. For non-geographic information, we should design query and analyze statistic function in object-oriented language according to the specific requirements of the system.

Conclusion

In the process of developing GIS, the first thing to consider is to choose a good development tool. Using a visual programming language alone is not a convenient way to achieve geographic map functions, the usual GIS software is a very professional interface, and can not fully meet the needs of various GIS users, and the use of "GIS components + object-oriented Visual programming language" model is more suitable for a variety of application needs.

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.