The Program Construction Method of Navigation Format Files GPX and KML Based on Geological Explorati

来源 :农业生物技术(英文版) | 被引量 : 0次 | 上传用户:lgx9527
下载到本地 , 更方便阅读
声明 : 本文档内容版权归属内容提供方 , 如果您对本文有版权争议 , 可与客服联系进行内容授权或下架
论文部分内容阅读
  Abstract GPX and KML are open and multi-purpose, which are widely used in many fields such as basic geological survey, geochemical survey, geophysical survey, engineering survey and so on. Based on the analysis of the syntax features, basic structure and expression of GPX and KML files, this paper discussed the construction methods of GPX and KML files by taking the construction of navigation files of point information as an example. According to the specifications of GPX and KML files, an automatic construction program of GPX and KML files is designed and compiled, which realizes the automatic generation of batch point navigation files and supports in related software, and shows good effects of holding and displaying, which is helpful to simplify work flow and improve work efficiency.
  Key words GPX; KML; Navigation file; Conversion program; Survey point
  Received: December 26, 2020  Accepted: March 2, 2021
  Songshi XIE (1981-), male, P. R. China, senior engineer, devoted to research about agricultural geology and environmental geochemistry.
  *Corresponding author.
   GPX and KML are widely used and have good supportability. They are common navigation and data storage formats used by geological survey software and equipment, and have a wide range of applications in field work in many fields such as basic geological survey, geochemical survey, geophysical survey and engineering survey[1-3]. GPX (GPS eXchange Format) is a general-purpose GPS data storage and exchange format based on XML (eXtensible Markup Language), which can be used to describe the location, altitude, time, and trajectory of waypoints.  It can be used to exchange data between different GPS devices and software, such as viewing trajectories, embedding geographic data in the exif data of photos. It is a positioning data format commonly supported by current mainstream maps, navigation software, and handheld locator devices such as MapSource, Ovi Interactive Map, Google Earth, and GISoffice. The GPX format is free and can be used without paying any license fees. KML (Keyhole Markup Language) is an XML-based markup language originally developed and maintained by Keyhole. It uses XML syntax format to describe geospatial data (such as points, lines, areas, polygons and models), and is suitable for geographic information collaboration and sharing under the network environment[4].  KML was announced as an open geographic information coding standard by OGC (Open Geospatial Consortium, Inc.) in 2008, and is currently widely supported by Ovi Interactive Maps, Google Earth, Google Maps and other software, as well as unmanned aerial vehicles. As far as field work in the geological survey industry is concerned, a small number of points can be navigated by manually inputting coordinates on a handheld locator, but for a large number of points, this method is quite cumbersome and even not operable. At present, GPX and KML formats are the most commonly used navigation file storage formats[5], and it is of significant practical significance to deeply understand their characteristics and to edit and produce navigation files based on this.   Methods
  Definitions of GPX and KML formats
  According to the GPX architecture document, all coordinates are relative to the WGS84 datum, and all measurements are in metric units. The GPX file contains a metadata header, followed by waypoints, routes, and tracks. The metadata header contains GPX version, creator information, copyright information, etc., which are essential, but do not require special attention. Waypoints, routes, and tracks are represented by <wpt>, <rte>, and <trk> tags, respectively. The relevant tag representation methods for further enriching the content of the file can be found in the GPX architecture document. Based on this, the simplest GPX file can be constructed manually. The following is an example of a GPX file containing 1 waypoint, 1 route, and 1 track.
  <gpxversion="1.0" creator="..." xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.topografix.com/GPX/1/0" xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
  <wptlat="36.9" lon="115.9"><name>WPT01</name><sym>donut</sym></wpt>
  <rte><name>RTE01</name>
  <rteptlat="37.2" lon="116.7"></rtept>
  <rteptlat="37.1" lon="116.4"></rtept></rte>
  <trk><trkseg><trkptlat="36.8" lon="116.8">
  <ele>11.1</ele><time>2020-01-01T12:00:04</time><geoidheight>3</geoidheight></trkpt></trkseg>
  <trkseg><trkptlat="37.6" lon="116.8">
  <ele>12.2</ele><time>2020-01-01T12:00:04</time><geoidheight>13</geoidheight></trkpt></trkseg></trk>
  </gpx>
  Basic KML files can describe location marks, overlays, routes, and polygons. They are created using <Placemark>, <GroundOverlay>, and <LineString> elements, respectively. Among them, KMLs rich location marking function is the most commonly used in geological surveys, and has better display effects in Ovi Interactive Map and Google Earth. The KML code containing a simple location mark and a route is as follows:
  <?xml version="1.0" encoding="UTF-8"?>
  <kmlxmlns="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:gx="http://www.google.com/kml/ext/2.2" >
  <Document><name>KML Example</name>   <Placemark><name>LINE01</name>
  <Style><LineStyle><color>ffffffff</color><width>3</width></LineStyle></Style>
  <LineString>
  <coordinates>115.94,36.97,23115.94,36.98,23115.95,36.97,23115.96,36.98,23</coordinates>
  </LineString></Placemark>
  <Placemark><name>POINT01</name>
  <Style><IconStyle>
  <Icon><href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href></Icon>
  <color>ffffffff</color><scale>1.0</scale></IconStyle></Style>
  <Point><coordinates>115.95,36.98,0</coordinates></Point>
  </Placemark></Document></kml>
   Theoretically speaking, GPX and KML files with a small amount of information can be constructed directly by writing, but in actual work, it is often necessary to convert a large amount of point information into GPX and KML, because it is inconvenient to write directly, and the characters and tags are not standardized and easily lead to format reading error. Obviously, it is a more feasible way to use program design to realize the conversion of survey point information to GPX and KML files. In the past, a variety of program design methods and ideas have been used in previous studies, and significant results have been achieved[6-9], which is of great practical significance for simplifying the work process and improving work efficiency.
  Construction programs of GPX and KML
  The grammatical formats of GPX and KML files are similar, so the construction methods are similar. Here we take the commonly used point information-based GPX and KML format file construction as an example to design the program. First of all, data preparation is required. The excel table should include at least the four columns of "longitude", "latitude", "point number" and "symbol" under WGS84 coordinates. If there is a requirement for the color of the point symbol in the generated KML, a "color" column will be needed. Secondly, the GPX and KML files are created and named, and the file header was written according to the rules; and then the point information is read from the specified data column position, and written according to the rules; and finally the end of the file is written, and the corresponding file is closed. The specific program code is implemented in VBA, and the KML conversion code is as follows:   Public Sub xls2xml()
  If Dir(ActiveWorkbook.Path& "\KML", vbDirectory) <> "" Then
  MsgBox "The generated folder already exists, click OK to overwrite the original file!"
  Else: MkDirActiveWorkbook.Path& "\KML" ‘Create output folder
  End If
  Set rmyrange = ActiveSheet.UsedRange.Cells
  latClm = Application.InputBox(prompt:="Enter the serial number of the latitude (N) column", Default:=1, Type:=1)
  lonClm = Application.InputBox(prompt:="Enter the serial number of the longitude (E) column", Default:=2, Type:=1)
  nameClm = Application.InputBox(prompt:="Enter the serial number of the name column", Default:=3, Type:=1)
  symClm = Application.InputBox(prompt:="Enter the serial number of the symbol column", Default:=4, Type:=1)
  clrClm = Application.InputBox(prompt:="Enter the serial number of the color column", Default:=5, Type:=1)
  sfilename = ActiveWorkbook.Path& "\KML\" &ActiveSheet.Name&sfilename& ".kml"
  ifilenum = FreeFile()
  The following rules for writing GPX and KML files are different
  Open sfilename For Output As #ifilenum
  Print #ifilenum, "<?xml version=""1.0"" encoding=""UTF-8""?>"
  Print #ifilenum, "<kmlxmlns=""http://www.opengis.net/kml/2.2"" xmlns:atom = ""http://www.w3.org/2005/Atom"" xmlns:gx = ""http://www.google.com/kml/ext/2.2"">"
  Print #ifilenum, "<Document>"
  Print #ifilenum, "<name>points</name>"
  Print #ifilenum, "<Folder>"
  Print #ifilenum, "<name>points.gpx</name>"
  For i = 2 Tormyrange.Rows.Count
  Print #ifilenum, "<Placemark><name>" &rmyrange.Cells(i, nameClm).Value & "</name><Style><IconStyle><Icon><href>http://maps.google.com/mapfiles/kml/shapes/" &rmyrange.Cells(i, symClm).Value & ".png</href></Icon><color>" &rmyrange.Cells(i, clrClm).Value & "</color><scale>1.0</scale></IconStyle></Style><Point><coordinates>" &rmyrange.Cells(i, lonClm).Value & "," &rmyrange.Cells(i, latClm).Value & ",0</coordinates></Point></Placemark>"
  Next
  Print #ifilenum, "</Folder></Document></kml>"
  Close #ifilenum
  End Sub
  The conversion code of GPX is similar to the KML file. The methods of obtaining the data information columns and creating the file are the same, while the rules for writing the files are different. The specific code is as follows:   sfilename = ActiveWorkbook.Path& "\GPX\" &ActiveSheet.Name&sfilename& ".gpx"
  ifilenum = FreeFile()
  Open sfilename For Output As #ifilenum
  Print #ifilenum, "<?xml version=""1.0"" encoding=""UTF-8"" standalone=""no"" ?>"
  Print #ifilenum, "<gpxxmlns=""http://www.topografix.com/GPX/1/1"" creator=""…"" version=""1.1"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xsi:schemaLocation=""http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"">"
  For i = 2 Tormyrange.Rows.Count
  Print #ifilenum, "<wptlat=""" &rmyrange.Cells(i, latClm).Value & """ lon=""" &rmyrange.Cells(i, lonClm).Value & """><name>" &rmyrange.Cells(i, nameClm).Value & "</name><sym>" &rmyrange.Cells(i, symClm).Value & "</sym></wpt>"
  Next
  Print #ifilenum, "</gpx> "
  Close #ifilenum
  Songshi XIE. The Program Construction Method of Navigation Format Files GPX and KML Based on Geological Exploration Point Information
  Results and Application
  Taking a certain surface soil survey point as an example, the total number of sample points was 470. First, the survey point coordinates were converted to WGS84 coordinates, and the coordinate unit was "degree". The conversion parameters in the conversion of the commonly used Beijing 54 coordinate system or Xian 80 coordinate system coordinates to WGS84 coordinates should be used correctly, otherwise it is easy to cause navigation deviation. By default, the first four columns in the survey point information data table were latitude, longitude, point number, symbol, and color. Different types of survey points could be distinguished by different symbols or colors. Different software may have different interpretations of symbol tags, which need to be determined according to the specific conditions of the symbol library provided by the software. The preparation of the point data information table is shown in Fig. 2. After clicking the "Generate GPX file" or "Generate KML file" button, the sub process in the corresponding module was executed, by which the program created a folder named "GPX" or "KML" in the directory where it was located, and the created navigation point file was saved into the corresponding folder. The display effect of the converted survey point GPX file in MapSource and the display effect of KML file in Ovi Interactive Map are shown in Fig. 3. It can be seen that the files generated by this program could be imported and displayed normally.
