Opened 5 years ago

Closed 4 years ago

#2187 closed defect (fixed)

WCPS switch translates to wrong rasql

Reported by: Bang Pham Huu Owned by: Bang Pham Huu
Priority: major Milestone: 10.0
Component: petascope Version: 9.8
Keywords: Cc: Dimitar Misev, Vlad Merticariu
Complexity: Medium

Description

The switch statement in WCPS gets translated to the wrong rasql query if one of the conditions contains several chained boolean expressions.

An example:

for soil in (Soil)
return encode(
  (
    switch
      case ((soil <= 100) and (soil > 50) )   return {red:181; green:0; blue: 38}
      default return {red:163;green:163;blue:163}
  )[ N(2833331.27917:2923461.0561), E(3803398.63017:3859122.07695)]
, "png")

is translated to:

SELECT encode( ( CASE WHEN ( soil > 50 ) THEN ( {181, 0, 38} ) ELSE ( {163, 163, 163} ) END ) [4282:7068,10312:14818], "png" , "{\"geoReference\":{\"crs\":\"EPSG:3034\",\"bbox\":{\"xmin\":3803389.999999907,\"ymin\":2833326.988199538,\"xmax\":3859129.999999907,\"ymax\":2923466.988199538}}}") FROM Soil AS soil

The 1st condition (soil ⇐ 100) is silently dropped in the translation. Wcps should treat ((soil ⇐ 100) and (soil > 50) ) as a single, boolean expression and translate the query to:

SELECT encode( ( CASE WHEN (soil <= 100 and soil > 50 ) THEN ( {181, 0, 38} ) ELSE ( {163, 163, 163} ) END ) [4282:7068,10312:14818], "png" , "{\"geoReference\":{\"crs\":\"EPSG:3034\",\"bbox\":{\"xmin\":3803389.999999907,\"ymin\":2833326.988199538,\"xmax\":3859129.999999907,\"ymax\":2923466.988199538}}}") FROM Soil AS soil

Change History (1)

comment:1 by Bang Pham Huu, 4 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.