diff --git a/CHANGELOG.md b/CHANGELOG.md index ce13da74e..09712db17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - Better detect files with geotransform data that aren't geospatial ([#1718](../../pull/1718)) - Better scale float-valued tiles ([#1725](../../pull/1725)) - Tile iterators now report their length ([#1730](../../pull/1730)) +- When using griddata annotations as heatmaps, allow setting scaleWithZoom ([#1731](../../pull/1731)) ### Changes diff --git a/girder_annotation/docs/annotations.rst b/girder_annotation/docs/annotations.rst index a3518219c..c050693c9 100644 --- a/girder_annotation/docs/annotations.rst +++ b/girder_annotation/docs/annotations.rst @@ -193,9 +193,9 @@ near by values aggregate together when viewed. # false, the rangeValues are in the # value domain. Defaults to true. Optional "scaleWithZoom": true # If true, scale the size of points with the zoom level of - # the map. Defaults to false. In this case, radius is in - # pixels of the associated image. If false or unspecified, - # radius is in screen pixels. Optional + # the map. In this case, radius is in pixels of the + # associated image. If false or unspecified, radius is in + # screen pixels. Defaults to false. Optional } Grid Data @@ -211,7 +211,7 @@ choropleth, a grid with a list of values can be specified. # Optional general shape properties "interpretation": "contour", # One of heatmap, contour, or choropleth "gridWidth": 6, # Number of values across the grid. Required - "origin": [0, 0, 0], # Origin including fized x value. Optional + "origin": [0, 0, 0], # Origin including fixed z value. Optional "dx": 32, # Grid spacing in x. Optional "dy": 32, # Grid spacing in y. Optional "colorRange": ["rgba(0, 0, 0, 0)", "rgba(255, 255, 0, 1)"], # A list of colors corresponding to @@ -227,6 +227,13 @@ choropleth, a grid with a list of values can be specified. "maxColor": "rgba(255, 255, 0, 1)", # The color of data above the maximum range. Optional "stepped": true, # For contours, whether discrete colors or continuous colors # should be used. Default false. Optional + "radius": 25, # Positive number. Optional. The size of the gaussian + # point when using the heatman interprettation + "scaleWithZoom": true # If true, when using the heatmap interprettation, scale + # the size of points with the zoom level of the map. In + # this case, radius is in pixels of the associated image. + # If false or unspecified, radius is in screen pixels. + # Defaults to false. Optional "values": [ 0.508, 0.806, diff --git a/girder_annotation/girder_large_image_annotation/models/annotation.py b/girder_annotation/girder_large_image_annotation/models/annotation.py index e0684c9c3..d6bd478ba 100644 --- a/girder_annotation/girder_large_image_annotation/models/annotation.py +++ b/girder_annotation/girder_large_image_annotation/models/annotation.py @@ -384,6 +384,12 @@ class AnnotationSchema: 'exclusiveMinimum': 0, 'description': 'radius used for heatmap interpretation', }, + 'scaleWithZoom': { + 'type': 'boolean', + 'description': + 'If true, and interpreted as a heatmap, scale the size ' + 'of points with the zoom level of the map.', + }, 'colorRange': colorRangeSchema, 'rangeValues': rangeValueSchema, 'normalizeRange': { diff --git a/girder_annotation/girder_large_image_annotation/web_client/annotations/convertFeatures.js b/girder_annotation/girder_large_image_annotation/web_client/annotations/convertFeatures.js index dc8b8331b..b809d7949 100644 --- a/girder_annotation/girder_large_image_annotation/web_client/annotations/convertFeatures.js +++ b/girder_annotation/girder_large_image_annotation/web_client/annotations/convertFeatures.js @@ -115,12 +115,15 @@ function convertGridToHeatmap(record, properties, layer) { const dx = (record.dx || 1); const dy = (record.dy || 1); const colorTable = heatmapColorTable(record, record.values); + const tileLayer = map.layers().find((l) => l instanceof window.geo.tileLayer && l.options && l.options.maxLevel !== undefined); + const scaleZoomFactor = tileLayer ? 2 ** -tileLayer.options.maxLevel : 1; const heatmap = heatmapLayer.createFeature('heatmap', { style: { - radius: record.radius || 25, + radius: (record.radius || 25) * (record.scaleWithZoom ? scaleZoomFactor : 1), blurRadius: 0, gaussian: true, - color: colorTable.color + color: colorTable.color, + scaleWithZoom: record.scaleWithZoom || false }, position: (d, i) => ({ x: x0 + dx * (i % record.gridWidth),