当前位置: 首页>>代码示例>>C#>>正文


C# Layer.GetStyleForFeature方法代码示例

本文整理汇总了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)
//.........这里部分代码省略.........
开发者ID:agrath,项目名称:cumberland,代码行数:101,代码来源:KeyholeMarkupLanguage.cs


注:本文中的Layer.GetStyleForFeature方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。