Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessing "value" value in CartoCSS #249

Open
AbelVM opened this issue Jan 13, 2016 · 1 comment
Open

Accessing "value" value in CartoCSS #249

AbelVM opened this issue Jan 13, 2016 · 1 comment

Comments

@AbelVM
Copy link

AbelVM commented Jan 13, 2016

In a Torque layer you only have value parameter, but it's only accesible in order to be compared in CartoCSS selectors, but you can't use its value

Test case:

  • Dataset: https://team.cartodb.com/u/solutions/tables/metar_db
  • The idea is to render the meteo data there in a torque layer (time field: t) using temp as color param and visibility as radius param. In order to achieve that, I have generated an aggregated field in my table called torque :
update metar_db set torque = 255 *(round(temp/4)+ round(visibility/500)/100 - min )/ (max-min)

Being min= -1, max = 8 from round(temp/4)+ round(visibility/500)/100

Then I try to extract both cat_temp = temp/4 and cat_visibility=visibility/500 and render color and radius using this CartoCSS:

/** torque_cat visualization */

Map {
-torque-frame-count:256;
-torque-animation-duration:30;
-torque-time-attribute:"t";
-torque-aggregation-function:"max(torque)";
-torque-resolution:1;
-torque-data-aggregation:linear;
}

#metar_db{
  comp-op: source-over;
  marker-fill-opacity: 0.9;
  marker-line-color: #FFF;
  marker-line-width: 0;
  marker-line-opacity: 1;
  marker-type: ellipse;
  marker-width: 6;
  marker-fill: #0F3B82;
}
#metar_db[frame-offset=1] {
 marker-width:8;
 marker-fill-opacity:0.45; 
}
#metar_db[frame-offset=2] {
 marker-width:10;
 marker-fill-opacity:0.225; 
}
#metar_db [ value <= 255] {
   marker-fill: #B10026;
   marker-width: value - 226.6666666667;
}
#metar_db [ value <= 226.6666666667] {
   marker-fill: #E31A1C;  
   marker-width: value - 198.3333333333;
}
#metar_db [ value <= 198.3333333333] {
   marker-fill: #FC4E2A;
   marker-width:value - 170;
}
#metar_db [ value <= 170] {
   marker-fill: #FD8D3C;
   marker-width: value - 141.6666666667;
}
#metar_db [ value <= 141.6666666667] {
   marker-fill: #FEB24C;
   marker-width: value - 113.3333333333;
}
#metar_db [ value <= 113.3333333333] {
   marker-fill: #FED976;
   marker-width: value - 85;
}
#metar_db [ value <= 85] {
   marker-fill: #FFFFB2;
   marker-width: value -56.6666666667;
}
#metar_db [ value <= 56.6666666667] {
   marker-fill: #FFFFB2;
   marker-width: value - 28.3333333333;
}
#metar_db [ value <= 28.3333333333] {
   marker-fill: #FFFFB2;
   marker-width: value;
}
#metar_db [ value <= 0] {
   marker-fill: #FFFFB2;
    marker-width: 10;
}

But I get an error message like:
Invalid value for marker-width, the type float is expected. value (of type keyword) was given.

@javisantana
Copy link
Contributor

Remember torque does not work with float values, it's only integer ones (also to use [value])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants