Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If a point has no stroke or fill, don't return it from pointSearch. #1003

Merged
merged 2 commits into from
Jun 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/pointFeature.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ var pointFeature = function (arg) {
* data changes.
*/
this._updateRangeTree = function () {
if (m_rangeTreeTime.timestamp() >= m_this.dataTime().timestamp()) {
if (m_rangeTreeTime.timestamp() >= m_this.dataTime().timestamp() && m_rangeTreeTime.timestamp() >= m_this.timestamp()) {
return;
}
var pts, position,
Expand Down Expand Up @@ -274,6 +274,7 @@ var pointFeature = function (arg) {
var min, max, data, idx = [], found = [], ifound = [], map, pt,
fgcs = m_this.gcs(), // this feature's gcs
corners,
fill = m_this.style.get('fill'),
stroke = m_this.style.get('stroke'),
strokeWidth = m_this.style.get('strokeWidth'),
radius = m_this.style.get('radius');
Expand Down Expand Up @@ -314,11 +315,14 @@ var pointFeature = function (arg) {
// Filter by circular region
idx.forEach(function (i) {
var d = data[i],
p = m_this.position()(d, i),
hasstroke = stroke(data[i], i);
if (!hasstroke && !fill(data[i], i)) {
return;
}
var p = m_this.position()(d, i),
dx, dy, rad, rad2;

rad = radius(data[i], i);
rad += stroke(data[i], i) ? strokeWidth(data[i], i) : 0;
rad += hasstroke ? strokeWidth(data[i], i) : 0;
if (rad) {
rad2 = rad * rad;
p = map.gcsToDisplay(p, fgcs);
Expand Down
9 changes: 8 additions & 1 deletion tests/cases/pointFeature.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,16 @@ describe('geo.pointFeature', function () {
expect(pt.found.length).toBe(1);
pt = point.pointSearch(map.displayToGcs({x: p.x, y: p.y + 4.05}));
expect(pt.found.length).toBe(0);
/* We should match two coincident pointss */
/* We should match two coincident points */
pt = point.pointSearch({x: 50, y: 10});
expect(pt.found.length).toBe(2);
/* If a point has no fill or stroke, it won't be found. */
point.style({
fill: function (d, i) { return i !== 16; },
stroke: function (d, i) { return i !== 16; }
});
pt = point.pointSearch({x: 50, y: 10});
expect(pt.found.length).toBe(1);
/* If we have zero-length data, we get no matches */
point.data([]);
pt = point.pointSearch({x: 22, y: 10});
Expand Down