def get_igac_property_record_card_query(names, ladm_units):
    query = {
        QueryNames.LEVEL_TABLE: {
            QueryNames.LEVEL_TABLE_NAME:
            names.LC_PLOT_T,
            QueryNames.LEVEL_TABLE_ALIAS:
            names.LC_PLOT_T,
            QueryNames.FILTER_SUB_LEVEL:
            FilterSubLevel(names.T_ID_F, names.LC_PLOT_T, names.T_ID_F),
            QueryNames.TABLE_FIELDS: [
                OwnField(
                    names.LC_PLOT_T_PLOT_AREA_F,
                    get_full_alias('Área', ladm_units, names.LC_PLOT_T,
                                   names.LC_PLOT_T_PLOT_AREA_F))
            ],
            QueryNames.LEVEL_TABLE: {
                QueryNames.LEVEL_TABLE_NAME:
                names.LC_PARCEL_T,
                QueryNames.LEVEL_TABLE_ALIAS:
                names.LC_PARCEL_T,
                QueryNames.FILTER_SUB_LEVEL:
                FilterSubLevel(names.COL_UE_BAUNIT_T_PARCEL_F,
                               names.COL_UE_BAUNIT_T,
                               names.COL_UE_BAUNIT_T_LC_PLOT_F),
                QueryNames.TABLE_FIELDS: [
                    OwnField(names.COL_BAUNIT_T_NAME_F, "Nombre"),
                    OwnField(names.LC_PARCEL_T_DEPARTMENT_F, "Departamento"),
                    OwnField(names.LC_PARCEL_T_MUNICIPALITY_F, "Municipio"),
                    OwnField(names.LC_PARCEL_T_NUPRE_F, "NUPRE"),
                    OwnField(names.LC_PARCEL_T_ID_OPERATION_F, "Id operación"),
                    OwnField(names.LC_PARCEL_T_FMI_F, "FMI"),
                    OwnField(names.LC_PARCEL_T_PARCEL_NUMBER_F,
                             "Número predial"),
                    OwnField(names.LC_PARCEL_T_PREVIOUS_PARCEL_NUMBER_F,
                             "Número predial anterior"),
                    DomainOwnField(names.LC_PARCEL_T_TYPE_F, "Tipo",
                                   names.COL_BAUNIT_TYPE_D)
                ]
            }
        }
    }

    return query
