def CroquisEmpadronador(ubigeos, WorkSpaceCroquis, mxd_croquis_emp, tipo):
    listaProblemas = []
    settings.conectionGDB_arcpy()
    settings.conectionDB_arcpy()

    for ubigeo in datosDistrito(ubigeos):

        mxd = arcpy.mapping.MapDocument(mxd_croquis_emp)
        df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]

        print ubigeo
        queryCapasAuxiliares(ubigeo[0], mxd)
        informacionCabecera(ubigeo, mxd)
        agregarLyrUbigeo(mxd, ubigeo[0], "UBIGEO")

        for ruta in datosRutas(ubigeo[0]):
            informacioCabeceraRutasSCR(mxd, ruta[1], tipo)

            for emp in dataEmp(ruta[0]):
                informacionCabeceraRutasEMP(mxd, emp, ruta[0])
                for aer in dataAER(ruta[0]):
                    observacionesCroquis(mxd, ruta[2], ruta[0], aer)
                    informacionCabeceraAER(mxd, aer)
                    informacionCabeceraRutasViv(mxd, aer, ruta[0])
                    querysLayers(mxd, ruta[0], "IDRUTA", aer)
                    querysLayersAER(mxd, aer, "IDAER")
                    # listarevisar = zoomAER3(mxd, df, emp)
                    listarevisar = zoomAER(mxd, df)

                    sufijo = sufijoNombrePDF(aer)

                    if tipo == 1:
                        CroquisPathPdf = os.path.join(WorkSpaceCroquis, "Rural", ubigeo[0], ruta[0] + emp + sufijo[0] + ".pdf")
                        if len(listarevisar) > 0:
                            listaRevisar(ubigeo[0], os.path.join(ruta[0] + emp))
                    else:
                        CroquisPathPdf = os.path.join(WorkSpaceCroquis, "Rural_FEN", ubigeo[0], ruta[0] + emp + sufijo[0] + ".pdf")

                    print CroquisPathPdf
                    arcpy.RefreshActiveView()
                    arcpy.mapping.ExportToPDF(mxd, CroquisPathPdf, "PAGE_LAYOUT")
                    # --------------------------------------------------------------------------------------------------
                    # GUARDAR MXD
                    # mxd.saveACopy(r'D:\SegmentacionRuralV2\Procesamiento\Croquis\Rural_mxd\{}.mxd'.format(ruta[0] + emp + sufijo[0]))

                    # --------------------------------------------------------------------------------------------------

                    try:
                        # print CroquisPathPdf
                        arcpy.RefreshActiveView()
                        # arcpy.mapping.ExportToPDF(mxd, CroquisPathPdf, "PAGE_LAYOUT")
                    except KeyboardInterrupt:
                        print "Error en pdf"
                        sys.exit(0)
                    # except Exception as ex:
                    #     print ex
        del mxd
예제 #2
0
def CroquisSeccion(ubigeos, WorkSpaceCroquis, SEGM_R_AER, SCR_LYR,
                   mxd_croquis_scr):

    listaProblemas = []

    mxd = arcpy.mapping.MapDocument(mxd_croquis_scr)
    df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
    settings.conectionGDB_arcpy()
    settings.conectionDB_arcpy()

    for ubigeo in datosDistrito(ubigeos):
        print ubigeo

        queryCapasAuxiliares(ubigeo[0], mxd)
        informacionCabecera(ubigeo, mxd)
        # agregarLyrUbigeo(mxd, ubigeo[0], "UBIGEO")

        for seccion in datosSeccion(ubigeo[0]):

            informacionCabeceraSCR(mxd, seccion[0], seccion[1], seccion[2],
                                   seccion[3])
            # idscr = seccion[0]
            agregarLyrUbigeo(mxd, ubigeo[0], "UBIGEO", seccion[0])
            querysLayers(mxd, seccion[0], "IDSCR", ubigeo[0])

            listarevisar = zoomCCPP(mxd, df, seccion)
            sql = aersenscr(seccion[0])
            geometriaScr(seccion[1], sql, SEGM_R_AER, df, SCR_LYR, mxd)
            # zoomAER2(mxd, df)

            CroquisPathPdf = os.path.join(WorkSpaceCroquis, "Rural", ubigeo[0],
                                          seccion[0] + ".pdf")
            print CroquisPathPdf
            if len(listarevisar) > 0:
                listaRevisar(ubigeo[0], seccion[0])

            arcpy.mapping.ExportToPDF(mxd, CroquisPathPdf, "PAGE_LAYOUT")
            # mxd.saveACopy(r'D:\SegmentacionRuralV2\Procesamiento\Croquis\Rural_mxd\{}.mxd'.format(seccion[0]))

            if len(listarevisar) > 0:
                print "Revisar croquis del ubigeo: " + str(ubigeo)
                print listaProblemas
