Opened 4 years ago

Closed 15 months ago

#360 closed defect (fixed)

Wrong substitution for variables labels in a WCPS trimming operation

Reported by: pcampalani Owned by: mdumitru
Priority: major Milestone: 9.2
Component: petascope Version: development
Keywords: variable labels condense construct Cc: mantovani@…, vmerticariu
Complexity: Medium

Description

When an over clause is used to define custom axes, the variable labels which are then used in the following clause (over or using, depending whether it is a coverage constructor or a condense operation) are badly translated (to 0s) when used inside a trimming operation.

E.g.

for c in (mean_summer_airtemp)
  return encode(
     coverage mincov
     over     $px x (100:101)
     values   min(c[x:"CRS:1"($px:$px + 1), y:"CRS:1"(300)]
     )
  ), "csv")

Translates to the following RasQL query

SELECT csv(marray i_i in [100:101] values min_cells((c) [0:0,300])) 
FROM   mean_summer_airtemp AS c

which instead should look like this:

SELECT csv(marray i_i in [100:101] values min_cells((c) [i_i[0]:i_i[1],300])) 
FROM   mean_summer_airtemp AS c

The same holds for a condense operation, e.g.:

for c in (mean_summer_airtemp)
  return encode(
     condense +
     over     $px x (100:101)
     using    min(c[x:"CRS:1"($px:$px+1), y:"CRS:1"(300:300)]
     )
  ), "csv")

Change History (10)

comment:1 Changed 4 years ago by pcampalani

  • Resolution set to duplicate
  • Status changed from new to closed

Closing this as it seems a duplicate of #335.

comment:2 Changed 4 years ago by abeccati

  • Milestone 9.0 deleted

comment:3 Changed 3 years ago by pcampalani

  • Cc mantovani@… added
  • Resolution duplicate deleted
  • Status changed from closed to reopened

Re-opening since this does not work on a temporal dimension now:

for c in (eobstest) return encode (
     coverage averaged_pixel_history
     over     $t t(0:1)
a)   values   max(c[Lat(0), Long(51), t:"CRS:1"($t:$t)])
b)   values   max(c[Lat(0), Long(51), t:"CRS:1"($t:$t+1)])
c)   values   max(c[Lat(0), Long(51), t:"CRS:1"($t:1+$t)])

Stack trace:

java.lang.NumberFormatException: For input string: "i_i[0]"
	at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
	at java.lang.Integer.parseInt(Integer.java:492)
	at java.lang.Integer.parseInt(Integer.java:527)
	at petascope.util.WcsUtil.toInt(WcsUtil.java:571)
	at petascope.util.WcsUtil.min(WcsUtil.java:536)
	at petascope.wcps.server.core.TrimCoverageExpr.computeRasQL(TrimCoverageExpr.java:174)
...

It works on spatial ones, but not when then variable is first operand and the operator is not preceded by a white space:

for c in (eobstest) return encode (
   coverage averaged_pixel_history
   over     $t x (0:1)
   values   max(c[Lat(0:1), Long:"CRS:1"($t:$t)])     -> OK
   values   max(c[Lat(0:1), Long:"CRS:1"($t:1+$t)])   -> OK
   values   max(c[Lat(0:1), Long:"CRS:1"($t:$t + 1)]) -> OK
   values   max(c[Lat(0:1), Long:"CRS:1"($t:$t+1)])   -> ERROR
, "csv" )
}}]

comment:4 Changed 3 years ago by pcampalani

  • Version changed from 8.4 to development

comment:5 Changed 3 years ago by pcampalani

Apparently, this is somehow not related to the type of dimension, but to the variable name. e.g. using $x instead of $t as name gives error:

for c in (eobscov) return encode (
   coverage averaged_pixel_history
   over     $x x (0:2)
   values   max(c[Long:"CRS:1"($x:$x), Lat(0)])
, "csv")

Error: For input string: "i_i[0]"

The same error message returned by the queries reported in comment:3.

comment:6 Changed 3 years ago by dmisev

Is Alan the right owner of this?

comment:7 Changed 3 years ago by pcampalani

  • Owner changed from abeccati to pcampalani
  • Status changed from reopened to assigned

comment:8 Changed 2 years ago by dmisev

  • Milestone set to 9.1

comment:9 Changed 23 months ago by dmisev

  • Cc vmerticariu added
  • Milestone changed from 9.1 to 9.2
  • Owner changed from pcampalani to mdumitru

comment:10 Changed 15 months ago by bphamhuu

  • Resolution set to fixed
  • Status changed from assigned to closed

The patch was accepted, close here, thanks.

Note: See TracTickets for help on using tickets.