1
- from dagster import asset , get_dagster_logger , Config
1
+ from dagster import asset , get_dagster_logger , Config , AssetExecutionContext
2
2
from pydantic import Field
3
3
4
4
from bag3d .core .assets .ahn .core import partition_definition_ahn
5
-
5
+ from bag3d . core . assets . ahn . download import LAZDownload
6
6
7
7
logger = get_dagster_logger ("ahn.index" )
8
8
@@ -22,15 +22,9 @@ class LasIndexConfig(Config):
22
22
)
23
23
24
24
25
- @asset (
26
- required_resource_keys = {"lastools" },
27
- partitions_def = partition_definition_ahn ,
28
- )
29
- def lasindex_ahn3 (context , config : LasIndexConfig , laz_files_ahn3 ):
30
- """Append a spatial index to the AHN3 LAZ file, using LASTools's `lasindex`.
31
-
32
- See https://lastools.osgeo.org/download/lasindex_README.txt.
33
- """
25
+ def run_lasindex (
26
+ context : AssetExecutionContext , config : LasIndexConfig , lazdownload : LAZDownload
27
+ ):
34
28
silent = not config .verbose
35
29
cmd_list = [
36
30
"{exe}" ,
@@ -41,51 +35,47 @@ def lasindex_ahn3(context, config: LasIndexConfig, laz_files_ahn3):
41
35
if not config .force :
42
36
cmd_list .append ("-dont_reindex" )
43
37
context .resources .lastools .app .execute (
44
- "lasindex" , " " .join (cmd_list ), local_path = laz_files_ahn3 .path , silent = silent
38
+ "lasindex" , " " .join (cmd_list ), local_path = lazdownload .path , silent = silent
45
39
)
46
40
47
41
48
42
@asset (
49
43
required_resource_keys = {"lastools" },
50
44
partitions_def = partition_definition_ahn ,
51
45
)
52
- def lasindex_ahn4 (context , config : LasIndexConfig , laz_files_ahn4 ):
46
+ def lasindex_ahn3 (
47
+ context : AssetExecutionContext , config : LasIndexConfig , laz_files_ahn3 : LAZDownload
48
+ ):
49
+ """Append a spatial index to the AHN3 LAZ file, using LASTools's `lasindex`.
50
+
51
+ See https://lastools.osgeo.org/download/lasindex_README.txt.
52
+ """
53
+ run_lasindex (context , config , laz_files_ahn3 )
54
+
55
+
56
+ @asset (
57
+ required_resource_keys = {"lastools" },
58
+ partitions_def = partition_definition_ahn ,
59
+ )
60
+ def lasindex_ahn4 (
61
+ context : AssetExecutionContext , config : LasIndexConfig , laz_files_ahn4 : LAZDownload
62
+ ):
53
63
"""Append a spatial index to the AHN4 LAZ file, using LASTools's `lasindex`.
54
64
55
65
See https://lastools.osgeo.org/download/lasindex_README.txt.
56
66
"""
57
- silent = not config .verbose
58
- cmd_list = [
59
- "{exe}" ,
60
- "-i {local_path}" ,
61
- "-tile_size" ,
62
- str (config .tile_size ),
63
- ]
64
- if not config .force :
65
- cmd_list .append ("-dont_reindex" )
66
- context .resources .lastools .app .execute (
67
- "lasindex" , " " .join (cmd_list ), local_path = laz_files_ahn4 .path , silent = silent
68
- )
67
+ run_lasindex (context , config , laz_files_ahn4 )
69
68
70
69
71
70
@asset (
72
71
required_resource_keys = {"lastools" },
73
72
partitions_def = partition_definition_ahn ,
74
73
)
75
- def lasindex_ahn5 (context , config : LasIndexConfig , laz_files_ahn5 ):
74
+ def lasindex_ahn5 (
75
+ context : AssetExecutionContext , config : LasIndexConfig , laz_files_ahn5 : LAZDownload
76
+ ):
76
77
"""Append a spatial index to the AHN5 LAZ file, using LASTools's `lasindex`.
77
78
78
79
See https://lastools.osgeo.org/download/lasindex_README.txt.
79
80
"""
80
- silent = not config .verbose
81
- cmd_list = [
82
- "{exe}" ,
83
- "-i {local_path}" ,
84
- "-tile_size" ,
85
- str (config .tile_size ),
86
- ]
87
- if not config .force :
88
- cmd_list .append ("-dont_reindex" )
89
- context .resources .lastools .app .execute (
90
- "lasindex" , " " .join (cmd_list ), local_path = laz_files_ahn5 .path , silent = silent
91
- )
81
+ run_lasindex (context , config , laz_files_ahn5 )
0 commit comments