Re: [QGIS-Developer] Why was selection tool behaviour changed in 3.x?

2019-04-14 Thread Cory Albrecht
> It's not true to say that QGIS is an outlier:

I think it's quite fair to say that it is the outlier, and I gave a bunch
of example where click+drag is the norm and aI gave anumber of exmaples.
Click+drag is ubiquitous. Next time you go into a text field of the feature
attributes form to edit that text attribute, let me know how much text you
select by doing click-move-click instead of click+drag. :-)

> along with the reasons Jo mentions and increasing the ability to be more
accurate if you don't have to hold down the button

I would disagree that having to hold the button down while selecting makes
it less accurate as it doesn't affect how much you are able to flex your
wrist or add to stress on the carpal tunnel. Click or no click, you wrist
would make the same movements. Given the ubiquity of click+track in the
computer world, choosing that offer the better UX experience to the users
because it doesn't requires them to relearn how they do simple, common
actions for just one application.

Especially the regular "Select Feature(s)" tool (not polygon, freehand or
radius) does requires you to click and drag. If carpal tunnel issues and
accuracy were actual issues/reasons, then this tool also should have been
change to click, move, left-click to end just like the other selection
tools were changed. That lack of consistency leads to a frustrating
experience for the user, ask any UX designer.

> was to align with the behaviour of CAD, which does use "click-click",
rather than click-and-drag.

How many people who start using QGIS were CAD users beforehand? I suspect
that even minimally experienced CAD users are in the minority. If there is
a decent chunk that could benefit from such a UX/UI change, perhaps it
would have been more appropriate to make that a switch in the settings that
would change the behaviours?

On Wed, Apr 10, 2019 at 6:40 AM Tom Chadwin  wrote:

> Hi Cory
>
> From memory, there was a lot of discussion about making this change in the
> vertex editor. It's not true to say that QGIS is an outlier: the rationale
> behind the change - along with the reasons Jo mentions and increasing the
> ability to be more accurate if you don't have to hold down the button - was
> to align with the behaviour of CAD, which does use "click-click", rather
> than click-and-drag.
>
> Tom
>
>
>
> -
> Buy Pie Spy: Adventures in British pastry 2010-11 on Amazon
> --
> Sent from:
> http://osgeo-org.1560.x6.nabble.com/QGIS-Developer-f4099106.html
> ___
> QGIS-Developer mailing list
> QGIS-Developer@lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [QGIS-Developer] Why was selection tool behaviour changed in 3.x?

2019-04-14 Thread Cory Albrecht
> I would like to see a mode where the node that will be moved is
autoselected based on proximity to the mouse pointer.

That would be a UX prone to mistakes unless it had to be explicitly turned
on and very visible when on. :-)

On Mon, Apr 8, 2019 at 11:23 PM Jo  wrote:

