public void TopoJsonWriterWrittenContentTest()
        {
            GeometryFactory factory = new GeometryFactory();
            IMultiPolygon   mp      = factory.CreateMultiPolygon
                                      (
                new List <IPolygon>
            {
                factory.CreatePolygon(factory.CreatePoint(10, 10),
                                      factory.CreatePoint(20, 10),
                                      factory.CreatePoint(25, 17),
                                      factory.CreatePoint(10, 10)),

                factory.CreatePolygon(factory.CreatePoint(50, 30),
                                      factory.CreatePoint(40, 20),
                                      factory.CreatePoint(20, 10),
                                      factory.CreatePoint(25, 17),
                                      factory.CreatePoint(30, 30),
                                      factory.CreatePoint(50, 30))
            }
                                      );

            Assert.AreEqual(2, mp.Count);

            IMultiPoint p = factory.CreateMultiPoint(
                new IPoint[2]
            {
                factory.CreatePoint(10, 10),
                factory.CreatePoint(23, 23)
            });

            ILineString lstr = factory.CreateLineString(
                factory.CreatePoint(50, 60),
                factory.CreatePoint(55, 60),
                factory.CreatePoint(71, 71)
                );

            List <IGeometry> geo = new List <IGeometry>()
            {
                p, lstr
            };

            string outFileName = _outputPath + ".topojson";

            TopoJsonWriter writer = new TopoJsonWriter(outFileName);

            writer.Write(mp as IGeometry);
            writer.Write(geo);
            writer.Close();

            TopoJsonReader    reader     = new TopoJsonReader(outFileName);
            IList <IGeometry> geometries = reader.ReadToEnd();

            reader.Close();

            GeometryComparer comp = new GeometryComparer();

            Assert.AreEqual(0, comp.Compare(geometries[0], mp));
            Assert.AreEqual(0, comp.Compare(geometries[1], p));
            Assert.AreEqual(0, comp.Compare(geometries[2], lstr));
        }
Esempio n. 2
0
        public void write_polygon_with_hole()
        {
            Coordinate      c0         = new Coordinate(10.1, 10);
            Coordinate      c1         = new Coordinate(20.2, 20);
            Coordinate      c2         = new Coordinate(30.3, 30);
            ILinearRing     shell      = Factory.CreateLinearRing(new[] { c0, c1, c2, c0 });
            Coordinate      h0         = new Coordinate(15, 15);
            Coordinate      h1         = new Coordinate(17, 15);
            Coordinate      h2         = new Coordinate(15, 17);
            ILinearRing     hole       = Factory.CreateLinearRing(new[] { h0, h1, h2, h0 });
            IGeometry       geometry   = Factory.CreatePolygon(shell, new[] { hole });
            AttributesTable attributes = new AttributesTable();

            attributes.Add("prop0", "value0");
            attributes.Add("prop1", "value1");
            IFeature feature = new Feature(geometry, attributes);

            TopoJsonWriter writer = new TopoJsonWriter();
            string         actual = writer.Write(feature);

            Assert.That(actual, Is.Not.Null);
            Assert.That(actual, Is.Not.Empty);
            Console.WriteLine(actual);
            Assert.That(actual, Is.EqualTo(TopoWriterData.PolygonWithHole));
        }
        public void write_simple_point()
        {
            IPoint geometry = Factory.CreatePoint(new Coordinate(23.4, 56.7));
            AttributesTable attributes = new AttributesTable();
            attributes.AddAttribute("prop0", "value0");
            attributes.AddAttribute("prop1", "value1");
            IFeature feature = new Feature(geometry, attributes);

            TopoJsonWriter writer = new TopoJsonWriter();
            string actual = writer.Write(feature);
            Assert.That(actual, Is.Not.Null);
            Assert.That(actual, Is.Not.Empty);
            Console.WriteLine(actual);
            Assert.That(actual, Is.EqualTo(TopoWriterData.SimplePoint));
        }
        public void TopoJsonWriterWriteTest()
        {
            IList <IGeometry> geometries = null;

            foreach (string path in _inputFilePaths)
            {
                TopoJsonReader reader = new TopoJsonReader(path);
                geometries = reader.ReadToEnd();
                reader.Close();

                string outFileName = _outputPath + Path.GetFileName(path);

                TopoJsonWriter writer = new TopoJsonWriter(outFileName);
                writer.Write(geometries);
                writer.Close();
            }
        }
