Пример #1
0
        public void TestCreateFromPolyLine()
        {
            PolyLine p = new PolyLine();
            Line l1 = new Line();
            l1.Points.Add(new Point(0,0));
            l1.Points.Add(new Point(5,0));
            l1.Points.Add(new Point(5,6));
            l1.Points.Add(new Point(0,5));
            p.Lines.Add(l1);

            Assert.AreEqual("MULTILINESTRING((0 0,5 0,5 6,0 5))", WellKnownText.CreateFromPolyLine(p));

            Line l2 = new Line();
            l2.Points.Add(new Point(1.1,1.1));
            l2.Points.Add(new Point(1.6,1.1));
            l2.Points.Add(new Point(1.4,1.4));
            l2.Points.Add(new Point(1.6,1.1));
            p.Lines.Add(l2);

            Assert.AreEqual("MULTILINESTRING((0 0,5 0,5 6,0 5),(1.1 1.1,1.6 1.1,1.4 1.4,1.6 1.1))",
                            WellKnownText.CreateFromPolyLine(p));
        }
Пример #2
0
        static PolyLine GetPolyLine(BinaryReader stream, uint dlen, bool hasMeasure)
        {
            stream.ReadDouble(); // double xmin =
            stream.ReadDouble(); // double ymin =
            stream.ReadDouble(); // double xmax =
            stream.ReadDouble(); // double ymax =

            uint numParts = stream.ReadUInt32();
            uint numPoints = stream.ReadUInt32();

            uint[] parts = new uint[numParts];
            int ii;
            for (ii=0; ii < numParts; ii++)
                parts[ii] = stream.ReadUInt32();

            Line[] lines = new Line[numParts];
            for (ii=0; ii < lines.Length; ii++)
               	lines[ii] = new Line();

            //PolyLine po = new PolyLine(xmin, ymin, xmax, ymax);
            PolyLine po = new PolyLine();

            ii=0;
            for (int jj=0; jj < numPoints; jj++)
            {
                if (ii < parts.Length-1)
                   	if (parts[ii+1] == jj)
                    {
                        po.Lines.Add(lines[ii]);
                       	ii++;
                    }
                Point p = new Point(stream.ReadDouble(), stream.ReadDouble());
                lines[ii].Points.Add(p);
            }
            po.Lines.Add(lines[ii]);

            if (hasMeasure)
            {
                stream.ReadDouble(); // Mmin
                stream.ReadDouble(); // Mmax

                for (int jj=0; jj < numPoints; jj++)
                {
                    stream.ReadDouble(); // Marray
                }
            }

            return po;
        }