# coding: utf-8
from sqlalchemy import ARRAY, Boolean, CheckConstraint, Column, Float, Integer, Numeric, String, Table, Text, text
from geoalchemy2.types import Geometry, Raster
from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()
metadata = Base.metadata


class ConventionalLandInformation(Base):
    __tablename__ = 'Conventional_land_information'
    __table_args__ = {'comment': '常规土地信息'}

    Lon = Column(Float(53), primary_key=True, nullable=False, comment='经度-Long.(°)')
    Lat = Column(Float(53), primary_key=True, nullable=False, comment='纬度-Lat.(°)')
    Altitude = Column(Numeric, comment='海拔-Alt.(m)')
    Landform = Column(Text, comment='地貌类型')
    Landuse = Column(Text, comment='土地利用类型')
    Soiltype = Column(Text, comment='土壤类型')
    Lithologic_type = Column(Text, comment='岩性类型')


class PointInformation(Base):
    __tablename__ = 'Point_information'
    __table_args__ = {'comment': '点位信息'}

    Lon = Column(Float(53), nullable=False, comment='经度-Long.(°)')
    Lat = Column(Float(53), nullable=False, comment='纬度-Lat.(°)')
    Province = Column(Text, nullable=False)
    City = Column(Text, comment='市')
    District = Column(Text, comment='县')
    Point_id = Column(Integer, primary_key=True, server_default=text("nextval('\"Point_information_Point_id_seq\"'::regclass)"), comment='唯一编码')


class FiftyThousandSurveyDatum(Base):
    __tablename__ = 'fifty_thousand_survey_data'

    gid = Column(Integer, primary_key=True, server_default=text("nextval('fifty_thousand_survey_data_gid_seq'::regclass)"))
    id = Column(Float(53))
    dwmc = Column(String(254))
    r_dwmc = Column(String(254))
    lat = Column(Float(53))
    lon = Column(Float(53))
    xmc = Column(String(254))
    zmc = Column(String(254))
    cmc = Column(String(254))
    tql_cd = Column(Float(53))
    tql_as = Column(Float(53))
    tql_pb = Column(Float(53))
    ph = Column(Float(53))
    zzm_cd = Column(Float(53))
    zzm_as = Column(Float(53))
    zzm_pb = Column(Float(53))
    wzm_cd = Column(Float(53))
    wzm_as = Column(Float(53))
    wzm_pb = Column(Float(53))
    tcb_cd = Column(Float(53))
    tcb_as = Column(Float(53))
    tcb_pb = Column(Float(53))
    mcb_cd = Column(Float(53))
    mcb_as = Column(Float(53))
    mcb_pb = Column(Float(53))
    tzs_cd = Column(Float(53))
    tzs_as = Column(Float(53))
    tzs_pb = Column(Float(53))
    z_mzs_cd = Column(Float(53))
    z_mzs_as = Column(Float(53))
    z_mzs_pb = Column(Float(53))
    w_mzs_cd = Column(Float(53))
    w_mzs_as = Column(Float(53))
    w_mzs_pb = Column(Float(53))
    tzs_max = Column(Float(53))
    mzs_max = Column(Float(53))
    s_tfj_max = Column(Float(53))
    s_mfj_max = Column(Float(53))
    h_tfj_max = Column(Float(53))
    h_mfj_max = Column(Float(53))
    s_pdtj = Column(String(254))
    h_pdtj = Column(String(254))
    s_xtfx = Column(String(254))
    h_xtfx = Column(String(254))
    mzs_cd_max = Column(Float(53))
    mzs_as_max = Column(Float(53))
    mzs_pd_max = Column(Float(53))
    tzs_cd_fj = Column(Float(53))
    tzs_as_fj = Column(Float(53))
    tzs_pb_fj = Column(Float(53))
    mzs_cd_fj = Column(Float(53))
    mzs_as_fj = Column(Float(53))
    mzs_pb_fj = Column(Float(53))
    s_cd_pdtj = Column(String(254))
    s_cd_pdtj1 = Column(String(254))
    s_pb_pdtj = Column(String(254))
    s_cd_xtfx = Column(String(254))
    s_as_xtfx = Column(String(254))
    s_pb_xtfx = Column(String(254))
    s_cd_fz = Column(Float(53))
    s_as_fz = Column(Float(53))
    cd_as_pdtj = Column(String(254))
    cd_as_fhwr = Column(String(254))
    wrlx = Column(String(254))
    wrlx_pb = Column(String(254))
    cec__cmol_ = Column(Float(53))
    tom_g_kg_ = Column(Float(53))
    mmax_cd = Column(Float(53))
    mmax_as = Column(Float(53))
    mmax_pb = Column(Float(53))
    bcf_cd = Column(Float(53))
    bcf_as = Column(Float(53))
    bcf_pb = Column(Float(53))
    nl_g_kg_ = Column(Float(53))
    fl_g_kg_ = Column(Float(53))
    sl_g_kg_ = Column(Float(53))
    nl_zb = Column(Float(53))
    fl_zb = Column(Float(53))
    sl_zb = Column(Float(53))
    trlx = Column(String(254))
    dtpa_cd = Column(Float(53))
    磷酸二氢铵 = Column(Float(53))
    dtpa_pb = Column(Float(53))
    zb_cd = Column(Float(53))
    zb_as = Column(Float(53))
    zb_pb = Column(Float(53))
    tql_cr = Column(Float(53))
    tql_hg = Column(Float(53))
    f_2_00mm = Column(String(254))
    _2_1mm = Column('2_1mm', Float(53))
    _1_0_5mm = Column('1_0_5mm', Float(53))
    _0_5_0_25mm = Column('0_5_0_25mm', Float(53))
    _0_25_0_05m = Column('0_25_0_05m', Float(53))
    _0_05_0_02m = Column('0_05_0_02m', Float(53))
    _0_02_0_002 = Column('0_02_0_002', Float(53))
    f_0_002mm = Column(Float(53))
    ph_fj = Column(Float(53))
    ph_fj_2 = Column(Float(53))
    geom = Column(Geometry('POINT', from_text='ST_GeomFromEWKT', name='geometry'), index=True)


