Computers & Geosciences 72 (2014) 176–183

Contents lists available at ScienceDirect

Computers & Geosciences

journal homepage: www.elsevier.com/locate/cageo

Moving KML geometry elements within Earth

Liang-feng Zhu n, Xi-feng Wang, Xin Pan

Key Laboratory of GIS, East China Normal University, Shanghai 200241, China article info abstract

Available online 1 August 2014 During the process of modeling and visualizing geospatial information on the virtual globe, fi Keywords: there is an increasing demand to carry out such operations as moving geospatial objects de ned by KML Virtual globe geometry elements horizontally or vertically. Due to the absence of the functionality and user interface Google Earth for performing the moving transformation, it is either hard or impossible to interactively move multiple KML geospatial objects only using the existing Google Earth desktop application, especially when the data Moving transformation sets are in large volume. In this paper, we present a general framework and associated implementation Geometry element methods for moving multiple KML geometry elements within Google Earth. In our proposed framework, we first load KML objects into the Google Earth plug-in, and then extract KML geometry elements from the imported KML objects. Subsequently, we interactively control the movement distance along a specified orientation by employing a custom user interface, calculate the transformed geographic location for each KML geometry element, and adjust geographic coordinates of the points in each KML objects. And finally, transformed KML geometry elements can be displayed in Google Earth for 3D visualization and spatial analysis. A key advantage of the proposed framework is that it provides a simple, uniform and efficient user interface for moving multiple KML geometry elements within Google Earth. More importantly, the proposed framework and associated implementations can be conveniently integrated into other customizable Google Earth applications to support interactively visualizing and analyzing geospatial objects defined by KML geometry elements. & 2014 Elsevier Ltd. All rights reserved.

1. Introduction environment from the low level, users of Google Earth only need to describe and save their own geospatial information in formats Nowadays a series of sophisticated and powerful online virtual according to the OpenGIS KML Encoding Standard, and the Google globes, led by Google Earth, are becoming reliable platforms for Earth virtual globe can effectively load and vividly visualize that communicating, analyzing and sharing geospatial information that information over the Internet (Zhu et al., 2014). is large-extent, multi-scaled, multi-source, massive and heteroge- In recent years, several earth scientists and industry developers neous (Butler, 2006; Bailey and Chen, 2011; Goodchild et al., 2012; have launched a series of explorations on how best to model and Yu and Gong, 2012). The Google Earth virtual globe has been widely visualize geospatial information within Google Earth using KML fi embraced by earth scientists, educators, government of cials and (Whitmeyer et al., 2010; Bailey et al., 2012; Stewart and Baldwin, the general public as an important and everyday tool to conduct 2012; Martínez-Graña et al., 2013; Wang et al., 2013). For example, research, exchange ideas and share knowledge with a global De Paor and Whitmeyer (2011) have described a variety of perspective in a natural and intuitive way, mainly because it techniques and methods through which KML can be used to possesses the ability to support the OpenGIS KML Encoding control the visualization of geological and geophysical data on Standard (OGC KML) (Wilson, 2008; Ballagh et al., 2011; De Paor Google Earth, and presented a method to create dynamic models et al., 2012; Lee and Guertin, 2012). As an open data standard for that illustrate the internal structure of the Earth by using COLLADA encoding representations of geospatial information visually, KML and JavaScript. Postpischl et al. (2011) addressed the problem of enables users of Google Earth or other geo-browsers to add custom the standardization and visualization of seismic tomographic geospatial data to virtual globes in a variety of formats, and allows models and earthquake focal mechanisms data sets using web users to create a variety of powerful user interface controls that technologies and KML. Blenkinsop (2012) has used a macro- interact with their own data (De Paor and Whitmeyer, 2011). enabled Excel workbook to convert field data into KML documents Without having to develop a more sophisticated 3D/4D virtual for the purpose of representing structural geology in Google Earth. Zhu et al. (2014) presented an automatic method for modeling and

