def __create_lookat(self): if not len(self.server.locations): return '' begin = format_iso_time(min(self.server.locations)) end = format_iso_time(max(self.server.locations)) lat = [y for y, _x, _z in self.server.locations.itervalues()] lon = [x for _y, x, _z in self.server.locations.itervalues()] latMin = min(lat) latMax = max(lat) lonMin = min(lon) lonMax = max(lon) latCen = (latMax + latMin) / 2 lonCen = (lonMax + lonMin) / 2 dist = haversine(latMin, latMax, lonMin, lonMax) dist = limit(dist, 100, 50000) lookAt = ('\t\t<LookAt>\n' '\t\t\t<latitude>{}</latitude>\n' '\t\t\t<longitude>{}</longitude>\n' '\t\t\t<altitudeMode>clampToGround</altitudeMode>\n' '\t\t\t<range>{}</range>\n' '\t\t\t<gx:TimeSpan>\n' '\t\t\t\t<begin>{}</begin>\n' '\t\t\t\t<end>{}</end>\n' '\t\t\t</gx:TimeSpan>\n' '\t\t</LookAt>\n').\ format(latCen, lonCen, dist * 2, begin, end) return lookAt
def __set_dev_grid(self): self.gridDev.Unbind(grid.EVT_GRID_EDITOR_CREATED) self.Unbind(grid.EVT_GRID_CELL_LEFT_CLICK) if wx.VERSION >= (3, 0, 0, 0): self.Unbind(grid.EVT_GRID_CELL_CHANGED) self.gridDev.ClearGrid() i = 0 for device in self.devices: self.gridDev.SetReadOnly(i, self.COL_SEL, True) self.gridDev.SetCellRenderer(i, self.COL_SEL, TickCellRenderer()) self.gridDev.SetCellValue(i, self.COL_NAME, device.name) cell = grid.GridCellChoiceEditor(sorted(DeviceGPS.TYPE), allowOthers=False) self.gridDev.SetCellValue(i, self.COL_TYPE, DeviceGPS.TYPE[device.type]) self.gridDev.SetCellEditor(i, self.COL_TYPE, cell) if device.type == DeviceGPS.NMEA_SERIAL: self.gridDev.SetCellValue(i, self.COL_HOST, device.get_serial_desc()) self.gridDev.SetReadOnly(i, self.COL_HOST, True) else: self.gridDev.SetCellValue(i, self.COL_HOST, device.resource) self.gridDev.SetReadOnly(i, self.COL_HOST, False) self.gridDev.SetCellValue(i, self.COL_TEST, '...') self.gridDev.SetCellAlignment(i, self.COL_SEL, wx.ALIGN_CENTRE, wx.ALIGN_CENTRE) i += 1 self.index = limit(self.index, 0, len(self.devices) - 1) self.__select_row(self.index) self.index = self.index self.gridDev.AutoSize() font = self.gridDev.GetFont() dc = wx.WindowDC(self.gridDev) dc.SetFont(font) width, _height = dc.GetTextExtent(max(DeviceGPS.TYPE, key=len)) self.gridDev.SetColSize(self.COL_TYPE, width * 1.5) self.gridDev.Bind(grid.EVT_GRID_EDITOR_CREATED, self.__on_create) self.Bind(grid.EVT_GRID_CELL_LEFT_CLICK, self.__on_click) if wx.VERSION >= (3, 0, 0, 0): self.Bind(grid.EVT_GRID_CELL_CHANGED, self.__on_change)