Example #1
0
        private void AddDataSource(IDataSource2D <double> field, Guid guid)
        {
            List <PolylineGeometry> geometry = new List <PolylineGeometry>();
            List <VisualPushpin>    labels   = new List <VisualPushpin>();

            isolineBuilder.DataSource = field;
            IsolineCollection collection = isolineBuilder.Build();

            annotater.WayBeforeText = 20.0;

            foreach (LevelLine segment in collection.Lines)
            {
                List <Coordinate2D> points = new List <Coordinate2D>();
                points.Add(new Coordinate2D(segment.StartPoint.X, segment.StartPoint.Y));
                foreach (Point point in segment.OtherPoints)
                {
                    points.Add(new Coordinate2D(point.X, point.Y));
                }
                PolyInfo style = PolyInfo.DefaultPolyline;
                Color    color = palette.GetColor(segment.Value01);
                style.LineColor = System.Drawing.Color.FromArgb(color.A, color.R, color.G, color.B);

                geometry.Add(new PolylineGeometry(guid.ToString(), Guid.NewGuid().ToString(), new Polyline2(Wgs84CoordinateReferenceSystem.Instance,
                                                                                                            Coordinate2DCollection.CreateUnsafe(points.ToArray())), style));
            }

            foreach (IsolineTextLabel label in annotater.Annotate(collection, new Rect()))
            {
                labels.Add(new VisualPushpin(30, 30, label.Text, LatLonAlt.CreateUsingDegrees(label.Position.Y, label.Position.X, 0), this, Guid.NewGuid().ToString()));
            }

            layers.Add(new IsolinesLayer()
            {
                Geometry = geometry, IsVisible = true, Guid = guid, Labels = labels
            });
            AddLayerToHost(layers[layers.Count - 1]);
        }
Example #2
0
        private void AddDataSource(PointSet pointSet, Guid guid)
        {
            List <Coordinate2D> points = new List <Coordinate2D>();

            foreach (PointSetElement point in pointSet.Data)
            {
                points.Add(new Coordinate2D(point.Longitude, point.Latitude));
            }
            PolyInfo style = PolyInfo.DefaultPolyline;

            style.LineColor = Color.Red;
            style.LineWidth = 0.5;

            string layerId      = Guid.NewGuid().ToString();
            string geometryId   = Guid.NewGuid().ToString();
            string dataSourceId = Guid.NewGuid().ToString();



            trajectoriesLayers.Add(new TrajectoriesLayer
            {
                DataSource   = new TrajectoriesDataSource(host, pointSet),
                Guid         = guid,
                GeometryID   = geometryId,
                LayerID      = layerId,
                DataSourceID = dataSourceId,
                IsVisible    = true,
                Geometry     = new PolylineGeometry(layerId, geometryId, new Polyline2(Wgs84CoordinateReferenceSystem.Instance,
                                                                                       Coordinate2DCollection.CreateUnsafe(points.ToArray())), style)
            });
            AddLayerToHost(trajectoriesLayers[trajectoriesLayers.Count - 1]);
        }