Exemple #1
0
        public void Equality()
        {
            var simpleFeatureA = new SimpleFeature(10.0);
            var simpleFeatureB = new SimpleFeature(20.0);

            // two FeatureLocation with same feature and offset should be equal ( valuetype)
            Assert.AreEqual(new FeatureLocation {
                Feature = simpleFeatureA
            }, new FeatureLocation {
                Feature = simpleFeatureA
            });
            Assert.AreNotEqual(new FeatureLocation {
                Feature = simpleFeatureA
            }, new FeatureLocation {
                Feature = simpleFeatureB
            });
        }
Exemple #2
0
        public void SetGetText()
        {
            var map = new Map(new Size(100, 100));

            var feature1 = new SimpleFeature {
                Data = 1, Geometry = new Point(50, 50)
            };
            var feature2 = new SimpleFeature {
                Data = 5, Geometry = new Point(50, 55)
            };
            var featureCollection = new FeatureCollection {
                Features = { feature1, feature2 }
            };

            var callCount = 0;

            var vectorLayer = new VectorLayer {
                DataSource = featureCollection
            };

            var labelLayer = new LabelLayer
            {
                Visible             = true,
                DataSource          = featureCollection,
                Parent              = vectorLayer,
                Map                 = map,
                LabelStringDelegate = delegate(IFeature feature)
                {
                    callCount++;

                    feature
                    .Should().Be.OfType <SimpleFeature>();

                    return(((SimpleFeature)feature).Data.ToString());
                }
            };

            labelLayer.Render();

            callCount
            .Should("labels of 2 simple feature rendered").Be.EqualTo(2);
        }
Exemple #3
0
        /// <summary>
        /// 创建点图元素
        /// </summary>
        /// <param name="layer">图层</param>
        /// <param name="xyz">坐标</param>
        /// <param name="name">名称</param>
        /// <returns></returns>
        private static SimpleFeature CreatePtFeature(Layer layer, XYZ xyz, string name)
        {
            AnyInfo.Geometries.Point p = new AnyInfo.Geometries.Point(CoordTransformer.XyzToGeoCoord(xyz));
            p.Name = name;
            p.Id   = name + new Random().Next(10000);

            SimpleFeatureBuilder b = new SimpleFeatureBuilder(layer.FeatureSource.FeatureCollection.Schema);

            b.SetGeometry(p);
            b.SetName(p.Name);
            b.SetFeatureId(p.Id);
            b.SetStyle(new AnyInfo.Styles.PointStyle()
            {
                Color = System.Drawing.Color.Red, Diameter = 12
            });
            SimpleFeature sf = b.Build();

            layer.FeatureSource.FeatureCollection.Add(sf);
            layer.Extent.Expands(sf.Envelope);
            return(sf);
        }
Exemple #4
0
        public void TestAsArgument()
        {
            IVariable <IFeatureLocation> a  = new Variable <IFeatureLocation>("argument");
            IVariable <double>           c1 = new Variable <double>("value");
            IVariable <string>           c2 = new Variable <string>("description");

            // f = (a, p)(h)
            IFunction f = new Function("rating curve");

            f.Arguments.Add(a);
            f.Components.Add(c1);
            f.Components.Add(c2);

            SimpleFeature    simpleFeature   = new SimpleFeature(10.0);
            IFeatureLocation featureLocation = new FeatureLocation {
                Feature = simpleFeature
            };

            // value based argument referencing.
            f[featureLocation] = new object[] { 1.0, "jemig de pemig" };

            IMultiDimensionalArray <double> c1Value = f.GetValues <double>(new ComponentFilter(f.Components[0]),
                                                                           new VariableValueFilter <IFeatureLocation>(
                                                                               f.Arguments[0],
                                                                               new FeatureLocation
            {
                Feature = simpleFeature
            }));

            Assert.AreEqual(1.0, c1Value[0], 1.0e-6);

            //IMultiDimensionalArray<string> c2Value = f.GetValues<string>(new ComponentFilter(f.Components[1]),
            //                                                             new VariableValueFilter<IFeatureLocation>(
            //                                                                 f.Arguments[0], featureLocation));

            //Assert.AreEqual("jemig de pemig", c2Value[0]);
        }
Exemple #5
0
        /// <summary>
        /// 建立图层
        /// </summary>
        /// <returns></returns>
        public Layer Build()
        {
            List <LineString> lines = new List <LineString>();
            var peroid       = SatPeriodInfoManager.TimePeriod;
            var spanSec      = peroid.Span;
            var spanIn180Deg = spanSec / 180.0;
            var startTime    = peroid.Start;
            var endTime      = peroid.End;

            double lat = -60;
            double lon = 0;

            int i = 0;

            foreach (var sat in SatPeriodInfoManager.Data)
            {
                foreach (var p in sat.Value)
                {
                    var pts  = new List <AnyInfo.Geometries.Point>();
                    var from = (p.Start - startTime) / spanIn180Deg;
                    var to   = (p.End - startTime) / spanIn180Deg;

                    var ptFrom = new AnyInfo.Geometries.Point(from, lat, i + "_from", sat.Key + "");
                    var ptTo   = new AnyInfo.Geometries.Point(to, lat, i + "_to", sat.Key + "");
                    pts.Add(ptFrom);
                    pts.Add(ptTo);

                    var line = new LineString(pts, sat.Key + "_" + p.ToTimeString());

                    lines.Add(line);
                }

                lat = lat + 1;//纬度每次递增
                i++;
            }

            // Layer layer = LayerFactory.CreateLineLayer(lines);

            //foreach (var path in dicData)
            //    CreatePtFeature(layer, path.Value, path.Key);


            //Create SimpleFeatureType
            SimpleFeatureType featureType = SimpleFeatureTypeFactory.GetDefaultLineStringFeatureType();

            //Create Geometry
            Dictionary <string, SimpleFeature> featureDic = new Dictionary <string, SimpleFeature>();


            IEnvelope envelope = null;
            Color     color    = Color.AliceBlue;
            int       j        = 0;

            foreach (LineString lineString in lines)
            {
                var style = new LineStyle();
                style.Width = 5;
                style.Color = GetColor(j++, lines.Count);

                // AnyInfo.Geometries.Point point = new AnyInfo.Geometries.Point(lonLat.Lon, lonLat.Lat);
                SimpleFeature feature = LayerFactory.CreateLineStringFeature(featureType, lineString, style);
                featureDic.Add(feature.Id, feature);

                if (envelope == null)
                {
                    envelope = lineString.Box;
                }
                else
                {
                    envelope = envelope.Expands(lineString.Box);
                }
            }

            //Create Feature Collection
            FeatureCollection <SimpleFeatureType, SimpleFeature> featureCollection =
                new FeatureCollection <SimpleFeatureType, SimpleFeature>(featureType, featureDic);

            Layer layer = new Layer("时段绘图", featureCollection, envelope);

            return(layer);


            //layer.FeatureSource.BuildIndexing();
            //layer.UseLayerStyle = false;
            //return (layer);
        }