def test_add_vrtdataset_float(): vrt = VRTWriter() vrt.add_vrtdataset(8.0, 8.0) assert not vrt.is_valid with pytest.raises(xmlschema.XMLSchemaEncodeError): vrt.to_string()
def test_clear(): vrt = VRTWriter() vrt.add_vrtdataset(8, 8) not_empty = vrt.to_string() vrt.clear() empty = vrt.to_string() assert empty != not_empty
def test_add_geotransform(): vrt = VRTWriter() vrt.add_vrtdataset(8, 8) vrt.add_geotransform((-123.0, 0.005, 0.0, 49.0, 0.0, 0.005)) assert vrt.is_valid assert ( vrt.to_string() == b'<VRTDataset rasterXSize="8" rasterYSize="8">\n <GeoTransform>-123.0, 0.005, 0.0, 49.0, 0.0, 0.005</GeoTransform>\n</VRTDataset>\n' )
def test_add_srs_srs(): srs = create_srs() vrt = VRTWriter() vrt.add_vrtdataset(8, 8) vrt.add_srs(srs=srs) expected = b'<VRTDataset rasterXSize="8" rasterYSize="8">\n <SRS>GEOGCS[&quot;WGS 84&quot;,DATUM[&quot;WGS_1984&quot;,SPHEROID[&quot;WGS 84&quot;,6378137,298.257223563,AUTHORITY[&quot;EPSG&quot;,&quot;7030&quot;]],AUTHORITY[&quot;EPSG&quot;,&quot;6326&quot;]],PRIMEM[&quot;Greenwich&quot;,0,AUTHORITY[&quot;EPSG&quot;,&quot;8901&quot;]],UNIT[&quot;degree&quot;,0.0174532925199433,AUTHORITY[&quot;EPSG&quot;,&quot;9122&quot;]],AXIS[&quot;Latitude&quot;,NORTH],AXIS[&quot;Longitude&quot;,EAST],AUTHORITY[&quot;EPSG&quot;,&quot;4326&quot;]]</SRS>\n</VRTDataset>\n' assert vrt.is_valid assert vrt.to_string() == expected vrt.clear() vrt.add_vrtdataset(8, 8) vrt.add_srs(wkt=srs.ExportToWkt()) assert vrt.is_valid assert vrt.to_string() == expected
def test_add_geotransform_invalid(): vrt = VRTWriter() vrt.add_vrtdataset(8, 8) with pytest.raises(ValueError): vrt.add_geotransform(tuple())
def test_add_vrtdataset_invalid_subclass(): vrt = VRTWriter() with pytest.raises(ValueError): vrt.add_vrtdataset(8, 8, subclass="NotVRTWarpedDataset")
def test_add_vrtdataset_subclass(): vrt = VRTWriter() subclasses = ("VRTWarpedDataset", "VRTPansharpenedDataset") for subclass in subclasses: vrt.add_vrtdataset(8, 8, subclass=subclass) assert vrt.is_valid
def test_add_vrtdataset_int(): vrt = VRTWriter() vrt.add_vrtdataset(8, 8) assert vrt.to_string( ) == b'<VRTDataset rasterXSize="8" rasterYSize="8" />\n'