コード例 #1
0
ファイル: ProfileSession.cs プロジェクト: DemonScarlett/DPP
        public IEnumerable <IPolyline> ConvertLinesToEsriPolypile(ISpatialReference spatialReference, int lineId = -1)
        {
            Func <ProfileLine, IPolyline> converter = (l) =>
            {
                var       surface = ProfileSurfaces.FirstOrDefault(s => l.Id == s.LineId);
                IPolyline result;

                if (DefinitionType == ProfileSettingsTypeEnum.Primitives && surface != null)
                {
                    var vertices = surface.ProfileSurfacePoints.Where(point => point.isVertex).Select(p => new Point {
                        X = p.X, Y = p.Y, Z = p.Z, SpatialReference = EsriTools.Wgs84Spatialreference
                    });
                    result = EsriTools.CreatePolylineFromPointsArray(vertices.ToArray(), spatialReference).First();
                }
                else
                {
                    var pointFrom = new Point {
                        X = l.PointFrom.X, Y = l.PointFrom.Y, SpatialReference = EsriTools.Wgs84Spatialreference
                    };
                    var pointTo = new Point {
                        X = l.PointTo.X, Y = l.PointTo.Y, SpatialReference = EsriTools.Wgs84Spatialreference
                    };

                    pointFrom.Project(spatialReference);
                    pointTo.Project(spatialReference);

                    result = EsriTools.CreatePolylineFromPoints(pointFrom, pointTo);
                }

                if (l.Line == null)
                {
                    l.Line = result;
                }

                return(result);
            };

            if (lineId <= 0 || lineId > ProfileLines.Length)
            {
                return(ProfileLines.Select(l => converter(l)).ToArray());
            }

            return(new IPolyline[] { converter(ProfileLines.First(l => l.Id == lineId)) });
        }