Esempio n. 5
0
        public void write_simple_point()
        {
            IPoint          geometry   = Factory.CreatePoint(new Coordinate(23.4, 56.7));
            AttributesTable attributes = new AttributesTable();

            attributes.Add("prop0", "value0");
            attributes.Add("prop1", "value1");
            IFeature feature = new Feature(geometry, attributes);

            TopoJsonWriter writer = new TopoJsonWriter();
            string         actual = writer.Write(feature);

            Assert.That(actual, Is.Not.Null);
            Assert.That(actual, Is.Not.Empty);
            Console.WriteLine(actual);
            Assert.That(actual, Is.EqualTo(TopoWriterData.SimplePoint));
        }
        public void write_simple_polygon()
        {
            Coordinate c0 = new Coordinate(10.1, 10);
            Coordinate c1 = new Coordinate(20.2, 20);
            Coordinate c2 = new Coordinate(30.3, 30);
            IPolygon geometry = Factory.CreatePolygon(new[] { c0, c1, c2, c0 });
            AttributesTable attributes = new AttributesTable();
            attributes.AddAttribute("prop0", "value0");
            attributes.AddAttribute("prop1", "value1");
            IFeature feature = new Feature(geometry, attributes);

            TopoJsonWriter writer = new TopoJsonWriter();
            string actual = writer.Write(feature);
            Assert.That(actual, Is.Not.Null);
            Assert.That(actual, Is.Not.Empty);
            Console.WriteLine(actual);
            Assert.That(actual, Is.EqualTo(TopoWriterData.SimplePolygon));
        }
Esempio n. 7
0
        public void write_simple_polygon()
        {
            Coordinate      c0         = new Coordinate(10.1, 10);
            Coordinate      c1         = new Coordinate(20.2, 20);
            Coordinate      c2         = new Coordinate(30.3, 30);
            IPolygon        geometry   = Factory.CreatePolygon(new[] { c0, c1, c2, c0 });
            AttributesTable attributes = new AttributesTable();

            attributes.Add("prop0", "value0");
            attributes.Add("prop1", "value1");
            IFeature feature = new Feature(geometry, attributes);

            TopoJsonWriter writer = new TopoJsonWriter();
            string         actual = writer.Write(feature);

            Assert.That(actual, Is.Not.Null);
            Assert.That(actual, Is.Not.Empty);
            Console.WriteLine(actual);
            Assert.That(actual, Is.EqualTo(TopoWriterData.SimplePolygon));
        }
        public void write_polygon_with_hole()
        {
            Coordinate c0 = new Coordinate(10.1, 10);
            Coordinate c1 = new Coordinate(20.2, 20);
            Coordinate c2 = new Coordinate(30.3, 30);
            ILinearRing shell = Factory.CreateLinearRing(new[] { c0, c1, c2, c0 });
            Coordinate h0 = new Coordinate(15, 15);
            Coordinate h1 = new Coordinate(17, 15);
            Coordinate h2 = new Coordinate(15, 17);
            ILinearRing hole = Factory.CreateLinearRing(new[] { h0, h1, h2, h0 });
            IGeometry geometry = Factory.CreatePolygon(shell, new[] { hole });
            AttributesTable attributes = new AttributesTable();
            attributes.AddAttribute("prop0", "value0");
            attributes.AddAttribute("prop1", "value1");
            IFeature feature = new Feature(geometry, attributes);

            TopoJsonWriter writer = new TopoJsonWriter();
            string actual = writer.Write(feature);
            Assert.That(actual, Is.Not.Null);
            Assert.That(actual, Is.Not.Empty);
            Console.WriteLine(actual);
            Assert.That(actual, Is.EqualTo(TopoWriterData.PolygonWithHole));
        }