Example #1
0
        private IEnumerable <IRing> ReadSingleExteriorRingPolygon(
            [NotNull] BinaryReader reader, Ordinates ordinates, bool?reverseOrder = null)
        {
            if (reader == null)
            {
                throw new ArgumentNullException(nameof(reader));
            }

            int ringCount = checked ((int)reader.ReadUInt32());

            bool zAware = ordinates == Ordinates.Xyz || ordinates == Ordinates.Xyzm;
            bool mAware = ordinates == Ordinates.Xym || ordinates == Ordinates.Xyzm;

            // NOTE: Somtimes this takes ca. 250ms (may be when the license is checked?)!
            IRing ringTemplate = GeometryFactory.CreateEmptyRing(zAware, mAware);

            if (ringCount > 0)
            {
                bool reverse         = reverseOrder ?? !AssumeWkbPolygonsClockwise;
                var  geometryBuilder = new WksPointListBuilder(reverse);

                foreach (WKSPointZ[] wksPoints in ReadLinestringsCore(
                             reader, ordinates, ringCount, geometryBuilder))
                {
                    IRing resultRing = GeometryFactory.Clone(ringTemplate);

                    GeometryUtils.SetWKSPointZs(resultRing, wksPoints);

                    yield return(resultRing);
                }
            }
        }
Example #2
0
        private static IPolyline ReadPolyline(BinaryReader reader, WkbGeometryType geometryType,
                                              Ordinates ordinates)
        {
            var geometryBuilder = new WksPointListBuilder();

            IEnumerable <WKSPointZ[]> linestrings =
                ReadLinestrings(reader, geometryType, ordinates, geometryBuilder);

            IEnumerable <IPath> paths =
                ToPaths(linestrings, geometryType, ordinates, geometryBuilder);

            return(CreatePolycurve <IPolyline>(paths, ordinates));
        }
Example #3
0
        private static IEnumerable <IPath> ToPaths(IEnumerable <WKSPointZ[]> wksLinestrings,
                                                   WkbGeometryType geometryType,
                                                   Ordinates ordinates,
                                                   WksPointListBuilder geometryBuilder)
        {
            IPath pathTemplate = CreateEmptyPath(ordinates);

            foreach (WKSPointZ[] wksPoints in wksLinestrings)
            {
                IPath resultPath = geometryType == WkbGeometryType.MultiLineString
                                                           ? GeometryFactory.Clone(pathTemplate)
                                                           : pathTemplate;

                GeometryUtils.SetWKSPointZs(resultPath, wksPoints);

                yield return(resultPath);
            }
        }
Example #4
0
        private static IMultipoint ReadMultipoint([NotNull] BinaryReader reader,
                                                  Ordinates ordinates)
        {
            int pointCount = checked ((int)reader.ReadUInt32());

            var geometryBuilder = new WksPointListBuilder();

            WKSPointZ[] wksZPoints =
                ReadMultipointCore(reader, ordinates, pointCount, geometryBuilder);

            bool zAware = ordinates == Ordinates.Xyz || ordinates == Ordinates.Xyzm;
            bool mAware = ordinates == Ordinates.Xym || ordinates == Ordinates.Xyzm;

            IMultipoint result = GeometryFactory.CreateEmptyMultipoint(zAware, mAware);

            GeometryUtils.SetWKSPointZs(result, wksZPoints);

            return(result);
        }