Tutoriais usados:
Instale a versão do php que estiver rodando no servidor, verifique a versão em http://localhost/dashboard/phpinfo.php
CREATE SCHEMA IF NOT EXISTS public; | |
DROP TABLE IF EXISTS public.cep_para_todos_pilotos_sp; | |
CREATE TABLE public.cep_para_todos_pilotos_sp ( | |
logradouro TEXT, | |
localidade TEXT, | |
bairro TEXT, | |
cep TEXT, | |
geom geometry(MultiLineString, 4326) | |
); | |
INSERT INTO public.cep_para_todos_pilotos_sp VALUES |
CREATE SCHEMA IF NOT EXISTS public; | |
DROP TABLE IF EXISTS public.cep_para_todos_pilotos_sp; | |
CREATE TABLE public.cep_para_todos_pilotos_sp ( | |
logradouro TEXT, | |
localidade TEXT, | |
bairro TEXT, | |
cep TEXT, | |
geom geometry(MultiPolygon, 4326) | |
); | |
INSERT INTO public.cep_para_todos_pilotos_sp VALUES |
FROM python:3.11 | |
WORKDIR /app | |
COPY ./requirements.txt /app | |
RUN apt-get update -y | |
RUN apt-get install -qqy python3-pip libgdal-dev gdal-bin postgresql-client nano | |
RUN apt-get clean |
import os | |
import sys | |
from qgis.core import ( | |
QgsApplication, | |
QgsProject, | |
QgsCoordinateReferenceSystem, | |
QgsProcessingContext, | |
QgsProcessingAlgorithm, | |
) |
Tutoriais usados:
Instale a versão do php que estiver rodando no servidor, verifique a versão em http://localhost/dashboard/phpinfo.php
SELECT
'ALTER TABLE '|| table_name || ' RENAME TO ''' || replace(table_name, '2021', '2020') ||''';'
FROM gpkg_geometry_columns
WHERE table_name like '%2021';
Esse SQL vai buscar os nomes das tabelas em gpkg_geometry_columns
e criar o sql de renomeação para cada uma das tabelas que passarem no WHERE
.
with_variable('lyr_name', -- variável que vai pegar o nome do estado | |
aggregate( | |
layer:='lim_unidade_federacao_a', -- nome da camda do estado | |
aggregate:='min', | |
expression:="sigla", -- campo que quer usar para gerar o nome da camada | |
filter:=contains($geometry, geometry(@parent)) | |
), | |
with_variable('lyrmaps', -- vai receber o nome de todas as camadas no projeto | |
array_foreach(@layers, layer_property(@element, 'name')), --pega o nome de todas as camadas do projeto em uma lista | |
with_variable('lyrpos', array_find(@lyrmaps, upper(@lyr_name)), -- lirpos procura o nome da camada na lista e retorna a posicao, se nao encontrar retorna -1 |
O agendamento do crontab está da seguinte forma
*/15 * * * * cd /root/pasta_script; ./script.sh --cron
o script sh tem permissão para execução.....
Quando executo o arquivo .sh manualmente, o arquivo de log recebe todos os prints que o arquivo python gera, quando o script é executado
// adaptado de https://github.com/tryber/sd-05-live-lectures/blob/39.1/expressoes.py | |
const MATCHES = { | |
'}': '{', | |
']': '[', | |
')': '(', | |
'"': '"', | |
"'": "'", | |
"`": "`", | |
"```": "```" | |
}; |
-- Expression to be used at SELECT BY EXPRESSION AT LAYER A | |
array_contains( -- This will return true if the array contains the value | |
aggregate( -- will aggregate all values from target in to a string, using semicolons as concatenator | |
layer:='<table_b>', -- Target table containing the values, replace <table_b> whith your table name | |
aggregate:='array_agg', | |
expression:=to_string("<field_from_table_b>"), -- Field from table_b containing the values | |
), | |
"<field_table_a>") -- Field from table a with values to compare, replace <field_table_a> with your field name |