Oct 10, 2011 at 2:24 PM
Edited Oct 12, 2011 at 12:27 AM
I have a set of KMZ files containing polygonal boundaries (outer and inner loops).
Some of these loops contain many more points than are necessary for viewing at any useful resolution (zoom level).
I wish to read the KMZ file, simplify the loops, and write the new KML file otherwise unaltered.
I am happy writing the simplify algorithm for the loops. That is not the subject of my question. (but for those interested, http://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm)
and yes I know it is available in various GIS tools.
I had intended to use LoadKml to get the KMLRoot, and then effectively do a traversal of the tree, writing out the nodes as is, as I went along except for polygon loops, that I would modify and then write out.
This approach meant I could recurse through the structure and except for the polygon loops, would never have to worry too much about state or memory consumption (at least at the level I would be writing it).
I was going to use the list of Children of each node to recurse through the structure.
Unfortunately, the Children is a protected Property, so I can't use it. However, Flatten() produces (I believe) a flattened list of all sub nodes.
At a pinch I can use this, but at this point it seems Flatten will lose me some information that I wanted, effectively some of the information regarding parents and children that is useful at the node level for traversing the tree.
At the minute I'm surprised and frustrated that I can't traverse the tree using the Children Property. If there is an easy work around then I'm interested, and if there is a good reason for hiding the Children then I'm also interested.
I believe SharpKml should be the right library for me to use once I've got used to it, but at the moment I keep running into problems.
So far, @samcragg has been extremely responsive, for which I'm very grateful. I hope I can continue to use the library.