コード例 #1
0
        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));
        }
コード例 #2
0
        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();
            }
        }