示例#1
0
    def uso_suelo(query, municipio) -> str:

        query = query.replace(
            "WHERE", " FROM " + Constants.grafo_uso_suelo() + " WHERE")

        query += (
            Constants.municipio() +
            " <http://purl.org/linked-data/sdmx/2009/dimension#refArea> " +
            Constants.etiqueta() + " . ")

        query += (TemplatesAragon.create_bif_contains(
            municipio, Constants.etiqueta()) + " . ")

        answerpart = (
            Constants.municipio() +
            " <http://opendata.aragon.es/def/iaest/dimension#corine-land-cover-2000-nivel-5-descripcion> "
            + Constants.aux1() + " . ")

        query += answerpart

        query += ("BIND(SUBSTR(STRDT(" + Constants.aux1() +
                  ", xsd:string),80) as" + Constants.answer0() + ") . ")

        query += TemplatesAragon.selecting_max_year(
            Constants.grafo_uso_suelo(), answerpart)
        return query
示例#2
0
    def antiguedad_edificios(query, municipio) -> str:

        query = query.replace(
            "WHERE",
            Constants.fecha() + " " + Constants.etiqueta2() + " FROM " +
            Constants.grafo_edificios_construccion() + " WHERE",
        )

        query += (
            Constants.municipio() +
            " <http://purl.org/linked-data/sdmx/2009/dimension#refArea> " +
            Constants.etiqueta() + " . ")

        query += (TemplatesAragon.create_bif_contains(
            municipio, Constants.etiqueta()) + " . ")

        answerpart = (
            Constants.municipio() +
            " <http://opendata.aragon.es/def/iaest/medida#numero-hogares> " +
            Constants.answer0() + " . ")

        query += answerpart

        query += TemplatesAragon.selecting_max_year(
            Constants.grafo_edificios_construccion(), answerpart)

        return query
示例#3
0
    def selecting_max_year(grafo: str, answerpart: str) -> str:

        query = " { SELECT DISTINCT MAX(xsd:integer(?max)) as " + Constants.year_max(
        )

        query += " FROM " + grafo

        query += " WHERE { "

        query += (
            Constants.municipio() +
            " <http://purl.org/linked-data/sdmx/2009/dimension#refArea> " +
            Constants.etiqueta() + " . ")

        query += (
            Constants.municipio() +
            " <http://purl.org/linked-data/sdmx/2009/dimension#refPeriod> " +
            Constants.fecha() + " . ")

        query += ("BIND(SUBSTR(STRDT(" + Constants.fecha() +
                  ", xsd:string),38,4) as ?max) . ")

        query += answerpart

        query += " }}"
        return query
示例#4
0
    def tipo_area_extranjeros(query, tipo_area) -> str:
        tipo_area = tipo_area.lower()

        if tipo_area == "continente":
            query = query.replace(
                "WHERE",
                " FROM " + Constants.grafo_extranjeros_continente() + " WHERE")

            query += (
                Constants.municipio() +
                " <http://opendata.aragon.es/def/iaest/medida#personas> " +
                Constants.answer0() + " . ")
        elif tipo_area == "pais":
            query = query.replace(
                "WHERE",
                " FROM " + Constants.grafo_extranjeros_pais() + " WHERE")

            query += (
                Constants.municipio() +
                " <http://opendata.aragon.es/def/iaest/medida#extranjeros> " +
                Constants.answer0() + " . ")

        query += (
            Constants.municipio() +
            " <http://opendata.aragon.es/def/iaest/dimension#nacionalidad-" +
            tipo_area + "-nombre> " + Constants.etiqueta2() + " . ")
        return query
示例#5
0
    def empresas_por_actividad(query, municipio) -> str:

        query = query.replace("SELECT DISTINCT ?answer0",
                              "SELECT DISTINCT SUM(?answer0) as ?answer0")

        query = query.replace(
            "WHERE", " FROM " + Constants.grafo_actividad_empresa() + " WHERE")

        query += (
            Constants.municipio() +
            " <http://purl.org/linked-data/sdmx/2009/dimension#refArea> " +
            Constants.etiqueta() + " . ")

        query += (TemplatesAragon.create_bif_contains(
            municipio, Constants.etiqueta()) + " . ")

        answerpart = (
            Constants.municipio() +
            " <http://opendata.aragon.es/def/iaest/medida#numero-de-actividades> "
            + Constants.answer0() + " . ")

        query += answerpart

        query += TemplatesAragon.selecting_max_year(
            Constants.grafo_sector_empresa(), answerpart)
        return query
