private MultiLineString ReadMultiLineString()
        {
            int nPolylines = m_objReader.ReadInt32();

            if (nPolylines <= 0)
            {
                return(null);
            }

            LineString[] lines = new LineString[nPolylines];
            for (int i = 0; i < nPolylines; i++)
            {
                BytesOrder byteOrder = (BytesOrder)m_objReader.ReadByte();  // handle the byte order
                m_objReader.Order = byteOrder;

                int geomType = m_objReader.ReadInt32();
                if (geomType != 2)
                {
                    throw new GeometryIOException("The data is badly formed. "
                                                  + "A LineString geometry is expected");
                }

                lines[i] = ReadLineString();
            }

            return(m_objFactory.CreateMultiLineString(lines));
        }
        public void test_IsSimple()
        {
            //create a geomerty collection
            MultiLineString multiLS = CreateMLS();

            Assertion.AssertEquals("IsSimple-1: ", false, multiLS.IsSimple());

            //now try it with a null geometry collection
            GeometryFactory gf = new GeometryFactory(_precMod, _sRID);

            multiLS = gf.CreateMultiLineString(null);

            Assertion.AssertEquals("IsSimple-2: ", true, multiLS.IsSimple());

            //now try it with a different geometry collection
            multiLS = CreateMLS1();

            //TODO: This is really slow!!!!!!!!!  Why?
            //Assertion.AssertEquals("IsSimple-3: ", false, multiLS.IsSimple());

            //now try it with a mixed geometry collection
            multiLS = nonSimpleMLS();

            Assertion.AssertEquals("IsSimple-4: ", false, multiLS.IsSimple());

            //now try it with a closed geometry collection
            multiLS = closedMLS();

            //TODO: Uncomment when IsSimple is working.
            Assertion.AssertEquals("IsSimple-5: ", true, multiLS.IsSimple());
        }
        public void test_Geometry()
        {
            LineString[] linestrings = new LineString[2];
            Coordinates  coords1     = new Coordinates();
            Coordinate   coord       = new Coordinate(5, 3);

            coords1.Add(coord);
            coord = new Coordinate(4, 5);
            coords1.Add(coord);
            coord = new Coordinate(3, 4);
            coords1.Add(coord);

            GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
            LineString      ls = gf.CreateLineString(coords1);

            linestrings[0] = ls;

            Coordinates coords2 = new Coordinates();

            coord = new Coordinate(2, 7);
            coords2.Add(coord);
            coord = new Coordinate(9, 2);
            coords2.Add(coord);
            coord = new Coordinate(7, 9);
            coords2.Add(coord);

            ls             = gf.CreateLineString(coords2);
            linestrings[1] = ls;

            MultiLineString mls = gf.CreateMultiLineString(linestrings);

            Assertion.AssertEquals("Geometry-1: ", "LineString:(5, 3, NaN),(4, 5, NaN),(3, 4, NaN)", mls.GetGeometryN(0).ToString());
            Assertion.AssertEquals("Geometry-2: ", "LineString:(2, 7, NaN),(9, 2, NaN),(7, 9, NaN)", mls.GetGeometryN(1).ToString());
        }
        private MultiLineString CreateMLS()
        {
            Coordinates     coords     = new Coordinates();
            Coordinate      coord      = new Coordinate();
            GeometryFactory gf         = new GeometryFactory(_precMod, _sRID);
            LineString      lineString = gf.CreateLineString(coords);

            LineString[] ls = new LineString[10];
            for (int i = 0; i < 10; i++)
            {
                coords = new Coordinates();
                for (int j = i; j < i + 10; j++)
                {
                    coord   = new Coordinate();
                    coord.X = (double)j;
                    coord.Y = (double)j + 5;
                    coords.Add(coord);
                }
                lineString = gf.CreateLineString(coords);
                ls[i]      = lineString;
            }
            MultiLineString multiLS = gf.CreateMultiLineString(ls);

            return(multiLS);
        }
