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


C# IFeature类代码示例

本文整理汇总了C#中IFeature的典型用法代码示例。如果您正苦于以下问题:C# IFeature类的具体用法?C# IFeature怎么用?C# IFeature使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IFeature类属于命名空间,在下文中一共展示了IFeature类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetCountryStyle

 /// <summary>
 /// This method is used for determining the color of country based on attributes.
 /// It is used as a delegate for the CustomTheme class.
 /// </summary>
 /// <param name="row"></param>
 /// <returns></returns>
 private VectorStyle GetCountryStyle(IFeature row)
 {
     VectorStyle style = new VectorStyle();
     switch (row.Attributes["NAME"].ToString().ToLower())
     {
         case "denmark": //If country name is Danmark, fill it with green
             style.Fill = Brushes.Green;
             return style;
         case "united states": //If country name is USA, fill it with Blue and add a red outline
             style.Fill = Brushes.Blue;
             style.Outline = Pens.Red;
             return style;
         case "china": //If country name is China, fill it with red
             style.Fill = Brushes.Red;
             return style;
         default:
             break;
     }
     //If country name starts with S make it yellow
     if (row.Attributes["NAME"].ToString().StartsWith("S"))
     {
         style.Fill = Brushes.Yellow;
         return style;
     }
         // If geometry is a (multi)polygon and the area of the polygon is less than 30, make it cyan
     else if (row.Geometry is IMultiPolygon && (row.Geometry as IMultiPolygon).Area < 30 ||
              row.Geometry is IPolygon && (row.Geometry as IPolygon).Area < 30)
     {
         style.Fill = Brushes.Cyan;
         return style;
     }
     else //None of the above -> Use the default style
         return null;
 }
开发者ID:geobabbler,项目名称:SharpMap,代码行数:40,代码来源:Bins.aspx.cs

示例2: GetFeatureAttr

 /// <summary>
 /// 获取选中要素的DataTable
 /// </summary>
 /// <param name="pSelection">IFeature</param>
 /// <returns>DataTable</returns>
 public static DataTable GetFeatureAttr(IFeature pFeature)
 {
     DataTable dt = new DataTable();
     dt.Columns.Add("name", System.Type.GetType("System.String"));  //名称
     dt.Columns.Add("value", System.Type.GetType("System.String"));  //值
     try
     {
         if (pFeature == null)
         {
             return dt;
         }
         ITable table = pFeature.Table;
         IFields fields = table.Fields;
         for (int i = 0; i < fields.FieldCount; i++)
         {
             //获取数据
             IField field = fields.get_Field(i);
             string aliasName = field.AliasName;
             //string name = GISConfig.ConvertFieldName(aliasName);
             if (aliasName != "XZQMC")
             {
                 continue;
             }
             string value = Convert.ToString(pFeature.get_Value(i));
             //写入数据
             DataRow dr = dt.NewRow();
             dr["name"] = aliasName;
             dr["value"] = value;
             dt.Rows.Add(dr);
         }
     }
     catch { }
     return dt;
 }
开发者ID:BNU-Chen,项目名称:CityPlanningGallery,代码行数:39,代码来源:clsGISHandler.cs

示例3: Draw

        public static void Draw(Canvas canvas, IViewport viewport, IStyle style, IFeature feature)
        {
            try
            {
                if (!feature.RenderedGeometry.ContainsKey(style)) feature.RenderedGeometry[style] = ToAndroidBitmap(feature.Geometry);
                var bitmap = (AndroidGraphics.Bitmap)feature.RenderedGeometry[style];
                
                var dest = WorldToScreen(viewport, feature.Geometry.GetBoundingBox());
                dest = new BoundingBox(
                    dest.MinX,
                    dest.MinY,
                    dest.MaxX,
                    dest.MaxY);

                var destination = RoundToPixel(dest);
                using (var paint = new Paint())
                {
                    canvas.DrawBitmap(bitmap, new Rect(0, 0, bitmap.Width, bitmap.Height), destination, paint);
                }

                DrawOutline(canvas, style, destination);
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }

        }
开发者ID:jdeksup,项目名称:Mapsui.Net4,代码行数:28,代码来源:RasterRenderer.cs

