@@ -254,6 +254,14 @@ private function formatCoordinate( $degrees, $precision ) {
254254 return $ this ->getInFloatFormat ( $ degrees );
255255 }
256256
257+ if ( $ format !== self ::TYPE_DD ) {
258+ if ( $ precision >= 1 - 1 / 60 && $ precision < 1 ) {
259+ $ precision = 1 ;
260+ } elseif ( $ precision >= 1 / 60 - 1 / 3600 && $ precision < 1 / 60 ) {
261+ $ precision = 1 / 60 ;
262+ }
263+ }
264+
257265 if ( $ format === self ::TYPE_DD || $ precision >= 1 ) {
258266 return $ this ->getInDecimalDegreeFormat ( $ degrees , $ precision );
259267 }
@@ -321,9 +329,11 @@ private function getInDecimalDegreeFormat( $floatDegrees, $precision ) {
321329 private function getInDegreeMinuteSecondFormat ( $ floatDegrees , $ precision ) {
322330 $ isNegative = $ floatDegrees < 0 ;
323331 $ secondDigits = $ this ->getSignificantDigits ( 3600 , $ precision );
332+
324333 $ seconds = round ( abs ( $ floatDegrees ) * 3600 , max ( 0 , $ secondDigits ) );
325334 $ minutes = (int )( $ seconds / 60 );
326335 $ degrees = (int )( $ minutes / 60 );
336+
327337 $ seconds -= $ minutes * 60 ;
328338 $ minutes -= $ degrees * 60 ;
329339
@@ -353,8 +363,10 @@ private function getInDegreeMinuteSecondFormat( $floatDegrees, $precision ) {
353363 private function getInDecimalMinuteFormat ( $ floatDegrees , $ precision ) {
354364 $ isNegative = $ floatDegrees < 0 ;
355365 $ minuteDigits = $ this ->getSignificantDigits ( 60 , $ precision );
366+
356367 $ minutes = round ( abs ( $ floatDegrees ) * 60 , max ( 0 , $ minuteDigits ) );
357368 $ degrees = (int )( $ minutes / 60 );
369+
358370 $ minutes -= $ degrees * 60 ;
359371
360372 $ space = $ this ->getSpacing ( self ::OPT_SPACE_COORDPARTS );
0 commit comments