Opened 11 years ago
Closed 10 years ago
#589 closed defect (fixed)
WCPS cast precedence
Reported by: | Piero Campalani | Owned by: | Vlad Merticariu |
---|---|---|---|
Priority: | critical | Milestone: | 9.1 |
Component: | petascope | Version: | development |
Keywords: | cast precedence | Cc: | Dimitar Misev, mantovani@…, Vlad Merticariu, Alex Dumitru |
Complexity: | Hard |
Description
Petascope does not properly prioritize a cast operator before a binary expression when mapping WCPS queries to RasQL.
In WCPS (OGC 08-068r2 — Sec.7.2.4), as in almost any other (programming) languages, casting (unary operator) takes precedence over binary expressions.
This is not currently true, thus leading to unexpected results.
In this example, I multiply two 16-bit signed short
values from eobstest
which result in short
overflow and hence need to be cast to a longer format.
c[Lat(0), Long(51), t("1950-01-04")] = -918 c[Lat(1), Long(51), t("1950-01-04")] = -1103 > (-918) * (-1103) [1] 1012554 > log2(1012554) [1] 19.94957 for c in (eobstest) return encode ( (long) c[Lat(0), Long(51), t("1950-01-04")] * c[Lat(1), Long(51), t("1950-01-04")] , "csv") [1] 32767
The result is wrong, since casting is applied at RasQL level to the result of the multiplication, and not the first operand.
Currently a workaround is to cast the second operand, or make explicit use of parenthesis.
Change History (5)
comment:1 by , 11 years ago
Cc: | added |
---|
comment:2 by , 10 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:3 by , 10 years ago
Milestone: | 9.0.x → 9.1 |
---|
comment:4 by , 10 years ago
Owner: | changed from | to
---|
comment:5 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Fixed in wcps2.
for c in (eobstest)
return encode (
, "csv")
{1012554}