10-09-2020 08:41 AM
In GeoMedia how can I round to the nearest 0.5?
45,64 -> 45,5
45,91 -> 46,0
43,81 -> 44,0
57,01 -> 57,0
56,33 -> 56,5
51,26 -> 51,5
35,43 -> 35,5
45,64 -> 45,5
59,29 -> 59,5
Solved! Go to Solution.
10-09-2020 08:52 AM
Does the ROUND operator help you, in Functional Attributes?
ROUND rounds a number to a specified number of digits.
I/O: Input R/O: Required DataType:I/O: Description: The number you want to round.
I/O: Input R/O: Required DataType:I/O: Description: The number of digits to which you want to round number.
If num_digits is greater than 0 (zero), then number is rounded to the specified number of decimal places.
If num_digits is 0, then number is rounded to the nearest integer.
If num_digits is less than 0, then number is rounded to the left of the decimal point.
10-09-2020 01:52 PM
Nice thing about the expression system is there's alternate ways of doing things... some methods better than others... I do NOT avocate this as being the most direct solution.
One way to think of the problem is that it's two conditional evalutions based on the value of the decimal portion of the value.
Condition 1: Decimal values >= 0.5, where the range is 0.5 to 1.0:
For these if the decimal value is closer to 0.5, then want the result to be Truc value + 0.5
if the decimal value is closer to 1.0, then want the result to be the Truc value + 1.0
Condition 2: Decimal values < 0.5, where the range is 0 to 0.5:
For these if the decimal value is closer to 0, then want the result to be Truc Value
if the decimal value is closer to 0.5, then want the result to be Truc value + 0.5
So with these conditions in mind in Functional Attributes you might try the following odd workflow..
In Functional Attributes build expressions:
ROUND(Input.Source_Value - Output.FA_INT, 2)
The next part is bit messy so before building any further expression think out the logic from above to build two separate IF statements:
Syntax for IF:
IF ([Conditional test], [Value if True], [Vaue if False])
For Decimal values >= 0.5
IF(1.0-Output.FA_DEC >=0.25, Output.FA_INT+0.5, OUTPUT.FA_INT+1)
For Decimal values < 0.5
IF(0.5-Output.FA_DEC >=0.25, Output.FA_INT, Output.FA_INT+0.5)
You could do an attribute query divide and conquer in two different runs using the expressions above (which is probably what I would do to avoid wrapping my head around a nested IF statement) but.... if you want to put it altogether as a nested IF it might look like the following:
IF(Output.FA_DEC >= 0.5, IF(1.0-Output.FA_DEC >=0.25, Output.FA_INT+0.5, Output.FA_INT+1), IF(0.5-Output.FA_DEC >=0.25, Output.FA_INT, Output.FA_INT+0.5))
Depth calculations for nautical charting?
10-13-2020 10:37 AM
Arrggg.. sorry for the wind.. that's definitely a simple solution! I thought I had tested Pavel's suggestion and noted that it did not always work but apparently my test was wrong.. perhaps I tested using FLOOR.