Ejemplo n.º 1
0
        public static void AddPaths([NotNull] IList <Linestring> linestringsToAdd,
                                    [NotNull] IPolyline toResult)
        {
            Func <Pnt3D, WKSPointZ> createPoint;

            if (GeometryUtils.IsZAware(toResult))
            {
                createPoint = p => WKSPointZUtils.CreatePoint(p.X, p.Y, p.Z);
            }
            else
            {
                createPoint = p => WKSPointZUtils.CreatePoint(p.X, p.Y, double.NaN);
            }

            IPath pathTemplate = GeometryFactory.CreateEmptyPath(toResult);

            foreach (Linestring resultLinestring in linestringsToAdd)
            {
                var pathPoints = new WKSPointZ[resultLinestring.SegmentCount + 1];

                var i = 0;
                foreach (Line3D line3D in resultLinestring)
                {
                    pathPoints[i++] = createPoint(line3D.StartPoint);
                }

                Pnt3D last = resultLinestring[resultLinestring.SegmentCount - 1].EndPoint;
                pathPoints[i] = createPoint(last);

                IPath path = GeometryFactory.Clone(pathTemplate);
                GeometryUtils.AddWKSPointZs((IPointCollection4)path, pathPoints);
                ((IGeometryCollection)toResult).AddGeometry(path);
            }
        }
Ejemplo n.º 2
0
        private IList <WKSPointZ> GetPointDifference(bool symmetric)
        {
            var result = new List <WKSPointZ>();

            if (!GeometryUtils.IsSamePoint((IPoint)_baseGeometry,
                                           (IPoint)_compareGeometry,
                                           _xyTolerance, _zTolerance))
            {
                result.Add(WKSPointZUtils.CreatePoint((IPoint)_baseGeometry));

                if (symmetric)
                {
                    result.Add(WKSPointZUtils.CreatePoint((IPoint)_compareGeometry));
                }
            }

            return(result);
        }
Ejemplo n.º 3
0
        public static void AddPoints(IEnumerable <Pnt3D> points, IMultipoint toResult)
        {
            Func <Pnt3D, WKSPointZ> createPoint;

            if (GeometryUtils.IsZAware(toResult))
            {
                createPoint = p => WKSPointZUtils.CreatePoint(p.X, p.Y, p.Z);
            }
            else
            {
                createPoint =
                    p => WKSPointZUtils.CreatePoint(p.X, p.Y, double.NaN);
            }

            WKSPointZ[] wksPointZs = points.Select(p => createPoint(p)).ToArray();

            GeometryUtils.AddWKSPointZs((IPointCollection4)toResult, wksPointZs);
        }
Ejemplo n.º 4
0
        private static WKSPointZ[] GetWksPoints(IEnumerable <Pnt3D> pnts, int pointCount)
        {
            WKSPointZ[] wksPointArray = GetWksPointArray(pointCount);

            var count = 0;

            foreach (Pnt3D pnt3D in pnts)
            {
                if (count == pointCount)
                {
                    break;
                }

                wksPointArray[count++] =
                    WKSPointZUtils.CreatePoint(pnt3D.X, pnt3D.Y, pnt3D.Z);
            }

            return(wksPointArray);
        }
Ejemplo n.º 5
0
        public void GetPlaneVectors(out WKSPointZ planeVector1, out WKSPointZ planeVector2)
        {
            WKSPointZ normal = GetNormalVector();

            if (TryGetPlaneVectors(normal, WKSPointZUtils.CreatePoint(1, 0, 0),
                                   out planeVector1, out planeVector2))
            {
                return;
            }

            if (TryGetPlaneVectors(normal, WKSPointZUtils.CreatePoint(0, 1, 0),
                                   out planeVector1, out planeVector2))
            {
                return;
            }

            if (TryGetPlaneVectors(normal, WKSPointZUtils.CreatePoint(0, 0, 1),
                                   out planeVector1, out planeVector2))
            {
                return;
            }

            throw new InvalidOperationException("unable to create plane vectors");
        }
Ejemplo n.º 6
0
        public WKSPointZ GetPlaneVector()
        {
            WKSPointZ normal = GetNormalVector();

            WKSPointZ planeVector;

            if (TryGetNormal(normal, WKSPointZUtils.CreatePoint(1, 0, 0), out planeVector))
            {
            }
            else if (TryGetNormal(normal, WKSPointZUtils.CreatePoint(0, 1, 0), out planeVector))
            {
            }
            else if (TryGetNormal(normal, WKSPointZUtils.CreatePoint(0, 0, 1), out planeVector))
            {
            }
            else
            {
                throw new InvalidOperationException("unable to create plane vector");
            }

            WKSPointZ normedPlaneVector = WKSPointZUtils.GetNormed(planeVector);

            return(normedPlaneVector);
        }