通过 Internet Explorer COM 在 Google Earth 插件中直接移动相机
我在 Google 地球插件中模仿直线时遇到问题。为了模仿直线,我通过 COM 从 MATLAB 调用 HTML 文档中的 JavaScript 方法。 (MATLAB 作为 COM-客户端,Internet Explorer 作为 COM-服务器)
JavaScript 代码如下:
function UpdateCamera(lat,lon,alt,bearing,pitch,roll) {
var camera = ge.getView().copyAsCamera(ge.ALTITUDE_ABSOLUTE);
// set the camera values
camera.setLatitude(lat);
camera.setLongitude(lon);
camera.setAltitude(alt);
camera.setHeading(bearing);
camera.setTilt(pitch);
camera.setRoll(roll);
// Set the FlyTo speed
ge.getOptions().setFlyToSpeed(ge.SPEED_TELEPORT);
// Update the view in Google Earth
ge.getView().setAbstractView(camera);
}
为了调用 JavaScript 方法,我在 MATLAB 中使用此方法:
for i=1:iend
h.Document.parentWindow.execScript(['tickAnimation(' num2str(cood(i,1)) ',' ...
num2str(cood(i,2)) ',' ...
num2str(cood(i,3)) ',' ...
num2str(70) ',' ...
num2str(90) ',' ...
num2str(0) ');'] , 'JavaScript');
pause(0.01)
end
我从距离中获取纬度和经度,这是模拟的输出。使用此处的公式 http://www.movable-type.co .uk/scripts/latlong-vincenty-direct.html (这个公式精确到0.5毫米以内!)
不幸的是,我仍然无法在Google Earth中获得直线运动。向前的运动包括之字形运动。您可以在此处查看结果 http://www.youtube.com/watch?v=KS77qORjFh8
向上的动作已经很顺利了。现在的问题只是向前移动。
期待您的意见。
问候, 万
I have a problem to imitate a straight line in Google Earth Plugin. To imitate the straight line, I invoke a JavaScript method in a HTML Document from MATLAB via COM. (MATLAB as COM- Client and Internet Explorer as COM-Server)
The JavaScript code is below:
function UpdateCamera(lat,lon,alt,bearing,pitch,roll) {
var camera = ge.getView().copyAsCamera(ge.ALTITUDE_ABSOLUTE);
// set the camera values
camera.setLatitude(lat);
camera.setLongitude(lon);
camera.setAltitude(alt);
camera.setHeading(bearing);
camera.setTilt(pitch);
camera.setRoll(roll);
// Set the FlyTo speed
ge.getOptions().setFlyToSpeed(ge.SPEED_TELEPORT);
// Update the view in Google Earth
ge.getView().setAbstractView(camera);
}
And for invoking the JavaScript method, I use this in MATLAB:
for i=1:iend
h.Document.parentWindow.execScript(['tickAnimation(' num2str(cood(i,1)) ',' ...
num2str(cood(i,2)) ',' ...
num2str(cood(i,3)) ',' ...
num2str(70) ',' ...
num2str(90) ',' ...
num2str(0) ');'] , 'JavaScript');
pause(0.01)
end
I get the latitude and longitude from the distance, which is the output of a simulation. Using the formula here http://www.movable-type.co.uk/scripts/latlong-vincenty-direct.html
(this formula is accurate within 0.5mm!)
Unfortunately, I still cannot get a straight movement in Google Earth. The movement forwards consists zig-zag motion. you can see the result here http://www.youtube.com/watch?v=KS77qORjFh8
The movements upwards is already smooth. the problem now is only the forwards movement.
Looking forward for your inputs.
Regards,
Wan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在移动过程中,不仅相机的纬度/经度发生变化,而且航向也发生变化。因此,您还需要更新标题。
During the movement not only lat/lng of the camera changes but also the heading. So, you need to update the heading as well.