[Qgis-developer] Measuring and QgsExpression

Magnus Homann magnus at homann.se
Thu Aug 30 10:51:17 PDT 2012


Hi all!

I've been cleaning up the map tools for measuring area, length and angle. Now, they all use the same setting as identifyresult,
the setting that is selected in "Options...", and includes preferred unit of measurment, what ellipsoid to calculate using, and
the possibility to select No ellipsoid / planimetric calculations. Also scalebar has the same behaviour. There has been some bugs
regarding this.

There's then the question of areas/length calculated by Fieldcalculator that Martin D wrote. Today, it uses planimetric calculation
on the layer CRS. If the layer is in WGS84 and th eprojection in SWEREF 99 TM, tha calculated area is reported in square degrees.
Also, it does not take into account preferred units.

So, I set out to fix this, but Martin raised - very valid - concerns about reproducability. QgsExpression is also used for
other things such as rendering, and when a project is saved and sent to another user who has different settings för units/ellipsoid, the
rendering styles (and field calculator of course) gives different result. Not so good. I have a couple of ideas:

1) Let units/ellipsoid settings be a part of the project rather than global settings.
2) Let fieldcalculator be aware of global settings, but other parts using expressions is not necessairly so (such as rendering)
3) Accept different results depending on user setting.

I have also another idea, to create a project-wide calculation context that is *shared* among all units. It should be aware of
physical units and handle arithmetics on those:1 m x 1m is 1 m2. Like in VHDL. :-) More or less extend QgsDistanceArea to include
units and "promote it" to proejct level (like Project CRS).

Adding functions to QgsExpression that pretty-prints physical values into text string seems also like a good ide. Or is there already?

Long post. Thoughts?

Magnus


More information about the Qgis-developer mailing list