Пример #1
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);
        }