SymbolixAU / mapdeck
1
#include <Rcpp.h>
2

3

4
#include "mapdeck_defaults.hpp"
5
#include "layers/layer_colours.hpp"
6
#include "spatialwidget/spatialwidget.hpp"
7

8
// Rcpp::List grid_defaults(int n) {
9
// 	return Rcpp::List::create();
10
// }
11

12 0
Rcpp::List heatmap_defaults(int n) {
13 0
	return Rcpp::List::create(
14 0
		_["weight"] = mapdeck::defaults::default_weight(n)
15
	);
16
}
17

18 0
Rcpp::List hexagon_defaults(int n) {
19 0
	return Rcpp::List::create();
20
}
21

22 1
Rcpp::List screengrid_defaults(int n) {
23 1
	return Rcpp::List::create(
24 1
		_["weight"] = mapdeck::defaults::default_weight(n)
25
	);
26
}
27

28 1
Rcpp::List get_aggregate_defaults( std::string layer_name, int data_rows ) {
29 1
	if( layer_name == "heatmap" ) {
30 0
		return heatmap_defaults( data_rows );
31
	// } else if ( layer_name == "grid" ) {
32
	// 	return grid_defaults( data_rows );
33 1
	} else if ( layer_name == "hexagon" ) {
34 0
		return hexagon_defaults( data_rows );
35
	}
36 1
	return screengrid_defaults( data_rows );
37
}
38

39

40
// [[Rcpp::export]]
41 0
Rcpp::List rcpp_aggregate_geojson(
42
		Rcpp::DataFrame data,
43
		Rcpp::List params,
44
		Rcpp::StringVector geometry_column,
45
		int digits,
46
		std::string layer_name
47
) {
48

49 0
	int data_rows = data.nrows();
50

51

52 0
	Rcpp::List lst_defaults = get_aggregate_defaults( layer_name, data_rows );
53

54 0
	std::unordered_map< std::string, std::string > aggregate_colours = mapdeck::layer_colours::no_colours;
55 0
	Rcpp::StringVector aggregate_legend = mapdeck::layer_colours::no_legend;
56 0
	Rcpp::StringVector parameter_exclusions = Rcpp::StringVector::create("legend","legend_options","palette","na_colour");
57

58 0
	return spatialwidget::api::create_geojson(
59
		data,
60
		params,
61
		lst_defaults,
62
		aggregate_colours,
63
		aggregate_legend,
64
		data_rows,
65
		parameter_exclusions,
66
		geometry_column,
67
		true,  // jsonify legend
68 0
		digits
69
	);
70
}
71

72
// [[Rcpp::export]]
73 1
Rcpp::List rcpp_aggregate_geojson_df(
74
		Rcpp::DataFrame data,
75
		Rcpp::List params,
76
		Rcpp::List geometry_columns,
77
		int digits,
78
		std::string layer_name
79
) {
80

81 1
	int data_rows = data.nrows();
82

83 1
	Rcpp::List lst_defaults = get_aggregate_defaults( layer_name, data_rows );
84

85 1
	std::unordered_map< std::string, std::string > aggregate_colours = mapdeck::layer_colours::no_colours;
86 1
	Rcpp::StringVector aggregate_legend = mapdeck::layer_colours::no_legend;
87 1
	Rcpp::StringVector parameter_exclusions = Rcpp::StringVector::create("legend","legend_options","palette","na_colour");
88

89 1
	return spatialwidget::api::create_geojson(
90
		data,
91
		params,
92
		lst_defaults,
93
		aggregate_colours,
94
		aggregate_legend,
95
		data_rows,
96
		parameter_exclusions,
97
		geometry_columns,
98
		true,  // jsonify legend
99 1
		digits
100
	);
101
}
102

103
// [[Rcpp::export]]
104 0
Rcpp::List rcpp_aggregate_polyline(
105
		Rcpp::DataFrame data,
106
		Rcpp::List params,
107
		Rcpp::StringVector geometry_columns,
108
		std::string layer_name
109
) {
110

111 0
	int data_rows = data.nrows();
112

113 0
	Rcpp::List lst_defaults = get_aggregate_defaults( layer_name, data_rows );
114

115 0
	std::unordered_map< std::string, std::string > aggregate_colours = mapdeck::layer_colours::no_colours;
116 0
	Rcpp::StringVector aggregate_legend = mapdeck::layer_colours::no_legend;
117 0
	Rcpp::StringVector parameter_exclusions = Rcpp::StringVector::create("legend","legend_options","palette","na_colour");
118

119 0
	return spatialwidget::api::create_polyline(
120
		data,
121
		params,
122
		lst_defaults,
123
		aggregate_colours,
124
		aggregate_legend,
125
		data_rows,
126
		parameter_exclusions,
127 0
		geometry_columns,
128
		true  // jsonify legend
129
	);
130
}
131

Read our documentation on viewing source code .

Loading