Chapter 54
Design and Implementation of Target Positioning System Based on Map API Hongwei Liu, Yongxin Liu, Yonggang Ji, Hui Zhang, and Zhiqiang Zheng Abstract This paper presents a method for target positioning on the map. It provides an intuitive and effective view of the target location. With this method the specific target positioning information can be gotten and the attribute of target can be viewed and analysed easily. The method is implemented using C# windows forms and JavaScript scripting based on Map API. The JavaScript scripting is used to create a page map and accomplish map coordinate covering and other necessary operations. The C# windows forms are used to build the operation and display interface in the VS2010 development environment. This approach is applied to the specific positioning of vessels. The results show that the vessel can be well positioned on the map, and can achieve a good purpose for the analysis of vessels. Keywords Positioning • Map API • JavaScript • C# • Map coordinate • Covering
54.1
Introduction
The application field of the map positioning system are very extensive, such as ship positioning, vehicle navigation, aircraft cruising, typhoon warning, seismic surveys, and missile guidance and so on. Map positioning system can provide accurate location information of the target, the location of the target can be shown through the form of map unfolded, which can give an intuitive and profound impression to people. It effectively improves the way of people to monitor the target, and greatly enhances the monitoring efficiency at the same time. Therefore, map positioning system has gradually become an important part of the current target monitoring fields [1–4]. Looking at the present situation of the development of map positioning system in domestic and foreign, there are three main ways to achieve map positioning. One is through the establishment of the professional website, such as the query system of H. Liu • Y. Liu (*) • H. Zhang • Z. Zheng College of Electronic Information Engineering, Inner Mongolia University, Hohhot 010021, China e-mail:
[email protected] Y. Ji First Institute of Oceanography, State Oceanic Administration, Qingdao 266061, China © Springer International Publishing Switzerland 2015 J. Mu et al. (eds.), The Proceedings of the Third International Conference on Communications, Signal Processing, and Systems, Lecture Notes in Electrical Engineering 322, DOI 10.1007/978-3-319-08991-1_54
521
522
H. Liu et al.
ship location of Ship Tracker, the second is to establish a dedicated map positioning software, such as Google Map and the third is by means of VC++ and other development software through calling Map API [5] interface for secondary development on the map. Professional map positioning website has a high efficiency development mode, but the amount of programming code is very large. The specialized map positioning software has high execution efficiency, but its expanding is poor and its update are more complex. With the software calling Map API interface for secondary development can both avoid large amount of programming code and has better application scalability, which is a popular way of research and development of map positioning system. To achieve map positioning, we must resolve how to load the map, how to process the target data and using what methods to mark the target position on the map. Because of its geographical location information contained in the map is very large, extremely complex and diverse, the workload of map programming process is enormous. From the study of the current situation, the current map processing is mostly to put the map into the webpage through programming, and it will be presented in front of the user in the form of webpage. We can complete various operations on the map on this basis. This paper presents a target map positioning method based on Map API and JavaScript technology, the technology platform is implemented in the VS2010 development environment. Using the C# windows forms application builds the control platform interface. To load and display in the WebBrowser control of windows forms program through the Map API interface. Then, we need programming to read the radar target data into the window and doing some pre processing. Finally, by calling windows forms and JavaScript, We can achieve the geographic location information of the target well display and match on the map.
54.2
Brief Introduction of JavaScript API
The way of secondary development on the map on API component provided by the current map website has been developed rapidly in recent years. Map JavaScript API is a set of application programming interface written by JavaScript language based on map service, using the interface can not only call the existing map, but also can realize secondary development on current map through independent coding. It provides convenience for the user to develop map, it can also help the developers to build rich and strong interactive map application, which can greatly improve the development efficiency of map application. Map API provides the using of map basic functional interface and it also provides a series of map operation development options. Using the different development options can achieve different operations of the target, such as using map parameter setting function can conveniently set the map center point and zoom level. Using the map tool can conveniently get the distance of two points and get the latitude and longitude of the current position and so on.
54
Design and Implementation of Target Positioning System Based on Map API
523
Through adding covering function provided by map API can add the mark to the position of the target, it can both add the mark using the default label icon and also implement custom covering design through programming. In addition to the various operations on the map, it also provides a series of controls to view the map, with which can achieve a good purpose to analysis and view the target on the map.
54.3
Loading Map in the WebBrowser Control
Loading map is achieved primarily through the following two steps. First, it needs to create an HTML page map using the JavaScript scripting language. Then, it needs to load the created page map into C# WebBrowser control. Map loading process is shown in Fig. 54.1. The establishing method of each part of the process is as follows:
54.3.1 Creating a Map in HTML Page The page map creates primarily through the following steps: • Designing a page to introduce Map API: JavaScript statement with Script tag is required to point to the API address, namely: . Of which, URL points to the location of the JavaScript file that includes all symbols and definitions required when using Map API, v¼1.3 means that the interface is the version 1.3. • Creating a map container element: This creates a div element, namely:
. Map requires an HTML element as a container, so as to show to the page. • Creating a map instance: Using the Map class of the BMap namespace creates a new instance of the map, namely: var map ¼ new BMap.Map(“allmap”). Among which, all map is the id attribute of div, and map is created in the allmap container. • Map initialization: Using setCenter () and setZoom () methods complete the map initialization, including setting the display mode, setting latitude and longitude of the center point, and setting zooming factor.
54.3.2 Loading Map in the WebBrowser Control Using the method of C# Forms program calls JavaScript to load the map. The main steps are as follows: • Two pieces of code is needed to be added before the Form1 class [PermissionSet (SecurityAction.Demand,Name¼“FullTrust”)]and[System.Runtime. InteropServices.ComVisible(true)].The purpose of these two pieces of code is to request permission for the assemblies, and make COM component visible for the application program [6]. • In the form loading function Form1_Load (), we need to write map loading program. To find the loaded map page, it needs to redefine the Uri address of the page file in the program, namely: string address ¼ “File: \cr” + Application. StartupPath + “\cr baidumap.html”. It also needs to set the properties of the WebBrowser control, namely: webBrowser.ObjectForScripting ¼ this, appointing the HTML page map as the access object of the control webpage. • The display effect after loading the map is shown in Fig. 54.2.
54.4
Reading and Preprocessing Target Data
It needs to add a positioning button in C# Forms program, and add the reference of System.IO namespace of the system. So that the class can be used directly under the namespace to read and do other operations of the source file. According to the original data’s format and type, the appropriate processing program is needed to be added. Reading process of objective data is shown in Fig. 54.3.
54
Design and Implementation of Target Positioning System Based on Map API
525
Fig. 54.2 Display the map after loading
Fig. 54.3 Reading process of target data
The basic algorithm flow of reading the target data is as follows: • A file input stream is needed to define, and using Read Line() method of Stream Reader class reads the input stream. It is used to read a line of the Characters from the input streams, and the result is returned as a string. • Using the line.Split() method splits the string, then the divided string stores in an string array. • In order to retain the accuracy of original data and be convenient to operate the data, it needs to converse the type of string data and double data, and the result is
526
H. Liu et al.
Fig. 54.4 The display result after reading of target data
stored in the converted double array. It can realize convenient processing and calling of the data. • The display effect of target data after reading is shown in Fig. 54.4.
54.5
Achieving Target Map Positioning
By calling JavaScript script functions in HTML page of C# Forms class achieves target map positioning. The algorithm flow chart is shown in Fig. 54.5. The basic process of the specific algorithm is as follows:
54.5.1 Positioning Method Written in HTML Pages A positioning method of custom icon label is designed. Steps are as follows: • Making an icon of the right size. If the background requires being transparent, images should be saved as .png format. Then it needs to take the picture into the Forms program debug folder.
54
Design and Implementation of Target Positioning System Based on Map API
527
Fig. 54.5 Flow chart of target map positioning
• For icons of different labels, it needs to program corresponding positioning function in the HTML page. First, icons which have already been made needs to define and add the appropriate reference. Sizes and dimensions should be consistent between defined function icons and the actual icons. Then, according to the parameter of the function, we can create corresponding label points by using Marker class under the BMap namespace. Finally, using the method of map.addOverlay() [7] adds the appropriate label on created annotation points.
54.5.2 Calling Positioning Method of HTML Page in C# Form Class Using webBrowser.Document.InvokeScript(“method name”, new object [] {parameter 1, parameter 2}) in C# Forms program calls positioning method of HTML page. The parameters in which are information in arrays when the target data is read and preprocessed, such as latitude and longitude, which are as actual parameters. It will be passed to parameters in the HTML page. Then the target location is determined, and we can add the icons calling this method.
528
H. Liu et al.
Fig. 54.6 Adding positioning analysis function module
After achieving positioning, in order to analyze and view the located target on the map, it needs to add some target analysis function on the map. It can achieve a well target analysis purpose by using a variety of map controls and events provided by Map API. The target map analysis module is defined and shown in Fig. 54.6.
54.6
Application Example
Figure 54.7 is the effect of co-locating of vessels’ HFSWR and AIS data in a certain area of Chinese sea on October 31st, 2011. The small square represents the radar data. The small triangle represents the AIS data. They all use custom annotation icon. Left mouse clicking the labeled icon of the current target, it will appear a dialog to display the latitude and longitude of the current target position [8]. Through zooming function, it can easily get the view of the overall and local effect of the map. Partial image of interception in Fig. 54.7 is analyzed as follows: It can be seen that some of the targets gathered in Fig. 54.8. The targets can not be effectively viewed and analyzed. Therefore, it needs to further amplify the map.
54
Design and Implementation of Target Positioning System Based on Map API
529
Fig. 54.7 The common display of HFSWR and AIS ship data Fig. 54.8 Image of part of Fig. 54.7
We select partial area for analysis in Fig. 54.8. The dashed boxed section is enlarged and shown in Fig. 54.9. By clicking the left mouse button to get the latitude and longitude information of the target, it can be further analyzed to obtain other relevant information. The solid line framed section in Fig. 54.8 is enlarged and analyzed, and the result is shown in Fig. 54.10. After achieving positioning, through the radar and AIS data or SAR and AIS data available to demonstrate on one map, using the position and velocity matching algorithm [9] can analyze and recognize the target.
530
H. Liu et al.
Fig. 54.9 Amplification and display of the dashed framed section of Fig. 54.8
Fig. 54.10 Zooming display and analysis of the solid line framed section of Fig. 54.8
Conclusion In the target location information display functions based on Map API, a target map positioning method using JavaScript programming language mixing with C# windows forms application is established. The results show that the location of the target can be clearly and precisely marked and displayed on the map. It can achieve the purpose of convenient observation (continued)
54
Design and Implementation of Target Positioning System Based on Map API
531
and analysis of the target. The method has wide applicability, it can be applied to vehicles, vessels and other areas that are required target monitoring, and it also has important and positive significance in positioning technology applications.
Acknowledgments This research is sponsored by National Natural Science Foundation of China (61362002).
References 1. Almomani IM, Alkhalil NY, Ahmad EM et al (2011) Ubiquitous GPS vehicle tracking and management system. In: IEEE Jordan conference on applied electrical engineering and computing technologies (AEECT), Amman, pp 1–6 2. Chang SJ (2004) Development and analysis of AIS applications as an efficient tool for vessel traffic service. In: Oceans ’04. MTTS/IEEE Techno-Ocean ’04, Kobe, vol 4, pp 2249–2253 3. He L, Lai ZJ (2010) The study and implementation of mobile GPS navigation system based on Google Maps. In: International conference on computer and information application (ICCIA), Tianjin, pp 87–90 4. Lin J-Y, Yang B-K, Do T-A et al (2013) The accuracy enhancement of GPS track in Google Map. In: Eighth international conference on broadband and wireless computing, communication and applications (BWCCA), Compiegne, pp 524–527 5. Dong ZY (2013) The communication map shows based on Baidu Maps JavaScript API. Electron Des Eng 21:73–76 6. Xu CR, Zhou CB (2013) The research of methods to browse Google satellite map in AutoCAD. Bulletin of Surveying and Mapping, pp 77–79 7. Qiang JP, Yang XT, Liu XX et al (2011) Construction of fast graphics traceability system for agricultural products. Trans Chin Soc Agric Eng 27:167–171 8. Su YZ, Zhang KY (2009) Study and design on the engineering data management system based on Google Maps API technology. Bulletin of Surveying and Mapping, pp 48–69 9. Chaturvedi SK, Yang C-S, Ouchi K et al (2012) Ship recognition by integration of SAR and AIS. J Navig 65:323–337