feat: 新增弱覆盖占比专题图
This commit is contained in:
@@ -77,6 +77,25 @@ class ContinuousHeatmapTest(unittest.TestCase):
|
||||
self.assertEqual(colors[0, 4].tolist(), list(main.CONTINUOUS_HEATMAP_RED))
|
||||
|
||||
|
||||
class WeakCoverRatioTest(unittest.TestCase):
|
||||
def test_fixed_percentage_color_boundaries(self):
|
||||
values = np.array([[0.0, 5.0, 5.01, 9.99, 10.0, 19.99, 20.0, 100.0]], dtype=np.float32)
|
||||
colors = main.weak_cover_ratio_rgb_for_values(values)
|
||||
self.assertEqual(
|
||||
colors.tolist(),
|
||||
[[
|
||||
list(main.WEAK_COVER_RATIO_GREEN),
|
||||
list(main.WEAK_COVER_RATIO_GREEN),
|
||||
list(main.WEAK_COVER_RATIO_BLUE),
|
||||
list(main.WEAK_COVER_RATIO_BLUE),
|
||||
list(main.WEAK_COVER_RATIO_YELLOW),
|
||||
list(main.WEAK_COVER_RATIO_YELLOW),
|
||||
list(main.WEAK_COVER_RATIO_RED),
|
||||
list(main.WEAK_COVER_RATIO_RED),
|
||||
]],
|
||||
)
|
||||
|
||||
|
||||
class SpatialNameIndexTest(unittest.TestCase):
|
||||
def test_largest_intersection_wins(self):
|
||||
geometries = [box(0, 0, 1, 1), box(0, 0, 2, 2)]
|
||||
@@ -178,6 +197,7 @@ class QgisProjectTest(unittest.TestCase):
|
||||
<mapcanvas name="mAreaCanvas"><extent><xmin>100</xmin><ymin>100</ymin><xmax>200</xmax><ymax>200</ymax></extent></mapcanvas>
|
||||
<projectlayers>
|
||||
<maplayer><layername>BuildingInfo</layername><datasource>./BuildingInfo.gpkg|layername=BuildingInfo</datasource><extent><xmin>0</xmin><ymin>0</ymin><xmax>1</xmax><ymax>1</ymax></extent></maplayer>
|
||||
<maplayer><layername>弱覆盖占比</layername><datasource>./弱覆盖占比.tif</datasource><extent><xmin>100</xmin><ymin>100</ymin><xmax>200</xmax><ymax>200</ymax></extent><wgs84extent><xmin>100</xmin><ymin>100</ymin><xmax>200</xmax><ymax>200</ymax></wgs84extent></maplayer>
|
||||
</projectlayers>
|
||||
</qgis>'''
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
@@ -203,9 +223,16 @@ class QgisProjectTest(unittest.TestCase):
|
||||
canvas = project.find(".//mapcanvas[@name='theMapCanvas']/extent")
|
||||
overview = project.find(".//mapcanvas[@name='mAreaCanvas']/extent")
|
||||
building_layer = project.find(".//projectlayers/maplayer/extent")
|
||||
ratio_layer = next(
|
||||
layer
|
||||
for layer in project.findall(".//projectlayers/maplayer")
|
||||
if layer.findtext("datasource") == "./弱覆盖占比.tif"
|
||||
)
|
||||
self.assertEqual(read_extent(canvas), (9, 19, 31, 41))
|
||||
self.assertEqual(read_extent(overview), (100, 100, 200, 200))
|
||||
self.assertEqual(read_extent(building_layer), (10, 20, 30, 40))
|
||||
self.assertEqual(read_extent(ratio_layer.find("extent")), (0, 0, 1, 1))
|
||||
self.assertEqual(read_extent(ratio_layer.find("wgs84extent")), (0, 0, 1, 1))
|
||||
self.assertEqual(result["extent_source"], "building_info")
|
||||
self.assertEqual(result["canvas_extent"], [9.0, 19.0, 31.0, 41.0])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user