示例#6
0
    def superficie_municipio(query, municipio) -> str:
        query += (Constants.municipio() + " aragopedia:areaTotal " +
                  Constants.answer0() + " . ")
        query += Constants.municipio() + " rdfs:label " + Constants.etiqueta()

        query += (TemplatesAragon.create_bif_contains(
            municipio, Constants.etiqueta()) + " . ")
        return query
示例#7
0
    def superficie_secano(query, municipio) -> str:
        query += (Constants.municipio() + " aragopedia:hasObservation " +
                  Constants.observacion() + " . ")
        query += Constants.municipio() + " rdfs:label " + Constants.etiqueta()

        query += (TemplatesAragon.create_bif_contains(
            municipio, Constants.etiqueta()) + " . ")

        query += (Constants.observacion() +
                  " aragopedia:hectareasCultivosSecano " +
                  Constants.answer0() + " . ")
        return query
示例#8
0
    def comarca_del_municipio(query, municipio) -> str:
        query += (Constants.municipio() + " aragopedia:enComarca " +
                  Constants.comarca() + " . ")

        query += Constants.municipio() + " rdfs:label " + Constants.etiqueta()

        query += (TemplatesAragon.create_bif_contains(
            municipio, Constants.etiqueta()) + " . ")

        query += Constants.comarca() + " rdfs:label " + Constants.answer0(
        ) + " . "
        return query
示例#9
0
    def cargo_municipio(query, municipio) -> str:
        # municipio = municipio.upper()  # En el campo esta en mayusculas el municipio

        query += (Constants.id_membresia() + " org:organization " +
                  Constants.municipio() + " . ")

        query += (Constants.municipio() + " ei2a:organizationName " +
                  Constants.etiqueta())

        query += (TemplatesAragon.create_bif_contains(
            municipio, Constants.etiqueta()) + " . ")
        return query
示例#10
0
    def poblacion(query, municipio) -> str:

        query += (
            Constants.municipio() +
            " <http://purl.org/linked-data/sdmx/2009/dimension#refArea> " +
            Constants.etiqueta() + " . ")

        query += (TemplatesAragon.create_bif_contains(
            municipio, Constants.etiqueta()) + " . ")

        query += (Constants.municipio() +
                  " <http://opendata.aragon.es/def/iaest/medida#poblacion> " +
                  Constants.answer0() + " . ")
        return query
示例#11
0
    def habitantes_municipio(query, municipio) -> str:
        query = query.replace(Constants.answer0(),
                              Constants.answer0() + " " + Constants.answer1())

        query += (Constants.municipio() + " aragopedia:menPopulation " +
                  Constants.answer0() + " . ")

        query += (Constants.municipio() + " aragopedia:womenPopulation " +
                  Constants.answer1() + " . ")

        query += Constants.municipio() + " rdfs:label " + Constants.etiqueta()

        query += (TemplatesAragon.create_bif_contains(
            municipio, Constants.etiqueta()) + " . ")
        return query
示例#12
0
    def email_ayuntamiento(query, municipio) -> str:
        # municipio = municipio.upper()  # En el campo esta en mayusculas el municipio

        query += (Constants.municipio() + " " + Constants.aux0() +
                  " ei2a:Ayuntamiento . ")

        query += (Constants.municipio() + " ei2a:organizationName " +
                  Constants.etiqueta())

        query += (TemplatesAragon.create_bif_contains(
            municipio, Constants.etiqueta()) + " . ")

        query += Constants.municipio() + " foaf:mbox " + Constants.answer0(
        ) + " . "
        return query
