# -*- coding: utf-8 -*-

# Define here the models for your scraped items
#
# See documentation in:
# https://docs.scrapy.org/en/latest/topics/items.html

import scrapy
import json


class AirPlaneLiveItem(scrapy.Item):
    # define the fields for your item here like:
    FlightID = scrapy.Field()  # 暂定航班id
    FlightIATA = scrapy.Field()  # iata，二字码
    Latitude = scrapy.Field()  # 纬度
    Longitude = scrapy.Field()  # 经度
    LastTime = scrapy.Field()  # 数据本身时间戳
    Height = scrapy.Field()  # 海拔
    model = scrapy.Field()  # 型号
    Speed = scrapy.Field()  # 水平速度
    Angle = scrapy.Field()  # 方位角
    source = scrapy.Field()  # 信息来源
    PlaneREG = scrapy.Field()  # 注册号
    origAirport = scrapy.Field()  # 起飞机场
    destAirport = scrapy.Field()  # 降落机场
    FlightICAO = scrapy.Field()  # icao即三字码前缀，后缀和二字码一致
    vs = scrapy.Field()  # 垂直速度
    UpdateTime = scrapy.Field()  # time.time()

    def jsonEncoder(self):
        dict = {}
        for key in self.keys():
            dict[key] = self[key]
        return json.dumps(dict)


class AirPlaneBaseItem(scrapy.Item):
    ID = scrapy.Field()  # 飞机id，guid
    MSN = scrapy.Field()  # 制造商序列号，获取不到
    Reg = scrapy.Field()  # 注册号['acr']
    ICAO = scrapy.Field()  # 所属航司icao，三字码['alic']
    Callsign = scrapy.Field()  # 呼号['sq']
    Owner = scrapy.Field()  # 所有者，一般为航空公司['alna']
    Nation = scrapy.Field()  # 所属国家
    Model = scrapy.Field()  # 机型名称['acd']
    image_urls = scrapy.Field()  # 图片地址'https://cdn.radarbox.com/photo/%s'%['th1']
    Image = scrapy.Field()
    Age = scrapy.Field()  # 机龄['acff']
    UpdateTime = scrapy.Field()  # 更新时间time.time()
    DataSource = scrapy.Field()  # 数据来源['so']
    LastTime = scrapy.Field()  # 数据本身的时间戳


class FlightBaseItem(scrapy.Item):
    FlightID = scrapy.Field()  # 航班id['fid']
    ICAO = scrapy.Field()  # ['cs']
    IATA = scrapy.Field()  # ['fnia]
    PlaneReg = scrapy.Field()  # 执行飞机注册号['acr]
    TakeoffBase = scrapy.Field()  # 起飞机场名
    TakeoffBaseICAO = scrapy.Field()  # icao
    TakeoffBaseIATA = scrapy.Field()  # iata
    LandBase = scrapy.Field()  # 降落机场名
    LandBaseICAO = scrapy.Field()  # icao
    LandBaseIATA = scrapy.Field()  # iata
    ScheduleBegTime = scrapy.Field()  # ['deps']
    ActualBegTime = scrapy.Field()  # ['depa']
    ScheduleArrTime = scrapy.Field()  # ['arrs']
    ActualArrTime = scrapy.Field()  # ['arre']
    UpdateTime = scrapy.Field()  # time.time()
    LastTime = scrapy.Field()  # 数据本身的时间戳


class PlaneRouteItem(scrapy.Item):
    Name = scrapy.Field()  # 航路名称
    StartBaseCode = scrapy.Field()  # 起始点
    EndBaseCode = scrapy.Field()  # 目的点
    Type = scrapy.Field()  # 类型（飞机航线/船舶航线）
    Navpoints = scrapy.Field()  # 航路点集合（包含全部信息）
    UpdateTime = scrapy.Field()  # 更新时间
    LastTime = scrapy.Field()  # 最后更新时间


class NavpointInfo(scrapy.Item):
    NavpointCode = scrapy.Field()  # 导航点编码
    Name = scrapy.Field()  # 导航点名称
    Longitude = scrapy.Field()  # 经度
    Latitude = scrapy.Field()  # 纬度
    Angle = scrapy.Field()  # 航向
    Seq = scrapy.Field()  # 导航点序号
    UpdateTime = scrapy.Field()  # 更新时间
    LastTime = scrapy.Field()  # 最后更新时间


class NotamInfo(scrapy.Item):
    ID = scrapy.Field()
    NotamNumber = scrapy.Field()
    IssueDate = scrapy.Field()
    Location = scrapy.Field()
    BeginningDatetime = scrapy.Field()
    EndingDateTime = scrapy.Field()
    Reason = scrapy.Field()
    Type = scrapy.Field()
    AffectedAreaType = scrapy.Field()
    AffectedAreas = scrapy.Field()
    EffectiveDates = scrapy.Field()
    Image = scrapy.Field()
    UpdateTime = scrapy.Field()
    Lasttime = scrapy.Field()