n visualizing large volume of borehole information on Google Earth Corresponding author. Tel.: þ86 13671721009. E-mail addresses: [email protected] (L.-f. Zhu), using KML. The above-mentioned advances have achieved suc- [email protected] (X.-f. Wang), [email protected] (X. Pan). cesses to a greater or lesser extent in specific fields of use, which http://dx.doi.org/10.1016/j.cageo.2014.07.016 0098-3004/& 2014 Elsevier Ltd. All rights reserved. L.-f. Zhu et al. / Computers & Geosciences 72 (2014) 176–183 177 also played significant roles in promoting the development and This script can be utilized to move continental components, crustal professional application of the Google Earth virtual globe. fragments and other geological structures for tectonic reconstruc- After a thorough evaluation of the applications, we have tions. However, due to the limitation of the implementation program, detected several serious limitations when using the existing this script seemed to lack the flexibility since it only supports the Google Earth desktop application and its user interface controls command-line (console) operation to process KML files. That is, users to model, visualize and analyze geospatial information. One of the could neither move KML objects interactively nor control the move- current main shortcomings of Google Earth is its inability to mentdistancethroughanefficient graphical user interface. By using represent the underground space of the Earth (De Paor and the Google Earth web plug-in and its JavaScript application program- Whitmeyer, 2011; Navin and de Hoog, 2011). Technically speaking, ming interface (API), Dordevic (2013) has designed a webpage Google Earth only provides a 2.5D digital globe that ideally suited (http://www.digitalplanet.org/API/SOS/index.html), which embeds for the modeling, visualization and analysis of geospatial informa- interactive screen overlays as custom sliders, to control COLLADA tion relevant to the Earth's surface and near-surface. Therefore, it models to emerge from the subsurface. This webpage has proven to is unable to directly display or analyze subsurface objects/phe- be quite effective for handling 3D COLLADA models, but it could not nomena/processes in the correct locations beneath the Earth's be expanded to deal with other types of geospatial objects. In brief, surface. In order to model, visualize and interpret subsurface up to now there are still no comprehensive methods or systematic features, some elegant tricks need to be designed and applied to applications for moving various types of geospatial objects within bring subsurface information into view. Recently, two techniques Google Earth. Therefore, there is a clear need for developing a have been developed to address the needs of visualizing the universal method to handle all types of KML objects. subsurface. One technique is to set an uplifted height value for In this paper, we explore the transformation techniques and the purpose of elevating the vertical position of subsurface associated implementation methods for moving KML geometry features and to make them visible above the Earth's terrain surface elements within Google Earth. Our ultimate goal is to present a (De Paor and Whitmeyer, 2011; Zhu et al., 2014). This is a static general framework for the moving transformation, which is way of elevating subsurface models into view, and has the suitable to deal with all types of KML geometry elements freely advantage of easy to implement. However, in this way, it is either and flexibly. This paper first summarizes the classification and the hard or impossible to interactively move subsurface features description of KML geometry elements, as well as the method for because their altitudes would be fixed after lifted. A second defining their geospatial positions. Subsequently, the overall approach is to pre-generate a set of KML objects containing KML framework and key steps for performing the moving transforma- 〈TimeSpan〉 tags with sequential increased altitudes, and to exploit tion are illustrated in great detail. The implementation program the built-in Google Earth time slider control to raise objects up out and its application are finally presented. of the surface (De Paor and Pinan-Llamas, 2006; De Paor and Williams, 2006; De Paor et al., 2008; De Paor and Whitmeyer, 2011; Dordevic, 2012). This approach provides high quality anima- 2. KML geometry elements tion capability with visually appealing appearances, but suffers from the huge data redundancy. Moreover, the built-in Google In digital globes, geospatial objects are generalized as points, Earth time slider is originally designed for controlling time lines, polygons and other types of geometry elements. As listed in intervals of displaying KML objects, thus it is not appropriate to Table 1, OGC KML 2.2 (Wilson, 2008) supports six types of geometry elevate subsurface models. During the elevating process, the elements derived from the abstract 〈kml:Geometry〉 element, double-thumb feature and the display of values/units for elevation including five primitive geometry elements (〈kml:Point〉, 〈kml:Line- in the time slider often cause users confusion (Dordevic, 2012). String〉, 〈kml:LinearRing〉, 〈kml:Polygon〉 and 〈kml:Model〉) and one Therefore, this approach is useful but should not be regarded as multiple geometry element (〈kml:MultiGeometry〉). For 〈kml:Point〉, a perfect method for the modeling and visualization of subsur- 〈kml:LineString〉, 〈kml:LinearRing〉 and 〈kml:Polygon〉 elements, face features. their positions on the Earth are defined by the 〈kml:coordinates〉 To overcome the above limitations on visualizing the subsur- element (Wernecke, 2009). The initial placement of the 〈kml: face, a more straightforward, intuitive and accessible solution can Model〉 element is specified by the 〈kml:Location〉 element, and be obtained by moving subsurface features interactively within the 〈kml:Location〉 element contains the 〈kml:longitude〉, 〈kml: Google Earth to change their locations in 3D space. However, the latitude〉 and 〈kml:altitude〉 child elements. The 〈kml:MultiGeome- current Google Earth desktop application, which falls short of try〉 element is a container for zero or more geometric primitives advanced functions in 3D interaction for geospatial objects, is associated with the same KML feature (Wilson, 2008; Wernecke, unable to offer existing tools or built-in functions to move 2009). Therefore, it can be decomposed into a set of primitive geospatial objects freely and flexibly, especially when the objects geometry elements like 〈kml:Point〉, 〈kml:LineString〉, 〈kml:LinearR- are massive. Using the stand-alone Google Earth desktop applica- ing〉, 〈kml:Polygon〉 or 〈kml:Model〉, and the position of each tion, users can choose and move a single KML geometry element, primitive geometry element is specified by the corresponding but they are unable to pick or move multiple geometry elements 〈kml:coordinates〉 or 〈kml:Location〉 element. simultaneously. In addition, users cannot precisely control the movement distance through the user interface provided by the standard Google Earth desktop application. This shortcoming 3. General framework and key steps seriously limits the use of Google Earth in some specific Earth science subjects (especially geology and geophysics) and multi- The existing Google Earth desktop application is insufficient to disciplinary research, and there is a pressing need for a more perform the moving transformation as it neither supports moving specialized tool to move geospatial objects within Google Earth. multiple objects simultaneously nor provides precise controls on Recently, some research teams have invested considerable effort movement distances. In order to move multiple KML geometry into how to move geospatial objects within Google Earth, and several elements freely and flexibly, we need to transition from the Google technologies have been proposed and applied by geologists and Earth desktop application to the Google Earth web-browser plug- engineers. For example, Whitmeyer (2012) has written a Perl script in, design and develop a custom component and corresponding to move points, lines and polygons in a KML file by a specified operating interface by employing the Google Earth plug-in and its number of meters without distorting the shapes of geospatial objects. JavaScript API. 178 L.-f. Zhu et al. / Computers & Geosciences 72 (2014) 176–183