示例#13
0
    def year_dataset(query, year) -> str:

        Log.log_debug("QUERIES_: Entrando a year_dataset()")
        Log.log_debug("QUERIES_: Year entrante: {0} ".format(year))

        if year == "":
            query = TemplatesAragon.year_max_one_paramater(query)
        else:

            Log.log_debug(
                "QUERIES_: query before replacing: {0} ".format(query))

            pos_init = query.find("{ SELECT")
            Log.log_debug("QUERIES_: posicion init: {0} ".format(pos_init))
            pos_end = query.find(" }}")
            Log.log_debug("QUERIES_: posicion end: {0} ".format(pos_end))
            subquery = query[pos_init:pos_end + 3]
            Log.log_debug("QUERIES_: subquery: {0} ".format(subquery))
            query = query.replace(subquery, "")

            Log.log_debug("QUERIES_: query post replace: {0} ".format(query))

            query += (
                Constants.municipio() +
                " <http://purl.org/linked-data/sdmx/2009/dimension#refPeriod> "
                + Constants.fecha() + " . ")

            query += (
                TemplatesAragon.create_bif_contains(year, Constants.fecha()) +
                " . ")

        return query
示例#14
0
    def year_dataset_max(query, cadena) -> str:

        Log.log_debug("QUERIES_: Entrando a year_dataset_max()")
        Log.log_debug("QUERIES_: query: {0} ".format(query))

        query = query.replace(
            Constants.etiqueta() + "  FROM",
            Constants.etiqueta() + " " + Constants.fecha() + " FROM",
        )

        query += (
            Constants.municipio() +
            " <http://purl.org/linked-data/sdmx/2009/dimension#refPeriod> " +
            Constants.fecha() + " . ")

        try:
            if int(cadena) > 1900:
                query += (TemplatesAragon.create_filter_regex_var(
                    "STRDT(" + str(cadena) + ", xsd:string)",
                    Constants.fecha()) + " . ")
        except:
            query += (TemplatesAragon.create_filter_regex_var(
                "STRDT(" + Constants.year_max() + ", xsd:string)",
                Constants.fecha()) + " . ")

        return query
示例#15
0
    def num_parados(query, municipio) -> str:

        query = query.replace("WHERE",
                              " FROM " + Constants.grafo_parados() + " WHERE")

        query += (
            Constants.municipio() +
            " <http://purl.org/linked-data/sdmx/2009/dimension#refArea> " +
            Constants.etiqueta() + " . ")

        query += (TemplatesAragon.create_bif_contains(
            municipio, Constants.etiqueta()) + " . ")

        query += (Constants.municipio() +
                  " <http://opendata.aragon.es/def/iaest/medida#n-parados> " +
                  Constants.answer0() + " . ")
        return query
示例#16
0
    def num_trabajadores(query: str, trabajadores: str) -> str:

        query += (Constants.municipio() +
                  " <http://opendata.aragon.es/def/iaest/dimension#estrato> " +
                  Constants.etiqueta2() + " . ")

        query += TemplatesAragon.create_bif_contains(trabajadores,
                                                     Constants.etiqueta2())
        return query
示例#17
0
    def hectareas_quemadas(query, municipio) -> str:

        query = query.replace(
            "WHERE", " FROM " + Constants.grafo_incendios() + " WHERE")

        query += (
            Constants.municipio() +
            " <http://purl.org/linked-data/sdmx/2009/dimension#refArea> " +
            Constants.etiqueta() + " . ")

        query += (TemplatesAragon.create_bif_contains(
            municipio, Constants.etiqueta()) + " . ")

        query += (
            Constants.municipio() +
            " <http://opendata.aragon.es/def/iaest/medida#superficie-forestal-afectada> "
            + Constants.answer0() + " . ")
        return query
示例#18
0
    def renta_per_capita(query, municipio) -> str:

        query = query.replace("WHERE",
                              " FROM " + Constants.grafo_renta() + " WHERE")

        query += (
            Constants.municipio() +
            " <http://purl.org/linked-data/sdmx/2009/dimension#refArea> " +
            Constants.etiqueta() + " . ")

        query += (TemplatesAragon.create_bif_contains(
            municipio, Constants.etiqueta()) + " . ")

        query += (
            Constants.municipio() +
            " <http://opendata.aragon.es/def/iaest/medida#renta-disponible-bruta-per-capita> "
            + Constants.answer0() + " . ")
        return query
示例#19
0
    def antiguedad(query: str, antiguedad: str) -> str:

        query += (
            Constants.municipio() +
            " <http://opendata.aragon.es/def/iaest/dimension#ano-de-construccion> "
            + Constants.etiqueta2() + " . ")

        query += (TemplatesAragon.create_bif_contains(
            antiguedad, Constants.etiqueta2()) + " . ")
        return query
