Skip to content

Commit

Permalink
Merge fb19857 into 9a76bec
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Mar 25, 2020
2 parents 9a76bec + fb19857 commit af738e8
Show file tree
Hide file tree
Showing 14 changed files with 137 additions and 112 deletions.
7 changes: 0 additions & 7 deletions .travis.yml
Expand Up @@ -56,13 +56,6 @@ jobs:
- doit test_all_recommended
after_success: coveralls

# python 2 flake checking typically catches python 2 syntax
# errors where python 3's been assumed...
- <<: *default
env: DESC="py2 flakes" PYTHON_VERSION=2.7
script: doit test_flakes
after_success: true # don't upload coverage

########## DOCS ##########

- &doc_build
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,10 @@
Version 1.8.0
=============

This release makes introduces no actual changes on top of version 1.7.0, it simply adds a dependency on bokeh>=2.0, which also means that this is the first version that requires Python 3.

- Compatibility with Bokeh 2.0 ([#449](https://github.com/holoviz/geoviews/pull/449))

Version 1.7.0
=============

Expand Down
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -59,6 +59,12 @@ only installs the minimal dependencies required to run geoviews:
conda install -c pyviz geoviews-core
```

In certain circumstances proj6 issues may prevent installation or
cause issues (particularly with cartopy<=0.17). If you encounter these
issues ensure you also pin proj4::

conda install proj4<6

Once installed you can copy the examples into the current directory
using the ``geoviews`` command and run them using the Jupyter
notebook:
Expand Down
7 changes: 6 additions & 1 deletion doc/index.rst
Expand Up @@ -19,12 +19,17 @@ You can install GeoViews and its dependencies using conda::

conda install -c pyviz geoviews


Alternatively you can install the geoviews-core package, which
only installs the minimal dependencies required to run geoviews::

conda install -c pyviz geoviews-core

In certain circumstances proj6 issues may prevent installation or
cause issues (particularly with cartopy<=0.17). If you encounter these
issues ensure you also pin proj4::

conda install proj4<6

Once installed you can copy the examples into the current directory
using the ``geoviews`` command and run them using the Jupyter
notebook::
Expand Down
7 changes: 7 additions & 0 deletions doc/releases.rst
@@ -1,6 +1,13 @@
Releases
========

Version 1.8.0
-------------

This release makes introduces no actual changes on top of version 1.7.0, it simply adds a dependency on bokeh>=2.0, which also means that this is the first version that requires Python 3.

- Compatibility with Bokeh 2.0 (`#449 <https://github.com/holoviz/geoviews/pull/449>`_)

Version 1.7.0
-------------

Expand Down
6 changes: 4 additions & 2 deletions examples/user_guide/Annotators.ipynb
Expand Up @@ -49,7 +49,8 @@
" Latitude = [ 3805587, 3803182, 3801073, 3799778])\n",
"\n",
"points = gv.Points(sample_points, crs=ccrs.GOOGLE_MERCATOR).opts(\n",
" size=10, line_color='black', padding=0.1, responsive=True, min_height=600)\n",
" size=10, line_color='black', responsive=True, min_height=600\n",
")\n",
"\n",
"point_annotate = annotate.instance()\n",
"\n",
Expand Down Expand Up @@ -167,7 +168,8 @@
"\n",
"\n",
"path = gv.Path([sample_poly], crs=ccrs.GOOGLE_MERCATOR).opts(\n",
" padding=0.1, line_width=2, color='black', responsive=True)\n",
" line_width=2, color='black', responsive=True\n",
")\n",
"\n",
"path_annotate = annotate.instance()\n",
"\n",
Expand Down
179 changes: 92 additions & 87 deletions geoviews/links.py
Expand Up @@ -56,22 +56,22 @@ class PointTableLinkCallback(LinkCallback):
on_target_changes = ['data', 'patching']

source_code = """
var projections = require("core/util/projections");
[x, y] = point_columns
var xs_column = source_cds.data[x];
var ys_column = source_cds.data[y];
var projected_xs = []
var projected_ys = []
for (i = 0; i < xs_column.length; i++) {
var xv = xs_column[i]
var yv = ys_column[i]
p = projections.wgs84_mercator.inverse([xv, yv])
const projections = Bokeh.require("core/util/projections");
const [x, y] = point_columns
const xs_column = source_cds.data[x];
const ys_column = source_cds.data[y];
const projected_xs = []
const projected_ys = []
for (let i = 0; i < xs_column.length; i++) {
const xv = xs_column[i]
const yv = ys_column[i]
const p = projections.wgs84_mercator.inverse([xv, yv])
projected_xs.push(p[0])
projected_ys.push(p[1])
}
target_cds.data[x] = projected_xs;
target_cds.data[y] = projected_ys;
for (col of source_cds.columns()) {
for (const col of source_cds.columns()) {
if ((col != x) && (col != y)) {
target_cds.data[col] = source_cds.data[col]
}
Expand All @@ -81,23 +81,23 @@ class PointTableLinkCallback(LinkCallback):
"""

target_code = """
var projections = require("core/util/projections");
[x, y] = point_columns
var xs_column = target_cds.data[x];
var ys_column = target_cds.data[y];
var projected_xs = []
var projected_ys = []
var empty = []
for (i = 0; i < xs_column.length; i++) {
var xv = xs_column[i]
var yv = ys_column[i]
p = projections.wgs84_mercator.forward([xv, yv])
var projections = Bokeh.require("core/util/projections");
const [x, y] = point_columns
const xs_column = target_cds.data[x];
const ys_column = target_cds.data[y];
const projected_xs = []
const projected_ys = []
const empty = []
for (let i = 0; i < xs_column.length; i++) {
const xv = xs_column[i]
const yv = ys_column[i]
const p = projections.wgs84_mercator.forward([xv, yv])
projected_xs.push(p[0])
projected_ys.push(p[1])
}
source_cds.data[x] = projected_xs;
source_cds.data[y] = projected_ys;
for (col of target_cds.columns()) {
for (const col of target_cds.columns()) {
if ((col != x) && (col != y)) {
source_cds.data[col] = target_cds.data[col]
}
Expand All @@ -117,38 +117,40 @@ class VertexTableLinkCallback(LinkCallback):
on_target_changes = ['data', 'patching']

source_code = """
var projections = require("core/util/projections");
var index = source_cds.selected.indices[0];
const projections = Bokeh.require("core/util/projections");
const index = source_cds.selected.indices[0];
let xs_column, ys_column
if (index == undefined) {
var xs_column = [];
var ys_column = [];
xs_column = [];
ys_column = [];
} else {
var xs_column = source_cds.data['xs'][index];
var ys_column = source_cds.data['ys'][index];
xs_column = source_cds.data['xs'][index];
ys_column = source_cds.data['ys'][index];
}
if (xs_column == undefined) {
var xs_column = [];
var ys_column = [];
xs_column = [];
ys_column = [];
}
var projected_xs = []
var projected_ys = []
const projected_xs = []
const projected_ys = []
var empty = []
for (i = 0; i < xs_column.length; i++) {
var x = xs_column[i]
var y = ys_column[i]
p = projections.wgs84_mercator.inverse([x, y])
for (let i = 0; i < xs_column.length; i++) {
const x = xs_column[i]
const y = ys_column[i]
const p = projections.wgs84_mercator.inverse([x, y])
projected_xs.push(p[0])
projected_ys.push(p[1])
empty.push(null)
}
[x, y] = vertex_columns
const [x, y] = vertex_columns
target_cds.data[x] = projected_xs
target_cds.data[y] = projected_ys
var length = projected_xs.length
for (var col in target_cds.data) {
const length = projected_xs.length
for (const col in target_cds.data) {
let data;
if (vertex_columns.indexOf(col) != -1) { continue; }
else if (col in source_cds.data) {
var path = source_cds.data[col][index];
const path = source_cds.data[col][index];
if ((path == undefined)) {
data = empty;
} else if (path.length == length) {
Expand All @@ -166,30 +168,31 @@ class VertexTableLinkCallback(LinkCallback):
"""

target_code = """
var projections = require("core/util/projections");
const projections = Bokeh.require("core/util/projections");
const types = Bokeh.require("core/util/types")
if (!source_cds.selected.indices.length) { return }
[x, y] = vertex_columns
xs_column = target_cds.data[x]
ys_column = target_cds.data[y]
var projected_xs = []
var projected_ys = []
var points = []
for (i = 0; i < xs_column.length; i++) {
var xv = xs_column[i]
var yv = ys_column[i]
p = projections.wgs84_mercator.forward([xv, yv])
const [x, y] = vertex_columns
const xs_column = target_cds.data[x]
const ys_column = target_cds.data[y]
const projected_xs = []
const projected_ys = []
const points = []
for (let i = 0; i < xs_column.length; i++) {
const xv = xs_column[i]
const yv = ys_column[i]
const p = projections.wgs84_mercator.forward([xv, yv])
projected_xs.push(p[0])
projected_ys.push(p[1])
points.push(i)
}
index = source_cds.selected.indices[0]
const index = source_cds.selected.indices[0]
const xpaths = source_cds.data['xs']
const ypaths = source_cds.data['ys']
var length = source_cds.data['xs'].length
for (var col in target_cds.data) {
const length = source_cds.data['xs'].length
for (const col in target_cds.data) {
if ((col == x) || (col == y)) { continue; }
if (!(col in source_cds.data)) {
var empty = []
const empty = []
for (i = 0; i < length; i++)
empty.push([])
source_cds.data[col] = empty
Expand All @@ -200,7 +203,9 @@ class VertexTableLinkCallback(LinkCallback):
if (pindex == index) { continue }
const xs = xpaths[pindex]
const ys = ypaths[pindex]
const column = source_cds.data[col][pindex]
let column = source_cds.data[col][pindex]
if (!types.isTypedArray(column))
source_cds.data[col][pindex] = column = Array.from(column)
if (column.length != xs.length) {
for (let ind = 0; ind < xs.length; ind++) {
column.push(null)
Expand All @@ -227,21 +232,21 @@ class VertexTableLinkCallback(LinkCallback):
class RectanglesTableLinkCallback(HvRectanglesTableLinkCallback):

source_code = """
var projections = require("core/util/projections");
var xs = source_cds.data[source_glyph.x.field]
var ys = source_cds.data[source_glyph.y.field]
var ws = source_cds.data[source_glyph.width.field]
var hs = source_cds.data[source_glyph.height.field]
const projections = Bokeh.require("core/util/projections");
const xs = source_cds.data[source_glyph.x.field]
const ys = source_cds.data[source_glyph.y.field]
const ws = source_cds.data[source_glyph.width.field]
const hs = source_cds.data[source_glyph.height.field]
var x0 = []
var x1 = []
var y0 = []
var y1 = []
for (i = 0; i < xs.length; i++) {
hw = ws[i]/2.
hh = hs[i]/2.
p1 = projections.wgs84_mercator.inverse([xs[i]-hw, ys[i]-hh])
p2 = projections.wgs84_mercator.inverse([xs[i]+hw, ys[i]+hh])
const x0 = []
const x1 = []
const y0 = []
const y1 = []
for (let i = 0; i < xs.length; i++) {
const hw = ws[i]/2.
const hh = hs[i]/2.
const p1 = projections.wgs84_mercator.inverse([xs[i]-hw, ys[i]-hh])
const p2 = projections.wgs84_mercator.inverse([xs[i]+hw, ys[i]+hh])
x0.push(p1[0])
x1.push(p2[0])
y0.push(p1[1])
Expand All @@ -254,23 +259,23 @@ class RectanglesTableLinkCallback(HvRectanglesTableLinkCallback):
"""

target_code = """
var projections = require("core/util/projections");
var x0s = target_cds.data[columns[0]]
var y0s = target_cds.data[columns[1]]
var x1s = target_cds.data[columns[2]]
var y1s = target_cds.data[columns[3]]
const projections = Bokeh.require("core/util/projections");
const x0s = target_cds.data[columns[0]]
const y0s = target_cds.data[columns[1]]
const x1s = target_cds.data[columns[2]]
const y1s = target_cds.data[columns[3]]
var xs = []
var ys = []
var ws = []
var hs = []
for (i = 0; i < x0s.length; i++) {
x0 = Math.min(x0s[i], x1s[i])
y0 = Math.min(y0s[i], y1s[i])
x1 = Math.max(x0s[i], x1s[i])
y1 = Math.max(y0s[i], y1s[i])
p1 = projections.wgs84_mercator.forward([x0, y0])
p2 = projections.wgs84_mercator.forward([x1, y1])
const xs = []
const ys = []
const ws = []
const hs = []
for (let i = 0; i < x0s.length; i++) {
const x0 = Math.min(x0s[i], x1s[i])
const y0 = Math.min(y0s[i], y1s[i])
const x1 = Math.max(x0s[i], x1s[i])
const y1 = Math.max(y0s[i], y1s[i])
const p1 = projections.wgs84_mercator.forward([x0, y0])
const p2 = projections.wgs84_mercator.forward([x1, y1])
xs.push((p1[0]+p2[0])/2.)
ys.push((p1[1]+p2[1])/2.)
ws.push(p2[0]-p1[0])
Expand Down
2 changes: 1 addition & 1 deletion geoviews/package.json
Expand Up @@ -5,7 +5,7 @@
"license": "BSD-3-Clause",
"repository": {},
"dependencies": {
"bokehjs": "^1.4.0"
"@bokeh/bokehjs": "^2.0.0"
},
"devDependencies": {}
}
2 changes: 1 addition & 1 deletion geoviews/plotting/bokeh/__init__.py
Expand Up @@ -116,7 +116,7 @@ class GeoRasterPlot(GeoPlot, RasterPlot):
_project_operation = project_image.instance(fast=False)

_hover_code = """
var projections = require("core/util/projections");
var projections = Bokeh.require("core/util/projections");
var x = special_vars.x
var y = special_vars.y
var coords = projections.wgs84_mercator.inverse([x, y])
Expand Down
6 changes: 3 additions & 3 deletions geoviews/plotting/bokeh/callbacks.py
Expand Up @@ -287,21 +287,21 @@ class PolyVertexEditCallback(GeoPolyEditCallback):
var vertices = vcds.selected.indices;
var pcds = poly.data_source;
var index = null;
for (i = 0; i < pcds.data.xs.length; i++) {
for (let i = 0; i < pcds.data.xs.length; i++) {
if (pcds.data.xs[i] === vcds.data.x) {
index = i;
}
}
if ((index == null) || !vertices.length) {return}
var vertex = vertices[0];
for (col of poly.data_source.columns()) {
for (const col of poly.data_source.columns()) {
var data = pcds.data[col][index];
var first = data.slice(0, vertex+1)
var second = data.slice(vertex)
pcds.data[col][index] = first
pcds.data[col].splice(index+1, 0, second)
}
for (c of vcds.columns()) {
for (const c of vcds.columns()) {
vcds.data[c] = [];
}
pcds.change.emit()
Expand Down

0 comments on commit af738e8

Please sign in to comment.