@@ -79,7 +79,7 @@ Please follow:
7979}
8080
8181struct AreaRings {
82- area_code : codes:: Area ,
82+ 地震情報細分区域 : codes:: 地震情報細分区域 ,
8383 bounding_box : BoundingBox < GeoDegree > ,
8484 rings : Vec < Ring > ,
8585}
@@ -89,14 +89,17 @@ impl AreaRings {
8989 let Shape :: Polygon ( polygon) = shape else {
9090 return None ;
9191 } ;
92- let area_code: codes:: Area = match record. get ( "code" ) . unwrap ( ) {
92+
93+ let 地震情報細分区域: codes:: 地震情報細分区域 = match record. get ( "code" ) . unwrap ( ) {
9394 FieldValue :: Character ( Some ( c) ) => match c. parse ( ) {
94- Ok ( c) => c ,
95+ Ok ( c) => codes :: 地震情報細分区域 ( c ) ,
9596 Err ( _) => panic ! ( "コワッ…コワれたshapefileきた!" ) ,
9697 } ,
97- FieldValue :: Character ( None ) => codes:: UNNUMBERED_AREA , // 北方領土・諸外国等がNoneになる
98+
99+ FieldValue :: Character ( None ) => codes:: 地震情報細分区域:: UNNUMBERED , // 北方領土・諸外国等がNoneになる
98100 _ => panic ! ( "知らないshapefileきた?🤔" ) ,
99101 } ;
102+
100103 let bounding_box = ( * polygon. bbox ( ) ) . into ( ) ;
101104 let rings = polygon
102105 . rings ( )
@@ -105,7 +108,7 @@ impl AreaRings {
105108 . collect ( ) ;
106109
107110 Some ( Self {
108- area_code ,
111+ 地震情報細分区域 ,
109112 bounding_box,
110113 rings,
111114 } )
@@ -119,20 +122,20 @@ pub(crate) struct PointReferences<'a> {
119122impl < ' a > PointReferences < ' a > {
120123 fn tally_of (
121124 shapefile : & ' a Shapefile ,
122- area_to_pref : & ' a HashMap < codes:: Area , codes:: Pref > ,
125+ area_to_pref : & ' a HashMap < codes:: 地震情報細分区域 , codes:: 地震情報都道府県等 > ,
123126 ) -> Self {
124127 let mut map: HashMap < Point , PointReference > = HashMap :: new ( ) ;
125128
126129 shapefile. entries . iter ( ) . for_each ( |area_rings| {
127- let area_code = area_rings. area_code ;
130+ let 地震情報細分区域 = area_rings. 地震情報細分区域 ;
128131
129132 area_rings. rings . iter ( ) . for_each ( |ring| {
130133 ring. iter_adjacent_points ( ) . for_each ( |point_set| {
131134 let reference = map
132135 . entry ( point_set. current )
133136 . or_insert ( PointReference :: new ( area_to_pref) ) ;
134137
135- reference. mark_area ( area_code ) ;
138+ reference. mark_area ( 地震情報細分区域 ) ;
136139 reference. mark_point ( point_set. previous ) ;
137140 reference. mark_point ( point_set. next ) ;
138141 } ) ;
@@ -162,38 +165,41 @@ impl<'a> PointReferences<'a> {
162165}
163166
164167pub ( crate ) struct PointReference < ' a > {
165- area_to_pref : & ' a HashMap < codes:: Area , codes:: Pref > ,
166- areas : HashSet < codes:: Area > ,
168+ area_to_pref : & ' a HashMap < codes:: 地震情報細分区域 , codes:: 地震情報都道府県等 > ,
169+ areas : HashSet < codes:: 地震情報細分区域 > ,
167170 adjacent_points : HashSet < Point > ,
168171}
169172
170173impl < ' a > PointReference < ' a > {
171- fn new ( area_to_pref : & ' a HashMap < codes:: Area , codes:: Pref > ) -> Self {
174+ fn new (
175+ area_to_pref : & ' a HashMap < codes:: 地震情報細分区域 , codes:: 地震情報都道府県等 >
176+ ) -> Self {
172177 Self {
173178 area_to_pref,
174179 areas : HashSet :: new ( ) ,
175180 adjacent_points : HashSet :: new ( ) ,
176181 }
177182 }
178183
179- fn mark_area ( & mut self , area : codes:: Area ) {
184+ fn mark_area ( & mut self , area : codes:: 地震情報細分区域 ) {
180185 self . areas . insert ( area) ;
181186 }
182187
183188 fn mark_point ( & mut self , point : Point ) {
184189 self . adjacent_points . insert ( point) ;
185190 }
186191
187- fn area_references ( & self ) -> & HashSet < codes:: Area > {
192+ fn area_references ( & self ) -> & HashSet < codes:: 地震情報細分区域 > {
188193 & self . areas
189194 }
190195
191- pub ( crate ) fn pref_references ( & self ) -> HashSet < codes:: Pref > {
196+ pub ( crate ) fn pref_references ( & self ) -> HashSet < codes:: 地震情報都道府県等 > {
192197 let areas = self
193198 . area_references ( )
194199 . iter ( )
195- . filter ( |a| * * a != codes:: UNNUMBERED_AREA )
200+ . filter ( |a| * * a != codes:: 地震情報細分区域 :: UNNUMBERED )
196201 . map ( |a| * self . area_to_pref . get ( a) . unwrap ( ) ) ;
202+
197203 HashSet :: from_iter ( areas)
198204 }
199205
@@ -202,15 +208,18 @@ impl<'a> PointReference<'a> {
202208 }
203209}
204210pub fn read (
205- #[ allow( non_snake_case) ] area_code__pref_code : & HashMap < codes:: Area , codes:: Pref > ,
211+ #[ allow( non_snake_case) ] area_code__pref_code : & HashMap <
212+ codes:: 地震情報細分区域 ,
213+ codes:: 地震情報都道府県等 ,
214+ > ,
206215) -> (
207- HashMap < codes:: Area , BoundingBox < GeoDegree > > , // area_bounding_box
208- HashMap < codes:: Area , Vertex < GeoDegree > > , // area_centers
209- Vec < ( f32 , f32 ) > , // vertex_buffer
210- Vec < u32 > , // map_indices
211- Vec < Vec < u32 > > , // area_lines
212- Vec < Vec < u32 > > , // pref_lines
213- Vec < ( f32 , usize ) > , // scale_level_map
216+ HashMap < codes:: 地震情報細分区域 , BoundingBox < GeoDegree > > , // area_bounding_box
217+ HashMap < codes:: 地震情報細分区域 , Vertex < GeoDegree > > , // area_centers
218+ Vec < ( f32 , f32 ) > , // vertex_buffer
219+ Vec < u32 > , // map_indices
220+ Vec < Vec < u32 > > , // area_lines
221+ Vec < Vec < u32 > > , // pref_lines
222+ Vec < ( f32 , usize ) > , // scale_level_map
214223) {
215224 let shapefile = Shapefile :: new (
216225 "../assets/shapefile/earthquake_detailed/earthquake_detailed_simplified.shp" ,
@@ -220,21 +229,24 @@ pub fn read(
220229
221230 // @Siro_256 にゃ~っ…! (ΦωΦ)
222231
223- let area_centers = calculate_area_centers ( & shapefile) ;
232+ let 地震情報細分区域_centers = calculate_地震情報細分区域_centers ( & shapefile) ;
224233
225- let area_bounding_box: HashMap < codes:: Area , BoundingBox < GeoDegree > > = shapefile
226- . entries
227- . iter ( )
228- . filter ( |area_rings| area_rings. area_code != codes:: UNNUMBERED_AREA )
229- . map ( |area_rings| ( area_rings. area_code , area_rings. bounding_box ) )
230- . collect ( ) ;
234+ let 地震情報細分区域_bounding_box: HashMap < codes:: 地震情報細分区域 , BoundingBox < GeoDegree > > =
235+ shapefile
236+ . entries
237+ . iter ( )
238+ . filter ( |rings| {
239+ rings. 地震情報細分区域 != codes:: 地震情報細分区域:: UNNUMBERED
240+ } )
241+ . map ( |rings| ( rings. 地震情報細分区域 , rings. bounding_box ) )
242+ . collect ( ) ;
231243
232244 let map_indices = shapefile
233245 . entries
234246 . iter ( )
235- . flat_map ( |area_rings | & area_rings . rings )
236- . flat_map ( |r| r . triangulate ( ) )
237- . map ( |p | vertex_buffer. insert ( p . into ( ) ) as u32 )
247+ . flat_map ( |rings | & rings . rings )
248+ . flat_map ( |ring| ring . triangulate ( ) )
249+ . map ( |point | vertex_buffer. insert ( point . into ( ) ) as u32 )
238250 . collect ( ) ;
239251
240252 let references = PointReferences :: tally_of ( & shapefile, area_code__pref_code) ;
@@ -322,8 +334,8 @@ pub fn read(
322334 // (ΦωΦ) < Meow !
323335 {
324336 (
325- area_bounding_box ,
326- area_centers ,
337+ 地震情報細分区域_bounding_box ,
338+ 地震情報細分区域_centers ,
327339 vertex_buffer. into_buffer ( ) ,
328340 map_indices,
329341 area_lines,
@@ -400,58 +412,60 @@ fn gen_lod(
400412 . collect ( )
401413}
402414
403- fn calculate_area_centers ( shapefile : & Shapefile ) -> HashMap < codes:: Area , Vertex < GeoDegree > > {
415+ fn calculate_地震情報細分区域_centers (
416+ shapefile : & Shapefile ,
417+ ) -> HashMap < codes:: 地震情報細分区域 , Vertex < GeoDegree > > {
404418 use geo:: {
405419 algorithm:: { Area , Centroid } ,
406420 LineString , Polygon ,
407421 } ;
408422
409- let area_weighted_vectors : HashMap < codes:: Area , Vec < ( f64 , geo:: Point ) > > = shapefile
423+ let weighted_vectors : HashMap < codes:: 地震情報細分区域 , Vec < ( f64 , geo:: Point ) > > = shapefile
410424 . entries
411425 . iter ( )
412- . filter ( |area_rings| area_rings . area_code != codes:: UNNUMBERED_AREA )
413- . map ( |area_rings | {
414- let area_polygons : Vec < ( f64 , geo:: Point ) > = area_rings
426+ . filter ( |rings| rings . 地震情報細分区域 != codes:: 地震情報細分区域 :: UNNUMBERED )
427+ . map ( |rings | {
428+ let polygons : Vec < ( f64 , geo:: Point ) > = rings
415429 . rings
416430 . iter ( )
417431 . map ( |ring| LineString :: new ( ring. points ( ) . iter ( ) . map ( |p| p. into ( ) ) . collect_vec ( ) ) )
418432 . map ( |geo_line_string| Polygon :: new ( geo_line_string, vec ! [ ] ) )
419433 . map ( |geo_polygon| ( geo_polygon. unsigned_area ( ) , geo_polygon. centroid ( ) . unwrap ( ) ) )
420434 . collect ( ) ;
421435
422- ( area_rings . area_code , area_polygons )
436+ ( rings . 地震情報細分区域 , polygons )
423437 } )
424438 . collect ( ) ;
425439
426- let area_centers : HashMap < codes:: Area , Point > = area_weighted_vectors
440+ let centers : HashMap < codes:: 地震情報細分区域 , Point > = weighted_vectors
427441 . into_iter ( )
428- . map ( |( area_code , weighted_vectors) | {
429- let area_weight : f64 = weighted_vectors
442+ . map ( |( 地震情報細分区域 , weighted_vectors) | {
443+ let weight : f64 = weighted_vectors
430444 . iter ( )
431445 . map ( |( weight, _vector) | weight)
432446 . sum ( ) ;
433447
434- let area_vector : Point = weighted_vectors
448+ let vector : Point = weighted_vectors
435449 . iter ( )
436450 . map ( |( weight, vector) | {
437451 let vector: Point = vector. into ( ) ;
438452 vector. multiply_by ( * weight as f32 )
439453 } )
440454 . fold ( Point :: new ( 0.0 . into ( ) , 0.0 . into ( ) ) , |a, b| a + b) ;
441455
442- ( area_code , area_vector . divide_by ( area_weight as f32 ) )
456+ ( 地震情報細分区域 , vector . divide_by ( weight as f32 ) )
443457 } )
444458 . collect ( ) ;
445459
446- let area_centers : HashMap < codes:: Area , Vertex < GeoDegree > > = area_centers
460+ let centers : HashMap < codes:: 地震情報細分区域 , Vertex < GeoDegree > > = centers
447461 . into_iter ( )
448- . map ( |( area_code , center) | {
462+ . map ( |( code , center) | {
449463 (
450- area_code ,
464+ code ,
451465 Vertex :: new ( center. latitude . into ( ) , center. longitude . into ( ) ) ,
452466 )
453467 } )
454468 . collect ( ) ;
455469
456- area_centers
470+ centers
457471}
0 commit comments