class RasterTable(Base):
    __tablename__ = 'raster_table'

    id = Column(Integer, primary_key=True, server_default=text("nextval('raster_table_id_seq'::regclass)"))
    rast = Column(Raster(from_text='raster', name='raster'), index=True)


class SpatialRefSy(Base):
    __tablename__ = 'spatial_ref_sys'
    __table_args__ = (
        CheckConstraint('(srid > 0) AND (srid <= 998999)'),
    )

    srid = Column(Integer, primary_key=True)
    auth_name = Column(String(256))
    auth_srid = Column(Integer)
    srtext = Column(String(2048))
    proj4text = Column(String(2048))


class Surveydatum(Base):
    __tablename__ = 'surveydata'

    id = Column(Float(53), primary_key=True, server_default=text("nextval('surveydata_id_seq'::regclass)"))
    dwmc = Column(String(50))
    r_dwmc = Column(String(50))
    lat = Column(Numeric(9, 6))
    lon = Column(Numeric(9, 6))
    xmc = Column(String(50))
    zmc = Column(String(50))
    cmc = Column(String(50))
    tql_cd = Column(Numeric(10, 6))
    tql_as = Column(Numeric(10, 6))
    tql_pb = Column(Numeric(10, 6))
    ph = Column(Numeric(4, 2))
    zzm_cd = Column(Numeric(10, 6))
    zzm_as = Column(Numeric(10, 6))
    zzm_pb = Column(Numeric(10, 6))
    wzm_cd = Column(Numeric(10, 6))
    wzm_as = Column(Numeric(10, 6))
    wzm_pb = Column(Numeric(10, 6))
    tcb_cd = Column(Numeric(10, 6))
    tcb_as = Column(Numeric(10, 6))
    tcb_pb = Column(Numeric(10, 6))
    mcb_cd = Column(Numeric(10, 6))
    mcb_as = Column(Numeric(10, 6))
    mcb_pb = Column(Numeric(10, 6))
    tzs_cd = Column(Numeric(10, 6))
    tzs_as = Column(Numeric(10, 6))
    tzs_pb = Column(Numeric(10, 6))
    z_mzs_cd = Column(Numeric(10, 6))
    z_mzs_as = Column(Numeric(10, 6))
    z_mzs_pb = Column(Numeric(10, 6))
    w_mzs_cd = Column(Numeric(10, 6))
    w_mzs_as = Column(Numeric(10, 6))
    w_mzs_pb = Column(Numeric(10, 6))
    tzs_max = Column(Numeric(10, 6))
    mzs_max = Column(Numeric(10, 6))
    s_tfj_max = Column(Numeric(10, 6))
    s_mfj_max = Column(Numeric(10, 6))
    h_tfj_max = Column(Numeric(10, 6))
    h_mfj_max = Column(Numeric(10, 6))
    s_pdtj = Column(String(10))
    h_pdtj = Column(String(10))
    s_xtfx = Column(String(50))
    h_xtfx = Column(String(50))
    cec_cmol = Column(Numeric(10, 6))
    tom_g_kg = Column(Numeric(10, 6))
    trlx = Column(String(50))
    dtpa_cd = Column(Numeric(10, 6))
    dtpa_pb = Column(Numeric(10, 6))
    geom = Column(Geometry('POINT', 4326, from_text='ST_GeomFromEWKT', name='geometry'), index=True)
    mzs_cd_max = Column(Float(53))
    mzs_as_max = Column(Float(53))
    mzs_pd_max = Column(Float(53))
    tzs_cd_fj = Column(Float(53))
    tzs_as_fj = Column(Float(53))
    tzs_pb_fj = Column(Float(53))
    mzs_cd_fj = Column(Float(53))
    mzs_as_fj = Column(Float(53))
    mzs_pb_fj = Column(Float(53))
    s_cd_pdtj = Column(String)
    s_cd_pdtj1 = Column(String)
    s_pb_pdtj = Column(String)
    s_cd_xtfx = Column(String)
    s_as_xtfx = Column(String)
    s_pb_xtfx = Column(String)
    s_cd_fz = Column(Float(53))
    s_as_fz = Column(Float(53))
    cd_as_pdtj = Column(String)
    cd_as_fhwr = Column(String)
    wrlx = Column(String)
    wrlx_pb = Column(String)
    cec__cmol_ = Column(Float(53))
    tom_g_kg_ = Column(Float(53))
    mmax_cd = Column(Float(53))
    mmax_as = Column(Float(53))
    mmax_pb = Column(Float(53))
    bcf_cd = Column(Float(53))
    bcf_as = Column(Float(53))
    bcf_pb = Column(Float(53))
    nl_g_kg_ = Column(Float(53))
    fl_g_kg_ = Column(Float(53))
    sl_g_kg_ = Column(Float(53))
    nl_zb = Column(Float(53))
    fl_zb = Column(Float(53))
    sl_zb = Column(Float(53))
    磷酸二氢铵 = Column(Float(53))
    zb_cd = Column(Float(53))
    zb_as = Column(Float(53))
    zb_pb = Column(Float(53))
    tql_cr = Column(Float(53))
    tql_hg = Column(Float(53))
    f_2_00mm = Column(String)
    _2_1mm = Column('2_1mm', Float(53))
    _1_0_5mm = Column('1_0_5mm', Float(53))
    _0_5_0_25mm = Column('0_5_0_25mm', Float(53))
    _0_25_0_05m = Column('0_25_0_05m', Float(53))
    _0_05_0_02m = Column('0_05_0_02m', Float(53))
    _0_02_0_002 = Column('0_02_0_002', Float(53))
    f_0_002mm = Column(Float(53))
    ph_fj = Column(Float(53))
    ph_fj_2 = Column(Float(53))


class UnitCeil(Base):
    __tablename__ = 'unit_ceil'

    gid = Column(Integer, primary_key=True, server_default=text("nextval('unit_ceil_gid_seq'::regclass)"))
    OBJECTID = Column(Float(53))
    BSM = Column(String(20))
    PXZQDM = Column(String(2))
    PXZQMC = Column(String(50))
    CXZQDM = Column(String(4))
    CXZQMC = Column(String(50))
    SUM_NYDTBM = Column(Numeric)
    XCDYBM = Column(String(20))
    Shape_Leng = Column(Numeric)
    Shape_Area = Column(Numeric)
    geom = Column(Geometry('GEOMETRYZM', 4490, 4, from_text='ST_GeomFromEWKT', name='geometry'), index=True)