Exemple #2
0
def get_igac_legal_query(names, ladm_units):
    lc_party_contact_fields = [
        OwnField(names.LC_PARTY_CONTACT_T_TELEPHONE_NUMBER_1_F, 'Teléfono 1'),
        OwnField(names.LC_PARTY_CONTACT_T_TELEPHONE_NUMBER_2_F, 'Teléfono 2'),
        OwnField(names.LC_PARTY_CONTACT_T_NOTIFICATION_ADDRESS_F,
                 'Domicilio notificación'),
        OwnField(names.LC_PARTY_CONTACT_T_EMAIL_F, 'Correo electrónico')
    ]

    lc_administrative_source_fields = [
        DomainOwnField(names.LC_ADMINISTRATIVE_SOURCE_T_TYPE_F,
                       "Tipo de fuente administrativa",
                       names.COL_ADMINISTRATIVE_SOURCE_TYPE_D),
        OwnField(names.LC_ADMINISTRATIVE_SOURCE_T_EMITTING_ENTITY_F,
                 "Ente emisor"),
        DomainOwnField(names.COL_SOURCE_T_AVAILABILITY_STATUS_F,
                       "Estado disponibilidad", names.COL_AVAILABILITY_TYPE_D),
        RelatedOwnFieldValue(
            'Archivo fuente', names.EXT_ARCHIVE_S,
            OwnField(names.EXT_ARCHIVE_S_DATA_F, 'Archivo fuente'),
            names.EXT_ARCHIVE_S_LC_ADMINISTRATIVE_SOURCE_F)
    ]

    lc_party_fields = [
        DomainOwnField(names.LC_PARTY_T_TYPE_F, "Tipo", names.LC_PARTY_TYPE_D),
        OwnField(names.LC_PARTY_T_DOCUMENT_ID_F, 'Cédula de ciudadanía'),
        OwnField(names.COL_PARTY_T_NAME_F, 'Nombre'),
        OwnField(names.LC_PARTY_T_GENRE_F, 'Género'),
        RelatedOwnFieldObject(names.LC_PARTY_CONTACT_T,
                              names.LC_PARTY_CONTACT_T,
                              lc_party_contact_fields,
                              names.LC_PARTY_CONTACT_T_LC_PARTY_F)
    ]

    lc_group_party_party_fields = [
        DomainOwnField(names.LC_PARTY_T_TYPE_F, "Tipo", names.LC_PARTY_TYPE_D),
        OwnField(names.LC_PARTY_T_DOCUMENT_ID_F, 'Cédula de ciudadanía'),
        OwnField(names.COL_PARTY_T_NAME_F, 'Nombre'),
        OwnField(names.LC_PARTY_T_GENRE_F, 'Género'),
        RelatedOwnFieldObject(names.LC_PARTY_CONTACT_T,
                              names.LC_PARTY_CONTACT_T,
                              lc_party_contact_fields,
                              names.LC_PARTY_CONTACT_T_LC_PARTY_F),
        RelatedRemoteFieldValue(
            names.FRACTION_S, names.FRACTION_S,
            EvalExpressionOwnField(
                "fracción",
                QgsExpression(
                    "round({numerador}/{denominador} * 100, 2)".format(
                        denominador=names.FRACTION_S_DENOMINATOR_F,
                        numerador=names.FRACTION_S_NUMERATOR_F))),
            names.FRACTION_S_MEMBER_F,
            FilterSubLevel(names.T_ID_F, names.MEMBERS_T,
                           names.MEMBERS_T_PARTY_F))
    ]

    lc_group_party_fields = [
        DomainOwnField(names.COL_GROUP_PARTY_T_TYPE_F,
                       "Tipo de agrupación de interesados",
                       names.COL_GROUP_PARTY_TYPE_D),
        OwnField(names.COL_PARTY_T_NAME_F, "Nombre")
    ]

    query = {
        QueryNames.LEVEL_TABLE: {
            QueryNames.LEVEL_TABLE_NAME:
            names.LC_PLOT_T,
            QueryNames.LEVEL_TABLE_ALIAS:
            names.LC_PLOT_T,
            QueryNames.FILTER_SUB_LEVEL:
            FilterSubLevel(names.T_ID_F, names.LC_PLOT_T, names.T_ID_F),
            QueryNames.TABLE_FIELDS: [
                OwnField(
                    names.LC_PLOT_T_PLOT_AREA_F,
                    get_full_alias("Área", ladm_units, names.LC_PLOT_T,
                                   names.LC_PLOT_T_PLOT_AREA_F))
            ],
            QueryNames.LEVEL_TABLE: {
                QueryNames.LEVEL_TABLE_NAME:
                names.LC_PARCEL_T,
                QueryNames.LEVEL_TABLE_ALIAS:
                names.LC_PARCEL_T,
                QueryNames.FILTER_SUB_LEVEL:
                FilterSubLevel(names.COL_UE_BAUNIT_T_PARCEL_F,
                               names.COL_UE_BAUNIT_T,
                               names.COL_UE_BAUNIT_T_LC_PLOT_F),
                QueryNames.TABLE_FIELDS: [
                    OwnField(names.COL_BAUNIT_T_NAME_F, "Nombre"),
                    OwnField(names.LC_PARCEL_T_NUPRE_F, "NUPRE"),
                    OwnField(names.LC_PARCEL_T_ID_OPERATION_F, "Id operación"),
                    OwnField(names.LC_PARCEL_T_FMI_F, "FMI"),
                    OwnField(names.LC_PARCEL_T_PARCEL_NUMBER_F,
                             "Número predial"),
                    OwnField(names.LC_PARCEL_T_PREVIOUS_PARCEL_NUMBER_F,
                             "Número predial anterior")
                ],
                '1' + QueryNames.LEVEL_TABLE: {
                    QueryNames.LEVEL_TABLE_NAME:
                    names.LC_RIGHT_T,
                    QueryNames.LEVEL_TABLE_ALIAS:
                    names.LC_RIGHT_T,
                    QueryNames.FILTER_SUB_LEVEL:
                    FilterSubLevel(names.T_ID_F, names.LC_RIGHT_T,
                                   names.COL_BAUNIT_RRR_T_UNIT_F),
                    QueryNames.TABLE_FIELDS: [
                        DomainOwnField(names.LC_RIGHT_T_TYPE_F,
                                       "Tipo de derecho",
                                       names.LC_RIGHT_TYPE_D),
                        OwnField(names.COL_RRR_T_DESCRIPTION_F, "Descripción")
                    ],
                    '1' + QueryNames.LEVEL_TABLE: {
                        QueryNames.LEVEL_TABLE_NAME:
                        names.LC_ADMINISTRATIVE_SOURCE_T,
                        QueryNames.LEVEL_TABLE_ALIAS:
                        names.LC_ADMINISTRATIVE_SOURCE_T,
                        QueryNames.FILTER_SUB_LEVEL:
                        FilterSubLevel(names.COL_RRR_SOURCE_T_SOURCE_F,
                                       names.COL_RRR_SOURCE_T,
                                       names.COL_RRR_SOURCE_T_LC_RIGHT_F),
                        QueryNames.TABLE_FIELDS:
                        lc_administrative_source_fields
                    },
                    '2' + QueryNames.LEVEL_TABLE: {
                        QueryNames.LEVEL_TABLE_NAME:
                        names.LC_PARTY_T,
                        QueryNames.LEVEL_TABLE_ALIAS:
                        names.LC_PARTY_T,
                        QueryNames.FILTER_SUB_LEVEL:
                        FilterSubLevel(names.COL_RRR_PARTY_T_LC_PARTY_F,
                                       names.LC_RIGHT_T, names.T_ID_F),
                        QueryNames.TABLE_FIELDS:
                        lc_party_fields
                    },
                    '3' + QueryNames.LEVEL_TABLE: {
                        QueryNames.LEVEL_TABLE_NAME:
                        names.LC_GROUP_PARTY_T,
                        QueryNames.LEVEL_TABLE_ALIAS:
                        names.LC_GROUP_PARTY_T,
                        QueryNames.FILTER_SUB_LEVEL:
                        FilterSubLevel(names.COL_RRR_PARTY_T_LC_GROUP_PARTY_F,
                                       names.LC_RIGHT_T, names.T_ID_F),
                        QueryNames.TABLE_FIELDS:
                        lc_group_party_fields,
                        QueryNames.LEVEL_TABLE: {
                            QueryNames.LEVEL_TABLE_NAME:
                            names.LC_PARTY_T,
                            QueryNames.LEVEL_TABLE_ALIAS:
                            names.LC_PARTY_T,
                            QueryNames.FILTER_SUB_LEVEL:
                            FilterSubLevel(names.MEMBERS_T_PARTY_F,
                                           names.MEMBERS_T,
                                           names.MEMBERS_T_GROUP_PARTY_F),
                            QueryNames.TABLE_FIELDS:
                            lc_group_party_party_fields
                        },
                    }
                },
                '2' + QueryNames.LEVEL_TABLE: {
                    QueryNames.LEVEL_TABLE_NAME:
                    names.LC_RESTRICTION_T,
                    QueryNames.LEVEL_TABLE_ALIAS:
                    names.LC_RESTRICTION_T,
                    QueryNames.FILTER_SUB_LEVEL:
                    FilterSubLevel(names.T_ID_F, names.LC_RESTRICTION_T,
                                   names.COL_BAUNIT_RRR_T_UNIT_F),
                    QueryNames.TABLE_FIELDS: [
                        DomainOwnField(names.LC_RESTRICTION_T_TYPE_F,
                                       "Tipo de restricción",
                                       names.LC_RESTRICTION_TYPE_D),
                        OwnField(names.COL_RRR_T_DESCRIPTION_F, "Descripción")
                    ],
                    '1' + QueryNames.LEVEL_TABLE: {
                        QueryNames.LEVEL_TABLE_NAME:
                        names.LC_ADMINISTRATIVE_SOURCE_T,
                        QueryNames.LEVEL_TABLE_ALIAS:
                        names.LC_ADMINISTRATIVE_SOURCE_T,
                        QueryNames.FILTER_SUB_LEVEL:
                        FilterSubLevel(
                            names.COL_RRR_SOURCE_T_SOURCE_F,
                            names.COL_RRR_SOURCE_T,
                            names.COL_RRR_SOURCE_T_LC_RESTRICTION_F),
                        QueryNames.TABLE_FIELDS:
                        lc_administrative_source_fields
                    },
                    '2' + QueryNames.LEVEL_TABLE: {
                        QueryNames.LEVEL_TABLE_NAME:
                        names.LC_PARTY_T,
                        QueryNames.LEVEL_TABLE_ALIAS:
                        names.LC_PARTY_T,
                        QueryNames.FILTER_SUB_LEVEL:
                        FilterSubLevel(names.COL_RRR_PARTY_T_LC_PARTY_F,
                                       names.LC_RESTRICTION_T, names.T_ID_F),
                        QueryNames.TABLE_FIELDS:
                        lc_party_fields
                    },
                    '3' + QueryNames.LEVEL_TABLE: {
                        QueryNames.LEVEL_TABLE_NAME:
                        names.LC_GROUP_PARTY_T,
                        QueryNames.LEVEL_TABLE_ALIAS:
                        names.LC_GROUP_PARTY_T,
                        QueryNames.FILTER_SUB_LEVEL:
                        FilterSubLevel(names.COL_RRR_PARTY_T_LC_GROUP_PARTY_F,
                                       names.LC_RESTRICTION_T, names.T_ID_F),
                        QueryNames.TABLE_FIELDS:
                        lc_group_party_fields,
                        QueryNames.LEVEL_TABLE: {
                            QueryNames.LEVEL_TABLE_NAME:
                            names.LC_PARTY_T,
                            QueryNames.LEVEL_TABLE_ALIAS:
                            names.LC_PARTY_T,
                            QueryNames.FILTER_SUB_LEVEL:
                            FilterSubLevel(names.MEMBERS_T_PARTY_F,
                                           names.MEMBERS_T,
                                           names.MEMBERS_T_GROUP_PARTY_F),
                            QueryNames.TABLE_FIELDS:
                            lc_group_party_party_fields
                        }
                    }
                }
            }
        }
    }

    return query
