Skip to content

Commit

Permalink
updating to v8.0.0 for #239
Browse files Browse the repository at this point in the history
  • Loading branch information
SymbolixAU committed Jan 20, 2020
1 parent 8d42d82 commit 8c3fad1
Show file tree
Hide file tree
Showing 44 changed files with 550 additions and 202 deletions.
4 changes: 1 addition & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Imports:
magrittr,
Rcpp,
shiny
RoxygenNote: 6.1.1
RoxygenNote: 7.0.2
Suggests:
covr,
jsonlite,
Expand All @@ -49,5 +49,3 @@ Remotes:
github::SymbolixAU/jsonify,
github::SymbolixAU/spatialwidget,
github::dcooley/sfheaders


3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# mapdeck 0.3


* v8.* of Deck.gl
- Arc layer supports 3D positions
* `show_view_state` option to overlay the current View State [issue238](https://github.com/SymbolixAU/mapdeck/issues/238)
* performance improvements for dates and factors [issue235](https://github.com/SymbolixAU/mapdeck/issues/235)
* `add_bitmap()` to add a bitmap / image to the map
Expand Down
36 changes: 30 additions & 6 deletions R/map_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,41 @@ resolve_od_data.data.frame <- function( data, l, origin, destination ) {
stop("mapdeck - origin and destination columns required")
}

if( length(origin) != 2 | length(destination) != 2 ) {
stop("mapdeck - origin and destination columns should both contain lon & lat values")
if( length( origin ) == 2 ) {
l[["start_lon"]] <- origin[1]
l[["start_lat"]] <- origin[2]
l[["start_elev"]] <- 0
} else if ( length( origin ) == 3 ) {
l[["start_lon"]] <- origin[1]
l[["start_lat"]] <- origin[2]
l[["start_elev"]] <- origin[3]
} else {
stop("mapdeck - origin and destination columns should contain lon & lat, and optionally elevation columns")
}

if( length( destination ) == 2 ) {
l[["end_lon"]] <- destination[1]
l[["end_lat"]] <- destination[2]
l[["end_elev"]] <- 0
} else if ( length( destination ) == 3 ) {
l[["end_lon"]] <- destination[1]
l[["end_lat"]] <- destination[2]
l[["end_elev"]] <- destination[3]
} else {
stop("mapdeck - origin and destination columns should contain lon & lat, and optionally elevation columns")
}

# if( length(origin) != 2 | length(destination) != 2 ) {
# stop("mapdeck - origin and destination columns should both contain lon & lat values")
# }

l[["data_type"]] <- "df"
l[["bbox"]] <- get_od_box( data, l )

l[["start_lon"]] <- origin[1]
l[["start_lat"]] <- origin[2]
l[["end_lon"]] <- destination[1]
l[["end_lat"]] <- destination[2]
# l[["start_lon"]] <- origin[1]
# l[["start_lat"]] <- origin[2]
# l[["end_lon"]] <- destination[1]
# l[["end_lat"]] <- destination[2]

l[["origin"]] <- NULL
l[["destination"]] <- NULL
Expand Down
2 changes: 1 addition & 1 deletion R/map_layer_arc.R
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ add_arc <- function(
geometry_column <- c( "origin", "destination" )
shape <- rcpp_od_geojson( data, l, geometry_column, digits, "arc" )
} else if ( tp == "df" ) {
geometry_column <- list( origin = c("start_lon", "start_lat"), destination = c("end_lon", "end_lat") )
geometry_column <- list( origin = c("start_lon", "start_lat", "start_elev"), destination = c("end_lon", "end_lat", "end_elev") )
shape <- rcpp_od_geojson_df( data, l, geometry_column, digits, "arc" )
} else if ( tp == "sfencoded" ) {
geometry_column <- c("origin", "destination")
Expand Down
2 changes: 1 addition & 1 deletion R/mapdeck_dependencies.R
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ deckgl_min_js <- function() {
list(
createHtmlDependency(
name = "deckgl",
version = "7.4.0",
version = "8.0.9",
src = system.file("htmlwidgets/lib/", package = "mapdeck"),
script = c("deckgl.min.js"),
all_files = FALSE
Expand Down
4 changes: 2 additions & 2 deletions inst/htmlwidgets/lib/arc/arc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function add_arc_geo( map_id, map_type, arc_data, layer_id, auto_highlight, high
extensions.push( new BrushingExtension() );
}

const arcLayer = new ArcLayer({
const arcLayer = new deck.ArcLayer({
map_id: map_id,
id: 'arc-'+layer_id,
data: arc_data,
Expand Down Expand Up @@ -48,7 +48,7 @@ function add_arc_polyline( map_id, map_type, arc_data, layer_id, auto_highlight,
extensions.push( new BrushingExtension() );
}

const arcLayer = new ArcLayer({
const arcLayer = new deck.ArcLayer({
map_id: map_id,
id: 'arc-'+layer_id,
data: arc_data,
Expand Down
2 changes: 1 addition & 1 deletion inst/htmlwidgets/lib/bitmap/bitmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

function add_bitmap(map_id, layer_id, image, bounds, desaturate, transparent_colour, tint_colour, bbox, focus_layer, update_view) {

const bitmapLayer = new BitmapLayer({
const bitmapLayer = new deck.BitmapLayer({
map_id: map_id,
id: "bitmap-"+layer_id,
image: image,
Expand Down
6 changes: 3 additions & 3 deletions inst/htmlwidgets/lib/deckgl.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions inst/htmlwidgets/lib/greatcircle/greatcircle.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function add_greatcircle_geo( map_id, map_type, greatcircle_data, layer_id, auto
extensions.push( new BrushingExtension() );
}

const greatcircleLayer = new GreatCircleLayer({
const greatcircleLayer = new deck.GreatCircleLayer({
map_id: map_id,
id: 'greatcircle-'+layer_id,
data: greatcircle_data,
Expand Down Expand Up @@ -53,7 +53,7 @@ function add_greatcircle_polyline( map_id, map_type, greatcircle_data, layer_id,
extensions.push( new BrushingExtension() );
}

const greatcircleLayer = new GreatCircleLayer({
const greatcircleLayer = new deck.GreatCircleLayer({
map_id: map_id,
id: 'greatcircle-'+layer_id,
data: greatcircle_data,
Expand Down
4 changes: 2 additions & 2 deletions inst/htmlwidgets/lib/line/line.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

function add_line_geo( map_id, map_type, line_data, layer_id, auto_highlight, highlight_colour, legend, bbox, update_view, focus_layer, js_transition ) {

const lineLayer = new LineLayer({
const lineLayer = new deck.LineLayer({
map_id: map_id,
id: 'line-'+layer_id,
data: line_data,
Expand Down Expand Up @@ -35,7 +35,7 @@ function add_line_geo( map_id, map_type, line_data, layer_id, auto_highlight, hi

function add_line_polyline( map_id, map_type, line_data, layer_id, auto_highlight, highlight_colour, legend, bbox, update_view, focus_layer, js_transition ) {

const lineLayer = new LineLayer({
const lineLayer = new deck.LineLayer({
map_id: map_id,
id: 'line-'+layer_id,
data: line_data,
Expand Down
2 changes: 1 addition & 1 deletion inst/htmlwidgets/lib/mesh/mesh.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function add_mesh( map_id, map_type, polygon_data, layer_id, light_settings, aut
*/


const meshLayer = new PolygonLayer({
const meshLayer = new deck.PolygonLayer({
map_id: map_id,
id: 'polygon-'+layer_id,
data: polygon_data,
Expand Down
17 changes: 14 additions & 3 deletions inst/htmlwidgets/lib/path/path.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
function add_path_geo( map_id, map_type, path_data, layer_id, auto_highlight, highlight_colour,
legend, bbox, update_view, focus_layer, js_transition, billboard ) {

const pathLayer = new PathLayer({
var extensions = [];
extensions.push(
new deck.PathStyleExtension({dash: true})
);

const pathLayer = new deck.PathLayer({
map_id: map_id,
id: 'path-'+layer_id,
data: path_data,
Expand All @@ -23,7 +28,8 @@ legend, bbox, update_view, focus_layer, js_transition, billboard ) {
onHover: md_update_tooltip,
autoHighlight: auto_highlight,
highlightColor: md_hexToRGBA( highlight_colour ),
transitions: js_transition || {}
transitions: js_transition || {},
extensions: extensions
});

if( map_type == "google_map") {
Expand All @@ -40,7 +46,12 @@ legend, bbox, update_view, focus_layer, js_transition, billboard ) {

function add_path_polyline( map_id, map_type, path_data, layer_id, auto_highlight, highlight_colour, legend, bbox, update_view, focus_layer, js_transition, billboard ) {

const pathLayer = new PathLayer({
var extensions = [];
extensions.push(
new deck.PathStyleExtension({dash: true})
);

const pathLayer = new deck.PathLayer({
map_id: map_id,
id: 'path-'+layer_id,
data: path_data,
Expand Down
4 changes: 2 additions & 2 deletions inst/htmlwidgets/lib/polygon/polygon.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

function add_polygon_geo( map_id, map_type, polygon_data, layer_id, light_settings, auto_highlight, highlight_colour, legend, bbox, update_view, focus_layer, js_transition, is_extruded, elevation_scale ) {

const polygonLayer = new PolygonLayer({
const polygonLayer = new deck.PolygonLayer({
map_id: map_id,
id: 'polygon-'+layer_id,
data: polygon_data,
Expand Down Expand Up @@ -41,7 +41,7 @@ function add_polygon_geo( map_id, map_type, polygon_data, layer_id, light_settin

function add_polygon_polyline( map_id, map_type, polygon_data, layer_id, light_settings, auto_highlight, highlight_colour, legend, bbox, update_view, focus_layer, js_transition, is_extruded, elevation_scale ) {

const polygonLayer = new PolygonLayer({
const polygonLayer = new deck.PolygonLayer({
map_id: map_id,
id: 'polygon-'+layer_id,
data: polygon_data,
Expand Down
4 changes: 2 additions & 2 deletions inst/htmlwidgets/lib/scatterplot/scatterplot.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function add_scatterplot_geo( map_id, map_type, scatter_data, layer_id, auto_hig
extensions.push( new BrushingExtension() );
}

const scatterLayer = new ScatterplotLayer({
const scatterLayer = new deck.ScatterplotLayer({
map_id: map_id,
id: 'scatterplot-'+layer_id,
data: scatter_data,
Expand Down Expand Up @@ -56,7 +56,7 @@ function add_scatterplot_polyline( map_id, map_type, scatter_data, layer_id, aut
if ( brush_radius > 0 ) {
extensions.push( new BrushingExtension() );
}
const scatterLayer = new ScatterplotLayer({
const scatterLayer = new deck.ScatterplotLayer({
map_id: map_id,
id: 'scatterplot-'+layer_id,
data: scatter_data,
Expand Down
4 changes: 2 additions & 2 deletions inst/htmlwidgets/lib/text/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function add_text_geo( map_id, map_type, text_data, layer_id, auto_highlight, hi
extensions.push( new BrushingExtension() );
}

const textLayer = new TextLayer({
const textLayer = new deck.TextLayer({
map_id: map_id,
id: 'text-'+layer_id,
data: text_data,
Expand Down Expand Up @@ -58,7 +58,7 @@ function add_text_polyline( map_id, map_type, text_data, layer_id, auto_highligh
extensions.push( new BrushingExtension() );
}

const textLayer = new TextLayer({
const textLayer = new deck.TextLayer({
map_id: map_id,
id: 'text-'+layer_id,
data: text_data,
Expand Down
4 changes: 2 additions & 2 deletions inst/htmlwidgets/lib/trips/trips.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
function add_trips_geo( map_id, map_type, trips_data, opacity, layer_id,
trail_length, start_time, end_time, animation_speed, legend ) {

var tripsLayer = new TripsLayer({
var tripsLayer = new deck.TripsLayer({
id: 'trips-'+layer_id,
data: trips_data,
parameters: {
Expand Down Expand Up @@ -45,7 +45,7 @@ trail_length, start_time, end_time, animation_speed, legend) {

var time = ((timestamp % loopTime) / loopTime) * loopLength;

var tripsLayer = new TripsLayer({
var tripsLayer = new deck.TripsLayer({
id: 'trips-'+layer_id,
data: trips_data,
parameters: {
Expand Down
11 changes: 6 additions & 5 deletions inst/htmlwidgets/mapdeck.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ HTMLWidgets.widget({
const deckgl = new deck.DeckGL({
map: false,
container: el.id,
//initialViewState: window[el.id + 'INITIAL_VIEW_STATE'],
viewState: window[el.id + 'INITIAL_VIEW_STATE'],
initialViewState: window[el.id + 'INITIAL_VIEW_STATE'],
//viewState: window[el.id + 'INITIAL_VIEW_STATE'], // no longer supported - deck.gl v8.0.0
layers: [],
controller: true
//onLayerHover: setTooltip
});
window[el.id + 'map'] = deckgl;
Expand All @@ -66,10 +67,10 @@ HTMLWidgets.widget({
//map: mapboxgl,
container: el.id,
mapStyle: x.style,
//initialViewState: window[el.id + 'INITIAL_VIEW_STATE'],
viewState: window[el.id + 'INITIAL_VIEW_STATE'],
initialViewState: window[el.id + 'INITIAL_VIEW_STATE'],
//viewState: window[el.id + 'INITIAL_VIEW_STATE'],
layers: [],
//controller: myController
controller: true,
//onLayerHover: setTooltip
onViewStateChange: ({viewState, interactionState}) => {

Expand Down
6 changes: 3 additions & 3 deletions inst/htmlwidgets/mapdeck_functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,11 @@ function md_update_layer( map_id, layer_id, layer ) {
}

// ## issue 137
var vs = window[ map_id + 'map'].viewState;
//var vs = window[ map_id + 'map'].viewState;

window[map_id + 'map'].setProps({
layers: [...window[map_id + 'layers'] ],
viewState: vs
layers: [...window[map_id + 'layers'] ]
//viewState: vs // issue 239 - viewState no longer supported in deck.gl v8.0.8
});
}

Expand Down
10 changes: 8 additions & 2 deletions inst/htmlwidgets/mapdeck_location.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ function md_change_location( map_id, map_type, location, zoom, pitch, bearing, d
window[map_id + 'map'].setZoom( zoom );
} else {

console.log( window[ map_id + 'map' ].viewState );

if ( window[ map_id + 'map'].viewState["default-view"] !== undefined ) {
currentLon = location === null ? window[ map_id + 'map'].viewState["default-view"].longitude : location[0];
currentLat = location === null ? window[ map_id + 'map'].viewState["default-view"].latitude : location[1];
Expand All @@ -22,6 +24,8 @@ function md_change_location( map_id, map_type, location, zoom, pitch, bearing, d
currentZoom = zoom === null ? window[ map_id + 'map'].viewState.zoom : zoom;
}

console.log( currentLon );

window[map_id + 'map'].setProps({
viewState: {
longitude: currentLon,
Expand All @@ -30,9 +34,11 @@ function md_change_location( map_id, map_type, location, zoom, pitch, bearing, d
pitch: currentPitch,
bearing: currentBearing,
transitionInterpolator: transition === "fly" ? new deck.FlyToInterpolator() : new deck.LinearInterpolator(),
transitionDuration: duration
},
transitionDuration: duration,
controller: true
}
});

}
}

Expand Down
37 changes: 28 additions & 9 deletions man/add_arc.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8c3fad1

Please sign in to comment.