Table 1 KML geometry element types.

KML geometry Description Define method for geospatial position element

〈kml:Point〉 0-Dimensional geometric primitive, representing a A spatial location defined by a single geodetic longitude, geodetic latitude, and (optional) spatial position. altitude coordinate tuple. 〈kml:LineString〉 Curve composed of a connected set of straight-line A list of two or more coordinate tuples. Each tuple contains the longitude, latitude, and segments. (optional) altitude. 〈kml:LinearRing〉 Closed line string that should not cross itself, A list of four or more coordinate tuples where the first and last coordinate tuples must be typically the outer or inner boundary of a polygon. the same (to form the closed loop). Each tuple contains the longitude, latitude, and (optional) altitude. 〈kml:Polygon〉 Planar surface defined by 1 exterior boundary and One outer boundary ring and zero or more inner boundary rings. Each ring is defined by 0 or more interior boundaries. the 〈kml:LinearRing〉 element. 〈kml:Model〉 3D object described in a COLLADA file. The exact coordinates of the initial placement of a 〈kml:Model〉 element is specified by the 〈kml:Location〉 element, comprising the 〈kml:longitude〉, 〈kml:latitude〉 and 〈kml:altitude〉 child elements. 〈kml:MultiGeometry〉 Container for zero or more geometric primitives A collection of discrete geometric primitives listed above. associated with the same KML feature.

Google Earth Server KML objects Load KML objects

Extract KML geometry Extract KML geometry elements elements Set movement distances Set movement distances Moving transformation

Adjust geographic coordinates of KML Transformed KML geometry elements geometry elements

Display transformed KML geometry elements on Google Earth General-purpose Interactive screen Visualize and analyze KML geometry elements slider controls overlays as sliders Fig. 2. Flow chart for implementing the moving transformation of KML geometry Graphical User Interface (GUI) for Moving Transformation Web-based Google Earth Plug-in elements within Google Earth.

Fig. 1. Overall framework for the moving transformation of KML geometry elements within Google Earth. The sharp-cornered rectangles represent the KML objects; the round-cornered rectangles represent the program components that process the KML objects; the thin black arrow lines denote the data flows in the file from a specified URL, while the parseKml method is ideally moving transformation; and the red double-headed arrows depict the graphical suited for loading an arbitrary KML string that is not hosted user interface controls and interaction between the program components and its publicly. user. (For interpretation of the references to color in this figure legend, the reader is referred to the web version of this article.) Here is an example of using the KmlNetworkLink approach to load a KML/KMZ file:

