@@ -41,7 +41,6 @@ def parse_wkb_table(table: pa.Table) -> List[pa.Table]:
41
41
return [table ]
42
42
43
43
# Handle WKB input
44
- parsed_tables = []
45
44
crs_str = get_field_crs (field )
46
45
shapely_arr = shapely .from_wkb (column )
47
46
@@ -67,35 +66,29 @@ def parse_wkb_table(table: pa.Table) -> List[pa.Table]:
67
66
(type_ids == GeometryType .POLYGON ) | (type_ids == GeometryType .MULTIPOLYGON )
68
67
)[0 ]
69
68
70
- if len (point_indices ) > 0 :
71
- point_field , point_arr = construct_geometry_array (
72
- shapely_arr [point_indices ],
73
- crs_str = crs_str ,
74
- )
75
- point_table = table .take (point_indices ).set_column (
76
- field_idx , point_field , point_arr
77
- )
78
- parsed_tables .append (point_table )
79
-
80
- if len (linestring_indices ) > 0 :
81
- linestring_field , linestring_arr = construct_geometry_array (
82
- shapely_arr [linestring_indices ],
83
- crs_str = crs_str ,
84
- )
85
- linestring_table = table .take (linestring_indices ).set_column (
86
- field_idx , linestring_field , linestring_arr
87
- )
88
- parsed_tables .append (linestring_table )
89
-
90
- if len (polygon_indices ) > 0 :
91
- polygon_field , polygon_arr = construct_geometry_array (
92
- shapely_arr [polygon_indices ],
93
- crs_str = crs_str ,
94
- )
95
- polygon_table = table .take (polygon_indices ).set_column (
96
- field_idx , polygon_field , polygon_arr
97
- )
98
- parsed_tables .append (polygon_table )
69
+ # Here we intentionally check geometries in a specific order.
70
+ # Starting from polygons, then linestrings, then points,
71
+ # so that the order of generated layers is polygon, then path then scatterplot.
72
+ # This ensures that points are rendered on top and polygons on the bottom.
73
+ parsed_tables = []
74
+ for single_type_geometry_indices in (
75
+ polygon_indices ,
76
+ linestring_indices ,
77
+ point_indices ,
78
+ ):
79
+ if len (single_type_geometry_indices ) > 0 :
80
+ single_type_geometry_field , single_type_geometry_arr = (
81
+ construct_geometry_array (
82
+ shapely_arr [single_type_geometry_indices ],
83
+ crs_str = crs_str ,
84
+ )
85
+ )
86
+ single_type_geometry_table = table .take (
87
+ single_type_geometry_indices
88
+ ).set_column (
89
+ field_idx , single_type_geometry_field , single_type_geometry_arr
90
+ )
91
+ parsed_tables .append (single_type_geometry_table )
99
92
100
93
return parsed_tables
101
94
0 commit comments