Velocity

Example

#include <fstream>

#include "nlohmann/json.hpp"

#include "xleaflet/xmap.hpp"
#include "xleaflet/xvelocity.hpp"

auto map = xlf::map::initialize();
map.center = xlf::map::point_type{0, 0};
map.zoom = 1;
map.finalize();

auto base_layer = xlf::basemap({"CartoDB", "DarkMatter"});
map.add_layer(base_layer);

std::ifstream file("velocity_data.json");
nlohmann::json data;
file >> data;

auto velocity = xlf::velocity::initialize();
velocity.data = data;
velocity.velocity_scale = 0.01;
velocity.max_velocity = 20;
velocity.display_options = R"({
    "velocityType": "Global Wind",
    "displayPosition": "bottomleft",
    "displayEmptyString": "No wind data"
})";
velocity.finalize();

map.add_layer(velocity);

map

Attributes

Attribute

Default Value

Doc

data

Null JSON objectdataset

Underlying dataset

units

None

Units

display_values

True

Display velocity data on mouse hover

display_options

{}

Display options

min_velocity

0.0

Used to align color scale

max_velocity

10.0

Used to align color scale

velocity_scale

0.005

Modifier for particle animations

color_scale

Empty std::vector of html colors

Array of hex/rgb colors for user-specified color scale.