示例#1
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;
            }
        }
示例#2
0
 static void TestOsmEntityInfoDatabaseLoadFromPbfReader()
 {
     using (PbfReader reader = new PbfReader("TestFiles\\test-file-dc.pbf", new OsmReaderSettings()
     {
         ReadMetadata = true
     })) {
         OsmEntityInfoDatabase db = OsmEntityInfoDatabase.Load(reader);
     }
 }
示例#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());
     }
 }
示例#4
0
        public void Read_ReadsNodeWithTags_NoCompression()
        {
            PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-node-tags.pbf"), new OsmReaderSettings()
            {
                ReadMetadata = false
            });
            NodeInfo readNode = target.Read() as NodeInfo;

            this.CompareNodes(_nodeTags, readNode);
        }
示例#5
0
        public void Read_ReadsRelationWithTags_NoCompresion()
        {
            PbfReader target = new PbfReader(new MemoryStream(PbfTestData.pbf_n_relation_tags), new OsmReaderSettings()
            {
                ReadMetadata = false
            });
            RelationInfo readRelation = target.Read() as RelationInfo;

            this.CompareRelation(_relationTags, readRelation);
        }
示例#6
0
        public void Read_ReadsWayWithoutNodes_NoCompresion()
        {
            PbfReader target = new PbfReader(new MemoryStream(PbfTestData.pbf_n_way_without_nodes), new OsmReaderSettings()
            {
                ReadMetadata = false
            });
            WayInfo readWay = target.Read() as WayInfo;

            this.CompareWays(_wayWithoutNodes, readWay);
        }
示例#7
0
        public void Constructor_StreamSettings_SetsSettingsAndMakesThemIsReadOnly()
        {
            var dataStream             = TestDataReader.OpenPbf("pbf-n-node.pbf");
            OsmReaderSettings settings = new OsmReaderSettings();

            using (PbfReader target = new PbfReader(dataStream, settings)) {
                Assert.Same(settings, target.Settings);
                Assert.True(settings.IsReadOnly);
            }
        }
示例#8
0
        public void Read_SkipsRelationMetadataIfProcessMetadataIsFalse_NoCompresion()
        {
            PbfReader target = new PbfReader(new MemoryStream(PbfTestData.pbf_n_relation_all_properties), new OsmReaderSettings()
            {
                ReadMetadata = false
            });
            RelationInfo readRelation = target.Read() as RelationInfo;

            Assert.Null(readRelation.Metadata);
        }
示例#9
0
        public void Read_ReadsRelationWithAllProperties_NoCompresion()
        {
            PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-relation-all-properties.pbf"), new OsmReaderSettings()
            {
                ReadMetadata = true
            });
            RelationInfo readRelation = target.Read() as RelationInfo;

            this.CompareRelation(_relationProperties, readRelation);
        }
示例#10
0
        public void Read_ReadsRelationWithTags_NoCompresion()
        {
            PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-relation-tags.pbf"), new OsmReaderSettings()
            {
                ReadMetadata = false
            });
            RelationInfo readRelation = target.Read() as RelationInfo;

            this.CompareRelation(_relationTags, readRelation);
        }
示例#11
0
        public void Read_ReadsWayWithoutNodes_NoCompresion()
        {
            PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-way-without-nodes.pbf"), new OsmReaderSettings()
            {
                ReadMetadata = false
            });
            WayInfo readWay = target.Read() as WayInfo;

            this.CompareWays(_wayWithoutNodes, readWay);
        }
示例#12
0
        public void Read_SkipsWayMetadataIfProcessMetadataIsFalse_NoCompresion()
        {
            PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-way-all-properties.pbf"), new OsmReaderSettings()
            {
                ReadMetadata = false
            });
            WayInfo readWay = target.Read() as WayInfo;

            Assert.Null(readWay.Metadata);
        }
示例#13
0
        public void Read_ReadsWayWithMetadata_NoCompresion()
        {
            PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-way-all-properties.pbf"), new OsmReaderSettings()
            {
                ReadMetadata = true
            });
            WayInfo readWay = target.Read() as WayInfo;

            this.CompareWays(_wayProperties, readWay);
        }
示例#14
0
        public void Read_SkipsNodeMetadataIfProcessMetadataIsFalse_NoCompression()
        {
            PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-node-all-properties.pbf"), new OsmReaderSettings()
            {
                ReadMetadata = false
            });
            NodeInfo readNode = target.Read() as NodeInfo;

            Assert.Null(readNode.Metadata);
        }