Exemple #3
0
def get_igac_physical_query(names, ladm_units):
    lc_spatial_source_fields = [
        DomainOwnField(names.COL_SPATIAL_SOURCE_T_TYPE_F,
                       "Tipo de fuente espacial",
                       names.COL_SPATIAL_SOURCE_TYPE_D),
        DomainOwnField(names.COL_SOURCE_T_AVAILABILITY_STATUS_F,
                       "Estado disponibilidad", names.COL_AVAILABILITY_TYPE_D),
        DomainOwnField(names.COL_SOURCE_T_MAIN_TYPE_F, "Tipo principal",
                       names.CI_CODE_PRESENTATION_FORM_D),
        OwnField(names.COL_SOURCE_T_DATE_DOCUMENT_F, "Fecha documento"),
        RelatedOwnFieldValue(
            'Archivo fuente', names.EXT_ARCHIVE_S,
            OwnField(names.EXT_ARCHIVE_S_DATA_F, 'Archivo fuente'),
            names.EXT_ARCHIVE_S_LC_SPATIAL_SOURCE_F)
    ]

    query = {
        QueryNames.LEVEL_TABLE: {
            QueryNames.LEVEL_TABLE_NAME:
            names.LC_PLOT_T,
            QueryNames.LEVEL_TABLE_ALIAS:
            names.LC_PLOT_T,
            QueryNames.FILTER_SUB_LEVEL:
            FilterSubLevel(names.T_ID_F, names.LC_PLOT_T, names.T_ID_F),
            QueryNames.TABLE_FIELDS: [
                OwnField(
                    names.LC_PLOT_T_PLOT_AREA_F,
                    get_full_alias("Área", ladm_units, names.LC_PLOT_T,
                                   names.LC_PLOT_T_PLOT_AREA_F))
            ],
            '1' + QueryNames.LEVEL_TABLE: {
                QueryNames.LEVEL_TABLE_NAME:
                names.LC_PARCEL_T,
                QueryNames.LEVEL_TABLE_ALIAS:
                names.LC_PARCEL_T,
                QueryNames.FILTER_SUB_LEVEL:
                FilterSubLevel(names.COL_UE_BAUNIT_T_PARCEL_F,
                               names.COL_UE_BAUNIT_T,
                               names.COL_UE_BAUNIT_T_LC_PLOT_F),
                QueryNames.TABLE_FIELDS: [
                    OwnField(names.COL_BAUNIT_T_NAME_F, "Nombre"),
                    OwnField(names.LC_PARCEL_T_NUPRE_F, "NUPRE"),
                    OwnField(names.LC_PARCEL_T_ID_OPERATION_F, "Id operación"),
                    OwnField(names.LC_PARCEL_T_FMI_F, "FMI"),
                    OwnField(names.LC_PARCEL_T_PARCEL_NUMBER_F,
                             "Número predial"),
                    OwnField(names.LC_PARCEL_T_PREVIOUS_PARCEL_NUMBER_F,
                             "Número predial anterior")
                ],
                QueryNames.LEVEL_TABLE: {
                    QueryNames.LEVEL_TABLE_NAME:
                    names.LC_BUILDING_T,
                    QueryNames.LEVEL_TABLE_ALIAS:
                    names.LC_BUILDING_T,
                    QueryNames.FILTER_SUB_LEVEL:
                    FilterSubLevel(names.COL_UE_BAUNIT_T_LC_BUILDING_F,
                                   names.COL_UE_BAUNIT_T,
                                   names.COL_UE_BAUNIT_T_PARCEL_F),
                    QueryNames.TABLE_FIELDS: [
                        OwnField(names.LC_BUILDING_T_BUILDING_AREA_F,
                                 "Área construcción"),
                        OwnField(names.LC_BUILDING_T_NUMBER_OF_FLOORS_F,
                                 "Número de pisos")
                    ],
                    '1' + QueryNames.LEVEL_TABLE: {
                        QueryNames.LEVEL_TABLE_NAME:
                        names.LC_BUILDING_UNIT_T,
                        QueryNames.LEVEL_TABLE_ALIAS:
                        names.LC_BUILDING_UNIT_T,
                        QueryNames.FILTER_SUB_LEVEL:
                        FilterSubLevel(names.T_ID_F, names.LC_BUILDING_UNIT_T,
                                       names.LC_BUILDING_UNIT_T_BUILDING_F),
                        QueryNames.TABLE_FIELDS: [
                            OwnField(names.LC_BUILDING_UNIT_T_TOTAL_FLOORS_F,
                                     "Número de pisos"),
                            DomainOwnField(names.LC_BUILDING_UNIT_T_USE_F,
                                           "Uso",
                                           names.LC_BUILDING_UNIT_USE_D),
                            DomainOwnField(
                                names.LC_BUILDING_UNIT_T_BUILDING_TYPE_F,
                                "Tipo construcción", names.LC_BUILDING_TYPE_D),
                            DomainOwnField(
                                names.LC_BUILDING_UNIT_T_BUILDING_UNIT_TYPE_F,
                                "Tipo unidad de construcción",
                                names.LC_BUILDING_UNIT_TYPE_D),
                            OwnField(
                                names.LC_BUILDING_UNIT_T_BUILT_PRIVATE_AREA_F,
                                get_full_alias(
                                    "Área privada construida", ladm_units,
                                    names.LC_BUILDING_UNIT_T, names.
                                    LC_BUILDING_UNIT_T_BUILT_PRIVATE_AREA_F)),
                            OwnField(
                                names.LC_BUILDING_UNIT_T_BUILT_AREA_F,
                                get_full_alias(
                                    "Área construida", ladm_units,
                                    names.LC_BUILDING_UNIT_T,
                                    names.LC_BUILDING_UNIT_T_BUILT_AREA_F))
                        ],
                        QueryNames.LEVEL_TABLE: {
                            QueryNames.LEVEL_TABLE_NAME:
                            names.LC_SPATIAL_SOURCE_T,
                            QueryNames.LEVEL_TABLE_ALIAS:
                            names.LC_SPATIAL_SOURCE_T,
                            QueryNames.FILTER_SUB_LEVEL:
                            FilterSubLevel(
                                names.COL_UE_SOURCE_T_SOURCE_F,
                                names.COL_UE_SOURCE_T,
                                names.COL_UE_SOURCE_T_LC_BUILDING_UNIT_F),
                            QueryNames.TABLE_FIELDS:
                            lc_spatial_source_fields
                        }
                    },
                    '2' + QueryNames.LEVEL_TABLE: {
                        QueryNames.LEVEL_TABLE_NAME:
                        names.LC_SPATIAL_SOURCE_T,
                        QueryNames.LEVEL_TABLE_ALIAS:
                        names.LC_SPATIAL_SOURCE_T,
                        QueryNames.FILTER_SUB_LEVEL:
                        FilterSubLevel(names.COL_UE_SOURCE_T_SOURCE_F,
                                       names.COL_UE_SOURCE_T,
                                       names.COL_UE_SOURCE_T_LC_BUILDING_F),
                        QueryNames.TABLE_FIELDS:
                        lc_spatial_source_fields
                    }
                }
            },
            '2' + QueryNames.LEVEL_TABLE: {
                QueryNames.LEVEL_TABLE_NAME:
                names.LC_BOUNDARY_T,
                QueryNames.LEVEL_TABLE_ALIAS:
                names.LC_BOUNDARY_T + " externos",
                QueryNames.FILTER_SUB_LEVEL:
                FilterSubLevel(names.MORE_BFS_T_LC_BOUNDARY_F,
                               names.MORE_BFS_T, names.MORE_BFS_T_LC_PLOT_F),
                QueryNames.TABLE_FIELDS: [
                    OwnField(
                        names.LC_BOUNDARY_T_LENGTH_F,
                        get_full_alias("Longitud", ladm_units,
                                       names.LC_BOUNDARY_T,
                                       names.LC_BOUNDARY_T_LENGTH_F))
                ]
            },
            '3' + QueryNames.LEVEL_TABLE: {
                QueryNames.LEVEL_TABLE_NAME:
                names.LC_BOUNDARY_POINT_T,
                QueryNames.LEVEL_TABLE_ALIAS:
                names.LC_BOUNDARY_POINT_T + " externos",
                QueryNames.FILTER_SUB_LEVEL:
                FilterSubLevel(
                    names.MORE_BFS_T_LC_BOUNDARY_F, names.MORE_BFS_T,
                    names.MORE_BFS_T_LC_PLOT_F,
                    FilterSubLevel(names.POINT_BFS_T_LC_BOUNDARY_POINT_F,
                                   names.POINT_BFS_T,
                                   names.POINT_BFS_T_LC_BOUNDARY_F)),
                QueryNames.TABLE_FIELDS: [
                    OwnField(names.LC_BOUNDARY_POINT_T_ID_F, "Nombre"),
                    EvalExpressionOwnField(
                        "Coordenadas",
                        QgsExpression(
                            "$x || ' ' || $y || ' ' || z($geometry)"))
                ]
            },
            '4' + QueryNames.LEVEL_TABLE: {
                QueryNames.LEVEL_TABLE_NAME:
                names.LC_BOUNDARY_T,
                QueryNames.LEVEL_TABLE_ALIAS:
                names.LC_BOUNDARY_T + " internos",
                QueryNames.FILTER_SUB_LEVEL:
                FilterSubLevel(names.LESS_BFS_T_LC_BOUNDARY_F,
                               names.LESS_BFS_T, names.LESS_BFS_T_LC_PLOT_F),
                QueryNames.TABLE_FIELDS: [
                    OwnField(
                        names.LC_BOUNDARY_T_LENGTH_F,
                        get_full_alias("Longitud", ladm_units,
                                       names.LC_BOUNDARY_T,
                                       names.LC_BOUNDARY_T_LENGTH_F))
                ]
            },
            '5' + QueryNames.LEVEL_TABLE: {
                QueryNames.LEVEL_TABLE_NAME:
                names.LC_BOUNDARY_POINT_T,
                QueryNames.LEVEL_TABLE_ALIAS:
                names.LC_BOUNDARY_POINT_T + " internos",
                QueryNames.FILTER_SUB_LEVEL:
                FilterSubLevel(
                    names.LESS_BFS_T_LC_BOUNDARY_F, names.LESS_BFS_T,
                    names.LESS_BFS_T_LC_PLOT_F,
                    FilterSubLevel(names.POINT_BFS_T_LC_BOUNDARY_POINT_F,
                                   names.POINT_BFS_T,
                                   names.POINT_BFS_T_LC_BOUNDARY_F)),
                QueryNames.TABLE_FIELDS: [
                    EvalExpressionOwnField(
                        "Coordenadas",
                        QgsExpression(
                            "$x || ' ' || $y || ' ' || z($geometry)"))
                ]
            },
            '6' + QueryNames.LEVEL_TABLE: {
                QueryNames.LEVEL_TABLE_NAME:
                names.LC_SURVEY_POINT_T,
                QueryNames.LEVEL_TABLE_ALIAS:
                names.LC_SURVEY_POINT_T,
                QueryNames.FILTER_SUB_LEVEL:
                SpatialFilterSubLevel(names.T_ID_F, names.LC_SURVEY_POINT_T,
                                      names.LC_PLOT_T,
                                      EnumSpatialOperationType.INTERSECTS),
                QueryNames.TABLE_FIELDS: [
                    EvalExpressionOwnField(
                        "Coordenadas",
                        QgsExpression(
                            "$x || ' ' || $y || ' ' || z($geometry)"))
                ]
            },
            '7' + QueryNames.LEVEL_TABLE: {
                QueryNames.LEVEL_TABLE_NAME:
                names.LC_SPATIAL_SOURCE_T,
                QueryNames.LEVEL_TABLE_ALIAS:
                names.LC_SPATIAL_SOURCE_T,
                QueryNames.FILTER_SUB_LEVEL:
                FilterSubLevel(names.COL_UE_SOURCE_T_SOURCE_F,
                               names.COL_UE_SOURCE_T,
                               names.COL_UE_SOURCE_T_LC_PLOT_F),
                QueryNames.TABLE_FIELDS:
                lc_spatial_source_fields
            }
        }
    }

    return query
