1
1
use std:: collections:: { HashSet , VecDeque } ;
2
2
3
- use geo:: {
4
- BoundingRect , Coord , Densify , LineString , MultiPolygon , Polygon , Rect , Scale , Translate ,
5
- } ;
3
+ use geo:: { BoundingRect , Coord , Densify , LineString , MultiPolygon , Rect } ;
6
4
7
5
use crate :: { Cell , MapModel , Neighbourhood } ;
8
6
@@ -103,17 +101,15 @@ impl RenderCells {
103
101
}
104
102
}
105
103
106
- //finalize(grid, cell_colors, bounds, boundary_polygon)
107
- debug_grid ( grid, cell_colors, bounds, boundary_polygon)
104
+ if true {
105
+ finalize ( grid, cell_colors, bounds)
106
+ } else {
107
+ debug_grid ( grid, cell_colors, bounds)
108
+ }
108
109
}
109
110
}
110
111
111
- fn finalize (
112
- grid : Grid < Option < usize > > ,
113
- cell_colors : Vec < Color > ,
114
- bounds : Rect ,
115
- boundary_polygon : Polygon ,
116
- ) -> RenderCells {
112
+ fn finalize ( main_grid : Grid < Option < usize > > , cell_colors : Vec < Color > , bounds : Rect ) -> RenderCells {
117
113
let mut result = RenderCells {
118
114
polygons_per_cell : Vec :: new ( ) ,
119
115
colors : Vec :: new ( ) ,
@@ -124,9 +120,9 @@ fn finalize(
124
120
// number per cell, so we can't directly use it -- the area >= some cell index is
125
121
// meaningless. Per cell, make a new grid that just has that cell.
126
122
let grid: Grid < f64 > = Grid {
127
- width : grid . width ,
128
- height : grid . height ,
129
- data : grid
123
+ width : main_grid . width ,
124
+ height : main_grid . height ,
125
+ data : main_grid
130
126
. data
131
127
. iter ( )
132
128
. map (
@@ -143,17 +139,17 @@ fn finalize(
143
139
144
140
let smooth = false ;
145
141
let contour_builder =
146
- contour:: ContourBuilder :: new ( grid. width as u32 , grid. height as u32 , smooth) ;
142
+ contour:: ContourBuilder :: new ( grid. width as u32 , grid. height as u32 , smooth)
143
+ . x_origin ( bounds. min ( ) . x )
144
+ . y_origin ( bounds. min ( ) . y )
145
+ . x_step ( RESOLUTION_M )
146
+ . y_step ( RESOLUTION_M ) ;
147
147
let thresholds = vec ! [ 1.0 ] ;
148
148
149
149
let mut cell_polygons = Vec :: new ( ) ;
150
150
for contour in contour_builder. contours ( & grid. data , & thresholds) . unwrap ( ) {
151
151
let ( multipolygon, _) = contour. into_inner ( ) ;
152
- cell_polygons. push (
153
- multipolygon
154
- . scale ( RESOLUTION_M )
155
- . translate ( bounds. min ( ) . x , bounds. min ( ) . y ) ,
156
- ) ;
152
+ cell_polygons. push ( multipolygon) ;
157
153
}
158
154
assert_eq ! ( cell_polygons. len( ) , 1 ) ;
159
155
@@ -167,12 +163,7 @@ fn finalize(
167
163
result
168
164
}
169
165
170
- fn debug_grid (
171
- grid : Grid < Option < usize > > ,
172
- cell_colors : Vec < Color > ,
173
- bounds : Rect ,
174
- boundary_polygon : Polygon ,
175
- ) -> RenderCells {
166
+ fn debug_grid ( grid : Grid < Option < usize > > , cell_colors : Vec < Color > , bounds : Rect ) -> RenderCells {
176
167
let mut result = RenderCells {
177
168
polygons_per_cell : Vec :: new ( ) ,
178
169
colors : Vec :: new ( ) ,
0 commit comments