> I guess the rationale was making it easier on the tendons in the carpal
> tunnel. Click, hold/move, click became click, move, click.
>
> I would like to see a mode where the node that will be moved is
> autoselected based on proximity to the mouse pointer. Then it would become
> move, click, move, click. Obviously this needs to be guided by a
> rubberband, whowing which node will be moved.
>
> In JOSM this "improve way accuracy" also allows Ctrl-Click for adding
> nodes, I mean vertices.
>
> Polyglot
>
> On Tue, Apr 9, 2019 at 2:54 AM Cory Albrecht  wrote:
>
>>
>> Cory Albrecht 
>> 8:14 PM (37 minutes ago)
>> to Régis
>> Hello Régis,
>>
>> Sorry for not being clear - I mean when using the selection tool in
>> freehand mode. I am definitely not talking about the identification tool,
>> assuming you're referring to the same thing that I am thinking of?
>> Ctrl+Shift+I, or the icon that is the cursor with a the letter "i" in a
>> sold blue circle. I'm not sure I would call that new as it's been part of
>> QGIS since I started using it in about 2015. Perhaps you're an old salt
>> from the 1.x days? ;-)
>>
>> As a principle of UX design, ideally, the user should do the same action
>> - click and drag - for any type of selection, both to maintain internal
>> consistency in the application and with common ways of doing things in the
>> broader computer universe. This lets people learn new software quickly by
>> having a set of transferable actions that can get them up and running and
>> doing rudimentary things quickly. It also helps reduce unintended errors
>> caused by using common actions that get unexpectedly interpreted different
>> than the user is used to. Things like this contribute to how easy or
>> frustrating an application is to use, both for new and long time users.
>>
>> 1. For the "Select Feature(s)", click and drag to indicate the diagonally
>> opposite corners of a selection rectangle.
>> 2. For the "Select Features by Freehand", click and drag to create an
>> irregular blob of selection area.
>> 3. For the "Select Features by Radius", click and drag to indicate the
>> centre of a selection circle and it's radius.
>>
>> In 2.x the answer to all of those was yes, but in 3.x it's yes, no, no.
>>
>> In vector and raster drawing applications, drawing rectangles, circles
>> and blobs is done by click and drag, as is selecting rectangular, circular
>> or irregular blobby areas. If you release and click elsewhere then drag,
>> you start drawing a new object, or you discard the first selection and
>> start outlining a new one. Word processing and text section, video editors
>> and frame selection, sound editors and lengths of time in a track, they all
>> have the user do these conceptually similar tasks in the same way - click
>> and drag to create a selection , new click discards old selection.
>>
>> Another principle of UX design is that you don't change how a user does
>> something unless there is clear benefit that outweighs the trouble of
>> relearning, especially for action concepts that are common in the broader
>> sphere. When you make changes without benefits you cause friction in your
>> user flows (some call those "point points"), and that means people find
>> that task (and potentially the application as a whole) difficult and
>> frustrating to use.
>>
>> For those three methods of selection there's nothing to be gained by
>> making QGIS 3.x the odd one out in how this is done. There's no benefit
>> added by extra functionality in these selection methods. All it does is
>> create pain points, both by being different from everybody else and by
>> being inconsistent internally.
>>
>> The exception to this is the poly gone selection tool. I've never
>> encountered it outside of QGIS and ArcGIS. Drawing applications have
>> polygon drawing tools in which you sequentially click the polygon's points,
>> just like how you create features on polygon or line layers in QGIS, but
>> there's no polygon selection analogue. As such it makes sense to take the
>> feature creation method of sequential clicks over for use in a polygon
>> selection tool rather than coming up with a whole new user flow like click
>> and drag and tapping the space bar for the points.
>>
>> And so I wonder - what was the rationale behind making this change?
>>
>> On Mon, Apr 8, 2019 at 6:00 AM Régis Haubourg 
>> wrote:
>>
>>> Hi Cory,
>>> I must say I didn't notice any difference on the selection tool behavior
>>> on my side.
>>> I don't think there was any explicit attempt to homogenize the selection
>>> behavior with the node tool new ergonomy.
>>>
>>> Just a check, in the maptool dropdown list for selection tool, are your
>>> using the freehand selection to

[QGIS-Developer] loading layer styles from PostGIS

2019-04-14 Thread Jo
I am trying to apply styles stored in a PostGIS DB.

In one method I'm trying to make an inventory, in the other method I try to
load the styles of a particular set for all layers.

I tried to find a solution using Google and this is the result of
assembling code using bits and pieces from other posts, but unfortunately
it still doesn't work.

def populate_layer_styles(self, layer):
for style in layer.listStylesInDatabase()[2]:
style_set = style[3]
if style_set not in self.layer_styles:
self.layer_styles[style_set] = {}
style_manager = layer.styleManager()
from PyQt5.QtXml import QDomDocument
self.query = "SELECT styleqml FROM public.layer_styles WHERE
stylename='{}'".format(style)
print(self.query)
self.perform_query()
styleqml = self.result[0]
style_doc = QDomDocument()
style_doc.setContent(styleqml)
print(layer.importNamedStyle(style_doc))
print(layer.loadNamedStyle(style))
style_manager.addStyleFromLayer(style)

