コード例 #1
0
        public void PbfReaderCanReadFileCreatedByPbfWriter_NoDenseDeflate()
        {
            MemoryStream stream = new MemoryStream();

            using (PbfWriter writer = new PbfWriter(stream, new PbfWriterSettings() { WriteMetadata = true, UseDenseFormat = false, Compression = CompressionMode.ZlibDeflate })) {
                foreach (var info in this.GetTestData()) {
                    writer.Write(info);
                }

                writer.Flush();

                stream.Seek(0, SeekOrigin.Begin);
                using (PbfReader reader = new PbfReader(stream, new OsmReaderSettings() { ReadMetadata = true })) {
                    this.TestReader(reader);
                }
            }
        }
コード例 #2
0
        public void Write_ThrowsArgumentNullExceptionIfMetadataContainsNullInsteadUsername()
        {
            _nodeProperties.Metadata.User = null;

            using (PbfWriter target = new PbfWriter(new MemoryStream(), new PbfWriterSettings() { UseDenseFormat = true, Compression = CompressionMode.None, WriteMetadata = true })) {
                Assert.Throws<ArgumentNullException>(() => target.Write(_nodeProperties));
            }
        }
コード例 #3
0
        public void PbfWriterWritesFilesCompatibleWithOsmosis_DenseDeflate()
        {
            string pbfFile = Path.GetFullPath("TestFiles\\pbfwriter-osmosis-compatibility-test-pbfwriter-real-file-dc.pbf");
            if (File.Exists(pbfFile)) {
                File.Delete(pbfFile);
            }

            using (PbfWriter writer = new PbfWriter(pbfFile, new PbfWriterSettings() { WriteMetadata = true, Compression = CompressionMode.ZlibDeflate, UseDenseFormat = true })) {
                foreach (var entityInfo in this.GetTestData()) {
                    writer.Write(entityInfo);
                }
            }

            string osmosisXmlFile = Path.GetFullPath("TestFiles\\pbfwriter-osmosis-compatibility-test-test-file.osm");
            if (File.Exists(osmosisXmlFile)) {
                File.Delete(osmosisXmlFile);
            }

            string osmosisArguments = string.Format("--read-pbf file={0} --write-xml file={1}", pbfFile, osmosisXmlFile);
            this.CallOsmosis(osmosisArguments);

            Assert.True(File.Exists(osmosisXmlFile));
            Assert.True(new FileInfo(osmosisXmlFile).Length > 0);
        }
コード例 #4
0
        public void Write_IOsmGeometry_WritesWay()
        {
            Way way = new Way(10, new Node[] { new Node(1), new Node(2), new Node(3) });
            PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false };
            MemoryStream stream = new MemoryStream();

            using (PbfWriter target = new PbfWriter(stream, settings)) {
                target.Write(way);
            }

            this.TestPbfOutput(stream, new WayInfo(way));
        }
コード例 #5
0
 public void Write_ThrowsArgumentExceptionIfWriteMetadataIsTrueButEntityDoesntHaveMetadata()
 {
     using (PbfWriter target = new PbfWriter(new MemoryStream(), new PbfWriterSettings() { UseDenseFormat = true, Compression = CompressionMode.None, WriteMetadata = true })) {
         Assert.Throws<ArgumentException>(() => target.Write(_node));
     }
 }
コード例 #6
0
        public void Write_IOsmGeometry_WritesNode()
        {
            Node node = new Node(1, 11.1, 12.1);
            PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false };
            MemoryStream stream = new MemoryStream();

            using (PbfWriter target = new PbfWriter(stream, settings)) {
                target.Write(node);
            }

            this.TestPbfOutput(stream, new NodeInfo(node));
        }
コード例 #7
0
        public void Write_IOsmGeometry_WritesRelation()
        {
            Relation relation = new Relation(100, new RelationMember[] { new RelationMember(new Node(1), "test-role") });

            PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false };
            MemoryStream stream = new MemoryStream();

            using (PbfWriter target = new PbfWriter(stream, settings)) {
                target.Write(relation);
            }

            this.TestPbfOutput(stream, new RelationInfo(relation));
        }
コード例 #8
0
        public void Write_IEntityInfo_WritesWayWithTags()
        {
            PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false };
            MemoryStream stream = new MemoryStream();

            using (PbfWriter target = new PbfWriter(stream, settings)) {
                target.Write(_wayTags);
            }

            this.TestPbfOutput(stream, _wayTags);
        }
コード例 #9
0
        public void Write_IOsmGeometry_ThrowsExceptionIfEntityIsNull()
        {
            PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false };
            MemoryStream stream = new MemoryStream();

            using (PbfWriter target = new PbfWriter(stream, settings)) {
                IOsmGeometry entity = null;
                Assert.Throws<ArgumentNullException>(() => target.Write(entity));
            }
        }
コード例 #10
0
        public void Write_IEntityInfo_WritesRelationWithMetadata()
        {
            PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = true };
            MemoryStream stream = new MemoryStream();

            using (PbfWriter target = new PbfWriter(stream, settings)) {
                target.Write(_relationNodeProperties);
            }

            this.TestPbfOutput(stream, _relationNodeProperties);
        }
コード例 #11
0
        public void Write_IEntityInfo_DoesntWriteWayMetadataIfWriteMetadataSettingsIsFalse()
        {
            PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false };
            MemoryStream stream = new MemoryStream();

            using (PbfWriter target = new PbfWriter(stream, settings)) {
                target.Write(_wayProperties);
            }

            this.TestPbfOutput(stream, _way);
        }
コード例 #12
0
        public void Flush_ForcesWriterToWriteDataToUnderalyingStorage()
        {
            MemoryStream stream = new MemoryStream();

            PbfWriter target = new PbfWriter(stream, new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false });

            //1000 nodes should fit into tokens
            for (int i = 0; i < 1000; i++) {
                NodeInfo node = new NodeInfo(i, 45.87, -126.5, new TagsCollection());
                target.Write(node);
            }
            int minimalExpectedLengthIncrease = 1000 * 8;

            long originalStreamLength = stream.Length;
            target.Flush();

            Assert.True(stream.Length > originalStreamLength + minimalExpectedLengthIncrease);
        }
コード例 #13
0
ファイル: Program.cs プロジェクト: najira/spatiallite-net
 static void TestPbfWriterSpeedWithoutMetadata()
 {
     using (PbfWriter writer = new PbfWriter("TestFiles\\temp.pbf", new PbfWriterSettings() { WriteMetadata = false, Compression = CompressionMode.None, UseDenseFormat = false })) {
         foreach (var entity in _entities) {
             writer.Write(entity);
         }
     }
 }
コード例 #14
0
ファイル: Program.cs プロジェクト: najira/spatiallite-net
 static void TestPbfWriterSpeedDenseDeflate()
 {
     using (PbfWriter writer = new PbfWriter("TestFiles\\temp.pbf", new PbfWriterSettings() { WriteMetadata = true, Compression = CompressionMode.ZlibDeflate, UseDenseFormat = true })) {
         foreach (var entity in _entities) {
             writer.Write(entity);
         }
     }
 }