File: rtkplot_ge.htm

package info (click to toggle)
rtklib 2.4.3%2Bdfsg1-2.1
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 41,796 kB
  • sloc: cpp: 51,592; ansic: 50,584; fortran: 987; makefile: 861; sh: 45
file content (233 lines) | stat: -rw-r--r-- 6,774 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
<!------------------------------------------------------------------------------
* rtkplot_ge.htm: rtkplot google earth plugin
*
* history: 2012/04/07 1.0  new
*------------------------------------------------------------------------------>
<html>
<head>
<title>RTKPLOT_GE</title>

<script type="text/javascript" src="http://www.google.com/jsapi"> </script>
<script type="text/javascript">

var ge = null;
var mark1,mark2,track1,track2,points,altmode;
var mark_icon1="http://maps.google.com/mapfiles/kml/paddle/ylw-circle.png";
var mark_icon2="http://maps.google.com/mapfiles/kml/paddle/red-circle.png";
var mark_icon3="http://maps.google.com/mapfiles/kml/paddle/wht-circle.png";

function init() {
    google.earth.createInstance("map3d",initCallback,failureCallback);
}

function initCallback(instance) {
    ge = instance;
    var opt = ge.getOptions();
    opt.setFlyToSpeed(ge.SPEED_TELEPORT);
    opt.setAtmosphereVisibility(false);
    opt.setMouseNavigationEnabled(true);
    opt.setBuildingSelectionEnabled(false);
    opt.setAutoGroundLevelViewEnabled(false);
    
    mark1 = GenMark('1',mark_icon1);
    mark2 = GenMark('2',mark_icon2);
    track1 = GenLine('track1','cc00ffff');
    track2 = GenLine('track2','cc0044ff');
    points = new Array();
    altmode = ge.ALTITUDE_CLAMP_TO_GROUND;
    ge.getWindow().setVisibility(true);
    
    document.getElementById('state').value='1';
    
    setInterval("UpdateState()",250);
}

function failureCallback(errcode) {
    document.write('<P align=center>Google Earth Plugin load error</P>');
    document.getElementById('state').value='-1';
}

function GenMark(name,mark_icon) {
    var pm = ge.createPlacemark('');
    var icon = ge.createIcon('');
    icon.setHref(mark_icon);
    var style = ge.createStyle('');
    style.getIconStyle().setIcon(icon);
    style.getIconstyle().getHotSpot().set(0.5,ge.UNITS_FRACTION,0,ge.UNITS_FRACTION);
    pm.setDescription(name);
    pm.setStyleSelector(style);
    ge.getFeatures().appendChild(pm);
    return pm;
}

function GenLine(name,color) {
    var pm = ge.createPlaceMark('');
    var ls = ge.createLineString('');
    var style = ge.createStyle('');
    style.getLineStyle().setWidth(3);
    style.getLineStyle().getColor().set(color);
    pm.setDescription(name);
    pm.setGeometry(ls);
    pm.setStyleSelector(style);
    ge.getFeatures().appendChild(pm);
    return pm;
}

function SetOpts(f1,f2,f3,f4,f5,f6,f7,f8,f9,f10) {
    if (ge == null) return;
    var opt = ge.getOptions();
    ge.getNavigationControl().setVisibility(f1?ge.VISIBILITY_SHOW:ge.VISIBILITY_HIDE);
    ge.getNavigationControl().setControlType(ge.NAVIGATION_CONTROL_SMALL);
    opt.setScaleLegendVisibility(f2);
    opt.setOverviewMapVisibility(f3);
    opt.setGridVisibility(f4);
    opt.setStatusBarVisibility(f5);
    ge.getLayerRoot().enableLayerById(ge.LAYER_TERRAIN,f6);
    ge.getLayerRoot().enableLayerById(ge.LAYER_ROADS,f7);
    ge.getLayerRoot().enableLayerById(ge.LAYER_BUILDINGS,f8);
    ge.getLayerRoot().enableLayerById(ge.LAYER_BUILDINGS_LOW_RESOLUTION,f8);
    ge.getLayerRoot().enableLayerById(ge.LAYER_BORDERS,f9);
    altmode = f10?ge.ALTITUDE_ABSOLUTE:ge.ALTITUDE_CLAMP_TO_GROUND;
}