Exemple #4
0
def get_igac_economic_query(names, ladm_units):
    query = {
        QueryNames.LEVEL_TABLE: {
            QueryNames.LEVEL_TABLE_NAME:
            names.LC_PLOT_T,
            QueryNames.LEVEL_TABLE_ALIAS:
            names.LC_PLOT_T,
            QueryNames.FILTER_SUB_LEVEL:
            FilterSubLevel(names.T_ID_F, names.LC_PLOT_T, names.T_ID_F),
            QueryNames.TABLE_FIELDS: [
                OwnField(
                    names.LC_PLOT_T_PLOT_VALUATION_F,
                    get_full_alias("Avalúo", ladm_units, names.LC_PLOT_T,
                                   names.LC_PLOT_T_PLOT_VALUATION_F)),
                OwnField(
                    names.LC_PLOT_T_PLOT_AREA_F,
                    get_full_alias("Área", ladm_units, names.LC_PLOT_T,
                                   names.LC_PLOT_T_PLOT_AREA_F))
            ],
            QueryNames.LEVEL_TABLE: {
                QueryNames.LEVEL_TABLE_NAME:
                names.LC_PARCEL_T,
                QueryNames.LEVEL_TABLE_ALIAS:
                names.LC_PARCEL_T,
                QueryNames.FILTER_SUB_LEVEL:
                FilterSubLevel(names.COL_UE_BAUNIT_T_PARCEL_F,
                               names.COL_UE_BAUNIT_T,
                               names.COL_UE_BAUNIT_T_LC_PLOT_F),
                QueryNames.TABLE_FIELDS: [
                    OwnField(names.COL_BAUNIT_T_NAME_F, "Nombre"),
                    OwnField(names.LC_PARCEL_T_DEPARTMENT_F, "Departamento"),
                    OwnField(names.LC_PARCEL_T_MUNICIPALITY_F, "Municipio"),
                    OwnField(names.LC_PARCEL_T_NUPRE_F, "NUPRE"),
                    OwnField(names.LC_PARCEL_T_ID_OPERATION_F, "Id operación"),
                    OwnField(names.LC_PARCEL_T_FMI_F, "FMI"),
                    OwnField(names.LC_PARCEL_T_PARCEL_NUMBER_F,
                             "Número predial"),
                    OwnField(names.LC_PARCEL_T_PREVIOUS_PARCEL_NUMBER_F,
                             "Número predial anterior"),
                    OwnField(
                        names.LC_PARCEL_T_VALUATION_F,
                        get_full_alias("Avalúo predio", ladm_units,
                                       names.LC_PARCEL_T,
                                       names.LC_PARCEL_T_VALUATION_F)),
                    DomainOwnField(names.LC_PARCEL_T_TYPE_F, "Tipo",
                                   names.LC_PARCEL_TYPE_D)
                ],
                QueryNames.LEVEL_TABLE: {
                    QueryNames.LEVEL_TABLE_NAME:
                    names.LC_BUILDING_T,
                    QueryNames.LEVEL_TABLE_ALIAS:
                    names.LC_BUILDING_T,
                    QueryNames.FILTER_SUB_LEVEL:
                    FilterSubLevel(names.COL_UE_BAUNIT_T_LC_BUILDING_F,
                                   names.COL_UE_BAUNIT_T,
                                   names.COL_UE_BAUNIT_T_PARCEL_F),
                    QueryNames.TABLE_FIELDS: [
                        OwnField(
                            names.LC_BUILDING_T_BUILDING_VALUATION_F,
                            get_full_alias(
                                "Avalúo", ladm_units, names.LC_BUILDING_T,
                                names.LC_BUILDING_T_BUILDING_VALUATION_F)),
                        OwnField(names.LC_BUILDING_T_BUILDING_AREA_F,
                                 "Área construcción")
                    ],
                    QueryNames.LEVEL_TABLE: {
                        QueryNames.LEVEL_TABLE_NAME:
                        names.LC_BUILDING_UNIT_T,
                        QueryNames.LEVEL_TABLE_ALIAS:
                        names.LC_BUILDING_UNIT_T,
                        QueryNames.FILTER_SUB_LEVEL:
                        FilterSubLevel(names.T_ID_F, names.LC_BUILDING_UNIT_T,
                                       names.LC_BUILDING_UNIT_T_BUILDING_F),
                        QueryNames.TABLE_FIELDS: [
                            OwnField(
                                names.
                                LC_BUILDING_UNIT_T_BUILDING_UNIT_VALUATION_F,
                                get_full_alias(
                                    "Avalúo", ladm_units,
                                    names.LC_BUILDING_UNIT_T, names.
                                    LC_BUILDING_UNIT_T_BUILDING_UNIT_VALUATION_F
                                )),
                            OwnField(
                                names.LC_BUILDING_UNIT_T_BUILT_AREA_F,
                                get_full_alias(
                                    "Área construida", ladm_units,
                                    names.LC_BUILDING_UNIT_T,
                                    names.LC_BUILDING_UNIT_T_BUILT_AREA_F)),
                            OwnField(
                                names.LC_BUILDING_UNIT_T_BUILT_PRIVATE_AREA_F,
                                get_full_alias(
                                    "Área privada construida", ladm_units,
                                    names.LC_BUILDING_UNIT_T, names.
                                    LC_BUILDING_UNIT_T_BUILT_PRIVATE_AREA_F)),
                            OwnField(names.LC_BUILDING_UNIT_T_TOTAL_FLOORS_F,
                                     "Número de pisos"),
                            OwnField(names.LC_BUILDING_UNIT_T_FLOOR_F,
                                     "Ubicación en el piso"),
                            DomainOwnField(names.LC_BUILDING_UNIT_T_USE_F,
                                           "Uso",
                                           names.LC_BUILDING_UNIT_USE_D),
                            OwnField(
                                names.LC_BUILDING_UNIT_T_YEAR_OF_BUILDING_F,
                                "Año construcción")
                        ]
                    }
                }
            }
        }
    }

    return query