self.layer_styles[style_set][style] = style_manager
for style_set in self.layer_styles:
if style_set not in self.dockwidget.rb_styles.button:
self.dockwidget.rb_styles.add_button(str(style_set),
self.activate_style_set)

def activate_style_set(self, style_set):

'''style_set is '1' or '2', etc'''
print(style_set.text())
for layer in QgsProject.instance().mapLayers().values():
# only for vector layers
if layer.type() != 0:
continue
# Extract table name using light regex
table_re = re.compile(r'table="main"."(mow_.+?)"')
table = table_re.search(layer.source())
if table:
table = table.group(1)
else:
continue
# And compare it with layer names used for reloading the layers
if table in self.tablenames:
style = 'set' + style_set.text() + '-' + table
print(style)
print(layer.loadNamedStyle(style))
style_manager = layer.styleManager()
# style_manager.addStyleFromLayer(style)
print(style_manager.mapLayerStyles())
# print(style_manager.layer().name())
print(style_manager.currentStyle())
style_manager.setCurrentStyle(style)
print(style_manager.currentStyle())
print(layer.id())
self.iface.layerTreeView().refreshLayerSymbology(layer.id())
self.iface.mapCanvas().refreshAllLayers()

def reload_layers(self):
self.iface.mapCanvas().layers()
geometrycol = "geom"
self.layer_styles = {}

for l in QgsProject.instance().mapLayers():
for table in self.tablenames:
if l.title().lower().startswith(table):
QgsProject.instance().removeMapLayer(l)
for table in self.tablenames:
uri = QgsDataSourceUri()
uri.setConnection(DB_ADDRESS, DB_PORT, DB_NAME, DB_USERNAME,
DB_PASSWORD)
uri.setDataSource("main", table, geometrycol)
layer = QgsVectorLayer(uri.uri(False), table, "postgres")
if not self.layer_styles:
self.populate_layer_styles(layer)
if not layer.isValid():
QgsMessageLog.logMessage("Layer failed to load",
level=Qgis.Critical)
else:
QgsProject.instance().addMapLayer(layer)
l = QgsProject.instance().layerTreeRoot().findLayer(layer)
l.setExpanded(False)
l.visibilityChanged.connect(self.update_layout_widgets)
layer.geometryChanged.connect(self.update_layout_widgets)
if layer.name().lower().startswith('mow_segment'):

QgsProject.instance().layerTreeRoot().findLayer(layer).setItemVisibilityChecked(False)
layer.triggerRepaint()

Jo
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

[QGIS-Developer] calculate real distances

2019-04-14 Thread Alhawash Aziz

Dear Ladies and Gentlemen,
Sehr geehrter Damen und Herren,


My question for a tip or a guide,
how QGIS or similar software can calculate real distances or real 
traffic for certain points?


Meine Frage nach einem Tipp oder einem Leitfaden,
wie man durch QGIS oder ähnliche Software reale Distanzen bzw. reale 
Verkehrsstrecke für bestimmte Punkte rechnen kann?





We are very thankful for any help, instruction or forwarding.
Yours sincerely
Aziz
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [QGIS-Developer] Why was selection tool behaviour changed in 3.x?

2019-04-14 Thread Saber Razmjooei
Hi
> 2) select by polygon: behaves the same

For select by polygon, there is an additional option: right-clicking allows
you to select features intersecting with existing polygon shapes (so that
you do not need to capture the same geometry):
https://twitter.com/lutraconsulting/status/1040328624002527232

Regards
Saber

On Thu, 11 Apr 2019 at 08:30, Bernhard Ströbl 
wrote:

> Hi,
>
> @Marco I can second Cory that the selection tools' behaviour is
> different between 2.18 (tested on Win) and 3.* (tested on Win and Ubuntu)
> 1) select by rectangle: behaves the same (click + drag)
> 2) select by polygon: behaves the same
> 3) select by freehand: behaves differently: 2.18 click + drag 3.* click
> + click
> 4) select by circle: behaves differently: 2.18 click + drag 3.* click +
> click
> I have no strong feeling for either behaviour (hardly use options 2 to
> 4) but I would think that the behaviour should be consistent within QGIS
> (either all click + drag or all click + click). Click + drag is well
> established (e.g. Inkscape, Bentley Microstation) at least for the
> rectangular selection, so maybe it would be better to use this approach.
> Furthermore this is how the rectangular selection works in the layout, too.
>
> @Cory concerning the vertex-editing tool there has been a lot of
> discussion and there were good reasons to change its behaviour. A lot
> has been improved recently: most prominent IMHO: feature can be locked
> for exclusive editing with a right click (similar to selecting a feature
> for editing in 2.*) but can be edited directly without locking e.g. by
> simply picking and moving vertices. May I therefore ask you to try again
> with current master (or a nightly build)? And may I further ask you to
> forget how it was in QGIS 2 and simply try how it works in 3?
> AFAIK there is no "standard" in mouse behaviour for vertex editing. CAD
> uses click + click (I can at least say for Microstation), Inkscape uses
> click + drag, so if one or the other seems familiar might depend on
> one's background.
>
> just my 2ct
>
> Bernhard
>
> Am 10.04.2019 um 17:38 schrieb Marco Bernasocchi:
> > Hi
> >
> > On 09.04.19 02:53, Cory Albrecht wrote:
> >>
> >>
> >>   Cory Albrecht mailto:m...@hanfastolfe.com
> >>
> >>
> >>
> >> 8:14 PM (37 minutes ago)
> >>
> >>
> >> to Régis
> >>
> >> Hello Régis,
> >>
> >> Sorry for not being clear - I mean when using the selection tool in
> >> freehand mode. I am definitely not talking about the identification
> >> tool, assuming you're referring to the same thing that I am thinking
> >> of? Ctrl+Shift+I, or the icon that is the cursor with a the letter "i"
> >> in a sold blue circle. I'm not sure I would call that new as it's been
> >> part of QGIS since I started using it in about 2015. Perhaps you're an
> >> old salt from the 1.x days? ;-)
> >>
> >> As a principle of UX design, ideally, the user should do the same
> >> action - click and drag - for any type of selection, both to maintain
> >> internal consistency in the application and with common ways of doing
> >> things in the broader computer universe. This lets people learn new
> >> software quickly by having a set of transferable actions that can get
> >> them up and running and doing rudimentary things quickly. It also
> >> helps reduce unintended errors caused by using common actions that get
> >> unexpectedly interpreted different than the user is used to. Things
> >> like this contribute to how easy or frustrating an application is to
> >> use, both for new and long time users.
> >>
> >> 1. For the "Select Feature(s)", click and drag to indicate the
> >> diagonally opposite corners of a selection rectangle.
> >> 2. For the "Select Features by Freehand", click and drag to create an
> >> irregular blob of selection area.
> >> 3. For the "Select Features by Radius", click and drag to indicate the
> >> centre of a selection circle and it's radius.
> >>
> >> In 2.x the answer to all of those was yes, but in 3.x it's yes, no, no.
> > I just tested and the answer are, as Régis mentioned, the same as in
> > 2.18 ( tested using 3.4.4). the behavior you describe is only true when
> > you activate "select by polygon".
> >>
> >> In vector and raster drawing applications, drawing rectangles, circles
> >> and blobs is done by click and drag, as is selecting rectangular,
> >> circular or irregular blobby areas. If you release and click elsewhere
> >> then drag, you start drawing a new object, or you discard the first
> >> selection and start outlining a new one. Word processing and text
> >> section, video editors and frame selection, sound editors and lengths
> >> of time in a track, they all have the user do these conceptually
> >> similar tasks in the same way - click and drag to create a selection ,
> >> new click discards old selection.
> >>
> >> Another principle of UX design is that you don't change how a user
> >> does something unless there is clear benefit that outweighs the
> >> trouble of relearning, especially f