This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE FUNCTION st_extend ( | |
geom geometry, | |
head_rate double precision, | |
head_constant double precision, | |
tail_rate double precision, | |
tail_constant double precision) | |
RETURNS geometry AS | |
$BODY$ | |
-- Extends a linestring. | |
-- First segment get extended by length * head_rate + head_constant. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def activate_visibility_preset(preset_name, *, project=None, coll=None): | |
"""Activates a visibility preset by its name. | |
Return a boolean indicating success.""" | |
# https://github.com/qgis/QGIS/blob/f044c95fd8927d86967ce8af3930bdc7523095fa/src/app/qgsmapthemes.cpp#L138 | |
if project is None: | |
project = qgis.core.QgsProject.instance() | |
if coll is None: | |
coll = project.mapThemeCollection() | |
if not coll.hasMapTheme(preset_name): | |
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# It is assumed that the layer has both "labelX" and a "labelY" attributes set as real number fields. | |
# Labels / Placement / Data Defined / Coordinate / X: | |
CASE WHEN "labelX" IS NULL THEN toreal(regexp_substr(geom_to_wkt(centroid($geometry)), '(-?\\d+\\.?\\d*) -?\\d+\\.?\\d*')) ELSE "labelX" END | |
# Labels / Placement / Data Defined / Coordinate / Y: | |
CASE WHEN "labelY" IS NULL THEN toreal(regexp_substr(geom_to_wkt(centroid($geometry)), '-?\\d+\\.?\\d* (-?\\d+\\.?\\d*)')) ELSE "labelY" END | |
# Labels / Placement / Data Defined / Alignment / horizontal: | |
'Center' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# project | |
project_crs = qgis.utils.iface.mapCanvas().mapRenderer().destinationCrs() | |
qgis.utils.iface.mapCanvas().mapRenderer().setDestinationCrs(new_project_crs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A gyógyszer tanított meg arra, hogy beteg legyek. | |
Az idő lejár; a cserebogár marad sárga cserebogár. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# QgsFields() of QgsVectorLayer() | |
# fields = layer.fields() # from QGIS 1.12+ | |
fields = layer.pendingFields() # and below... | |
# list QgsField() from QgsFields() | |
fieldlist = fields.toList() | |
# list of layer fieldnames | |
[f.name() for f in fieldlist] |