Fig. 1 shows a schematic representation of the overall frame- var link¼ge.createLink("); work for the moving transformation of KML geometry elements var kmlUrl ¼‘http://www.sirrs.org/movekml/testpoint.kml’; within Google Earth. As Fig. 2 shows, the implementation of the //A KML file that is hosted at some public URL moving transformation can be decomposed into five steps, and the link.setHref(kmlUrl); step-by-step execution is explained below. var networkLink¼ge.createNetworkLink("); networkLink.set(link, true, true); 3.1. Load KML objects ge.getFeatures().appendChild(networkLink); Here is the JavaScript code of using the fetchKml technique to The first step is to load KML objects into the Google Earth plug- load a KML/KMZ file: in, as initial input data for the moving transformation. KML objects var kmlUrl¼‘http://www.sirrs.org/movekml/testpoint.kml’; are usually stored in a KML string or a hosted KML/KMZ file. In //The hosted KML file Google Earth API (Google, 2014), there are three methods of google.earth.fetchKml(ge, kmlUrl, function(kmlObject) { importing KML objects into the Google Earth plug-in: KmlNet- if (kmlObject) workLink, fetchKml and parseKml (Nurik, 2009). The KmlNetwork- ge.getFeatures().appendChild(kmlObject); Link and fetchKml methods can be used to load a hosted KML/KMZ }); L.-f. Zhu et al. / Computers & Geosciences 72 (2014) 176–183 179

The JavaScript code for loading and displaying a KML string thumb is translated into the value of the movement distance to with the parseKml method looks like this: change the displacement of the KML geometry elements. A more compelling approach for controlling the displacement var kmlString¼" is to create custom slider controls within the Google Earth þ‘o?xml version¼“1.0” encoding¼“UTF-8”?4’ container by employing interactive screen overlays (Dordevic, þ‘okml xmlns¼“http://www.opengis.net/kml/2.2”4’ 2012), and to drag those custom sliders in order to set movement þ‘oPlacemark4’ distances. A screen overlay is an image that is fixed to a specified þ‘oname4Placemark from KML stringo/name4’ location on the screen (Wernecke, 2009). We can generate a þ‘oPoint4’ custom slider through arranging two screen overlays with appro- þ‘ocoordinates4-122.1, 37.9, 0o/coordinates4’ priate sizes into corresponding positions on the window of the þ‘o/Point4’ Google Earth plug-in. One screen overlay is used as the stationary þ‘o/Placemark4’ track, and the other screen overlay is used as the draggable thumb þ‘o/kml4’; (Dordevic, 2012). Similar to the built-in Google Earth navigation var kmlObject¼ge.parseKml(kmlString); controls, this custom slider also has the virtue of being semitran- ge.getFeatures().appendChild(kmlObject); sparent. That is, only when the screen defined by the slider gains focus can the slider becomes interactive and draggable. By using this screen-overlay-based slider, we can maintain application 3.2. Extract KML geometry elements responsiveness and enhance interactivity when setting movement distances for KML geometry elements. The second step is to extract KML geometry elements from the imported KML objects in the Google Earth plug-in, used for the 3.4. Adjust geographic coordinates of KML geometry elements subsequent moving transformation. We can use the getElement- ById or getElementByUrl functions in the Google Earth API to get a The main work of the fourth step contains calculating the specified KML geometry element by its ID or URL (Google, 2014): transformed geographic location for each KML geometry element var kmlElements¼ge.getElementById(string ID); //Get a KML according to the movement distance, and adjusting geographic geometry element by its ID coordinates of the points in each KML geometry element. In this var kmlElements¼ge.getElementByUrl (string url); //Get a KML step, two essential problems need to be solved: one is how to geometry element by its URL calculate the transformed location for a KML geometry element, In order to get a list of elements by a specified geometry type, and the other is how to adjust geographic coordinates of multiple we employ the getElementsByType function as follows (Google, KML geometry elements in a fast and batched way. The following 2014): subsections are explanations of these problems.

var points¼ge.getElementsByType(‘KmlPoint’);//Get all points 3.4.1. Calculate geographic locations for moving transformation var linestrings¼ge.getElementsByType(‘KmlLineString’);//Get Any moving transformation to a specified KML geometry all line strings element can be ultimately attributed to the coordinate transfor- var linearrings¼ge.getElementsByType(‘KmlLinearRing’);//Get mation of the points composed that KML geometry element. In a all linear rings relatively small range of the Earth's surface and near-surface, after var polygons¼ge.getElementsByType(‘KmlPolygon’);//Get all moving transformation the geographic coordinate (longitude, polygons latitude and altitude) of a specified point can be calculated as var models¼ge.getElementsByType(‘KmlModel’);//Get follows (Whitmeyer, 2012): all models Δλ var MultiGeometries¼ge.getElementsByType(‘KmlMultiGeo- λ ¼ λ þ 180 1 0 π ð þ Þ φ metry’); //Get all multi-geometries r h0 cos 0

Δφ φ ¼ φ þ 180 1 0 þπ 3.3. Set movement distances 2c h0