function SetView(lat,lon,range,heading) {
    if (ge == null) return;
    var la = ge.getView().copyAsLookAt(ge.ALTITUDE_RELATIVE_TO_GROUND);
    la.setLatitude (lat);
    la.setLongitude(lon);
    la.setRange(range*1000.0);
    la.setHeading(heading);
    ge.getView().setAbstractView(la);
}

function SetCent(lat,lon) {
    if (ge == null) return;
    var la = ge.getView().copyAsLookAt(ge.ALTITUDE_RELATIVE_TO_GROUND);
    la.setLatitude (lat);
    la.setLongitude(lon);
    ge.getView().setAbstractView(la);
}

function SetRange(range) {
    if (ge == null) return;
    var la = ge.getView().copyAsLookAt(ge.ALTITUDE_RELATIVE_TO_GROUND);
    la.setRange(range*1000.0);
    ge.getView().setAbstractView(la);
}

function SetHeading(angle) {
    if (ge == null) return;
    var la = ge.getView().copyAsLookAt(ge.ALTITUDE_RELATIVE_TO_GROUND);
    la.setHeading(angle);
    ge.getView().setAbstractView(la);
}

function SetTilt(angle) {
    if (ge == null) return;
    var la = ge.getView().copyAsLookAt(ge.ALTITUDE_RELATIVE_TO_GROUND);
    la.setTilt(angle);
    ge.getView().setAbstractView(la);
}

function SetMark(index,lat,lon,alt) {
    if (ge == null) return;
    var mark = index==1?mark1:mark2;
    var point = ge.createPoint('');
    point.set(lat,lon,alt,altmode,1,1);
    mark.setGeometry(point);
}

function ShowMark(index) {
    if (ge == null) return;
    var mark = index==1?mark1:mark2;
    mark.setVisibility(1);
}

function HideMark(index) {
    if (ge == null) return;
    var mark = index==1?mark1:mark2;
    mark.setVisibility(0);
}

function ClearTrack(index) {
    if (ge == null) return;
    var track=index==1?track1:track2;
    var ls = track.getGeometry();
    ls.getCoordinates().clear();
}

function AddTrack(index,lat,lon) {
    if (ge == null) return;
    var track=index==1?track1:track2;
    var ls = track.getGeometry();
    ls.getCoordinates().pushLatLngAlt(lat,lon,0);
}

function ShowTrack(index) {
    if (ge == null) return;
    var track=index==1?track1:track2;
    track.setVisibility(1);
}

function HideTrack(index) {
    if (ge == null) return;
    var track=index==1?track1:track2;
    track.setVisibility(0);
}

function ClearPoint() {
    if (ge == null) return;
    for (var i = 0; i < points.length; i++) {
        ge.getFeatures().removeChild(points[i]);
    }
    points.length = 0;
}

function AddPoint(name,lat,lon,alt) {
    if (ge == null) return;
    var mark = GenMark(name,mark_icon3);
    var p = ge.createPoint('');
    p.set(lat,lon,alt,altmode,1,1);
    mark.setGeometry(p);
    points.push(mark);
}

function ShowPoint() {
    if (ge == null) return;
    for (var i = 0; i < points.length; i++) {
        var mark = points[i];
        mark.setVisibility(1);
    }
}

function HidePoint() {
    if (ge == null) return;
    for (var i = 0; i < points.length; i++) {
        var mark = points[i];
        mark.setVisibility(0);
    }
}

function UpdateState() {
    if (ge == null) return;
    var la = ge.getView().copyAsLookAt(ge.ALTITUDE_RELATIVE_TO_GROUND);
    var lat=la.getLatitude ();
    var lon=la.getLongitude();
    var range=la.getRange()/1000.0;
    var heading=la.getHeading();
    document.getElementById('view').value=
        lat.toFixed(9)+","+lon.toFixed(9)+","+range.toFixed(3)+","+heading.toFixed(1);
}

google.load("earth","1");
google.setOnLoadCallback(init);

</script>
</head>

<body style="margin: 0;"; scroll="no";>
    <div id="map3d" style="height: 100%; width: 100%;"> </div>
    <input id="state" type="hidden" value="0">
    <input id="view"  type="hidden" value="0,0,0,0">
</body>
</html>