示例4: GetHeader

 /// <summary>
 /// Gets the stub header.
 /// </summary>
 /// <param name="feature">The feature.</param>
 /// <param name="count">The count.</param>
 /// <returns></returns>
 public static DbaseFileHeader GetHeader(IFeature feature, int count)
 {
     IAttributesTable attribs = feature.Attributes;
     string[] names = attribs.GetNames();
     DbaseFileHeader header = new DbaseFileHeader();
     header.NumRecords = count;
     foreach (string name in names)
     {
         Type type = attribs.GetType(name);
         if (type == typeof(double) || type == typeof(float))
             header.AddColumn(name, 'N', DoubleLength, DoubleDecimals);
         else if (type == typeof(short) || type == typeof(ushort) ||
                  type == typeof(int) || type == typeof(uint) ||
                  type == typeof(long) || type == typeof(ulong))
             header.AddColumn(name, 'N', IntLength, IntDecimals);
         else if (type == typeof(string))
             header.AddColumn(name, 'C', StringLength, StringDecimals);
         else if (type == typeof(bool))
             header.AddColumn(name, 'L', BoolLength, BoolDecimals);
         else if (type == typeof(DateTime))
             header.AddColumn(name, 'D', DateLength, DateDecimals);
         else throw new ArgumentException("Type " + type.Name + " not supported");
     }
     return header;
 }
开发者ID:barentswatch,项目名称:NetTopologySuite,代码行数:31,代码来源:ShapefileDataWriter.cs