h ¼ h þΔh In the third step, we manually input the displacement along a 1 0 specified orientation to specify how a transformation is performed where λ0, φ0,and h0 are initial 3D coordinates (longitude, latitude on the selected objects. Within Google Earth, there are three cases and altitude respectively) of the point (the longitude and latitude of moving transformation to be taken into account: moving along are defined in decimal degrees, and the altitude is defined the vertical direction, moving along the latitudinal (east–west) in meters); λ1, φ1, and h1 are 3D coordinates of the transformed direction, and moving along the longitudinal (north–south) direc- point; Δλ is the movement distance (in meters) along the long- tion. Correspondingly, we have an obligation to set the movement itudinal (north–south) direction; Δφ is the movement distance (in distances respectively along each direction. meters) along the latitudinal (east–west) direction; Δh is the When setting movement distances within the Google Earth movement distance (in meters) along the vertical direction; r is plug-in, there are two practical graphical user interfaces to control the equatorial radius, r¼6,378,137 m; c is the distance from the the displacement interactively: equator to a pole, c¼10001965.729 m; and π is the circumference The simplest approach is to incorporate existing general-purpose ratio (pi). slider controls, such as the Tigra slider control (SoftComplex Inc., It should be pointed out that the above equations relate only to 2010) and the HTML-native slider, to control the movement distances small scale objects and motions in a relatively small range of the interactively. The general-purpose slider control, which could be Earth's surface and near-surface (from meters to tens of kilo- located on the webpage outside the Google Earth container (De Paor meters). In this situation, the curvature of the Earth is not an issue et al., 2012), usually consists of two elements: the draggable piece and should not be considered when moving transformation. For (thumb), and the track along which the thumb can travel freely. Once large objects such as continents and large movements over the thumb is dragged to a position on the track, the position of the thousands of kilometers, a different approach using Euler poles 180 L.-f. Zhu et al. / Computers & Geosciences 72 (2014) 176–183 and quaternion interpolation (De Paor, 1996; Dordevic and var pointCoordArray¼null; Whitmeyer, 2014) is required. pointi¼linestrings.item(i); pointCoordArray¼pointi.getCoordinates (); for (var j¼0;jopointCoordArray.getLength(); jþþ){ 3.4.2. Adjust geographic coordinates in a fast and batched way var pointCoord¼pointCoordArray.get(j ); On the Google Earth virtual globe, usually there are plenty of //The initial 3D coordinates of a point KML geometry elements that need to be moved almost simulta- var lati¼pointCoord.getLatitude(); neously. Due to the vast amount and complicated structure of KML var lngi¼pointCoord.getLongitude(); geometry elements, challenges arise when adjusting geographic var alti¼pointCoord.getAltitude(); coordinates of massive KML geometry elements at one time. In //Calculate the offsets of 3D coordinates order to enhance the efficiency of moving a large volume of KML deltaLat1¼(deltaLatn180)/(2nc_distanceþpi_valuenalti); geometry elements within Google Earth, an automatic, fast and deltaLng1¼(deltaLngn180)/(pi_valuen(radius_earthþalti)n batched method to adjust geographic coordinates of KML geome- Math.cos(lati n pi_value/180.0)); try elements needs to be designed and implemented. In the fourth deltaAlt1¼deltaAlt; step, we first use Google Earth API to extract the initial 3D var newlati¼latiþdeltaLat1; coordinates of each point in each KML geometry element, and var newlngi¼lngiþdeltaLng1; then calculate the offsets of the 3D coordinates according to the if (newlati490) {newlati¼90;} movement distances, and finally adjust the location of the point in if (newlatio 90) { newlati¼90; } terms of the offsets. if (newlngi4180) { newlngi¼newlngi360;} The JavaScript code of moving multiple KML geometry ele- if (newlngio 180) {newlngi¼newlatiþ360;} ments almost at the same time works as follows: //Adjust the location of the point using the offsets pointCoordArray.setLatLngAlt(j, newlati, newlngi, altiþ function moveKmlGeometryElements(deltaLat, deltaLng, deltaAlt1); deltaAlt) { } // deltaLat – The movement distance (in meters) along the } latitudinal (east–west) direction //Move 3D models // deltaLng – The movement distance (in meters) along the var models¼ge.getElementsByType(‘KmlModel’); //Get all longitudinal (north–south) direction 3D models // deltaAlt – The movement distance (in meters) along the for (i¼0; iomodels.getLength(); iþþ){ vertical direction var modeli¼models.item(i); var i¼null; var modelLoc¼null; var pi_value¼Math.PI; //Pi modelLoc¼modeli.getLocation(); var radius_earth¼6378137; //The equatorial radius //The initial placement of a model var c_distance¼10001965.729; //The distance from the equator var lati¼modelLoc.getLatitude(); to a pole var lngi¼modelLoc.getLongitude(); var deltaLat1¼0; var alti¼modelLoc.getAltitude(); var deltaLng1¼0; //Calculate the offsets of 3D coordinates var deltaAlt1¼0; deltaLat1¼(deltaLatn180)/(2nc_distanceþpi_valuenalti); //Move points deltaLng1¼(deltaLngn180)/(pi_valuen(radius_earthþalti)n var points¼ge.getElementsByType(‘KmlPoint’);//Get all points Math.cos(lati n pi_value/180.0 )); for ( i¼0; iopoints.getLength(); iþþ){ deltaAlt1¼deltaAlt; var pointi¼points.item(i); var newlati¼latiþdeltaLat1; //The initial 3D coordinates of a point var newlngi¼lngiþdeltaLng1; var lati¼pointi.getLatitude(); if (newlati490) {newlati¼90;} var lngi¼pointi.getLongitude(); if (newlatio 90) {newlati¼-90; } var alti¼pointi.getAltitude(); if (newlngi4180) { newlngi¼newlngi – 360;} //Calculate the offsets of 3D coordinates according to the if (newlngio 180) {newlngi¼newlatiþ360;} movement distances //Adjust the location of the model using the offsets deltaLat1¼(deltaLatn180)/(2nc_distanceþpi_valuenalti); modelLoc.setLatLngAlt(newlati, newlngi,altiþdeltaAlt1); deltaLng1¼(deltaLngn180)/(pi_valuen(radius_earthþalti)n } Math.cos(lati n pi_value/180.0 )); } deltaAlt1¼deltaAlt; var newlati¼latiþdeltaLat1; var newlngi¼lngiþdeltaLng1; In this example, we use a code fragment to handle line strings, if (newlati490) { newlati¼90; } linear rings and polygons simultaneously. As presented in Table 1, if (newlatio 90) { newlati¼-90;} geospatial positions of the outer/inner boundaries in polygons are if (newlngi4180) { newlngi¼newlngi - 360; } defined by the KML 〈LinearRing〉 elements. While in Google Earth if (newlngio 180) { newlngi¼newlatiþ360; } API, the KmlLinearRing class is derived from the KmlLineString //Adjust the location of the point using the offsets class. Therefore, any transformation to a polygon or linear ring can pointi.setLatLngAlt(newlati, newlngi, altiþdeltaAlt1); be traced back to the KML 〈LineString〉 element. Accordingly, the } moving transformation of polygons and linear rings can be //Handle line strings, linear rings and polygons handled along with line strings. var linestrings¼ge.getElementsByType(‘KmlLineString’);//Get It should be pointed out that we do not need any special code to all line strings, also including linear rings and polygons deal with multi-geometries. This is because the 〈MultiGeometry〉 for ( i¼0; iolinestrings.getLength(); iþþ){ element is only a collection of multiple geometry elements asso- var pointi¼null; ciated with the same KML feature, and the transformation of any L.-f. Zhu et al. / Computers & Geosciences 72 (2014) 176–183 181 multi-geometry can be traced back to corresponding geometric as the interactive tool to control the movement distance. Any primitives like points, line strings, linear rings, polygons or models. computer that already has the Google Earth web plug-in installed can freely visit this webpage on a decent broadband connection. 3.5. Display transformed KML geometry elements on Google Earth After loading a hosted KML/KMZ file from a specified URL, users of this webpage can move multiple KML geometry elements arbitrarily. Finally, transformed KML geometry elements are displayed in When using MovingKML, we first input the URL of any hosted the Google Earth plug-in for 3D visualization and spatial analysis. KML/KMZ file and click the “Load KML/KMZ” button, and then the Using graphical interactive devices (such as the mouse and the KML geometry elements stored in the KML/KMZ file immediately keyboard) in the 3D-rendering environment provided by Google appear in the Google Earth container. By employing the general- Earth, we can freely observe the locations of the transformed KML purpose slider controls, which are located on the webpage beside geometry elements, and query the property information asso- the Google Earth container, we can manually set the movement ciated with those elements. distance along a specified direction. Alternatively, the screen- overlay-based custom sliders, which are embedded in the Google Earth container, also can be used to control the movement 4. Implementation and application distances. In the light of the predefined movement distance, MovingKML automatically adjusts the geographic coordinates of To illustrate the effectiveness of the proposed framework for the the KML geometry elements, and displays the transformed KML moving transformation of KML geometry elements, a webpage geometry elements on the Google Earth container quasi-instantly. (http://www.sirrs.org/MoveKml/en/MoveKml.html), termed Moving By performing the above-mentioned operations with a flexible KML, is designed and developed using the Google Earth web browser and intuitive graphical user interface (GUI), we are able to move a plug-in and its JavaScript API. As shown in Fig. 3,theuserinterfaceof large volume of KML geometry elements in a fast and batched way. MovingKML is composed of three parts: (1) the input area, which is An example of moving KML geometry elements is illustrated in designed for importing the URL of a hosted KML/KMZ file, is located Fig. 4. In this example, a KML file (http://www.sirrs.org/MoveKml/ inthetopofthewebpage;(2)theGoogleEarthcontainer,also testkml/TestKmlFile.kml) is loaded into the Google Earth con- incorporating three screen-overlay-based custom sliders, is located in tainer. This file contains several subsurface objects, including a the left side of the screen; and (3) the slider control area, containing borehole model that incorporates a drilling location, several strata three general-purpose slider controls, is located in the right side of and corresponding contacts, and a COLLADA model that represents the screen. In the slider control area, the Tigra slider control the subsurface geological structure. As shown in Fig. 4A, the (SoftComplex Inc., 2010), a frequently-used DHTML component for subsurface objects originally hide behind the Earth's surface. adding vertical/horizontal sliders to HTML webpages, is instantiated Therefore, they couldn’t be directly displayed on the Google Earth