Beispiel #5
0
        private Feature ConvertRelation(CompleteRelation relation)
        {
            if (IsMultipolygon(relation))
            {
                return(ConvertToMultipolygon(relation));
            }

            var nodes = relation.Members.Select(m => m.Member).OfType <Node>().ToList();

            if (nodes.Any())
            {
                var multiPoint = _geometryFactory.CreateMultiPoint(nodes.Select(n => _geometryFactory.CreatePoint(ConvertNode(n))).ToArray());
                return(new Feature(multiPoint, ConvertTags(relation)));
            }

            var geometries = GetGeometriesFromWays(GetAllWays(relation));

            if (!geometries.Any())
            {
                return(null);
            }
            var jointLines = geometries.OfType <LineString>().ToList();

            jointLines.AddRange(geometries.OfType <Polygon>().Select(p => _geometryFactory.CreateLineString(p.ExteriorRing.Coordinates.ToArray()) as LineString));
            var multiLineString = _geometryFactory.CreateMultiLineString(jointLines.ToArray());

            return(new Feature(multiLineString, ConvertTags(relation)));
        }
Beispiel #6
0
 public static IReadOnlyList <MultiLineStringEntity> CreateMultiLineStringEntities(GeometryFactory factory)
 => new[]
 {
     new MultiLineStringEntity
     {
         Id = 1,
         MultiLineString = factory.CreateMultiLineString(
             new[]
         {
             factory.CreateLineString(
                 new[]
             {
                 new Coordinate(0, 0),
                 new Coordinate(0, 1)
             }),
             factory.CreateLineString(
                 new[]
             {
                 new Coordinate(1, 0),
                 new Coordinate(1, 1)
             })
         })
     },
     new MultiLineStringEntity
     {
         Id = 2,
         MultiLineString = null
     }
 };
Beispiel #7
0
        public override MultiLineString CreateGeometry(
            object?coordinates,
            int?crs)
        {
            if (!(coordinates is Coordinate[][] parts))
            {
                throw Serializer_Parse_CoordinatesIsInvalid();
            }

            var lineCount  = parts.Length;
            var geometries = new LineString[lineCount];

            for (var i = 0; i < lineCount; i++)
            {
                geometries[i] = GeoJsonLineStringSerializer.Default
                                .CreateGeometry(parts[i], crs);
            }

            if (crs is not null)
            {
                GeometryFactory factory =
                    NtsGeometryServices.Instance.CreateGeometryFactory(crs.Value);

                return(factory.CreateMultiLineString(geometries));
            }

            return(new MultiLineString(geometries));
        }
        /// <summary>
        /// Writes to the given stream the equilivent shape file record given a Geometry object.
        /// </summary>
        /// <param name="geometry">The geometry object to write.</param>
        /// <param name="writer">The stream to write to.</param>
        /// <param name="factory">The geometry factory to use.</param>
        public override void Write(Geometry geometry, BinaryWriter writer, GeometryFactory factory)
        {
            if (geometry == null)
            {
                throw new ArgumentNullException("geometry");
            }

            var multi = geometry as MultiLineString;

            if (multi == null)
            {
                var ls = geometry as LineString;
                if (ls == null)
                {
                    string err = string.Format("Expected geometry that implements 'MultiLineString' or 'LineString', but was '{0}'",
                                               geometry.GetType().Name);
                    throw new ArgumentException(err, "geometry");
                }

                var arr = new[] { ls };
                multi = factory.CreateMultiLineString(arr);
            }

            writer.Write((int)ShapeType);

            var box = multi.EnvelopeInternal;

            writer.Write(box.MinX);
            writer.Write(box.MinY);
            writer.Write(box.MaxX);
            writer.Write(box.MaxY);

            int numParts  = multi.NumGeometries;
            int numPoints = multi.NumPoints;

            writer.Write(numParts);
            writer.Write(numPoints);

            // Write the offsets
            int offset = 0;

            for (int i = 0; i < numParts; i++)
            {
                var g = multi.GetGeometryN(i);
                writer.Write(offset);
                offset = offset + g.NumPoints;
            }

            var zList = HasZValue() ? new List <double>() : null;
            var mList = HasMValue() ? new List <double>() : null;

            for (int part = 0; part < numParts; part++)
            {
                var geometryN = (LineString)multi.GetGeometryN(part);
                var points    = geometryN.CoordinateSequence;
                WriteCoords(points, writer, zList, mList);
            }

            WriteZM(writer, numPoints, zList, mList);
        }
        /// <summary>
        /// Reads a <see cref="MultiLineString"/> from the input stream.
        /// </summary>
        /// <param name="reader">The binary reader.</param>
        /// <param name="factory">The geometry factory to use for geometry creation.</param>
        /// <returns>The MultiLineString</returns>
        protected MultiLineString ReadMultiLineString(BinaryReader reader, GeometryFactory factory)
        {
            int numGeometries = reader.ReadInt32();
            var strings       = new LineString[numGeometries];

            ReadGeometryArray(reader, strings);
            return(factory.CreateMultiLineString(strings));
        }