예제 #3
0
#!/usr/bin/python
# -*- coding: utf-8-*-

import arcpy
from Generales import settings, funcionesGenerales

arcpy.overwriteOutput = True
CALIDAD_VIV_PRESEGM = r'Database Connections\CPV_SEGMENTACION_GDB.sde\CPV_SEGMENTACION_GDB.SDE.CALIDAD_RURAL\CPV_SEGMENTACION_GDB.SDE.CALIDAD_VIV_PRESEGM'
conn = settings.conectionDB_pymmsql()
conexionGDB = settings.conectionGDB_arcpy()
conexionDB = settings.conectionDB_arcpy()


def ubigeosDisponibles(conn=conn):
    cursor = conn.cursor()
    cursor.execute(
        "SELECT DISTINCT UBIGEO FROM VW_SEGM_R_INSUMOS WHERE TB_AER = 1 AND CPV_SEGMENTACION_GDB.sde.TB_CCPP = 1 AND TB_VIVIENDA_R = 1 AND TB_CPV0301_VIVIENDA_R = 1"
    )
    ubigeos = [x[0] for x in cursor]
    return ubigeos


def viv_E1(expresion, conn=conn):
    cursor = conn.cursor()
    cursor.execute(
        "SELECT IDVIV FROM TB_VIVIENDA_R WHERE ({}) GROUP BY IDVIV HAVING COUNT(IDVIV) > 1"
        .format(expresion))
    informacion = [[x[0], 1] for x in cursor]
    cursor.close()
    return informacion
예제 #4
0
from Generales import settings, funcionesGenerales
import arcpy

SEGM_R_CCPPRUTA = r'Database Connections\CPV_SEGMENTACION.sde\CPV_SEGMENTACION.dbo.SEGM_R_CCPPRUTA'
SEGM_R_RUTA = r'Database Connections\CPV_SEGMENTACION.sde\CPV_SEGMENTACION.dbo.SEGM_R_RUTA'
RUTA = r'Database Connections\CPV_SEGMENTACION_GDB.sde\CPV_SEGMENTACION_GDB.SDE.MODULO_SEGM_RURAL\CPV_SEGMENTACION_GDB.SDE.SEGM_R_RUTA'
CCPPRUTA = r'Database Connections\CPV_SEGMENTACION_GDB.sde\CPV_SEGMENTACION_GDB.SDE.MODULO_SEGM_RURAL\CPV_SEGMENTACION_GDB.SDE.SEGM_R_CCPPRUTA'

conn = settings.conectionDB_pymmsql()
settings.conectionGDB_arcpy()
settings.conectionDB_arcpy()


def actualizaRutas(ubigeo):
    cursorsql2 = conn.cursor()
    cursorsql2.execute("EXEC ACTUALIZAR_RUTAS '{}'".format(ubigeo))
    conn.commit()
    cursorsql2.close()


def agregarCategoria(conn=conn):
    cursor = conn.cursor()
    cursor.execute(
        "UPDATE A SET A.CAT_CCPP = B.CATEGORIA_O FROM CPV_SEGMENTACION_GDB.SDE.SEGM_R_CCPPRUTA AS A INNER JOIN CPV_SEGMENTACION_GDB.sde.TB_CCPP AS B ON A.IDCCPP COLLATE DATABASE_DEFAULT = B.LLAVE_CCPP COLLATE DATABASE_DEFAULT WHERE A.CAT_CCPP IS NULL"
    )
    conn.commit()
    cursor.close()


def agregarAers(conn=conn):
    cursor = conn.cursor()