Input KML/KMZFile

General-purpose slider controls

Google Earth Container

Screen-overlay-based sliders

Fig. 3. User interface of MovingKML. 182 L.-f. Zhu et al. / Computers & Geosciences 72 (2014) 176–183

Original Position

Fig. 4. Example of moving KML geometry elements using MovingKML: (A) The subsurface objects are originally located below the Earth's surface, and cannot be directly displayed on Google Earth. (B) The vertical positions of the subsurface objects are manually elevated by 200 m in order to make them visible above the Earth's terrain surface. (C) The horizontal positions of the subsurface objects are shifted by 325 m westwards from the previous positions.

virtual globe. In order to make them visible above the Earth's 5. Conclusion terrain surface, we employ vertical sliders to manually uplift the altitudes of the subsurface KML objects, and the subsurface objects With the increasing need for geospatial information and the immediately emerge from the subsurface (Fig. 4B). Similarly, using widespread use of the Google Earth virtual globe, KML is becoming horizontal sliders provided by MovingKML, we also can horizon- an international standard that has been widely embraced by tally move the KML geometry elements through setting the geoscientists as a means to represent, publish and exchange movement distance along the latitudinal (east–west) or long- geospatial objects, and there are increasing amounts of KML- itudinal (north–south) direction (Fig.4C). based information resources available that cater to different L.-f. Zhu et al. / Computers & Geosciences 72 (2014) 176–183 183 disciplines and audiences. In the field of Digital Earth science and De Paor, D.G., Pinan-Llamas, A., 2006. Application of novel presentation techniques technology, it has become a topical research area to focus on to a structural and metamorphic map of the Pampean Orogenic Belt, NW interactively visualizing and analyzing geospatial information Argentina. Geol. Soc. Am. Abstr. Programs 38 (7), 326. De Paor, D.G., Whitmeyer, S.J., 2011. Geological and geophysical modeling on virtual within virtual globe applications. Due to the current limitations globes using KML, COLLADA, and Javascript. Comput. Geosci. 37 (1), 100–110. of Google Earth, it is either hard or impossible to interactively De Paor, D.G., Whitmeyer, S.J., Gobert, J., 2008. Emergent models for teaching move KML objects only using the existing Google Earth desktop geology and geophysics using Google Earth. Eos Trans. Am. Geophys. Union 89 (53) (abstract ED31A-0599). application, especially when the data sets are in large volume. In De Paor, D.G., Whitmeyer, S.J., Marks, M., Bailey, J.E., 2012. Geoscience applications this paper, we have designed and illustrated the general frame- of client/server scripts, google fusion , and dynamic KML. Geological work and associated implementation methods for moving multi- Society of America Special Papers 492, pp. 77–104. ple KML geometry elements within Google Earth. A key advantage De Paor, D.G., Williams, N.R., 2006. Solid modeling of moment tensor solutions and temporal aftershock sequences for the Kiholo Bay earthquake using Google of the proposed framework is that it provides a simple, uniform Earth with a surface bump-out. Eos Trans. Am. Geophys. Union, 87; (abstract and efficient user interface for moving multiple KML geometry S53E-05). elements within the Google Earth virtual globe. More importantly, Dordevic, M.M., 2012. Designing interactive screen overlays to enhance effective- the proposed framework and associated implementations can be ness of Google Earth geoscience resources. Geo. Soc. Am. Special Pap. 492, 105–111. conveniently integrated into other customizable Google Earth Dordevic, M.M., 2013. Slope Faliure at Kilauea Volcano 〈http://www.digitalplanet. applications to support interactively visualizing and analyzing org/API/SOS/index.html〉 (accessed 28.03.14.). geospatial objects defined by KML geometry elements, especially Dordevic, M., Whitmeyer, S., 2014. Move and Rotate Google Earth Elements. 〈http:// 〉 subsurface features. geode.net/etc/poly (accessed 04.07.13.). Goodchild, M.F., Guo, H., Annoni, A., Bian, L., de Bie, K., Campbell, F., Craglia, M., Ehlers, M., van Genderen, J., Jackson, D., Lewis, A.J., Pesaresi, M., Remetey- Fülöpp, G., Simpson, R., Skidmore, A., Wang, C., Woodgate, P., 2012. Next- Acknowledgments generation digital Earth. Proc. Natl. Acad. Sci. USA 109 (28), 11088–11094. Google, 2014. Google Earth API Reference. 〈https://developers.google.com/earth/ 〉 This research was supported by the Social Science Foundation documentation/reference (accessed 20.03.14.). Lee, T., Guertin, L., 2012. Building an education game with the Google Earth of Shanghai (Grant no. 2014BCK002), the National Natural Science application programming interface to enhance geographic literacy. Geol. Soc. Foundation of China (Grant no. 40902093), the National Science Am. Special Pap. 492, 395–401. and Technology Program of China (Grant no. SinoProbe-08), the Martínez-Graña, A.M., Goy, J.L., Cimarra, C.A., 2013. A virtual tour of geological heritage: Valourising geodiversity using Google Earth and QR code. Comput. Development Foundation of Experimental Teaching Equipment in Geosci. 61 (1), 83–93. East China Normal University (Grant no. 64100010), and the Open Navin, J., de Hoog, M., 2011. Presenting geoscience using virtual globes. AusGeo Foundation of Key Laboratory for GIS (Grant no.KLGIS2014C02). News 104, 15–19. 〈 We would like to thank Declan G. De Paor, Tom G. Blenkinsop and Nurik, R., 2009. An overview of using KML in the Earth API. https://developers. google.com/earth/articles/earthapikml〉 (accessed 20.03.14). the Editor for their helpful and constructive suggestions for Postpischl, L., Danecek, P., Morelli, A., Pondrelli, S., 2011. Standardization of seismic improving the paper. tomographic models and earthquake focal mechanisms data sets based on web technologies, visualization with . Comput. Geosci. 37 (1), 47–56. Appendix A. Supporting information SoftComplex Inc., 2010. Tigra Slider Control. 〈http://www.softcomplex.com/pro ducts/tigra_slider_control〉 (accessed 07.07.13.). Stewart, M.E., Baldwin, K., 2012. Workshops, community outreach, and KML for Supplementary data associated with this article can be found in visualization of marine resources in the Grenadine Islands. Geol. Soc. Am. the online version at http://dx.doi.org/10.1016/j.cageo.2014.07.016. Special Pap. 492, 63–76. Wang, Y., Huynh, G., Williamson, C., 2013. Integration of /Earth with microscale meteorology models and data visualization. Comput. Geosci. 61 (1), References 23–31. Wernecke, J., 2009. The KML Handbook: Geographic Visualization for the Web. Bailey, J.E., Chen, A., 2011. The role of virtual globes in geoscience. Comput. Geosci. Addison-Wesley, Upper Saddle River, USA p. 339. 〈 37 (1), 1–2. Whitmeyer, S., 2012. Moving Polygons in Google Earth. http://www.digitalplanet. 〉 Bailey, J.E., Whitmeyer, S.J., De Paor, D.G., 2012. Introduction: the application of org/site/NewOct12.html (accessed 04.09.13.). Google Geo Tools to geoscience education and research. Geological Society of Whitmeyer, S.J., Nicoletti, J., De Paor, D.G., 2010. The digital revolution in geologic – America Special Papers 492, pp. vii–xix. mapping. GSA Today 20 (4/5), 4 10. Ballagh, L.M., Raup, B.H., Duerr, R.E., Khalsa, S.J.S., Helm, C., Fowler, D., Gupte, A., Wilson, T. (Ed.), 2008. OGC KML. OGC07-147r2. Open Geospatial Consortium, Inc. 2011. Representing scientific data sets in KML: methods and challenges. 〈http://portal.opengeospatial.org/files/?artifact_id=27810〉 (251 pp. accessed Comput. Geosci. 37 (1), 57–64. 28.03.14). Blenkinsop, T.G., 2012. Visualizing structural geology: from Excel to Google Earth. Yu, L., Gong, P., 2012. Google Earth as a virtual globe tool for Earth science Comput. Geosci. 45 (1), 52–56. applications at the global scale: progress and perspectives. Int. J. Remote Sens. Butler, D., 2006. Virtual globes: the web-wide world. Nature 439 (7078), 776–778. 33 (12), 3966–3986. De Paor, D.G., 1996. Computation of orientations for GIS – the ‘Roll’ of quaternions. Zhu, L., Wang, X., Zhang, B., 2014. Modeling and visualizing borehole information Comput. Methods Geosci. 15, 447–456. on virtual globes using KML. Comput. Geosci. 62 (1), 62–70.