示例#20
0
    def actividad(query: str, actividad: str) -> str:

        query += (
            Constants.municipio() +
            " <http://opendata.aragon.es/def/iaest/dimension#rama-de-actividad> "
            + Constants.etiqueta2() + " . ")

        query += (TemplatesAragon.create_bif_contains(
            actividad, Constants.etiqueta2()) + " . ")
        return query
示例#21
0
    def sector(query: str, sector: str) -> str:

        query += (
            Constants.municipio() +
            " <http://opendata.aragon.es/def/iaest/dimension#sector-descripcion> "
            + Constants.etiqueta2() + " . ")

        query += TemplatesAragon.create_bif_contains(sector,
                                                     Constants.etiqueta2())
        return query
示例#22
0
    def tipo_superficie(query: str, tipo_superficie: str) -> str:

        query += (
            Constants.municipio() +
            " <http://opendata.aragon.es/def/iaest/dimension#corine-land-cover-2000-nivel-1-descripcion> "
            + Constants.aux1() + " . ")

        query += TemplatesAragon.create_bif_contains(tipo_superficie,
                                                     Constants.aux1())
        return query
示例#23
0
    def poblacion_extranjeros(query, municipio) -> str:

        query += (
            Constants.municipio() +
            " <http://purl.org/linked-data/sdmx/2009/dimension#refArea> " +
            Constants.etiqueta() + " . ")

        query += (TemplatesAragon.create_bif_contains(
            municipio, Constants.etiqueta()) + " . ")
        return query
示例#24
0
    def fax_municipio(query, municipio) -> str:
        # municipio = municipio.upper()  # En el campo esta en mayusculas el municipio

        query += (Constants.municipio() + " " + Constants.aux0() +
                  " ei2a:Ayuntamiento . ")

        query += (Constants.municipio() + " ei2a:organizationName " +
                  Constants.etiqueta())

        query += (TemplatesAragon.create_bif_contains(
            municipio, Constants.etiqueta()) + " . ")

        query += Constants.municipio() + " org:hasSite " + Constants.sede(
        ) + " . "

        query += Constants.sede() + " org:siteAddress " + Constants.aux1(
        ) + " . "

        query += Constants.aux1() + " vcard:Fax " + Constants.answer0() + " . "
        return query
示例#25
0
    def empresas_por_trabajadores(query, municipio) -> str:

        query = query.replace("SELECT DISTINCT ?answer0",
                              "SELECT DISTINCT SUM(?answer0) as ?answer0")

        query = query.replace(
            "WHERE",
            " FROM " + Constants.grafo_trabajadores_empresa() + " WHERE")

        query += (
            Constants.municipio() +
            " <http://purl.org/linked-data/sdmx/2009/dimension#refArea> " +
            Constants.etiqueta() + " . ")

        query += (TemplatesAragon.create_bif_contains(
            municipio, Constants.etiqueta()) + " . ")

        query += (
            Constants.municipio() +
            " <http://opendata.aragon.es/def/iaest/medida#numero-empresas> " +
            Constants.answer0() + " . ")
        return query
示例#26
0
    def sexo(query, sexo) -> str:
        sexo = sexo.lower()

        query = query.replace("SELECT DISTINCT ?answer0",
                              "SELECT DISTINCT SUM(?answer0) as ?answer0")

        query += (Constants.municipio() +
                  " <http://opendata.aragon.es/def/iaest/dimension#sexo> " +
                  Constants.aux1() + " . ")

        if sexo == "mujeres" or sexo == "hombres":
            query += TemplatesAragon.create_bif_contains(
                sexo, Constants.aux1()) + " . "
        return query
示例#27
0
    def hectareas_zona(query, municipio) -> str:

        query = query.replace(
            "WHERE", " FROM " + Constants.grafo_hectareas_zona() + " WHERE")

        query += (
            Constants.municipio() +
            " <http://purl.org/linked-data/sdmx/2009/dimension#refArea> " +
            Constants.etiqueta() + " . ")

        query += (TemplatesAragon.create_bif_contains(
            municipio, Constants.etiqueta()) + " . ")

        answerpart = (
            Constants.municipio() +
            " <http://opendata.aragon.es/def/iaest/medida#superficie-has> " +
            Constants.answer0() + " . ")

        query += answerpart

        query += TemplatesAragon.selecting_max_year(
            Constants.grafo_contenedores_vidrio(), answerpart)
        return query