I have a spatial table in SQL Server with point features, and connected it to QGIS which neatly shows all points.
Now I want to select points in this table (and show them in the map) within a certain radius from a certain point.
I am building a plugin in QGIS to perform this, based on a postal code api (which gives a point) and a radius.
My question is: how to select these points with Python? With the setSubsetString command? If yes, what should be the filtering criterion string, and if not, how then?
I have already working code to request the postal code api, and centre the map on the resulting point (lon, lat).
The code for the postal code point is:
map_pos = QgsPointXY(lon, lat)
The code for the layer to be queried / filtered is:
pr = QgsProject.instance().mapLayersByName('Project')
The points in this layer are in the geography type field 'Position'.
Then I want to use
pr.setSubsetString( 'filterstring') to select the points in this layer that are within a radius of say 1 km around point map_pos.
Which 'filterstring' should I use?