@@ -294,26 +294,28 @@ func (e *Ellipsoid) doSize(ps *support.ProjString) error {
294294 return nil
295295}
296296
297- func ( e * Ellipsoid ) doShape ( ps * support.ProjString ) error {
297+ func getShapeKey ( ps * support.ProjString ) ( bool , string , float64 ) {
298298
299- P := e
299+ /* Check which shape key is specified */
300300
301301 keys := []string {"rf" , "f" , "es" , "e" , "b" }
302302
303- /* Check which shape key is specified */
304- found := false
305- var foundValue float64
306- var foundKey string
307303 for _ , key := range keys {
308304 value , ok := ps .GetAsFloat (key )
309305 if ok {
310- found = true
311- foundKey = key
312- foundValue = value
313- break
306+ return true , key , value
314307 }
315308 }
316309
310+ return false , "" , 0.0
311+ }
312+
313+ func (e * Ellipsoid ) doShape (ps * support.ProjString ) error {
314+
315+ P := e
316+
317+ found , foundKey , foundValue := getShapeKey (ps )
318+
317319 /* Not giving a shape parameter means selecting a sphere, unless shape */
318320 /* has been selected previously via ellps=xxx */
319321 if ! found && P .Es != 0 {
@@ -409,6 +411,18 @@ func (e *Ellipsoid) doShape(ps *support.ProjString) error {
409411 return nil
410412}
411413
414+ func getSphereKey (ps * support.ProjString ) string {
415+ keys := []string {"R_A" , "R_V" , "R_a" , "R_g" , "R_h" , "R_lat_a" , "R_lat_g" }
416+
417+ for _ , key := range keys {
418+ if ps .ContainsKey (key ) {
419+ return key
420+ }
421+ }
422+
423+ return ""
424+ }
425+
412426func (e * Ellipsoid ) doSpherification (ps * support.ProjString ) error {
413427
414428 P := e
@@ -420,19 +434,10 @@ func (e *Ellipsoid) doSpherification(ps *support.ProjString) error {
420434 const RV4 = 5 / 72.
421435 const RV6 = 55 / 1296.
422436
423- keys := []string {"R_A" , "R_V" , "R_a" , "R_g" , "R_h" , "R_lat_a" , "R_lat_g" }
424-
425- var key string
426- found := false
427- for _ , key = range keys {
428- if ps .ContainsKey (key ) {
429- found = true
430- break
431- }
432- }
437+ key := getSphereKey (ps )
433438
434439 /* No spherification specified? Then we're done */
435- if ! found {
440+ if key == "" {
436441 return nil
437442 }
438443
0 commit comments