Beispiel #10
0
        static IMultiLineString ParseFlatbufMultiLineStringSinglePart(double[] coords, byte dimensions)
        {
            var sequenceFactory = new PackedCoordinateSequenceFactory();
            var factory         = new GeometryFactory(sequenceFactory);
            var lineString      = factory.CreateLineString(sequenceFactory.Create(coords, dimensions));

            return(factory.CreateMultiLineString(new [] { lineString }));
        }
        /// <summary>
        /// Creates a MultiLineString.
        /// </summary>
        /// <returns></returns>
        private Geometry CreateMultiLineString(CoordinateSequence[] sequences)
        {
            var ls = new LineString[sequences.Length];

            for (int i = 0; i < sequences.Length; i++)
            {
                ls[i] = _factory.CreateLineString(sequences[i]);
            }
            return(_factory.CreateMultiLineString(ls));
        }
Beispiel #12
0
        /// <summary>
        /// Transforms a <see cref="GisSharpBlog.NetTopologySuite.Geometries.MultiLineString"/>.
        /// </summary>
        /// <param name="lines">MultiLineString to transform</param>
        /// <param name="transform">MathTransform</param>
        /// <returns>Transformed MultiLineString</returns>
        public static IMultiLineString TransformMultiLineString(IMultiLineString lines, IMathTransform transform)
        {
            List <ILineString> strings = new List <ILineString>(lines.Geometries.Length);

            foreach (ILineString ls in lines.Geometries)
            {
                strings.Add(TransformLineString(ls, transform));
            }
            return(GeometryFactory.CreateMultiLineString(strings.ToArray()));
        }
Beispiel #13
0
        private static IMultiLineString SqlGeometryToGeometryMultiLineString(SqlGeometry geometry, GeometryFactory factory)
        {
            ILineString[] lineStrings = new ILineString[geometry.STNumGeometries().Value];
            for (int i = 1; i <= lineStrings.Length; i++)
            {
                lineStrings[i - 1] = SqlGeometryToGeometryLineString(geometry.STGeometryN(i), factory);
            }

            return(factory.CreateMultiLineString(lineStrings));
        }
