public InMemoryOsmDatabase Provide() { consoleLogger.WriteLine(log, Level.Info, "Loading OSM file '{0}'...", osmFileName); InMemoryOsmDatabase osmDatabase = new InMemoryOsmDatabase(); OsmXmlReader osmXmlReader = new OsmXmlReader(); osmXmlReader.Read(osmFileName, fileSystem, osmDatabase); osmDatabase.RemoveWaysWithMissingNodes(); return(osmDatabase); }
static void TestXmlReaderSpeed() { int entitiesRead = 0; IEntityInfo info = null; using (OsmXmlReader reader = new OsmXmlReader("TestFiles\\test-file.osm", new OsmXmlReaderSettings() { ReadMetadata = true })) { while ((info = reader.Read()) != null) { entitiesRead++; } } }
public void Read_ReadsWayWithoutNodes() { OsmXmlReader target = new OsmXmlReader(new MemoryStream(XmlTestData.osm_way_without_nodes), new OsmXmlReaderSettings() { ReadMetadata = false }); WayInfo readWay = target.Read() as WayInfo; this.CompareWays(_wayWithoutNodes, readWay); }
public void Read_ReadsWayWithAllAttributes() { OsmXmlReader target = new OsmXmlReader(new MemoryStream(XmlTestData.osm_way_all_properties), new OsmXmlReaderSettings() { ReadMetadata = true }); WayInfo readWay = target.Read() as WayInfo; this.CompareWays(_wayProperties, readWay); }
public void Read_ReadsSimpleWay() { OsmXmlReader target = new OsmXmlReader(new MemoryStream(XmlTestData.osm_simple_way), new OsmXmlReaderSettings() { ReadMetadata = false }); WayInfo readWay = target.Read() as WayInfo; this.CompareWays(_way, readWay); }
public void Read_ReadsSimpleNode() { OsmXmlReader target = new OsmXmlReader(new MemoryStream(XmlTestData.osm_simple_node), new OsmXmlReaderSettings() { ReadMetadata = false }); NodeInfo readNode = target.Read() as NodeInfo; this.CompareNodes(_node, readNode); }
static void TestXmlReaderSpeedWithoutMetadata() { int entitiesRead = 0; IEntityInfo info = null; using (OsmXmlReader reader = new OsmXmlReader("TestFiles\\test-file.osm", new OsmXmlReaderSettings() { ReadMetadata = false })) { while ((info = reader.Read()) != null) { entitiesRead++; } } }
public void Read_ThrowsExceptionIfWayNDHasNotRef() { OsmXmlReader target = new OsmXmlReader(new MemoryStream(XmlTestData.osm_way_nd_without_ref), new OsmXmlReaderSettings() { ReadMetadata = false }); Assert.Throws<XmlException>(() => target.Read()); }
public void Read_ThrowsExceptionIfRelationMemberHasNotType() { OsmXmlReader target = new OsmXmlReader(new MemoryStream(XmlTestData.osm_relation_member_without_type), new OsmXmlReaderSettings() { ReadMetadata = false }); Assert.Throws<XmlException>(() => target.Read()); }
public void Read_ReadsNodeWithUnknownElement() { OsmXmlReader target = new OsmXmlReader(new MemoryStream(XmlTestData.osm_node_with_tag_and_unknown_element), new OsmXmlReaderSettings() { ReadMetadata = false }); NodeInfo readNode = target.Read() as NodeInfo; this.CompareNodes(_node, readNode); // nothing more left to read in the file Assert.Null(target.Read()); }
public void Read_ReadsNodeWithTags() { OsmXmlReader target = new OsmXmlReader(new MemoryStream(XmlTestData.osm_node_with_tags), new OsmXmlReaderSettings() { ReadMetadata = false }); NodeInfo readNode = target.Read() as NodeInfo; this.CompareNodes(_nodeTags, readNode); }
public void Read_ReadsNodeWithAllAttributes() { OsmXmlReader target = new OsmXmlReader(new MemoryStream(XmlTestData.osm_node_all_properties), new OsmXmlReaderSettings() { ReadMetadata = true }); NodeInfo readNode = target.Read() as NodeInfo; this.CompareNodes(_nodeProperties, readNode); }
public void Read_DoesNotThrowExceptionIPieceOffMetadataIsMissingAndStrictModeIsFalse() { OsmXmlReader target = new OsmXmlReader(new MemoryStream(XmlTestData.osm_node_missing_timestamp), new OsmXmlReaderSettings() { ReadMetadata = true, StrictMode = false }); Assert.DoesNotThrow(() => target.Read()); }
private void TestXmlOutput(MemoryStream xmlStream, IEntityInfo expected, bool readMetadata) { if (xmlStream.CanSeek) { xmlStream.Seek(0, SeekOrigin.Begin); } else { xmlStream = new MemoryStream(xmlStream.GetBuffer()); } OsmXmlReader reader = new OsmXmlReader(xmlStream, new OsmXmlReaderSettings() { ReadMetadata = readMetadata }); 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; } }
public void Read_ReadsWayWithUnknownElement() { OsmXmlReader target = new OsmXmlReader(new MemoryStream(XmlTestData.osm_way_with_tags_and_unknown_element), new OsmXmlReaderSettings() { ReadMetadata = false }); WayInfo readWay = target.Read() as WayInfo; this.CompareWays(_wayTags, readWay); }
public void Read_SkipsUnknownElements() { OsmXmlReader target = new OsmXmlReader(new MemoryStream(XmlTestData.osm_unknown_inner_element), new OsmXmlReaderSettings() { ReadMetadata = false }); IEntityInfo result = target.Read(); Assert.NotNull(result as NodeInfo); }
public void Read_ReadsRelationWithAllProperties() { OsmXmlReader target = new OsmXmlReader(new MemoryStream(XmlTestData.osm_relation_all_properties), new OsmXmlReaderSettings() { ReadMetadata = true }); RelationInfo readRelation = target.Read() as RelationInfo; this.CompareRelation(_relationProperties, readRelation); }
public void Read_ThrowsExceptionIfTagHasNotValue() { OsmXmlReader target = new OsmXmlReader(new MemoryStream(XmlTestData.osm_node_tag_without_value), new OsmXmlReaderSettings() { ReadMetadata = false }); Assert.Throws<XmlException>(() => target.Read()); }
public void Read_ReadsRelationWithTagsAndUnknownElement() { OsmXmlReader target = new OsmXmlReader(new MemoryStream(XmlTestData.osm_relation_with_tags_and_unknown_element), new OsmXmlReaderSettings() { ReadMetadata = false }); RelationInfo readRelation = target.Read() as RelationInfo; this.CompareRelation(_relationTags, readRelation); }
public void Read_ThrowsExceptionIPieceOffMetadataIsMissingAndStrictModeIsTrue() { OsmXmlReader target = new OsmXmlReader(new MemoryStream(XmlTestData.osm_node_missing_timestamp), new OsmXmlReaderSettings() { ReadMetadata = true, StrictMode = true }); Assert.Throws<XmlException>(() => target.Read()); }
public void Read_ReadsRelationWithWayMember() { OsmXmlReader target = new OsmXmlReader(new MemoryStream(XmlTestData.osm_relation_way), new OsmXmlReaderSettings() { ReadMetadata = false }); RelationInfo readRelation = target.Read() as RelationInfo; this.CompareRelation(_relationWay, readRelation); }