Skip to content

Commit

Permalink
Fixed and disabled fast image projection
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Nov 3, 2017
1 parent 1f9d69d commit 583db14
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
13 changes: 10 additions & 3 deletions geoviews/operation.py
Expand Up @@ -165,7 +165,7 @@ def _fast_process(self, element, key=None):
else:
array = element.dimension_values(2, flat=False)

(x0, x1), (y0, y1) = element.range(0), element.range(1)
(x0, y0, x1, y1) = element.bounds.lbrt()
width = int(w) if self.p.width is None else self.p.width
height = int(h) if self.p.height is None else self.p.height

Expand All @@ -175,8 +175,11 @@ def _fast_process(self, element, key=None):
xvalues = []
for xb in bounds['x']:
px0, py0, px1, py1 = project_extents((xb[0], yb[0], xb[1], yb[1]), element.crs, proj)
xfraction = (xb[1]-xb[0])/(x1-x0)
fraction_width = int(width*xfraction)
if len(bounds['x']) > 1:
xfraction = (xb[1]-xb[0])/(x1-x0)
fraction_width = int(width*xfraction)
else:
fraction_width = width
xs = np.linspace(px0, px1, fraction_width)
ys = np.linspace(py0, py1, height)
cxs, cys = cartesian_product([xs, ys])
Expand All @@ -186,6 +189,10 @@ def _fast_process(self, element, key=None):
icys = (((pys-y0) / (y1-y0)) * h).astype(int)
xvalues.append(xs)

icxs[icxs<0] = 0
icys[icys<0] = 0
icxs[icxs>=w] = w-1
icys[icys>=h] = h-1
resampled_arr = array[icys, icxs]
if isinstance(element, RGB):
nvdims = len(element.vdims)
Expand Down
4 changes: 2 additions & 2 deletions geoviews/plotting/bokeh/__init__.py
Expand Up @@ -68,12 +68,12 @@ class GeoPointPlot(GeoPlot, PointPlot):

class GeoRasterPlot(GeoPlot, RasterPlot):

_project_operation = project_image.instance(fast=True)
_project_operation = project_image.instance(fast=False)


class GeoRGBPlot(GeoPlot, RGBPlot):

_project_operation = project_image.instance(fast=True)
_project_operation = project_image.instance(fast=False)


class GeoPolygonPlot(GeoPlot, PolygonPlot):
Expand Down

0 comments on commit 583db14

Please sign in to comment.