CartoDB / torque

Temporal mapping for CARTO
http://cartodb.github.com/torque/
BSD 4-Clause "Original" or "Old" License
397 stars 129 forks source link

Mystery of the disappearing pixels #166

Closed andrewxhill closed 9 years ago

andrewxhill commented 9 years ago

ha

Watch the cluster of dots as they first draw. Notice the dot in the lower left of the cluster. It appears... then disappears!! I have mentioned this a number of times in the past but it still is there.

This is cumulative

Here is the map, https://team.cartodb.com/u/andrew/viz/bd7be8d8-de31-11e4-8c23-0e018d66dc29/embed_map

andrewxhill commented 9 years ago

Likely related,

https://team.cartodb.com/u/andrew/viz/1fbc2928-de4f-11e4-bfb7-0e4fddd5de28/embed_map

should have plenty of points in the middle of america

screen shot 2015-04-08 at 8 25 04 pm

The difference is that in the second version I have this,

  marker-fill: blue;
  [value=3]{marker-fill: blue;}
  [value=1]{marker-fill: magenta;}
  [value=2]{marker-fill: aqua;}

Versus the non-working one which is this,

  [value=3]{marker-fill: blue;}
  [value=1]{marker-fill: magenta;}
  [value=2]{marker-fill: aqua;}

In the one that doens't work, I don't have a default color fill. Now, this doesn't make sense mathematically, so there probably is a hiccup someplace inside the library...

My data is from twitter, I only have a category of 1 or 2. My aggregation function is,

-torque-aggregation-function:"sum(distinct(category_name))";

You see, distinct can either be a 1, or a 2 or both! So the only possible values from my function (unless I'm tired) are, 1 (if they all happen to be 1) or 2 (if they all happen to be 2) or 3 (if some are 1 and some are 2). So there is no reason why my first set of rules shouldn't cover all values.

andrewxhill commented 9 years ago

disa

it's very strange. i think this must be related. there is no reason a BLUE dot should ever turn back into an AQUA map. impossible given the rule, torque must be doing something wrong in the render

fdansv commented 9 years ago

@andrewxhill ok I think I've figured it out. With torque-aggregation-function, you do control the way that values attached to points are aggregated. But you're not controlling the way in which those values accumulate over time, which is always by adding the new value to the previous one.

So here's, from your own example, a disappearing point:

{
    x__uint8: 36, 
    y__uint8: 5,
    vals__uint8: [
        2,
        2
    ],
    dates__uint16: [
        23,
        45
    ]
}

In accumulative mode, at step 45, torque is adding the new value (2), to the previous value being displayed (again, 2), which will render a value of 4. Now if you take a look at the CartoCSS:

/** torque visualization */ Map {
    -torque-frame-count:256;
    -torque-animation-duration:20;
    -torque-time-attribute:"postedtime";
    -torque-aggregation-function:"sum(distinct(category_name))";
    -torque-resolution:2;
    -torque-data-aggregation:cumulative;
}
#ncaa_finals_game_tweets{
    comp-op: multiply;
    marker-fill-opacity: 0.6;
    marker-line-color: #FFF;
    marker-line-width: 0;
    marker-line-opacity: 0;
    marker-type: ellipse;
    marker-width: 6;
    [value>=3]{
        marker-fill: blue;
    }
    [value=1]{
        marker-fill: magenta;
    }
    [value=2]{
        marker-fill: aqua;
    }
}

... you'll see that there is no colour specified for values higher than 3, or a default marker colour for that matter. By changing the blue rule to [value=3]{ instead of just equal, the points stop disappearing:

dis

cc @javisantana I think this is a non-issue, but definitely writing up the more formal specification of the torque format should clear these kind of things up :)