Example #1
0
        static void LoadSourceData()
        {
            _entities = new List<IEntityInfo>();

            IEntityInfo info = null;
            using (PbfReader reader = new PbfReader("TestFiles\\test-file-dc.pbf", new OsmReaderSettings() { ReadMetadata = true })) {
                while ((info = reader.Read()) != null) {
                    _entities.Add(info);
                }
            }
        }
        private IEnumerable<IEntityInfo> GetTestData()
        {
            List<IEntityInfo> data = new List<IEntityInfo>();

            using (MemoryStream stream = new MemoryStream(Data.IOTestData.pbf_real_test_file_1)) {
                using (PbfReader reader = new PbfReader(stream, new OsmReaderSettings() { ReadMetadata = true })) {
                    IEntityInfo info = null;
                    while ((info = reader.Read()) != null) {
                        data.Add(info);
                    }
                }
            }

            return data;
        }
Example #3
0
 public void Read_ThrowInvalidDataExceptionIfOsmDataBlockSizeExceedesAllowdValue()
 {
     using (PbfReader reader = new PbfReader(new MemoryStream(PbfTestData.pbf_too_large_data_block), new OsmReaderSettings() {ReadMetadata = false})) {
         Assert.Throws<InvalidDataException>(() => reader.Read());
     }
 }
Example #4
0
        public void Read_SkipsWayMetadataIfProcessMetadataIsFalse_NoCompresion()
        {
            PbfReader target = new PbfReader(new MemoryStream(PbfTestData.pbf_n_way_all_properties), new OsmReaderSettings() {ReadMetadata = false});
            WayInfo readWay = target.Read() as WayInfo;

            Assert.Null(readWay.Metadata);
        }
Example #5
0
        public void Read_SkipsNodeMetadataIfProcessMetadataIsFalse_NoCompression()
        {
            PbfReader target = new PbfReader(new MemoryStream(PbfTestData.pbf_n_node_all_properties), new OsmReaderSettings() {ReadMetadata = false});
            NodeInfo readNode = target.Read() as NodeInfo;

            Assert.Null(readNode.Metadata);
        }
Example #6
0
        public void Read_ReturnsNullIfAllEntitiesHaveBeenRead()
        {
            PbfReader target = new PbfReader(new MemoryStream(PbfTestData.pbf_n_node), new OsmReaderSettings() {ReadMetadata = false});
            //read only entity
            IEntityInfo read = target.Read();

            // should return null
            read = target.Read();
            Assert.Null(read);
        }
Example #7
0
        public void Read_ReadsWay_NoCompresion()
        {
            PbfReader target = new PbfReader(new MemoryStream(PbfTestData.pbf_n_way), new OsmReaderSettings() {ReadMetadata = false});
            WayInfo readWay = target.Read() as WayInfo;

            this.CompareWays(_way, readWay);
        }
Example #8
0
        public void Read_ReadsWayWithMetadata_NoCompresion()
        {
            PbfReader target = new PbfReader(new MemoryStream(PbfTestData.pbf_n_way_all_properties), new OsmReaderSettings() {ReadMetadata = true});
            WayInfo readWay = target.Read() as WayInfo;

            this.CompareWays(_wayProperties, readWay);
        }
Example #9
0
        public void Read_ReadsRelationWithWay_NoCompresion()
        {
            PbfReader target = new PbfReader(new MemoryStream(PbfTestData.pbf_n_relation_way), new OsmReaderSettings() {ReadMetadata = false});
            RelationInfo readRelation = target.Read() as RelationInfo;

            this.CompareRelation(_relationWay, readRelation);
        }
Example #10
0
        public void Read_ReadsRelationWithAllProperties_NoCompresion()
        {
            PbfReader target = new PbfReader(new MemoryStream(PbfTestData.pbf_n_relation_all_properties), new OsmReaderSettings() {ReadMetadata = true});
            RelationInfo readRelation = target.Read() as RelationInfo;

            this.CompareRelation(_relationProperties, readRelation);
        }
Example #11
0
        public void Read_ReadsNode_NoCompression()
        {
            PbfReader target = new PbfReader(new MemoryStream(PbfTestData.pbf_n_node), new OsmReaderSettings() {ReadMetadata = false});
            NodeInfo readNode = target.Read() as NodeInfo;

            this.CompareNodes(_node, readNode);
        }
Example #12
0
        public void Read_ReadsNodeWithMetadata_NoCompression()
        {
            PbfReader target = new PbfReader(new MemoryStream(PbfTestData.pbf_n_node_all_properties), new OsmReaderSettings() {ReadMetadata = true});
            NodeInfo readNode = target.Read() as NodeInfo;

            this.CompareNodes(_nodeProperties, readNode);
        }
Example #13
0
        private void TestPbfOutput(MemoryStream pbfStream, IEntityInfo expected)
        {
            if (pbfStream.CanSeek) {
                pbfStream.Seek(0, SeekOrigin.Begin);
            }
            else {
                pbfStream = new MemoryStream(pbfStream.GetBuffer());
            }

            PbfReader reader = new PbfReader(pbfStream, new OsmReaderSettings() { ReadMetadata = true });
            IEntityInfo read = reader.Read();

            switch (expected.EntityType) {
                case EntityType.Node: this.CompareNodes(expected as NodeInfo, read as NodeInfo); break;
                case EntityType.Way: this.CompareWays(expected as WayInfo, read as WayInfo); break;
                case EntityType.Relation: this.CompareRelation(expected as RelationInfo, read as RelationInfo); break;
            }
        }
Example #14
0
        static void TestPbfReaderSpeedNoDenseNoCompressionWithoutMetadata()
        {
            int entitiesRead = 0;

            IEntityInfo info = null;
            using (PbfReader reader = new PbfReader("TestFiles\\test-file.pbf", new OsmReaderSettings() { ReadMetadata = false })) {
                while ((info = reader.Read()) != null) {
                    entitiesRead++;
                }
            }
        }
Example #15
0
        static void TestPbfReaderSpeedDenseDeflate()
        {
            int entitiesRead = 0;

            IEntityInfo info = null;
            using (PbfReader reader = new PbfReader("TestFiles\\test-file-dc.pbf", new OsmReaderSettings() { ReadMetadata = true })) {
                while ((info = reader.Read()) != null) {
                    entitiesRead++;
                }
            }
        }