سؤال

I wrote a web app that uses Google Earth plugin for visualizing dozens (if not hundreds) of geotagged data sources as network links. At this point, the only way to get updates on the display, is to set the auto refresh on each network link. However, with many links and short refresh interval (1-2s), the server hosting the links gets easily overwhelmed (CPU usage goes up to nearly 100%). A lot of these updates return no data, thus I wish I could use a push mechanism and be able to push KML updates back to the client upon new data - this would save me a lot of processing. Is there a way to asynchronously push KML to the GE plugin (preferably in Java)?

هل كانت مفيدة؟

المحلول

In theory can do this with a form of long polling.

You just set the server to keep the connection open, and perodically check if new content is available, as soon as it is, it returns it to the client.

GE will only open one connection perk network link, so the while the connection is held open, nothing happens the, old content is visible. As soon as the data refreshes, a new connection is opened after X seconds. Repeating the process.

The server needs to be able to keep a large number of connections open, but they are mostly dorment, so shouldnt cause any load. (you just need a webserver application capable of doing it)

But in practice its riffled with pitfalls. Mainly that if there is any proxy inbetween GE and the server, they will often time out before anything happens, and cut the connection. And unfortunatly once a network link fails once, GE usually stops trying to update that link.


Alternativly could use a the Update Mechanism, built into KML. IN this way you have only ONE, refreshing network link. But it can be tricky to get to work reliably.


Finally, and probably the most recommedned - is to implement the refresh mechanism outside of the plugin, in Javascript. So the fact that a link as updated is pushed to the Javascript container, which then just specifically refreshes certain content when needed.

Can use a similar long polling in JS, or can use something like websockets for Push notifications. There are robust implementations you can just reuse.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top