Beispiel #14
0
        /// <summary>
        /// Reads a stream and converts the shapefile record to an equilivent geometry object.
        /// </summary>
        /// <param name="file">The stream to read.</param>
        /// <param name="geometryFactory">The geometry factory to use when making the object.</param>
        /// <returns>The Geometry object that represents the shape file record.</returns>
        public override Geometry Read(BigEndianBinaryReader file, GeometryFactory geometryFactory)
        {
            int       shapeTypeNum = file.ReadInt32();
            ShapeType shapeType    = (ShapeType)Enum.Parse(typeof(ShapeType), shapeTypeNum.ToString());

            if (shapeType != ShapeType.Arc)
            {
                throw new ShapefileException("Attempting to load a non-arc as arc.");
            }
            //read and for now ignore bounds.
            double[] box = new double[4];
            for (int i = 0; i < 4; i++)
            {
                double d = file.ReadDouble();
                box[i] = d;
            }



            int numParts  = file.ReadInt32();
            int numPoints = file.ReadInt32();

            int[] partOffsets = new int[numParts];
            for (int i = 0; i < numParts; i++)
            {
                partOffsets[i] = file.ReadInt32();
            }

            LineString[] lines = new LineString[numParts];
            int          start, finish, length;

            for (int part = 0; part < numParts; part++)
            {
                start = partOffsets[part];
                if (part == numParts - 1)
                {
                    finish = numPoints;
                }
                else
                {
                    finish = partOffsets[part + 1];
                }
                length = finish - start;
                Coordinates points = new Coordinates();
                points.Capacity = length;
                Coordinate external;
                for (int i = 0; i < length; i++)
                {
                    external = new Coordinate(file.ReadDouble(), file.ReadDouble());
                    points.Add(geometryFactory.PrecisionModel.ToInternal(external));
                }
                lines[part] = geometryFactory.CreateLineString(points);
            }
            return(geometryFactory.CreateMultiLineString(lines));
        }
        /// <summary>
        /// Creates a <see cref="MultiLineString"/> using the next token in the stream.
        /// </summary>
        /// <param name="tokenizer">tokenizer over a stream of text in Well-known Text format. The next tokens must form a MultiLineString Text</param>
        /// <param name="factory">The factory to create the result geometry</param>
        /// <returns>a <see cref="MultiLineString"/> specified by the next token in the stream</returns>
        private static MultiLineString ReadMultiLineStringText(WktStreamTokenizer tokenizer, GeometryFactory factory)
        {
            string nextToken = GetNextEmptyOrOpener(tokenizer);

            if (nextToken == "EMPTY")
            {
                return(factory.CreateMultiLineString(null));
            }

            var lineStrings = new List <LineString>();

            lineStrings.Add(ReadLineStringText(tokenizer, factory));
            nextToken = GetNextCloserOrComma(tokenizer);
            while (nextToken == ",")
            {
                lineStrings.Add(ReadLineStringText(tokenizer, factory));
                nextToken = GetNextCloserOrComma(tokenizer);
            }
            return(factory.CreateMultiLineString(lineStrings.ToArray()));
        }
Beispiel #16
0
        /// <summary>
        /// Transforms a <see cref="NetTopologySuite.Geometries.MultiLineString"/>.
        /// </summary>
        /// <param name="lines">MultiLineString to transform</param>
        /// <param name="transform">MathTransform</param>
        /// <param name="targetFactory">The factory to create the target geometry</param>
        /// <returns>Transformed MultiLineString</returns>
        public static MultiLineString TransformMultiLineString(MultiLineString lines, MathTransform transform, GeometryFactory targetFactory)
        {
            var lineList = new LineString[lines.NumGeometries];

            for (var i = 0; i < lines.NumGeometries; i++)
            {
                var line = (LineString)lines[i];
                lineList[i] = TransformLineString(line, transform, targetFactory);
            }
            return(targetFactory.CreateMultiLineString(lineList));
        }
Beispiel #17
0
        public void CreateEmptyMultiLineStringSucceeds()
        {
            GeometryFactory factory = new GeometryFactory(
                new BufferedCoordinate2DFactory(),
                new BufferedCoordinate2DSequenceFactory());

            IMultiLineString l = factory.CreateMultiLineString();

            Assert.IsNotNull(l);
            Assert.IsTrue(l.IsEmpty);
        }
        private MultiLineString CreateMultiLineString(IEnumerable <IEnumerable <Coordinate> > coordinates)
        {
            var strings = new List <LineString>();

            foreach (var seq in coordinates)
            {
                strings.Add(_factory.CreateLineString(seq as Coordinate[] ?? seq.ToArray()));
            }

            return(_factory.CreateMultiLineString(strings.ToArray()));
        }
