Hi,
I was looking into the KML 2.1 schemas today and noticed
that any element extending from FeatureType can either have
a styleURL _or_ have an embedded style.
So it seems the easy solution is to embed the styles instead
of putting them just before the feature?
<complexType name="FeatureType" abstract="true">
<complexContent>
<extension base="kml:ObjectType">
<sequence>
<element name="name" type="string" minOccurs="0"/>
<element name="visibility" type="boolean" default="1" minOccurs="0"/>
<element name="open" type="boolean" default="1" minOccurs="0"/>
<element name="address" type="string" minOccurs="0"/>
<element name="phoneNumber" type="string" minOccurs="0"/>
<element name="Snippet" type="kml:SnippetType" minOccurs="0"/>
<element name="description" type="string" minOccurs="0"/>
<element ref="kml:LookAt" minOccurs="0"/>
<element ref="kml:TimePrimitive" minOccurs="0"/>
<element ref="kml:styleUrl" minOccurs="0"/>
<element ref="kml:StyleSelector" minOccurs="0" maxOccurs="unbounded"/>
<element ref="kml:Region" minOccurs="0"/>
<element name="Metadata" type="kml:MetadataType" minOccurs="0"/>
</sequence>
</extension>
</complexContent>
</complexType>
<complexType name="PlacemarkType" final="#all">
<complexContent>
<extension base="kml:FeatureType">
<sequence>
<element ref="kml:Geometry" minOccurs="0"/>
</sequence>
</extension>
</complexContent>
</complexType>
Anyways, the way we're outputting the styles can be kept for
the "shared styles" (see the OGC KML spec), so we can still
leverage it for the SLD styles whose symbolizers do not
reference an attribute directly, which is the vast majority
of them. By direct reference I mean something like:
<CssParameter name="stroke-width"><ogc:PropertyName>width</ogc:PropertyName></CSSParameter>
whilst anything used in a Rule filter can be turned into
a static filter (hint, each Rule gets turned into a KML style,
as each feature gets matched by at most one rule, if there
are multiple feature type styles we have to build the
possible combinations of rules in ft1 and ft2, and so on,
which is a simple exercise with nested loops unless you
want to be smart and avoid generating combinations
that cannot happen in practice).
Cheers
Andrea
--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.