Exemple #5
0
def get_igac_basic_query(names, ladm_units):
    required_address_fields = [
        DomainOwnField(names.EXT_ADDRESS_S_ADDRESS_TYPE_F, "Tipo dirección", names.EXT_ADDRESS_TYPE_D),
        OwnField(names.EXT_ADDRESS_S_POSTAL_CODE_F, 'Código postal'),
        EvalExpressionOwnField("Dirección",
                               QgsExpression("""trim(
                                coalesce(get_domain_value_from_code( '{dominio_clase_via_principal}',  "{clase_via_principal}" , False, False)||' ', '') ||
                                coalesce({valor_via_principal} || ' ', '') ||
                                coalesce({letra_via_principal} || ' ', '') ||
                                coalesce(get_domain_value_from_code( '{dominio_sector_ciudad}',  "{sector_ciudad}", False, False)||' ', '') ||
                                coalesce({valor_via_generadora} || ' ', '') ||
                                coalesce({letra_via_generadora} || ' ', '') ||
                                coalesce({numero_predio} || ' ', '') ||
                                coalesce(get_domain_value_from_code( '{dominio_sector_predio}',  "{sector_predio}", False, False)||' ', '') ||
                                coalesce({complemento} || ' ', '') ||
                                coalesce({nombre_predio}, '')
                            )""".format(
                             dominio_clase_via_principal=names.EXT_ADDRESS_TYPE_MAIN_ROAD_CLASS_D,
                             clase_via_principal=names.EXT_ADDRESS_S_MAIN_ROAD_CLASS_F,
                             valor_via_principal=names.EXT_ADDRESS_S_VALUE_MAIN_ROAD_F,
                             letra_via_principal=names.EXT_ADDRESS_S_LETTER_MAIN_ROAD_F,
                             dominio_sector_ciudad=names.EXT_ADDRESS_TYPE_CITY_SECTOR_D,
                             sector_ciudad=names.EXT_ADDRESS_S_CITY_SECTOR_F,
                             valor_via_generadora=names.EXT_ADDRESS_S_VALUE_GENERATOR_ROAD_F,
                             letra_via_generadora=names.EXT_ADDRESS_S_LETTER_GENERATOR_ROAD_F,
                             numero_predio=names.EXT_ADDRESS_S_PARCEL_NUMBER_F,
                             dominio_sector_predio=names.EXT_ADDRESS_TYPE_PARCEL_SECTOR_D,
                             sector_predio=names.EXT_ADDRESS_S_PARCEL_SECTOR_F,
                             complemento=names.EXT_ADDRESS_S_COMPLEMENT_F,
                             nombre_predio=names.EXT_ADDRESS_S_PARCEL_NAME_F)))]

    query = {
        QueryNames.LEVEL_TABLE: {
            QueryNames.LEVEL_TABLE_NAME: names.LC_PLOT_T,
            QueryNames.LEVEL_TABLE_ALIAS: names.LC_PLOT_T,
            QueryNames.FILTER_SUB_LEVEL: FilterSubLevel(names.T_ID_F, names.LC_PLOT_T, names.T_ID_F),
            QueryNames.TABLE_FIELDS: [OwnField(names.LC_PLOT_T_PLOT_AREA_F, get_full_alias("Área", ladm_units, names.LC_PLOT_T, names.LC_PLOT_T_PLOT_AREA_F)),
                                      RelatedOwnFieldObject(names.EXT_ADDRESS_S, names.EXT_ADDRESS_S,
                                                            required_address_fields,
                                                            names.EXT_ADDRESS_S_LC_PLOT_F)],
            QueryNames.LEVEL_TABLE: {
                QueryNames.LEVEL_TABLE_NAME: names.LC_PARCEL_T,
                QueryNames.LEVEL_TABLE_ALIAS: names.LC_PARCEL_T,
                QueryNames.FILTER_SUB_LEVEL: FilterSubLevel(names.COL_UE_BAUNIT_T_PARCEL_F,
                                                            names.COL_UE_BAUNIT_T,
                                                            names.COL_UE_BAUNIT_T_LC_PLOT_F),
                QueryNames.TABLE_FIELDS: [
                    OwnField(names.COL_BAUNIT_T_NAME_F, "Nombre"),
                    OwnField(names.LC_PARCEL_T_DEPARTMENT_F, "Departamento"),
                    OwnField(names.LC_PARCEL_T_MUNICIPALITY_F, "Municipio"),
                    OwnField(names.LC_PARCEL_T_NUPRE_F, "NUPRE"),
                    OwnField(names.LC_PARCEL_T_ID_OPERATION_F, "Id operación"),
                    OwnField(names.LC_PARCEL_T_FMI_F, "FMI"),
                    OwnField(names.LC_PARCEL_T_PARCEL_NUMBER_F, "Número predial"),
                    OwnField(names.LC_PARCEL_T_PREVIOUS_PARCEL_NUMBER_F, "Número predial anterior"),
                    DomainOwnField(names.LC_PARCEL_T_TYPE_F, "Tipo", names.COL_BAUNIT_TYPE_D)
                ],
                QueryNames.LEVEL_TABLE: {
                    QueryNames.LEVEL_TABLE_NAME: names.LC_BUILDING_T,
                    QueryNames.LEVEL_TABLE_ALIAS: names.LC_BUILDING_T,
                    QueryNames.FILTER_SUB_LEVEL: FilterSubLevel(names.COL_UE_BAUNIT_T_LC_BUILDING_F,
                                                                names.COL_UE_BAUNIT_T,
                                                                names.COL_UE_BAUNIT_T_PARCEL_F),
                    QueryNames.TABLE_FIELDS: [
                        OwnField(names.LC_BUILDING_T_BUILDING_AREA_F, "Área"),
                        RelatedOwnFieldObject(names.EXT_ADDRESS_S, names.EXT_ADDRESS_S,
                                              required_address_fields, names.EXT_ADDRESS_S_LC_BUILDING_F)
                    ],
                    QueryNames.LEVEL_TABLE: {
                        QueryNames.LEVEL_TABLE_NAME: names.LC_BUILDING_UNIT_T,
                        QueryNames.LEVEL_TABLE_ALIAS: names.LC_BUILDING_UNIT_T,
                        QueryNames.FILTER_SUB_LEVEL: FilterSubLevel(names.T_ID_F, names.LC_BUILDING_UNIT_T,
                                                                    names.LC_BUILDING_UNIT_T_BUILDING_F),
                        QueryNames.TABLE_FIELDS: [
                            OwnField(names.LC_BUILDING_UNIT_T_TOTAL_FLOORS_F, "Número de pisos"),
                            OwnField(names.LC_BUILDING_UNIT_T_TOTAL_ROOMS_F, "Número de habitaciones"),
                            OwnField(names.LC_BUILDING_UNIT_T_TOTAL_BATHROOMS_F, "Número de baños"),
                            OwnField(names.LC_BUILDING_UNIT_T_TOTAL_LOCALS_F, "Número de locales"),
                            DomainOwnField(names.LC_BUILDING_UNIT_T_BUILDING_TYPE_F, "Tipo construcción",
                                           names.LC_BUILDING_TYPE_D),
                            DomainOwnField(names.LC_BUILDING_UNIT_T_BUILDING_UNIT_TYPE_F,
                                           "Tipo unidad de construcción", names.LC_BUILDING_UNIT_TYPE_D),
                            DomainOwnField(names.LC_BUILDING_UNIT_T_FLOOR_TYPE_F, "Tipo de planta",
                                           names.LC_BUILDING_FLOOR_TYPE_D),
                            DomainOwnField(names.LC_BUILDING_UNIT_T_DOMAIN_TYPE_F, "Tipo dominio",
                                           names.LC_DOMAIN_BUILDING_TYPE_D),
                            OwnField(names.LC_BUILDING_UNIT_T_FLOOR_F, "Ubicación en el piso"),
                            OwnField(names.LC_BUILDING_UNIT_T_BUILT_AREA_F, get_full_alias("Área construida", ladm_units, names.LC_BUILDING_UNIT_T, names.LC_BUILDING_UNIT_T_BUILT_AREA_F)),
                            DomainOwnField(names.LC_BUILDING_UNIT_T_USE_F, "Uso",
                                           names.LC_BUILDING_UNIT_USE_D),
                            RelatedOwnFieldObject(names.EXT_ADDRESS_S, names.EXT_ADDRESS_S,
                                                  required_address_fields, names.EXT_ADDRESS_S_LC_BUILDING_UNIT_F)
                        ]
                    }
                }
            }
        }
    }

    return query