Beispiel #19
0
 private void SimplifyGeometriesCollection(List <Feature> results)
 {
     foreach (var feature in results)
     {
         if (!(feature.Geometry is GeometryCollection geometryCollection))
         {
             continue;
         }
         if (geometryCollection.Geometries.All(g => g is Point || g is MultiPoint))
         {
             var points = geometryCollection.Geometries
                          .OfType <MultiPoint>()
                          .SelectMany(mls => mls.Geometries.OfType <Point>())
                          .Concat(geometryCollection.Geometries.OfType <Point>())
                          .ToArray();
             feature.Geometry = _geometryFactory.CreateMultiPoint(points);
             continue;
         }
         var nonPointGeometries = geometryCollection.Geometries.Where(g => !(g is Point));
         if (nonPointGeometries.Count() == 1)
         {
             feature.Geometry = nonPointGeometries.First();
             continue;
         }
         if (nonPointGeometries.All(g => g is LineString || g is MultiLineString))
         {
             var lines = nonPointGeometries
                         .OfType <MultiLineString>()
                         .SelectMany(mls => mls.Geometries.OfType <LineString>())
                         .Concat(nonPointGeometries.OfType <LineString>())
                         .ToArray();
             feature.Geometry = _geometryFactory.CreateMultiLineString(lines);
             continue;
         }
         if (nonPointGeometries.All(g => g is Polygon || g is MultiPolygon))
         {
             var polygons = nonPointGeometries
                            .OfType <MultiPolygon>()
                            .SelectMany(mls => mls.Geometries.OfType <Polygon>())
                            .Concat(nonPointGeometries.OfType <Polygon>())
                            .ToArray();
             feature.Geometry = _geometryFactory.CreateMultiPolygon(polygons);
             if (!feature.Geometry.IsValid)
             {
                 feature.Attributes.AddOrUpdate(FeatureAttributes.POI_CONTAINER, false);
                 _reportLogger.LogWarning("There was a problem merging the following feature " + feature.GetTitle(Languages.HEBREW) + " (" + feature.GetId() + ") ");
             }
             continue;
         }
         _reportLogger.LogWarning("The following merge created a weird geometry: " + feature.GetTitle(Languages.HEBREW) + " (" + feature.GetId() + ") " + string.Join(", ", geometryCollection.Geometries.Select(g => g.GeometryType)));
         feature.Geometry = nonPointGeometries.FirstOrDefault();
     }
 }
Beispiel #20
0
        internal static MultiLineString ToNTSMultiLineString(Geometries.MultiLineString multiLineString,
                                                             GeometryFactory factory)
        {
            LineString[] lstrings = new LineString[multiLineString.LineStrings.Count];
            int          index    = 0;

            foreach (Geometries.LineString lstring in multiLineString.LineStrings)
            {
                lstrings[index++] = ToNTSLineString(lstring, factory);
            }
            return(factory.CreateMultiLineString(lstrings) as MultiLineString);
        }
        private static MultiLineString ToMultiLineString(ICollection <LineSegment> segs, GeometryFactory factory)
        {
            var lines = new LineString[segs.Count];
            int i     = 0;

            foreach (var seg in segs)
            {
                lines[i++] = seg.ToGeometry(factory);
            }

            return(factory.CreateMultiLineString(lines));
        }