其他文献
Abstract Yunnan gardening in the southern extension of the Himalayas has its specificity. Because of extremely rich elements, the natural endowment has objectively "casted" a series of vivid "Chinese
期刊
Abstract Meizhou is the main citrus fruit producing area in China, and its pomelo planting area and output value rank second in China. In this paper, the present situation of prevention and control of
期刊
Abstract [Objectives] This study was conducted to explore whether the coastal wetlands in the Yellow River Delta have become secondary pollution sources.   [Methods] With a coastal reed wetland in the
期刊
Abstract Ningqiao 1 was selected as the material to study the effects of planting density on physiological indices, agronomic traits and yield of buckwheat. The results showed that high density result
期刊
Abstract [Objectives] This study was conducted to study early reproduction techniques of yellow catfish (Pelteobagrus fulvidraco) in Jianghan Plain.   [Methods] Parents of P. fulvidraco were cultured
期刊
Abstract In this study, noncumulative slope length (NCSL) calculation method and spatial analytical calculation (SAC) method were respectively applied to extract slope length and slope length factor f
期刊
Abstract [Objectives] This study was conducted to detect the twodimensional diffusion concentration distribution from sloped wave bank.   [Methods] Diffusion experiments of instantaneous line source d
期刊
Abstract The agronomic traits of the new wheat variety Anmai 1241 were comprehensively evaluated, in order to provide comprehensive and objective theoretical basis for further improvement and producti
期刊
Abstract On the basis of referring plenty of literatures, we summarized the research advance in effects of nitrogen on the internal quality of peach fruit. Most studies have shown that proper nitrogen
期刊
Abstract Understanding the photosynthetic characteristics of high-yield soybean [Glycine max (L.) Merr] cultivar (HYC) would aid research aiming at investigating the soybean high yield formation mecha
期刊