Bug report #8457
$length fails silently for polygons
|Affected QGIS version:||master||Regression?:||No|
|Operating System:||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:||duplicate|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||17225|
I have a polygon. If I label it with the following it works fine.
'polygon' || $area
However, if I change it to the below, using $length, I get absolutely no output, not even the string.
'polygon' || $length
Yes, I know I should use $perimeter. The bug is that QGIS isn't telling me as the user that. Worse, it's not rendering anything that is still valid (the string).
Both the "Output preview" and the on-map labels are completely empty.
windows 7 x64 - QGIS a13cdf8
#2 Updated by Jonathan Moules about 7 years ago
Also field calculator does the exact same thing, so it's not labelling specific.
Nathan Woodrow wrote:
$legnth is returning NULL. String + NULL = NULL.
Maybe it should be converted to:
String + NULL = String.
After all, 1 + 0 = 1, and String + '' = String. I'm aware that NULL != 0 or '' but I think the premise holds :-)
#7 Updated by Jonathan Moules about 7 years ago
I'm not sure it should be renamed to that as it's not unique to length.
If I try "$x" and "$y" with a polygon they also fail (though I'd argue that's a problem with the calculator - I expected it to return the centroid, but that's neither here nor there for this). $geometry is also blank (no help so not sure what it's supposed to do).
I imagine that area\\length\\perimeter all become blank when used against a POINT feature.
So the issue is more generic than a single function.