Example #1
0
        TcsGeometry(this MultiPoint multiPoint)
        {
            var goePoints = multiPoint.Coordinates.Select(TcsGeometry).ToList();

            var result = new CoreSpatial.BasicGeometrys.MultiPoint(goePoints);

            return(result);
        }
        public void MultiPoint()
        {
            var geom = new MultiPoint(new [] { new Point(0,1), new Point(2,3) });

            var actualOriginalWkt = _originalWktWriter.Write(geom);
            Assert.AreEqual("MULTIPOINT ((0 1), (2 3))", actualOriginalWkt, "If the original writer does not include extra parens around the points, consider removing the SdeStWktWriter class.");

            var actualSdeStWkt = _sdeStWktWriter.Write(geom);
            Assert.AreEqual("MULTIPOINT (0 1, 2 3)", actualSdeStWkt);
        }
        /// <summary>
        /// Creates a Point 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 &lt;Point Text&gt;.</param>
        /// <returns>Returns a Point specified by the next token in
        /// the stream.</returns>
        /// <remarks>
        /// ParseException is thrown if an unexpected token is encountered.
        /// </remarks>
        private static MultiPoint ReadMultiPointText(WktStreamTokenizer tokenizer)
        {
            var arrpoints = new List<IPoint>();

            string nextToken = GetNextEmptyOrOpener(tokenizer);
            if (nextToken == "EMPTY")
                return new MultiPoint(arrpoints.ToArray());
            
            arrpoints.Add(new Point(GetNextNumber(tokenizer), GetNextNumber(tokenizer)));
            nextToken = GetNextCloserOrComma(tokenizer);
            while (nextToken == ",")
            {
                arrpoints.Add(new Point(GetNextNumber(tokenizer), GetNextNumber(tokenizer)));
                nextToken = GetNextCloserOrComma(tokenizer);
            }

            MultiPoint mp = new MultiPoint(arrpoints.ToArray());
            return mp;
        }
        private static MultiPoint CreateWKBMultiPoint(BinaryReader reader, WkbByteOrder byteOrder)
        {
            // Get the number of points in this multipoint.
            int numPoints = (int) ReadUInt32(reader, byteOrder);
            var arrpoints = new IPoint[numPoints];

            // Loop on the number of points.
            for (int i = 0; i < numPoints; i++)
            {
                // Read point header
                reader.ReadByte();
                ReadUInt32(reader, byteOrder);

                // TODO: Validate type

                // Create the next point and add it to the point array.
                arrpoints[i] = CreateWKBPoint(reader, byteOrder);
            }

            // Create a new array for the points.
            MultiPoint points = new MultiPoint(arrpoints);
            
            return points;
        }
        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 = new MultiPoint(nodes.Select(n => new Point(ConvertNode(n)) as IPoint).ToArray());
                return new Feature(multiPoint, ConvertTags(relation.Tags, relation.Id));
            }

            var geometries = GetGeometriesFromWays(GetAllWays(relation));
            if (!geometries.Any())
            {
                return null;
            }
            var jointLines = geometries.OfType<ILineString>().ToList();
            jointLines.AddRange(geometries.OfType<Polygon>().Select(p => new LineString(p.Coordinates) as ILineString));
            var multiLineString = new MultiLineString(jointLines.ToArray());
            return new Feature(multiLineString, ConvertTags(relation.Tags, relation.Id));
        }
        /// <summary>
        /// This method produces instances of type <see cref="MultiPoint"/>.
        /// </summary>
        /// <returns>The created geometries</returns>
        internal override Collection<SimpleGisShape> createGeometries()
        {
            SimpleGisShape shp = null;

            IPathNode multiPointNode = new PathNode(_GMLNS, "MultiPoint", (NameTable)_xmlReader.NameTable);
            IPathNode pointMemberNode = new PathNode(_GMLNS, "pointMember", (NameTable)_xmlReader.NameTable);
            string[] labelValue = new string[1];

            try
            {
                ParseBoundingBox();

                // Reading the entire feature's node makes it possible to collect label values that may appear before or after the geometry property
                while ((_featureReader = GetSubReaderOf(_xmlReader, null, _featureNode)) != null)
                {
                    while ((_geomReader = GetSubReaderOf(_featureReader, null, _propertyNode)) != null)
                    {
                        bool isSelected;
                        int uid;
                        List<string> ll = ParseProperties(_geomReader, out isSelected, out uid);

                        _geomReader = GetSubReaderOf(_featureReader, labelValue, multiPointNode, pointMemberNode);

                        GeometryFactory geomFactory = new PointFactory(_geomReader, _featureTypeInfo, _fieldNames);
                        Collection<SimpleGisShape> shapePoints = geomFactory.createGeometries();

                        var points = new List<IPoint>();
                        foreach (var shp1 in shapePoints)
                        {
                            points.Add(shp1.Geometry as IPoint);
                        }

                        MultiPoint multiPoint = new MultiPoint(points.ToArray());
                        shp = new SimpleGisShape(multiPoint);
                        shp.IsSelected = isSelected;
                        shp.UID = uid;

                        _shapes.Add(shp);
                        FillShapeFields(shp, ll);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return _shapes;
        }
        /// <summary>
        /// Writes a multipoint.
        /// </summary>
        /// <param name="mp">The multipoint to be written.</param>
        /// <param name="bWriter">Stream to write to.</param>
        /// <param name="byteorder">Byte order</param>
        private static void WriteMultiPoint(MultiPoint mp, BinaryWriter bWriter, WkbByteOrder byteorder)
        {
            //Write the number of points.
            WriteUInt32((uint) mp.Geometries.Length, bWriter, byteorder);

            //Loop on the number of points.
            foreach (var g in mp.Geometries)
            {
                var p = g as Point;
                if (p == null)
                    throw new ArgumentNullException("Point inside a multipoint");

                //Write Points Header
                bWriter.Write((byte) byteorder);
                WriteUInt32((uint) WKBGeometryType.wkbPoint, bWriter, byteorder);
                //Write each point.
                WritePoint(p, bWriter, byteorder);
            }
        }
 /// <summary>
 /// Converts a MultiPoint to &lt;MultiPoint Text&gt; format, then
 /// Appends it to the writer.
 /// </summary>
 /// <param name="multiPoint">The MultiPoint to process.</param>
 /// <param name="writer">The output stream writer to Append to.</param>
 private static void AppendMultiPointText(MultiPoint multiPoint, StringWriter writer)
 {
     if (multiPoint == null || multiPoint.IsEmpty)
         writer.Write("EMPTY");
     else
     {
         writer.Write("(");
         for (int i = 0; i < multiPoint.Geometries.Length; i++)
         {
             if (i > 0)
                 writer.Write(", ");
             AppendCoordinate(multiPoint[i].Coordinate, writer);
         }
         writer.Write(")");
     }
 }
 /// <summary>
 /// Converts a MultiPoint to &lt;MultiPoint Tagged Text&gt;
 /// format, then Appends it to the writer.
 /// </summary>
 /// <param name="multipoint">The MultiPoint to process.</param>
 /// <param name="writer">The output writer to Append to.</param>
 private static void AppendMultiPointTaggedText(MultiPoint multipoint, StringWriter writer)
 {
     writer.Write("MULTIPOINT ");
     AppendMultiPointText(multipoint, writer);
 }