Beispiel #22
0
        public void TestIsClosed()
        {
            var l = (LineString)reader.Read("LINESTRING EMPTY");

            Assert.IsTrue(l.IsEmpty);
            Assert.IsTrue(!l.IsClosed);

            var r = geometryFactory.CreateLinearRing((CoordinateSequence)null);

            Assert.IsTrue(r.IsEmpty);
            Assert.IsTrue(r.IsClosed);

            var m = geometryFactory.CreateMultiLineString(
                new LineString[] { l, r });

            Assert.IsTrue(!m.IsClosed);

            var m2 = geometryFactory.CreateMultiLineString(
                new LineString[] { r });

            Assert.IsTrue(!m2.IsClosed);
        }
        /// <summary>
        /// Creates a <c>MultiLineString</c> using the next token in the stream.
        /// </summary>
        /// <param name="tokens">
        /// Tokenizer over a stream of text in Well-known Text
        /// format. The next tokens must form a MultiLineString Text.
        /// </param>
        /// <returns>
        /// A <c>MultiLineString</c> specified by the
        /// next token in the stream.</returns>
        private MultiLineString ReadMultiLineStringText(IList tokens)
        {
            string nextToken = GetNextEmptyOrOpener(tokens);

            if (nextToken.Equals("EMPTY")) //NOXLATE
            {
                return(geometryFactory.CreateMultiLineString(Array.Empty <LineString>()));
            }

            var lineStrings = new List <LineString>();
            var lineString  = ReadLineStringText(tokens);

            lineStrings.Add(lineString);
            nextToken = GetNextCloserOrComma(tokens);
            while (nextToken.Equals(",")) //NOXLATE
            {
                lineString = ReadLineStringText(tokens);
                lineStrings.Add(lineString);
                nextToken = GetNextCloserOrComma(tokens);
            }
            return(geometryFactory.CreateMultiLineString(lineStrings.ToArray()));
        }
        private MultiLineString nonSimpleMLS()
        {
            Coordinates     coords     = new Coordinates();
            Coordinate      coord      = new Coordinate();
            GeometryFactory gf         = new GeometryFactory(_precMod, _sRID);
            LineString      lineString = gf.CreateLineString(coords);

            LineString[] ls = new LineString[1];

            coord = new Coordinate(2, 2);
            coords.Add(coord);
            coord = new Coordinate(3, 3);
            coords.Add(coord);
            coord = new Coordinate(4, 4);
            coords.Add(coord);
            coord = new Coordinate(5, 5);
            coords.Add(coord);
            coord = new Coordinate(6, 6);
            coords.Add(coord);
            coord = new Coordinate(7, 7);
            coords.Add(coord);
            coord = new Coordinate(8, 8);
            coords.Add(coord);
            coord = new Coordinate(9, 7);
            coords.Add(coord);
            coord = new Coordinate(10, 6);
            coords.Add(coord);
            coord = new Coordinate(10, 5);
            coords.Add(coord);
            coord = new Coordinate(9, 4);
            coords.Add(coord);
            coord = new Coordinate(8, 3);
            coords.Add(coord);
            coord = new Coordinate(7, 4);
            coords.Add(coord);
            coord = new Coordinate(7, 5);
            coords.Add(coord);
            coord = new Coordinate(6, 6);
            coords.Add(coord);
            coord = new Coordinate(5, 7);
            coords.Add(coord);
            coord = new Coordinate(4, 8);
            coords.Add(coord);
            coord = new Coordinate(3, 9);
            coords.Add(coord);
            ls[0] = gf.CreateLineString(coords);

            MultiLineString multiLS = gf.CreateMultiLineString(ls);

            return(multiLS);
        }
            private static Geometry CreateMultiLineString(Ordinates ordinates, bool empty)
            {
                if (empty)
                {
                    Factory.CreateMultiLineString(null);
                }

                int numLineStrings = Rnd.Next(0, 11);

                if (numLineStrings <= 2)
                {
                    numLineStrings = 0;
                }

                var lineString = new LineString[numLineStrings];

                for (int i = 0; i < numLineStrings; i++)
                {
                    lineString[i] = (LineString)CreateLineString(ordinates, false);
                }

                return(Factory.CreateMultiLineString(lineString));
            }
        /// <summary>
        /// Gets the geometry for the edges in the subdivision as a <see cref="MultiLineString"/>
        /// containing 2-point lines.
        /// </summary>
        /// <param name="geomFact">the GeometryFactory to use</param>
        /// <returns>a MultiLineString</returns>
        public MultiLineString GetEdges(GeometryFactory geomFact)
        {
            var quadEdges = GetPrimaryEdges(false);
            var edges     = new LineString[quadEdges.Count];
            int i         = 0;

            foreach (var qe in quadEdges)
            {
                edges[i++] = geomFact.CreateLineString(new[] {
                    qe.Orig.Coordinate, qe.Dest.Coordinate
                });
            }
            return(geomFact.CreateMultiLineString(edges));
        }
