1- use japan_geoid:: { Geoid , MemoryGrid } ;
1+ use japan_geoid:: gsi:: MemoryGrid ;
2+ use japan_geoid:: Geoid ;
23
34/// Convert from JGD 2011 Geograhpic 3D (EPSG:6697) to WGS84 Geograhpic 3D (EPSG:4979)
45pub struct JGD2011ToWGS84 {
@@ -7,13 +8,9 @@ pub struct JGD2011ToWGS84 {
78
89impl JGD2011ToWGS84 {
910 /// Create a new instance with the embed geoid model data.
10- pub fn from_embedded_model ( ) -> Self {
11- const EMBEDDED_MODEL : & [ u8 ] = include_bytes ! ( "../examples/data/gsigeo2011_ver2_2.bin.lz4" ) ;
12- let decompressed = & lz4_flex:: decompress_size_prepended ( EMBEDDED_MODEL ) . unwrap ( ) ;
13- let mut reader = std:: io:: Cursor :: new ( decompressed) ;
14-
11+ pub fn new ( ) -> Self {
1512 Self {
16- geoid : MemoryGrid :: from_binary_reader ( & mut reader ) . unwrap ( ) ,
13+ geoid : japan_geoid :: gsi :: load_embedded_gsigeo2011 ( ) ,
1714 }
1815 }
1916
@@ -24,14 +21,20 @@ impl JGD2011ToWGS84 {
2421 }
2522}
2623
24+ impl Default for JGD2011ToWGS84 {
25+ fn default ( ) -> Self {
26+ Self :: new ( )
27+ }
28+ }
29+
2730#[ cfg( test) ]
2831mod tests {
2932 use super :: * ;
3033
3134 #[ test]
3235 fn fixtures ( ) {
3336 let ( lng_jgd, lat_jgd, elevation) = ( 138.2839817085188 , 37.12378643088312 , 0. ) ;
34- let jgd_to_wgs = JGD2011ToWGS84 :: from_embedded_model ( ) ;
37+ let jgd_to_wgs = JGD2011ToWGS84 :: new ( ) ;
3538 let ( lng_wgs, lat_wgs, ellips_height) = jgd_to_wgs. convert ( lng_jgd, lat_jgd, elevation) ;
3639 assert ! ( ( ellips_height - 39.47387115961899 ) . abs( ) < 1e-8 ) ;
3740 // (lng, lat) must not change.
0 commit comments