Listando todas as funções disponíveis na Camada Virtual do QGIS

Dec 23 2020

Como posso obter automaticamente uma lista de todas as funções disponíveis para uso na Camada Virtual do QGIS?

Do meu próprio entendimento / experiência e da Documentação QGIS , a Camada Virtual do QGIS emprega uma mistura de funções fornecidas em PostGIS , SQLite , SpatiaLite e as Funções de expressões QGIS . (Espero não ter perdido nada vital.)

Eu vi vários tópicos Quais funções espaciais estão disponíveis para shapefiles como “camadas virtuais” no QGIS DB Manager? e Camadas virtuais para QGIS (GitHub) , infelizmente, em nenhuma delas, consegui encontrar a solução para minha preocupação.

Respostas

11 J.Monticolo Dec 23 2020 at 22:14

Você pode acessar diretamente as camadas virtuais com o poder da introspecção Python e módulos QGIS Python bem formatados com este código abaixo executado no console QGIS:

from db_manager.db_plugins.vlayers import sql_dictionary

print(f"Functions: {sql_dictionary.functions}")
print(f"Math functions: {sql_dictionary.math_functions}")
print(f"String functions: {sql_dictionary.string_functions}")
print(f"Aggregate functions: {sql_dictionary.aggregate_functions}")
print(f"Spatialite functions: {sql_dictionary.spatialite_functions}")
print(f"QGIS functions: {sql_dictionary.qgis_functions}")

Resulta em:

Functions: ['changes', 'coalesce', 'glob', 'ifnull', 'hex', 'last_insert_rowid', 'nullif', 'quote', 'random', 'randomblob', 'replace', 'round', 'soundex', 'total_change', 'typeof', 'zeroblob', 'date', 'datetime', 'julianday', 'strftime']
Math functions: ['Abs', 'ACos', 'ASin', 'ATan', 'Cos', 'Cot', 'Degrees', 'Exp', 'Floor', 'Log', 'Log2', 'Log10', 'Pi', 'Radians', 'Round', 'Sign', 'Sin', 'Sqrt', 'StdDev_Pop', 'StdDev_Samp', 'Tan', 'Var_Pop', 'Var_Samp']
String functions: ['Length', 'Lower', 'Upper', 'Like', 'Trim', 'LTrim', 'RTrim', 'Replace', 'Substr']
Aggregate functions: ['Max', 'Min', 'Avg', 'Count', 'Sum', 'Group_Concat', 'Total', 'Var_Pop', 'Var_Samp', 'StdDev_Pop', 'StdDev_Samp']
Spatialite functions: ['*iszipblob', '*ispdfblob', '*isgifblob', '*ispngblob', '*isjpegblob', '*isexifblob', '*isexifgpsblob', '*geomfromexifgpsblob', 'MakePoint', 'BuildMbr', '*buildcirclembr', 'ST_MinX', 'ST_MinY', 'ST_MaxX', 'ST_MaxY', 'ST_GeomFromText', '*pointfromtext', '*geomfromwkb', '*pointfromwkb', 'ST_AsText', 'ST_AsBinary', '*assvg', '*asfgf', '*geomfromfgf', 'ST_Dimension', 'ST_GeometryType', 'ST_Srid', 'ST_SetSrid', 'ST_isEmpty', 'ST_isSimple', 'ST_isValid', 'ST_Boundary', 'ST_Envelope', 'ST_X', 'ST_Y', 'ST_StartPoint', 'ST_EndPoint', 'ST_Length', 'ST_isClosed', 'ST_isRing', 'ST_Simplify', '*simplifypreservetopology', 'ST_NumPoints', 'ST_PointN', 'ST_Centroid', 'ST_PointOnSurface', 'ST_Area', 'ST_ExteriorRing', 'ST_InteriorRingN', 'ST_NumGeometries', 'ST_GeometryN', 'MbrEqual', 'MbrDisjoint', 'MbrTouches', 'MbrWithin', 'MbrOverlaps', 'MbrIntersects', 'MbrContains', 'ST_Equals', 'ST_Disjoint', 'ST_Touches', 'ST_Within', 'ST_Overlaps', 'ST_Crosses', 'ST_Intersects', 'ST_Contains', 'ST_Relate', 'ST_Distance', 'ST_Intersection', 'ST_Difference', 'ST_Union', 'ST_SymDifference', 'ST_Buffer', 'ST_ConvexHull', 'ST_Transform', '*initspatialmetadata', '*addgeometrycolumn', '*recovergeometrycolumn', '*discardgeometrycolumn', '*createspatialindex', '*creatembrcache', '*disablespatialindex', '*checkspatialmetadata', '*autofdostart', '*autofdostop', '*initfdospatialmetadata', '*addfdogeometrycolumn', '*recoverfdogeometrycolumn', '*discardfdogeometrycolumn', '*filtermbrwithin', '*filtermbrcontains', '*filtermbrintersects', '*buildmbrfilter']
QGIS functions: ['atan2', 'round', 'rand', 'randf', 'clamp', 'scale_linear', 'scale_exp', '_pi', 'to_int', 'toint', 'to_real', 'toreal', 'to_string', 'tostring', 'to_datetime', 'todatetime', 'to_date', 'todate', 'to_time', 'totime', 'to_interval', 'tointerval', 'regexp_match', 'now', '_now', 'age', 'year', 'month', 'week', 'day', 'hour', 'minute', 'second', 'day_of_week', 'title', 'levenshtein', 'longest_common_substring', 'hamming_distance', 'wordwrap', 'regexp_replace', 'regexp_substr', 'concat', 'strpos', '_left', '_right', 'rpad', 'lpad', 'format', 'format_number', 'format_date', 'color_rgb', 'color_rgba', 'ramp_color', 'color_hsl', 'color_hsla', 'color_hsv', 'color_hsva', 'color_cmyk', 'color_cmyka', 'color_part', 'darker', 'lighter', 'set_color_part', 'point_n', 'start_point', 'end_point', 'nodes_to_points', 'segments_to_lines', 'make_point', 'make_point_m', 'make_line', 'make_polygon', 'x_min', 'xmin', 'x_max', 'xmax', 'y_min', 'ymin', 'y_max', 'ymax', 'geom_from_wkt', 'geomFromWKT', 'geom_from_gml', 'relate', 'intersects_bbox', 'bbox', 'translate', 'buffer', 'point_on_surface', 'reverse', 'exterior_ring', 'interior_ring_n', 'geometry_n', 'bounds', 'num_points', 'num_interior_rings', 'num_rings', 'num_geometries', 'bounds_width', 'bounds_height', 'is_closed', 'convex_hull', 'sym_difference', 'combine', '_union', 'geom_to_wkt', 'geomToWKT', 'transform', 'uuid', '_uuid', 'layer_property', 'var', '_specialcol_', 'project_color']