def format(self, altitude=None, deg_char='', min_char='m', sec_char='s'): latitude = "%s %s" % (format.format_degrees( abs(self.latitude), symbols={ 'deg': deg_char, 'arcmin': min_char, 'arcsec': sec_char }), self.latitude >= 0 and 'N' or 'S') longitude = "%s %s" % (format.format_degrees( abs(self.longitude), symbols={ 'deg': deg_char, 'arcmin': min_char, 'arcsec': sec_char }), self.longitude >= 0 and 'E' or 'W') coordinates = [latitude, longitude] if altitude is None: altitude = bool(self.altitude) if altitude: if not isinstance(altitude, string_compare): altitude = 'km' coordinates.append(self.format_altitude(altitude)) return ", ".join(coordinates)
def format(self, altitude=None, deg_char='', min_char='m', sec_char='s'): """ Format decimal degrees (DD) to degrees minutes seconds (DMS) """ latitude = "%s %s" % ( format_degrees(abs(self.latitude), symbols={ 'deg': deg_char, 'arcmin': min_char, 'arcsec': sec_char }), self.latitude >= 0 and 'N' or 'S' ) longitude = "%s %s" % ( format_degrees(abs(self.longitude), symbols={ 'deg': deg_char, 'arcmin': min_char, 'arcsec': sec_char }), self.longitude >= 0 and 'E' or 'W' ) coordinates = [latitude, longitude] if altitude is None: altitude = bool(self.altitude) if altitude: if not isinstance(altitude, string_compare): altitude = 'km' coordinates.append(self.format_altitude(altitude)) return ", ".join(coordinates)
def update_display(self): if self._lcdplate.is_pressed(LCD_BTN_SELECT): self._dispmode += 1 self._lcdplate.clear() if self._dispmode == StationServer.DISPMODE_COUNT: self._dispmode = 0 if self._dispmode == StationServer.DISPMODE_PRESSURE_HUMIDITY: self._lcdplate.set_color(0.0, 0.0, 1.0) self._lcdplate.set_cursor(0, 0) self._lcdplate.message("Hum: {0:.2f} {1} ".format( StationServer.DATA["hih3610"]["humidity"], StationServer.DATA["hih3610"]["humidity_uom"].encode( "ascii", "ignore"))) self._lcdplate.set_cursor(0, 1) self._lcdplate.message("Pres: {0:.2f} {1} ".format( StationServer.DATA["ms5534"]["pressure"], StationServer.DATA["ms5534"]["pressure_uom"].encode( "ascii", "ignore"))) elif self._dispmode == StationServer.DISPMODE_TEMPERATURE_ANALOG: self._lcdplate.set_color(1.0, 0.0, 0.0) self._lcdplate.set_cursor(0, 0) self._lcdplate.message("Ta1: {0:.2f} {1} ".format( StationServer.DATA["lm35_1"]["temperature"], StationServer.DATA["lm35_1"]["temperature_uom"].encode( "ascii", "ignore"))) self._lcdplate.set_cursor(0, 1) self._lcdplate.message("Ta2: {0:.2f} {1} ".format( StationServer.DATA["lm35_2"]["temperature"], StationServer.DATA["lm35_2"]["temperature_uom"].encode( "ascii", "ignore"))) elif self._dispmode == StationServer.DISPMODE_TEMPERATURE_DIGITAL: self._lcdplate.set_color(1.0, 1.0, 0.0) self._lcdplate.set_cursor(0, 0) self._lcdplate.message("Tdt: {0:.2f} {1} ".format( StationServer.DATA["ds1624"]["temperature"], StationServer.DATA["ds1624"]["temperature_uom"].encode( "ascii", "ignore"))) self._lcdplate.set_cursor(0, 1) self._lcdplate.message("Tps: {0:.2f} {1} ".format( StationServer.DATA["ms5534"]["temperature"], StationServer.DATA["ms5534"]["temperature_uom"].encode( "ascii", "ignore"))) elif self._dispmode == StationServer.DISPMODE_GPS: self._lcdplate.set_color(0.0, 1.0, 0.0) self._lcdplate.set_cursor(0, 0) dms_format = "%(degrees)dd %(minutes)dm %(seconds)ds" latitude = "N/A" longitude = "N/A" if "lat" in StationServer.DATA["gps"]["TPV"].keys(): latitude = format_degrees( StationServer.DATA["gps"]["TPV"]["lat"], fmt=dms_format) if "lon" in StationServer.DATA["gps"]["TPV"].keys(): longitude = format_degrees( StationServer.DATA["gps"]["TPV"]["lon"], fmt=dms_format) self._lcdplate.message("La: {0} ".format(latitude)) self._lcdplate.set_cursor(0, 1) self._lcdplate.message("Ln: {0} ".format(longitude))
def test_format(self): """ format_degrees """ self.assertEqual( format_degrees(Point.parse_degrees('-13', '19', 0)), "-13 19\' 0.0\"" )
def format(self, altitude=None, deg_char='', min_char='m', sec_char='s'): latitude = "%s %s" % ( format.format_degrees(abs(self.latitude), symbols = {'deg': deg_char, 'arcmin': min_char, 'arcsec': sec_char}), self.latitude >= 0 and 'N' or 'S' ) longitude = "%s %s" % ( format.format_degrees(abs(self.longitude), symbols = {'deg': deg_char, 'arcmin': min_char, 'arcsec': sec_char}), self.longitude >= 0 and 'E' or 'W' ) coordinates = [latitude, longitude] if altitude is None: altitude = bool(self.altitude) if altitude: if not isinstance(altitude, basestring): altitude = 'km' coordinates.append(self.format_altitude(altitude)) return ", ".join(coordinates)
def format(self, altitude=None, deg_char='', min_char='m', sec_char='s'): """ Format decimal degrees (DD) to degrees minutes seconds (DMS):: >>> p = Point(41.5, -81.0, 12.3) >>> p.format() '41 30m 0s N, 81 0m 0s W, 12.3km' >>> p = Point(41.5, 0, 0) >>> p.format() '41 30m 0s N, 0 0m 0s E' See also :meth:`.format_unicode`. :param bool altitude: Whether to include ``altitude`` value. By default it is automatically included if it is non-zero. """ latitude = "%s %s" % (format_degrees(abs(self.latitude), symbols={ 'deg': deg_char, 'arcmin': min_char, 'arcsec': sec_char }), self.latitude >= 0 and 'N' or 'S') longitude = "%s %s" % (format_degrees(abs(self.longitude), symbols={ 'deg': deg_char, 'arcmin': min_char, 'arcsec': sec_char }), self.longitude >= 0 and 'E' or 'W') coordinates = [latitude, longitude] if altitude is None: altitude = bool(self.altitude) if altitude: if not isinstance(altitude, str): altitude = 'km' coordinates.append(self.format_altitude(altitude)) return ", ".join(coordinates)
def test_format(self): """ format_degrees """ self.assertEqual(format_degrees(Point.parse_degrees("-13", "19", 0)), "-13 19' 0.0\"")
def test_format(self): """ format_degrees """ self.assertEqual(format_degrees(Point.parse_degrees('-13', '19', 0)), "-13 19\' 0.0\"")
def test_format_float_precision(input, expected): assert format_degrees(Point.parse_degrees(*input)) == expected
def test_format_simple(input, expected): assert format_degrees(Point.parse_degrees(*input)) == expected