Matt,
I took a look at what you have so far and while I understand what you
are trying to do, I don't think the approach you're taking will work
in the current architecture. The ideas laid out on the wiki look
good, but the implementation needs to be different. My thoughts on
the czmlLayers branch code are below, followed by some high-level
thoughts on implementation. I can also put some information on the
wiki to flesh them out some more, but I didn't want to "step on your
toes" so to speak. I'll also mention that I'm treating layers as a
separate feature compared to external links. My plan would be to
implement external links completely and get it into master and then
add layers after that. Our concept for Czml layers (which still needs
to be fleshed out) is very different than the structural layout of KML
folders, so trying to simply treat external links as a layer won't
work for us. This concept will be needed in KML coversion anyway once
we go to impelement NetworkLinkUpdate in addition to just NetworkLink.
Branch review
Core/getJson - The documentation is no longer correct for this
function, since no dojo is involved.
Core/xhrGet - The headers should probably be passed in as parameters
rather than hardcoded, otherwise xhrGet will only work with json text.
DynamicScene/CompositeDynamicObjectCollection.js - The private
_getOrCreateObject method needs to remain private, it should never be
called externally as the only objects allowed to exist in a
CompositeDynamicObjectCollection are wrapper objects consisting of
properties from other DynamicObjectCollections. Objects are never
allowed to be added to a \CompositeDynamicObjectCollection.js manually
or otherwise.
DynamicScene/CzmlDefaults - You'll need a merger and cleaner for
processCzmlPacketExternal as well, or CompositeDynamicObjectCollection
won't work. Also, instead of having processCzmlPacketExternal on
DynamicObject, you should have an ExternalLink object (like we have a
DynamicBillboard) because external will ultimately consist of multiple
properties and not just be a single property; more on that below.
DynamicScene/DynamicExternalDocumentProperty - This object shouldn't
exist because the handling of external documents should not be done at
CZML processing time. CZML processing simply turns CZML JSON into
usable properties. It doesn't actually do anything with those
properties. Also, the external document shouldn't be processing in
the same DynamicObjectCollection as the parent CZML, this way the
external data is merged non-destructively.
DynamicScene/processCzml - Since we shouldn't actually process the
external document data as part of the processCzml step, none of these
changes are needed any longer.
My thoughts on implementation
Create an ExternalLink object, following the same strategy as other
objects such as DynamicBillboard. This object contains all properties
related to defining a single external link. An "external" property in
CZML gets turned into ExternalLink instances during the CZML
processing stage. All of these properties can vary with time just
like any other CZML property.
Create a new CzmlDocumentManager object, this object manages mutliple
CZML sources and processes and updates external links and produces a
single CompositeDynamicObjectCollection property (maybe
CzmlDocumentManager.dynamicObjects?) as output which can be used by
clients for visualization. This is similar to
CompositeObjectDynamicCollection, but it's one level of abstraction
hire and may eventually serve as the main interface for a
DocumentManager UI.
Most of the "heaving lifting" would be performed in
CzmlDocumentManager.update. This function iterates over all of the
DynamicObjects looking for "externalLink" properties. If it finds an
externalLink, it checks it against a map of existing links and sees
what processing (if any) is needed during this update. External links
are almost always processed in their own DynamicObjectCollection
instance, this way it can be non-destrucively merged with the rest of
the data. At the end of the process, it needs to remove all of the
dynamicObjectCollection instances associated with externaLinks that no
longer exist. (Of course depending on the nature of the link, it
might want to cache them rather than destroy them out right so that
they can be quickly brought back as animation changes.) To the
outside observer, the result of the CzmlDocumentManager.update is
simply changes to the flat collection of objects in the
CzmlDocumentManager.dynamicObjects. The rest of the system doesn't
require any knowledge of external links whatsoever.
Using these two objects, it's now easy to change the ViewerWidget to
simply have an instance of CzmlDocumentManager and pass the
CzmlDocumentManager.dynamicObjectCollection it produces to the
visualizer collection. During the render loop, you first call
update(time) on CzmlDocumentManager and then call update on
visualizers. I feel like I didn't do the best job explaining my
thoughts, but hopefully this helps get us on the same page. Lets get
together sometime soon to discuss this and flesh things out some more.
Thanks,
Matt