本文整理汇总了C#中Layer.GetStyleForFeature方法的典型用法代码示例。如果您正苦于以下问题:C# Layer.GetStyleForFeature方法的具体用法?C# Layer.GetStyleForFeature怎么用?C# Layer.GetStyleForFeature使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Layer
的用法示例。
在下文中一共展示了Layer.GetStyleForFeature方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateFromFeature
static void CreateFromFeature(XmlTextWriter xtw,
Layer layer,
Feature feature,
ProjFourWrapper source,
ProjFourWrapper destination)
{
Style style = layer.GetStyleForFeature(feature.ThemeFieldValue);
if (style == null) return;
string name = !string.IsNullOrEmpty(feature.LabelFieldValue) ?
feature.LabelFieldValue :
!string.IsNullOrEmpty(feature.ThemeFieldValue) ?
feature.ThemeFieldValue : null;
bool transform = destination != null;
if (layer.Data.SourceFeatureType == FeatureType.Point)
{
Point pt = feature as Point;
if (transform)
{
pt = source.Transform(destination, pt);
}
xtw.WriteStartElement("Placemark");
if (style != null && !string.IsNullOrEmpty(style.Id))
{
xtw.WriteElementString("styleUrl", "#" + style.Id);
}
if (name != null)
{
xtw.WriteElementString("name", name);
}
xtw.WriteStartElement("Point");
xtw.WriteElementString("coordinates", string.Format("{0},{1}",
pt.X.ToString(CultureInfo.InvariantCulture),
pt.Y.ToString(CultureInfo.InvariantCulture)));
xtw.WriteEndElement(); // Point
xtw.WriteEndElement(); // Placemark
}
else if (layer.Data.SourceFeatureType == FeatureType.Polyline)
{
PolyLine pl = feature as PolyLine;
foreach (Line l in pl.Lines)
{
xtw.WriteStartElement("Placemark");
if (style != null && !string.IsNullOrEmpty(style.Id))
{
xtw.WriteElementString("styleUrl", "#" + style.Id);
}
if (name != null)
{
xtw.WriteElementString("name", name);
}
xtw.WriteStartElement("LineString");
xtw.WriteElementString("tessellate", "1");
StringBuilder sb = new StringBuilder();
foreach (Point pt in l.Points)
{
Point tpt = pt;
if (transform)
{
tpt = source.Transform(destination, pt);
}
sb.AppendFormat("{0},{1} ",
tpt.X.ToString(CultureInfo.InvariantCulture),
tpt.Y.ToString(CultureInfo.InvariantCulture));
}
xtw.WriteElementString("coordinates", sb.ToString());
xtw.WriteEndElement(); // LineString
xtw.WriteEndElement(); // Placemark
}
}
else if (layer.Data.SourceFeatureType == FeatureType.Polygon)
{
Polygon pg = feature as Polygon;
bool inRing = false;
bool clockwiseIsExterior = true;
foreach (Ring r in pg.Rings)
{
// Assumptions:
// - The first ring in an polygon is an exterior ring
// - Interior rings will come consecutively after exterior rings
// - Exterior/interior rings are determined by their ring orientation (clockwise/counter)
//.........这里部分代码省略.........