示例5: CreateInteractor

        public virtual IFeatureInteractor CreateInteractor(ILayer layer, IFeature feature)
        {
            if (null == feature)
                return null;

            var vectorLayer = layer as VectorLayer;
            var vectorStyle = (vectorLayer != null ? vectorLayer.Style : null);

            // most specific type should be first
            if (feature is RegularGridCoverageCell)
                return new LineStringInteractor(layer, feature, vectorStyle, null);

            if (feature is IGridFace || feature is IGridVertex)
                return new LineStringInteractor(layer, feature, vectorStyle, null);
            
            if (feature.Geometry is ILineString)
                return new LineStringInteractor(layer, feature, vectorStyle, null);
            
            if (feature.Geometry is IPoint)
                return new PointInteractor(layer, feature, vectorStyle, null);
            
            // todo implement custom mutator for Polygon and MultiPolygon
            // LineStringMutator will work as long as moving is not supported.
            if (feature.Geometry is IPolygon)
                return new LineStringInteractor(layer, feature, vectorStyle, null);
            
            if (feature.Geometry is IMultiPolygon)
                return new LineStringInteractor(layer, feature, vectorStyle, null);
            
            return null;
            //throw new ArgumentException("Unsupported type " + feature.Geometry);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:32,代码来源:FeatureEditor.cs

示例6: GetStyle

		public IStyle GetStyle(IFeature row)
		{
			IStyle style = StyleDelegate(row);
			if (style != null)
				return style;
		    return DefaultStyle;
		}
开发者ID:HackatonArGP,项目名称:Guardianes,代码行数:7,代码来源:CustomTheme.cs

示例7: Draw

        public static void Draw(IViewport viewport, IStyle style, IFeature feature)
        {
            var lineString = ((LineString)feature.Geometry).Vertices;

            float lineWidth = 1;
            var lineColor = Color.White;

            var vectorStyle = style as VectorStyle;

            if (vectorStyle != null)
            {
                lineWidth = (float)vectorStyle.Line.Width;
                lineColor = vectorStyle.Line.Color;
            }

            float[] points = ToOpenTK(lineString);
            WorldToScreen(viewport, points);

            GL.LineWidth(lineWidth);
            GL.Color4((byte)lineColor.R, (byte)lineColor.G, (byte)lineColor.B, (byte)lineColor.A);
            GL.EnableClientState(All.VertexArray);
            GL.VertexPointer(2, All.Float, 0, points);
            GL.DrawArrays(All.Lines, 0, points.Length / 2);
            GL.DisableClientState(All.VertexArray);
        }
开发者ID:jdeksup,项目名称:Mapsui.Net4,代码行数:25,代码来源:LineStringRenderer.cs

示例8: IsEnabledCallsAllToggles

        public void IsEnabledCallsAllToggles([Frozen] IFeatureToggleProvider toggleProvider, IFeature feature,
            Fixture fixture, FeatureContext sut)
        {
            var featureToggles = fixture.CreateMany<Fake<IFeatureToggle>>().ToList();
            foreach (Fake<IFeatureToggle> fake in featureToggles)
            {
                fake.CallsTo(ft => ft.IsEnabled(feature))
                    .Returns(null);
            }
            var finalTogle = A.Fake<Fake<IFeatureToggle>>();
            finalTogle.CallsTo(ft => ft.IsEnabled(feature))
                .Returns(true);
            featureToggles.Add(finalTogle);

            A.CallTo(() => toggleProvider.GetFeatureToggles())
                .Returns(featureToggles.Select(f => f.FakedObject));

            sut.IsEnabled(feature);

            foreach (Fake<IFeatureToggle> fake in featureToggles)
            {
                fake.CallsTo(ft => ft.IsEnabled(feature))
                    .MustHaveHappened();
            }
        }
开发者ID:johnduhart,项目名称:toggled,代码行数:25,代码来源:FeatureContextTests.cs

示例9: Render

        public override bool Render(IFeature feature, Graphics g, ILayer layer)
        {
            var segmentsLayer = (NetworkCoverageSegmentLayer) layer;
            var coverage = ((NetworkCoverageFeatureCollection)layer.DataSource).RenderedCoverage;
            IEnvelope mapExtents = layer.Map.Envelope;
            
            var sliceValues = coverage.GetValues();

            // 1 find the segments withing the current extend
            var segments = coverage.Segments.Values;//.Where(seg => seg.Geometry.EnvelopeInternal.Intersects(mapExtents)).ToList();

            for (int i = 0; i < segments.Count; i++)
            {
                INetworkSegment segment = segments[i];
                if (segment.Geometry.EnvelopeInternal.Intersects(mapExtents) && sliceValues.Count > 0)
                {
                    // 2 get the values for this segment
                    // if SegmentGenerationMethod == SegmentGenerationMethod.RouteBetweenLocations the segments and 
                    // location do not have to match; return default value
                    double value = coverage.SegmentGenerationMethod == SegmentGenerationMethod.RouteBetweenLocations
                                       ? 0
                                       : (double) sliceValues[i];

                    // 3 use the Theme of the layer to draw 
                    var style = (VectorStyle)segmentsLayer.Theme.GetStyle(value);
                    VectorRenderingHelper.RenderGeometry(g, layer.Map, segment.Geometry, style, null, true);
                }
            }
            return true;
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:30,代码来源:NetworkCoverageSegmentRenderer.cs

示例10: Draw

        // todo:
        // try to remove the feature argument. LabelStyle should already contain the feature specific text
        // The visible feature iterator should create this LabelStyle
        public static void Draw(SKCanvas canvas, IViewport viewport, IStyle style, IFeature feature, 
            IGeometry geometry, IDictionary<int, SKBitmapInfo> symbolBitmapCache)
        {
            var point = geometry as Point;
            var destination = viewport.WorldToScreen(point);

            if (style is LabelStyle)              // case 1) LabelStyle
            {
                LabelRenderer.Draw(canvas, (LabelStyle) style, feature, (float) destination.X, (float) destination.Y);
            }
            else if (style is SymbolStyle)
            {
                var symbolStyle = (SymbolStyle)style;

                if ( symbolStyle.BitmapId >= 0)   // case 2) Bitmap Style
                {
                    DrawPointWithBitmapStyle(canvas, symbolStyle, destination, symbolBitmapCache);
                }
                else                              // case 3) SymbolStyle without bitmap
                {
                    DrawPointWithSymbolStyle(canvas, symbolStyle, destination, symbolStyle.SymbolType);
                }
            }
            else if (style is VectorStyle)        // case 4) VectorStyle
            {
                DrawPointWithVectorStyle(canvas, (VectorStyle) style, destination);
            }
            else
            {
                throw new Exception($"Style of type '{style.GetType()}' is not supported for points");
            }
        }
开发者ID:pauldendulk,项目名称:Mapsui,代码行数:35,代码来源:PointRenderer.cs

示例11: Corridor

 public Corridor(Position startingPosition, Direction direction, int maxLenght, IFeature spawningFeature)
 {
     Trail = new List<Floor>();
     ConnectedFeatureA = spawningFeature;
     Direction = direction;
     InitTrail(startingPosition, maxLenght);
 }
开发者ID:Ramzawulf,项目名称:DungeonGenerator,代码行数:7,代码来源:Corridor.cs

示例12: CreateBalloonCalloutForFeature

 /// <summary>
 /// Creates a Balloon Callout with the value from the given field name for the given feature.
 /// </summary>
 /// <param name="displayFieldName">The name of the field.</param>
 /// <param name="feature">The feature for which to create the callout.</param>
 /// <returns>Returns an element with a callout symbol.</returns>
 public static IElement CreateBalloonCalloutForFeature(string displayFieldName, IFeature feature)
 {
     string methodName = MethodBase.GetCurrentMethod().Name;
         object o = DatabaseUtil.GetFieldValue(feature, displayFieldName, true);
         string val = o != null ? o.ToString() : string.Empty;
         return CreateBalloonCalloutForFeature(feature, val);
 }
开发者ID:Ramakrishnapv,项目名称:FuturaNetwork,代码行数:13,代码来源:Cartography.cs

示例13: Draw

        public static void Draw(SKCanvas canvas, IViewport viewport, IStyle style, IFeature feature,
            IDictionary<object, SKBitmapInfo> skBitmapCache, long currentIteration)
        {
            try
            {
                var raster = (IRaster)feature.Geometry;

                SKBitmapInfo textureInfo;

                if (!skBitmapCache.Keys.Contains(raster))
                {
                    textureInfo = BitmapHelper.LoadTexture(raster.Data);
                    skBitmapCache[raster] = textureInfo;
                }
                else
                {
                    textureInfo = skBitmapCache[raster];
                }

                textureInfo.IterationUsed = currentIteration;
                skBitmapCache[raster] = textureInfo;
                var destination = WorldToScreen(viewport, feature.Geometry.GetBoundingBox());
                BitmapHelper.RenderRaster(canvas, textureInfo.Bitmap, RoundToPixel(destination).ToSkia());
            }
            catch (Exception ex)
            {
                Logger.Log(LogLevel.Error, ex.Message, ex);
            }
        }
开发者ID:pauldendulk,项目名称:Mapsui,代码行数:29,代码来源:RasterRenderer.cs

示例14: Contains

 public virtual bool Contains(IFeature feature)
 {
     if (Features.Count == 0)
     {
         return false;
     }
     // Since Features can be strongly collection typed we must prevent searching objects of an invalid type
     if (FeatureType != null)
     {
         // test if feature we are looking for is derived from FeatureType
         if (!FeatureType.IsAssignableFrom(feature.GetType()))
         {
             return false;
         }
     }
     else
     {
         // if FeatureType is not set use type of first object in collection.
         if (Features[0].GetType() != feature.GetType())
         {
             return false;
         }
     }
     return Features.Contains(feature);
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:25,代码来源:FeatureCollection.cs

示例15: RenderGeometry

        public void RenderGeometry(MultiPolygon multiPolygon, IStyle style, IFeature feature, IViewport viewport)
        {
            if (_bgWorker == null)
                _bgWorker = new BackgroundWorker();
            /*
            while (_bgWorker.IsBusy) {
                Thread.Sleep (00001);
            }
            */
            _bgWorker.RunWorkerCompleted += (sender, e) =>
                {
                    var layer = e.Result as CALayer;

                    if (layer != null)
                    {
                        var styleKey = style.GetHashCode().ToString();
                        feature[styleKey] = layer;
                    }
                };

            _bgWorker.DoWork += delegate(object sender, DoWorkEventArgs e)
                {
                    var layer = RenderImage(multiPolygon, style, viewport);
                    e.Result = layer;
                };

            _bgWorker.RunWorkerAsync();
        }
开发者ID:jdeksup,项目名称:Mapsui.Net4,代码行数:28,代码来源:ContextRenderer.cs


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