The values of properties with units need a 'no formatting' option.
Closed, ResolvedPublic

Description

Author: dan.bolser

Description:
When querying the value of a property that has custom units, there is no way to get an 'unformatted' value returned by the query.

Specifically, numbers are always full of commas (e.g. 10,004,039) and the value is always attached to a unit (separated by an " ").

I think the 'natural' way to do this would be to specify "Plain (unformatted) printouts" for the property in question

http://semantic-mediawiki.org/wiki/Help:Displaying_information#Plain_.28unformatted.29_printouts

However, SMW insists on putting commas in large numbers [1] and outputting a unit and putting a " " between the printed value and the unit.

All nice ideas in principle, but the whole point of SMW is to provide *data* not *formatting*. Currently you can't get at the underlying data, to include it in a calculation, for example, so this is a bug.

[1] http://tinyurl.com/34vuf4y

This bug is different from but related to bug 15541.


Version: unspecified
Severity: normal

bzimport set Reference to bz23679.
bzimport created this task.Via LegacyMay 27 2010, 10:03 AM
bzimport added a comment.Via ConduitMay 27 2010, 10:17 AM

dan.bolser wrote:

See thread: http://tinyurl.com/349b92z

mkroetzsch added a comment.Via ConduitMay 27 2010, 1:37 PM

Ok, fixed in SVN (and thus to be released with SMW 1.5.1 next week).

The unit is still shown in plain format since it is part of the data, but it is separated with a simple space (no  ), and no number formatting is applied.

bzimport added a comment.Via ConduitMay 27 2010, 2:12 PM

dan.bolser wrote:

Cheers Markus!

Just to clarify, the above formatting takes effect only when "plain (unformatted)
printouts" are used for the property? i.e.

{{#show: Some page | ? My property # - }}

?

Given that plain (unformatted) printout is just a special case of the way units are selected, don't you think it's reasonable to suppress the output of units when using plain (unformatted) printouts?

i.e. If I say:

  • {{#show: Some page | ? My property # seconds }}
  • {{#show: Some page | ? My property # hours }}

It's clear that I want the result in seconds or hours, respectively. However, if I say:

  • {{#show: Some page | ? My property # - }}

Isn't it clear that I don't want units?

I'm being fussy about this because I want to take the values and pass them to calculations using the #expr: parser function. This won't work if their is a unit in the result.

I read somewhere that bug reports are not the place for discussions, so I'll paste this text into the thread where this issue is raised so that we can open it up for broader discussion.

Cheers,
Dan.

mkroetzsch added a comment.Via ConduitMay 28 2010, 1:18 PM

I now also added support for the formatting strings "-n" and "-u" to be used with Type:Number and with types with custom units. The format "-n" produces a plain number without showing the unit, the format "-u" produces the plain unit string without showing the number.

Add Comment