private void TestXmlOutput(MemoryStream xmlStream, IEntityInfo expected, bool readMetadata) { if (xmlStream.CanSeek) { xmlStream.Seek(0, SeekOrigin.Begin); } else { xmlStream = new MemoryStream(xmlStream.ToArray()); } 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 Constructor_StreamSettings_SetsSettingsAndMakesItReadOnly() { OsmXmlReaderSettings settings = new OsmXmlReaderSettings() { ReadMetadata = false }; using (OsmXmlReader target = new OsmXmlReader(new MemoryStream(XmlTestData.osm_simple_node), settings)) { Assert.Same(settings, target.Settings); Assert.True(settings.IsReadOnly); } }
public void Read_ThrowsExceptionIfWayNDHasNotRef() { OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-way-nd-without-ref.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); Assert.Throws <XmlException>(() => target.Read()); }
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_ThrowsExceptionIfNodeHasNotLon() { OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-without-lon.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); Assert.Throws <XmlException>(() => target.Read()); }
public void Constructor_StringSettings_SetsSettingsAndMakesItReadOnly() { string path = "../../src/Tests.SpatialLite.Osm/Data/Xml/osm-real-file.osm"; OsmXmlReaderSettings settings = new OsmXmlReaderSettings() { ReadMetadata = false }; using (OsmXmlReader target = new OsmXmlReader(path, settings)) { Assert.Same(settings, target.Settings); Assert.True(settings.IsReadOnly); } }
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_DoesNotThrowExceptionIPieceOffMetadataIsMissingAndStrictModeIsFalse() { OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-missing-timestamp.osm"), new OsmXmlReaderSettings() { ReadMetadata = true, StrictMode = false }); target.Read(); }
public void Read_ThrowsExceptionIPieceOffMetadataIsMissingAndStrictModeIsTrue() { OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-missing-timestamp.osm"), new OsmXmlReaderSettings() { ReadMetadata = true, StrictMode = true }); Assert.Throws <XmlException>(() => target.Read()); }
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()); }
public void Read_ThrowsExceptionIfNodeHasNotLon() { OsmXmlReader target = new OsmXmlReader(new MemoryStream(XmlTestData.osm_node_without_lon), new OsmXmlReaderSettings() { ReadMetadata = false }); Assert.Throws <XmlException>(() => target.Read()); }
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 Load_ThrowsExceptionIfAllRelationReferencesAreNotResolvedAtTheEndOfLoadingAndIgnoreMissingIsFalse() { IOsmReader reader = new OsmXmlReader(TestDataReader.OpenOsmDB("osm-relation-invalid-ref.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); Assert.Throws <ArgumentException>(() => OsmGeometryDatabase.Load(reader, false)); }
public void Load_ThrowsExceptionIfAllRelationReferencesAreNotResolvedAtTheEndOfLoadingAndIgnoreMissingIsFalse() { IOsmReader reader = new OsmXmlReader(new MemoryStream(OsmDatabaseTestData.osm_relation_invalid_ref), new OsmXmlReaderSettings() { ReadMetadata = true }); Assert.Throws <ArgumentException>(() => OsmGeometryDatabase.Load(reader, false)); }
public void Read_ThrowsExceptionIfRelationMemberHasNotType() { OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-member-without-type.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); Assert.Throws <XmlException>(() => target.Read()); }
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_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_ReadsRelationWithRelationMember() { OsmXmlReader target = new OsmXmlReader(new MemoryStream(XmlTestData.osm_relation_relation), new OsmXmlReaderSettings() { ReadMetadata = false }); RelationInfo readRelation = target.Read() as RelationInfo; this.CompareRelation(_relationRelation, readRelation); }
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_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 XmlOsmReaderReadsFilesCreatedByOsmosis() { string xmlFile = Path.GetFullPath("TestFiles\\xmlreader-osmosis-compatibility-test-osmosis-real-file.osm"); string osmosisArguments = string.Format("--read-pbf file={0} --write-xml file={1}", Path.GetFullPath(TestFilePath), xmlFile); this.CallOsmosis(osmosisArguments); using (OsmXmlReader reader = new OsmXmlReader(xmlFile, new OsmXmlReaderSettings() { ReadMetadata = true, StrictMode = false })) { this.TestReader(reader); } }
public void Read_SkipsUnknownElements() { OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-unknown-inner-element.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); IEntityInfo result = target.Read(); Assert.NotNull(result as NodeInfo); }
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_ReadsWayWithoutNodes() { OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-way-without-nodes.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); WayInfo readWay = target.Read() as WayInfo; this.CompareWays(_wayWithoutNodes, readWay); }
public void Read_ReadsNodeWithTags() { OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-with-tags.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); NodeInfo readNode = target.Read() as NodeInfo; this.CompareNodes(_nodeTags, readNode); }
public void Read_ReadsNodeWithAllAttributes() { OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-all-properties.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); NodeInfo readNode = target.Read() as NodeInfo; this.CompareNodes(_nodeProperties, readNode); }
public void Read_ReadsSimpleNode() { OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-simple-node.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); NodeInfo readNode = target.Read() as NodeInfo; this.CompareNodes(_node, readNode); }
public void Read_ReadsRelationWithTagsAndUnknownElement() { OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-with-tags-and-unknown-element.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); RelationInfo readRelation = target.Read() as RelationInfo; this.CompareRelation(_relationTags, readRelation); }
public void Read_ReadsRelationWithAllProperties() { OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-all-properties.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); RelationInfo readRelation = target.Read() as RelationInfo; this.CompareRelation(_relationProperties, readRelation); }
public void Read_ReadsWayWithAllAttributes() { OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-way-all-properties.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); WayInfo readWay = target.Read() as WayInfo; this.CompareWays(_wayProperties, readWay); }
public void Read_ReadsRelationWithRelationMember() { OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-relation.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); RelationInfo readRelation = target.Read() as RelationInfo; this.CompareRelation(_relationRelation, readRelation); }
public void Read_ReadsWayWithUnknownElement() { OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-way-with-tags-and-unknown-element.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); WayInfo readWay = target.Read() as WayInfo; this.CompareWays(_wayTags, readWay); }
public void Read_ReadsSimpleWay() { OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-simple-way.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); WayInfo readWay = target.Read() as WayInfo; this.CompareWays(_way, readWay); }
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 Load_IOsmReader_LoadsWay() { IOsmReader reader = new OsmXmlReader(new MemoryStream(OsmDatabaseTestData.osm_way), new OsmXmlReaderSettings() { ReadMetadata = true }); OsmEntityInfoDatabase target = OsmEntityInfoDatabase.Load(reader); Assert.Equal(3, target.Nodes.Count); Assert.True(target.Nodes.Contains(1)); Assert.True(target.Nodes.Contains(2)); Assert.True(target.Nodes.Contains(3)); Assert.Equal(1, target.Ways.Count); Assert.True(target.Ways.Contains(10)); }
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 Load_CanLoadRelationsWithReferenceToRelationsNotYetCreated() { IOsmReader reader = new OsmXmlReader(new MemoryStream(OsmDatabaseTestData.osm_relation_ref_other_relation), new OsmXmlReaderSettings() { ReadMetadata = true }); OsmGeometryDatabase target = OsmGeometryDatabase.Load(reader, true); Assert.Equal(2, target.Relations.Count); Assert.True(target.Relations.Contains(100)); Assert.True(target.Relations.Contains(101)); Assert.Equal(101, target.Relations[100].Geometries[0].Member.ID); }
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); }
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); }
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_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_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_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_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_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); }
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_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 Load_LoadsRelation() { IOsmReader reader = new OsmXmlReader(new MemoryStream(OsmDatabaseTestData.osm_relation), new OsmXmlReaderSettings() { ReadMetadata = true }); OsmGeometryDatabase target = OsmGeometryDatabase.Load(reader, true); Assert.Equal(1, target.Nodes.Count); Assert.True(target.Nodes.Contains(1)); Assert.Equal(1, target.Relations.Count); Assert.True(target.Relations.Contains(100)); }
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 Dispose_ClosesOutputStreamIfWritingToStream() { MemoryStream stream = new MemoryStream(XmlTestData.osm_real_file); OsmXmlReader target = new OsmXmlReader(stream, new OsmXmlReaderSettings() { ReadMetadata = false }); target.Dispose(); Assert.False(stream.CanRead); }
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_DoesNotThrowExceptionIPieceOffMetadataIsMissingAndStrictModeIsFalse() { OsmXmlReader target = new OsmXmlReader(new MemoryStream(XmlTestData.osm_node_missing_timestamp), new OsmXmlReaderSettings() { ReadMetadata = true, StrictMode = false }); Assert.DoesNotThrow(() => target.Read()); }
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 Load_IOsmReader_LoadedRealFile() { OsmXmlReader reader = new OsmXmlReader(new MemoryStream(OsmDatabaseTestData.osm_real_file), new OsmXmlReaderSettings() { ReadMetadata = true }); OsmEntityInfoDatabase target = OsmEntityInfoDatabase.Load(reader); Assert.Equal(6688, target.Nodes.Count); Assert.Equal(740, target.Ways.Count); Assert.Equal(75, target.Relations.Count); }
public void Load_DoesNotThrowExceptionIfIgnoreMissingIsTrueAndWaysNodeIsMissing() { IOsmReader reader = new OsmXmlReader(new MemoryStream(OsmDatabaseTestData.osm_way_invalid_ref), new OsmXmlReaderSettings() { ReadMetadata = true }); OsmGeometryDatabase target = null; Assert.DoesNotThrow(() => target = OsmGeometryDatabase.Load(reader, true)); Assert.Equal(2, target.Nodes.Count); Assert.Equal(0, target.Ways.Count); }
public void Load_ThrowsExceptionIfAllRelationReferencesAreNotResolvedAtTheEndOfLoadingAndIgnoreMissingIsFalse() { IOsmReader reader = new OsmXmlReader(new MemoryStream(OsmDatabaseTestData.osm_relation_invalid_ref), new OsmXmlReaderSettings() { ReadMetadata = true }); Assert.Throws<ArgumentException>(() => OsmGeometryDatabase.Load(reader, false)); }
public void Dispose_ClosesOutputStreamIfWritingToFiles() { string filename = "../../src/Tests.SpatialLite.Osm/Data/Xml/osm-real-file.osm"; OsmXmlReader target = new OsmXmlReader(filename, new OsmXmlReaderSettings() { ReadMetadata = false }); target.Dispose(); FileStream testStream = null; Assert.DoesNotThrow(() => testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite)); testStream.Dispose(); }
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++; } } }