示例#15
0
        public void Read_ReadsNodeWithMetadata_NoCompression()
        {
            PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-node-all-properties.pbf"), new OsmReaderSettings()
            {
                ReadMetadata = true
            });
            NodeInfo readNode = target.Read() as NodeInfo;

            this.CompareNodes(_nodeProperties, readNode);
        }
示例#16
0
        public void Read_SkipsRelationMetadataIfProcessMetadataIsFalse_NoCompresion()
        {
            PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-relation-all-properties.pbf"), new OsmReaderSettings()
            {
                ReadMetadata = false
            });
            RelationInfo readRelation = target.Read() as RelationInfo;

            Assert.Null(readRelation.Metadata);
        }
示例#17
0
        public void Constructor_StringSettings_SetsSettingsAndMakesThemIsReadOnly()
        {
            string            filename = "..\\..\\src\\Tests.SpatialLite.Osm\\Data\\Pbf\\pbf-n-node.pbf";
            OsmReaderSettings settings = new OsmReaderSettings();

            using (PbfReader target = new PbfReader(filename, settings)) {
                Assert.Same(settings, target.Settings);
                Assert.True(settings.IsReadOnly);
            }
        }
示例#18
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);
        }
示例#19
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);
        }
示例#20
0
        public void Constructor_StreamSettings_SetsSettingsAndMakesThemIsReadOnly()
        {
            MemoryStream      dataStream = new MemoryStream(PbfTestData.pbf_n_node);
            OsmReaderSettings settings   = new OsmReaderSettings();

            using (PbfReader target = new PbfReader(dataStream, settings)) {
                Assert.Same(settings, target.Settings);
                Assert.True(settings.IsReadOnly);
            }
        }
示例#21
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);
        }
示例#22
0
        public void Read_ReadsNodeWithTags_NoCompression()
        {
            PbfReader target = new PbfReader(new MemoryStream(PbfTestData.pbf_n_node_tags), new OsmReaderSettings()
            {
                ReadMetadata = false
            });
            NodeInfo readNode = target.Read() as NodeInfo;

            this.CompareNodes(_nodeTags, readNode);
        }
示例#23
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);
        }
示例#24
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);
        }
示例#25
0
        public void Read_ReturnsNullIfAllEntitiesHaveBeenRead()
        {
            PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-node.pbf"), new OsmReaderSettings()
            {
                ReadMetadata = false
            });
            //read only entity
            IEntityInfo read = target.Read();

            // should return null
            read = target.Read();
            Assert.Null(read);
        }
示例#26
0
        public void Dispose_ClosesOutputStreamIfWritingToStream()
        {
            MemoryStream      stream   = new MemoryStream(PbfTestData.pbf_n_node);
            OsmReaderSettings settings = new OsmReaderSettings()
            {
                ReadMetadata = true
            };

            PbfReader target = new PbfReader(stream, settings);

            target.Dispose();

            Assert.False(stream.CanRead);
        }
示例#27
0
        public void Dispose_ClosesOutputStreamIfWritingToStream()
        {
            var stream = TestDataReader.OpenPbf("pbf-n-node.pbf");
            OsmReaderSettings settings = new OsmReaderSettings()
            {
                ReadMetadata = true
            };

            PbfReader target = new PbfReader(stream, settings);

            target.Dispose();

            Assert.False(stream.CanRead);
        }
示例#28
0
        public void PbfReaderReadsFilesCreatedByOsmosis_DenseDeflate()
        {
            string pbfFile = PathHelper.GetTempFilePath("pbfreader-osmosis-compatibility-test-osmosis-real-file-dc.pbf");

            string osmosisArguments = string.Format("--read-pbf file={0} --write-pbf file={1} usedense=true compress=deflate", PathHelper.RealPbfFilePath, pbfFile);

            this.CallOsmosis(osmosisArguments);

            using (PbfReader reader = new PbfReader(pbfFile, new OsmReaderSettings()
            {
                ReadMetadata = true
            })) {
                this.TestReader(reader);
            }
        }
示例#29
0
        static void TestPbfReaderSpeedDenseDeflateWithoutMetadata()
        {
            int entitiesRead = 0;

            IEntityInfo info = null;

            using (PbfReader reader = new PbfReader("TestFiles\\test-file-dc.pbf", new OsmReaderSettings()
            {
                ReadMetadata = false
            })) {
                while ((info = reader.Read()) != null)
                {
                    entitiesRead++;
                }
            }
        }
示例#30
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);
                }
            }
        }