def toStr(self): # PYCHOK expected '''Return this reference frame as a text string. @return: This L{RefFrame}'s attributes (C{str}). ''' e = self.ellipsoid t = ('%s=%r' % (_name_, self.name), '%s=%s' % (_epoch_, fstrzs('%.3F' % (self.epoch,))), '%s=%s(%s=%r)' % (_ellipsoid_, classname(e), _name_, e.name)) return _COMMA_SPACE_.join(t)
def toStr(self): # PYCHOK expected '''Return this reference frame as a text string. @return: This L{RefFrame}'s attributes (C{str}). ''' e = self.ellipsoid t = ('name=%r' % (self.name, ), 'epoch=%s' % (fstrzs('%.3F' % (self.epoch, )), ), 'ellipsoid=%s(name=%r)' % (classname(e), e.name)) return ', '.join(t)
def degDMS(deg, prec=6, s_D=S_DEG, s_M=S_MIN, s_S=S_SEC, neg=_MINUS_, pos=NN): '''Convert degrees to a string in degrees, minutes B{I{or}} seconds. @arg deg: Value in degrees (C{scalar}). @kwarg prec: Optional number of decimal digits (0..9 or C{None} for default). Trailing zero decimals are stripped for B{C{prec}} values of 1 and above, but kept for negative B{C{prec}}. @kwarg s_D: Symbol for degrees (C{str}). @kwarg s_M: Symbol for minutes (C{str}) or C{""}. @kwarg s_S: Symbol for seconds (C{str}) or C{""}. @kwarg neg: Optional sign for negative (C{'-'}). @kwarg pos: Optional sign for positive (C{''}). @return: I{Either} degrees, minutes B{I{or}} seconds (C{str}). ''' try: deg = float(deg) except (TypeError, ValueError) as x: raise _ValueError(deg=deg, txt=str(x)) d, s = abs(deg), s_D if d < 1: if s_M: d *= _60_0 if d < 1 and s_S: d *= _60_0 s = s_S else: s = s_M elif s_S: d *= 3600 s = s_S n = neg if deg < 0 else pos z = int(prec) t = NN(n, Fmt.F(d, prec=abs(z))) if z > 1: t = fstrzs(t) return NN(t, s)
def fStrzs(floatstr): # PYCHOK no cover '''DEPRECATED, use function L{fstrzs}. ''' from pygeodesy.streprs import fstrzs return fstrzs(floatstr)
def _toDMS(deg, form, prec, sep, ddd, suff): # MCCABE 15 by .units.py '''(INTERNAL) Convert degrees to C{str}, with/-out sign and/or suffix. ''' try: deg = float(deg) except (TypeError, ValueError) as x: raise _ValueError(deg=deg, txt=str(x)) form = form.lower() sign = form[:1] if sign in _PLUSMINUS_: form = form[1:] else: sign = S_NUL if prec is None: z = p = _F_prec.get(form, 6) else: z = int(prec) p = abs(z) w = p + (1 if p else 0) d = abs(deg) if form in _F_symb: s_deg = s_min = s_sec = S_NUL # no symbols else: s_deg, s_min, s_sec = S_DEG, S_MIN, S_SEC F = _F_case.get(form, F_DMS) if F is F_DMS: # 'deg+min+sec' d, s = divmod(round(d * _3600_0, p), _3600_0) m, s = divmod(s, _60_0) t = NN(_0wpF(ddd, 0, d), s_deg, sep, _0wpF(2, 0, m), s_min, sep, _0wpF(w + 2, p, s)) s = s_sec elif F is F_DM: # 'deg+min' d, m = divmod(round(d * _60_0, p), _60_0) t = NN(_0wpF(ddd, 0, d), s_deg, sep, _0wpF(w + 2, p, m)) s = s_min elif F is F_D: # 'deg' t = _0wpF(ddd + w, p, d) s = s_deg elif F is F_RAD: t = NN(_PERCENTDOTSTAR_, 'F') % (p, radians(d)) s = S_RAD else: # F in (F__E, F__F, F__G) t = NN(_PERCENTDOTSTAR_, F) % (p, d) s = S_NUL if z > 1: t = fstrzs(t, ap1z=F is F__G) if sign: if deg < 0: t = _MINUS_ + t elif deg > 0 and sign == _PLUS_: t = _PLUS_ + t elif suff: # and deg: # zero suffix? s += sep + suff return t + s