Skip to content

Commit

Permalink
add cran comments, move/buildignore experiments
Browse files Browse the repository at this point in the history
  • Loading branch information
timelyportfolio committed Jun 30, 2017
1 parent 9ecf44b commit f3b770d
Show file tree
Hide file tree
Showing 17 changed files with 165 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
^README\.Rmd$
^README-.*\.png$
^CONDUCT\.md$
^experiments
^cran-comments\.md$
16 changes: 16 additions & 0 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## Test environments
* local OS X install, R 3.4.0
* ubuntu 12.04 (on travis-ci), R 3.4.0
* win-builder (devel and release)
* rhub::check_for_cran()

## R CMD check results

0 errors | 0 warnings | 1 note

* This is a new release.

## Reverse dependencies

This is a new release, so there are no reverse dependencies.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
147 changes: 147 additions & 0 deletions experiments/flubber_playback.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
library(sf)
library(mapview)
library(mapedit)
library(geojsonio)
library(htmltools)

#ed <- editMap()
#rec <- attr(ed, "recorder")

#bbox <- unclass(
# st_bbox(
# mapedit:::combine_list_of_sf(
# lapply(rec,function(x){x$feature})
# )
# )
#)

bbox_rect <- geojson_json(
st_polygon(
list(matrix(
c(
c(bbox[1], bbox[4]),
c(bbox[3], bbox[4]),
c(bbox[3], bbox[2]),
c(bbox[1], bbox[2]),
c(bbox[1], bbox[4])
),
ncol=2,
byrow=TRUE
))
)
)

tl <- tagList(
tags$head(tags$script(src="https://unpkg.com/flubber")),
d3r::d3_dep_v4(offline = FALSE),
tags$script(HTML(
sprintf(
"
var feat = %s;
var bbox = %s;
var feat_lookup = {};
var proj = d3.geoMercator().fitSize(
[800,400],
bbox
);
var path = d3.geoPath().projection(proj);
var svg = d3.select('body').append('svg')
.style('height', 400)
.style('width', 800)
.classed('map', true);
function draw(ed, delay) {
var path_f = svg
.append('path')
.datum(ed)
.style('fill', 'none')
.style('stroke', 'black')
.style('opacity', 0.0001)
.transition(2000)
.delay(delay * 1000)
.style('opacity', 1)
.attr('d', path(ed.feature));
feat_lookup[ed.feature.features[0].properties.X_leaflet_id] = {
pathd : path(ed.feature),
pathsvg: path_f.node(0)
}
};
function edit(ed, delay) {
var path_f = feat_lookup[ed.feature.features[0].properties.X_leaflet_id];
var interpolator = flubber.interpolate(
path_f.pathd,
path(ed.feature)
);
d3.select(path_f.pathsvg)
.transition(2000)
.delay(delay * 1000)
.attrTween('d', function(d) {return interpolator});
};
function del(ed, delay) {
var path_f = feat_lookup[ed.feature.features[0].properties.X_leaflet_id];
d3.select(path_f.pathsvg)
.transition(2000)
.delay(delay * 1000)
.style('opacity', 0.0001)
.remove();
};
var actions = {
'map_draw_new_feature' : draw,
'map_draw_edited_features': edit,
'map_draw_deleted_features': del
};
feat.forEach(function(ed, i) {
actions[ed.evt](ed, i)
});
/*
var fpath = svg.append('g')
.selectAll('path')
.data([feat[0]])
.enter()
.append('path')
.attr('d', path)
.style('stroke', 'black')
.style('fill', 'none')
.style('pointer-events', 'all');
feat.slice(1).reduce(
function(left,right,i) {
var interpolator = flubber.interpolate(
path(feat[i]),
path(right)
);
return left
.transition()
.duration(2000)
.attrTween('d', function(d) {return interpolator});
},
fpath
);
*/
",
jsonlite::toJSON(
Map(
function(x){
x$feature <-geojson_list(x$feature);
x
},
rec
),
auto_unbox=TRUE,
force=TRUE
),
bbox_rect
)
))
)

browsable(tl)
Binary file added experiments/flubber_playback.RData
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit f3b770d

Please sign in to comment.