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

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

7 1
Rcpp::List polygon_defaults(int n) {
8 1
	return Rcpp::List::create(
9 1
		_["elevation"] = mapdeck::defaults::default_elevation(n),
10 1
		_["fill_colour"] = mapdeck::defaults::default_fill_colour(n),
11 1
		_["stroke_colour"] = mapdeck::defaults::default_stroke_colour(n)
12
	);
13
}
14

15
// [[Rcpp::export]]
16 0
Rcpp::List rcpp_polygon_geojson(
17
		Rcpp::DataFrame data,
18
		Rcpp::List params,
19
		Rcpp::StringVector geometry_columns,
20
		int digits
21
	) {
22

23 0
	int data_rows = data.nrows();
24

25 0
	Rcpp::List lst_defaults = polygon_defaults( data_rows );  // initialise with defaults
26

27 0
	std::unordered_map< std::string, std::string > polygon_colours = mapdeck::layer_colours::fill_stroke_colours;
28 0
	Rcpp::StringVector polygon_legend = mapdeck::layer_colours::fill_stroke_legend;
29 0
	Rcpp::StringVector parameter_exclusions = Rcpp::StringVector::create("legend","legend_options","palette","na_colour");
30

31 0
	return spatialwidget::api::create_geojson(
32
		data,
33
		params,
34
		lst_defaults,
35
		polygon_colours,
36
		polygon_legend,
37
		data_rows,
38
		parameter_exclusions,
39
		geometry_columns,
40
		true,  // jsonify legend
41 0
		digits
42
	);
43
}
44

45
// // [[Rcpp::export]]
46
// Rcpp::List rcpp_polygon_quadmesh( Rcpp::DataFrame data,
47
//                                   Rcpp::List params,
48
//                                   Rcpp::List geometry_columns) {
49
//
50
// 	int data_rows = data.nrow();
51
//
52
// 	Rcpp::List lst_defaults = polygon_defaults( data_rows );  // initialise with defaults
53
// 	std::unordered_map< std::string, std::string > polygon_colours = mapdeck::polygon::polygon_colours;
54
// 	Rcpp::StringVector polygon_legend = mapdeck::polygon::polygon_legend;
55
// 	Rcpp::StringVector parameter_exclusions = Rcpp::StringVector::create("legend","legend_options","palette","na_colour");
56
//
57
//
58
// 	return spatialwidget::api::create_geojson_quadmesh(
59
// 		data,
60
// 		params,
61
// 		lst_defaults,
62
// 		polygon_colours,
63
// 		polygon_legend,
64
// 		geometry_columns,
65
// 		data_rows,
66
// 		parameter_exclusions,
67
// 		true  // jsonify legend
68
// 		);
69
// }
70

71

72
// [[Rcpp::export]]
73 1
Rcpp::List rcpp_polygon_polyline(
74
		Rcpp::DataFrame data,
75
		Rcpp::List params,
76
		Rcpp::StringVector geometry_columns
77
	) {
78

79 1
	int data_rows = data.nrows();
80

81 1
	Rcpp::List lst_defaults = polygon_defaults( data_rows );  // initialise with defaults
82

83 1
	std::unordered_map< std::string, std::string > polygon_colours = mapdeck::layer_colours::fill_stroke_colours;
84 1
	Rcpp::StringVector polygon_legend = mapdeck::layer_colours::fill_stroke_legend;
85 1
	Rcpp::StringVector parameter_exclusions = Rcpp::StringVector::create("legend","legend_options","palette","na_colour");
86

87 1
	return spatialwidget::api::create_polyline(
88
		data,
89
		params,
90
		lst_defaults,
91
		polygon_colours,
92
		polygon_legend,
93
		data_rows,
94
		parameter_exclusions,
95 1
		geometry_columns,
96
		true  // jsonify legend
97
	);
98
}
99

Read our documentation on viewing source code .

Loading