def __init__(self, name='', lon=0.0, lat=0.0, alt=0.0, timestamp='', parent='', bmp_index=-1): self.tree_node = None self.uuid = uuid.uuid1().__str__() self.name = name self.description = '' self.parent = parent # 父亲节点的uuid self.order_in_parent = -1 self.lon = lon self.lat = lat self.alt = alt self.timestamp = timestamp # 字符串形式的时间戳,缺省格式为:'yyyy-mm-ddThh:MM:ssZ',例如:2017-06-29T13:01:19Z self.fpx = transform.get_fpx_from_longitude(self.lon) self.fpy = transform.get_fpy_from_latitude(self.lat) self.bmp_index = bmp_index self.is_visible = True self.timestamp_local = None self.timestamp_utc = None if timestamp: self.set_timestamp_from_str(timestamp) self.spx = None self.spy = None
def compute_coordinate(self, original=True): if not original: self._corner1_fpx_wgs84 = transform.get_fpx_from_longitude(self._corner1_lon_wgs84) self._corner1_fpy_wgs84 = transform.get_fpy_from_latitude(self._corner1_lat_wgs84) self._corner2_fpx_wgs84 = transform.get_fpx_from_longitude(self._corner2_lon_wgs84) self._corner2_fpy_wgs84 = transform.get_fpy_from_latitude(self._corner2_lat_wgs84) self._corner1_lon_gcj02, self._corner1_lat_gcj02 = jiupian.wgs84_to_gcj02(self._corner1_lon_wgs84, self._corner1_lat_wgs84) self._corner1_fpx_gcj02 = transform.get_fpx_from_longitude(self._corner1_lon_gcj02) self._corner1_fpy_gcj02 = transform.get_fpy_from_latitude(self._corner1_lat_gcj02) self._corner2_lon_gcj02, self._corner2_lat_gcj02 = jiupian.wgs84_to_gcj02(self._corner2_lon_wgs84, self._corner2_lat_wgs84) self._corner2_fpx_gcj02 = transform.get_fpx_from_longitude(self._corner2_lon_gcj02) self._corner2_fpy_gcj02 = transform.get_fpy_from_latitude(self._corner2_lat_gcj02)
def __init__(self, track_line, lon, lat, alt=0.0, timestamp=None, fpx=None, fpy=None, restore_from_db=False): self.track_line = track_line self.lon = lon self.lat = lat self.alt = alt self.timestamp = timestamp # 字符串形式的时间戳,缺省格式为:'yyyy-mm-ddThh:MM:ssZ',例如:2017-06-29T13:01:19Z self.spx = None # 屏幕像素坐标,地图变化时会变动 self.spy = None self.timestamp_local = None self.timestamp_utc = None if restore_from_db: self.fpx = fpx self.fpy = fpy else: self.set_timestamp_from_str() self.fpx = transform.get_fpx_from_longitude(self.lon) self.fpy = transform.get_fpy_from_latitude(self.lat)
def __init__(self, path, db_record=None): if db_record: self.restore_from_db_record(db_record) return self.uuid = uuid.uuid1().__str__() self.name = os.path.basename(path) self.path = path self.lon = None self.lat = None self.alt = None self.timestamp = None self.bmp = None self.fpx = None self.fpy = None self.spx = None self.spy = None self.img_direction = None exif_info = {} gps_info = {} if not os.path.isfile(self.path): return pil_image = PIL.Image.open(self.path) if hasattr(pil_image, '_getexif'): exif = pil_image._getexif() if exif: for tag, value in exif.items(): tag_name = TAGS.get(tag, tag) exif_info[tag_name] = value if 'GPSInfo' in exif_info: for tag, value in exif_info['GPSInfo'].items(): tag_name = GPSTAGS.get(tag, tag) gps_info[tag_name] = value if not gps_info: return lon_ref = gps_info.get('GPSLongitudeRef') lat_ref = gps_info.get('GPSLatitudeRef') if not lon_ref or not lat_ref: return lon_d, lon_m, lon_s = gps_info.get('GPSLongitude') self.lon = lon_d[0] / lon_d[1] + lon_m[0] / lon_m[1] / 60 + lon_s[ 0] / lon_s[1] / 3600 if lon_ref == 'W': self.lon = 0 - self.lon lat_d, lat_m, lat_s = gps_info.get('GPSLatitude') self.lat = lat_d[0] / lat_d[1] + lat_m[0] / lat_m[1] / 60 + lat_s[ 0] / lat_s[1] / 3600 if lat_ref == 'S': self.lat = 0 - self.lat alt = gps_info.get('GPSAltitude') if alt: self.alt = alt[0] / alt[1] img_direction = gps_info.get('GPSImgDirection') if img_direction: self.img_direction = img_direction[0] / img_direction[1] self.timestamp = exif_info.get('DateTimeDigitized') pil_image32 = PIL.Image.new('RGBX', (32, 32), color=255) pil_image30 = pil_image.resize((30, 30)) pil_image32.paste(pil_image30, (1, 1)) img = wx.Image(32, 32) img.SetData(pil_image32.convert('RGB').tobytes()) self.bmp = wx.Bitmap(img) self.fpx = transform.get_fpx_from_longitude(self.lon) self.fpy = transform.get_fpy_from_latitude(self.lat)