Dynamiclly generating kml files

84 views
Skip to first unread message

Blade

unread,
Dec 13, 2008, 9:03:16 AM12/13/08
to KML Developer Support - Advanced Support for KML
Hey there!
I've got a problem when I use kml of GoogleEarth. The basic goal of my
application is as following:
1. I want to make a record of a gps track from a gps module of my car,
it can communicate with my laptop through bluetooth devices.
2. I want to mark the direction of my car when I driving;

U know that we should use refreshmode in kml to realize the
refreshment of data. While doing this, I use WM_TIMER in C++ to
generator new kml files every 1 second, this will overwrite the former
kml file, which is still using by the update kml files, so problem
come up when the update kml file starts to read from the kml file
which is still be written by C++ application, then warning from Google
Earth turns up, that is awful.

Someone has told me I can use data streams to realize this function,
but I have no idea about that at all, Can Anybody Hopefully Help Me?

Thanks A Lot!

nicodemussunrise

unread,
Dec 15, 2008, 8:26:37 PM12/15/08
to KML Developer Support - Advanced Support for KML
Blade,

That's tricky. I'm going to assume that you *have* to do this 1-second
refresh. If you are taking in enough data to need that fast refresh
rate, and you're accumulating this data and rewriting the KML just as
fast, keep in mind that your PC will have to work harder (longer) each
iteration.

Here's what I'd do:
1. Make sure you are open()ing the output KML file at the (reasonable)
last minute (that is, don't hold the file open for the entire
duration, open it once you're ready to write, then close it.
(Basically, try to avoid a situation where you're looping through the
data and appending kml to the file)

2. Use libkml (http://code.google.com/p/libkml/) to create your KML in
a data structure within your program, so the entire file-writing code
looks something like
std::ofstream file;
file.open("output.kml");
file << kml_data_structure;
file.close();

That'd be my recommendation.

-ns

Blade

unread,
Dec 16, 2008, 8:48:19 AM12/16/08
to KML Developer Support - Advanced Support for KML
Thanks very much, nicodemussunrise!

I've tried to use libkml to write my kml files, and that really helps
a lot!

Hope it can run smoothly in my app!

But does there has to be an temp kml file? what about load streams
directly. using kind of http://localhost:***?
I'm still working on it! Let's see what will happen next!

Thanks again!
> > Thanks A Lot!- 隐藏被引用文字 -
>
> - 显示引用的文字 -
Reply all
Reply to author
Forward
0 new messages