@@ -122,6 +122,10 @@ impl LngLat {
122122 pub fn is_authority_code_lnglat ( string_value : & str ) -> bool {
123123 string_value == "OGC:CRS84" || string_value == "EPSG:4326"
124124 }
125+
126+ pub fn srid ( ) -> Option < u32 > {
127+ Some ( 4326 )
128+ }
125129}
126130
127131/// Implementation of an authority:code CoordinateReferenceSystem
@@ -213,6 +217,8 @@ impl CoordinateReferenceSystem for AuthorityCode {
213217 fn srid ( & self ) -> Result < Option < u32 > > {
214218 if self . authority . eq_ignore_ascii_case ( "EPSG" ) {
215219 Ok ( self . code . parse :: < u32 > ( ) . ok ( ) )
220+ } else if LngLat :: is_lnglat ( self ) {
221+ Ok ( LngLat :: srid ( ) )
216222 } else {
217223 Ok ( None )
218224 }
@@ -287,9 +293,8 @@ impl CoordinateReferenceSystem for ProjJSON {
287293 let authority_code_opt = self . to_authority_code ( ) ?;
288294 if let Some ( authority_code) = authority_code_opt {
289295 if LngLat :: is_authority_code_lnglat ( & authority_code) {
290- return Ok ( Some ( 4326 ) ) ;
291- }
292- if let Some ( ( _, code) ) = AuthorityCode :: split_auth_code ( & authority_code) {
296+ return Ok ( LngLat :: srid ( ) ) ;
297+ } else if let Some ( ( _, code) ) = AuthorityCode :: split_auth_code ( & authority_code) {
293298 return Ok ( code. parse :: < u32 > ( ) . ok ( ) ) ;
294299 }
295300 }
@@ -391,5 +396,9 @@ mod test {
391396 Some ( "EPSG:4269" . to_string( ) )
392397 ) ;
393398 assert_eq ! ( new_crs. unwrap( ) . srid( ) . unwrap( ) , Some ( 4269 ) ) ;
399+
400+ let value: Value = serde_json:: from_str ( "\" EPSG:4326\" " ) . unwrap ( ) ;
401+ let new_crs = deserialize_crs ( & value) . unwrap ( ) ;
402+ assert_eq ! ( new_crs. clone( ) . unwrap( ) . srid( ) . unwrap( ) , Some ( 4326 ) ) ;
394403 }
395404}
0 commit comments