Beispiel #27
0
        private static Geometry ToLines(IList <Coordinate[]> sections, GeometryFactory factory)
        {
            var lines = new LineString[sections.Count];
            int i     = 0;

            foreach (var pts in sections)
            {
                lines[i++] = factory.CreateLineString(pts);
            }
            if (lines.Length == 1)
            {
                return(lines[0]);
            }
            return(factory.CreateMultiLineString(lines));
        }
Beispiel #28
0
        public void TestCreateEmpty()
        {
            CheckEmpty(Factory.CreateEmpty(Dimension.Point), typeof(Point));
            CheckEmpty(Factory.CreateEmpty(Dimension.Curve), typeof(LineString));
            CheckEmpty(Factory.CreateEmpty(Dimension.Surface), typeof(Polygon));

            CheckEmpty(Factory.CreatePoint(), typeof(Point));
            CheckEmpty(Factory.CreateLineString(), typeof(LineString));
            CheckEmpty(Factory.CreatePolygon(), typeof(Polygon));

            CheckEmpty(Factory.CreateMultiPoint(), typeof(MultiPoint));
            CheckEmpty(Factory.CreateMultiLineString(), typeof(MultiLineString));
            CheckEmpty(Factory.CreateMultiPolygon(), typeof(MultiPolygon));
            CheckEmpty(Factory.CreateGeometryCollection(), typeof(GeometryCollection));
        }
Beispiel #29
0
        /// <summary>
        /// Converts a collection of <see cref="ISegmentString"/>s into a <see cref="Geometry"/>.
        /// The geometry will be either a <see cref="LineString"/>
        /// or a <see cref="MultiLineString"/> (possibly empty).
        /// </summary>
        /// <param name="segStrings">A collection of <see cref="ISegmentString"/>.</param>
        /// <param name="geomFact">A geometry factory</param>
        /// <returns>A <see cref="LineString"/> or a <see cref="MultiLineString"/>.</returns>
        public static Geometry ToGeometry(IList <ISegmentString> segStrings, GeometryFactory geomFact)
        {
            var lines = new LineString[segStrings.Count];
            int index = 0;

            foreach (var ss in segStrings)
            {
                var line = geomFact.CreateLineString(ss.Coordinates);
                lines[index++] = line;
            }
            if (lines.Length == 1)
            {
                return(lines[0]);
            }
            return(geomFact.CreateMultiLineString(lines));
        }
        private MultiLineString CreateMultiLine(int dim, int lrs, Decimal[] elemInfo, int elemIndex,
                                                List <Coordinate> coords, int numGeom)
        {
            int      sOffset        = StartingOffset(elemInfo, elemIndex);
            SdoEType etype          = EType(elemInfo, elemIndex);
            int      interpretation = Interpretation(elemInfo, elemIndex);

            int length = coords.Count * dim;

            if (!(sOffset >= 1) || !(sOffset <= length))
            {
                throw new ArgumentException("ELEM_INFO STARTING_OFFSET " + sOffset +
                                            " inconsistent with ORDINATES length " + coords.Count);
            }
            if (!(etype == SdoEType.Line))
            {
                throw new ArgumentException("ETYPE " + etype + " inconsistent with expected LINE");
            }
            if (!(interpretation == 1))
            {
                // we cannot represent INTERPRETATION > 1
                return(null);
            }

            int endTriplet = (numGeom != -1) ? (elemIndex + numGeom) : (elemInfo.Length / 3);

            var list = new List <LineString>();

            Boolean cont = true;

            for (int i = elemIndex; cont && i < endTriplet && (etype = EType(elemInfo, i)) != SdoEType.Unknown; i++)
            {
                if (etype == SdoEType.Line)
                {
                    list.Add(CreateLine(dim, lrs, elemInfo, i, coords));
                }
                else
                {
                    // not a LineString - get out of here
                    cont = false;
                }
            }

            var lines = _factory.CreateMultiLineString(list.ToArray());

            return(lines);
        }