Skip to content

Drop unused lod option which uses function constructor #3

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

Merged
merged 1 commit into from
Jan 18, 2021
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
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"license": "MIT",
"dependencies": {
"array-bounds": "^1.0.1",
"binary-search-bounds": "^2.0.4",
"clamp": "^1.0.1",
"defined": "^1.0.0",
"dtype": "^2.0.0",
Expand Down
51 changes: 0 additions & 51 deletions quad.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

'use strict'

const search = require('binary-search-bounds')
const clamp = require('clamp')
const rect = require('parse-rect')
const getBounds = require('array-bounds')
Expand Down Expand Up @@ -208,13 +207,6 @@ module.exports = function cluster (srcPoints, options) {
}
maxLevel = Math.min(maxLevel, levels.length)

// return levels of details
if (options.lod) {
return lod(nminX, nminY, nmaxX, nmaxY, maxLevel)
}



// do selection ids
let selection = []

Expand Down Expand Up @@ -275,49 +267,6 @@ module.exports = function cluster (srcPoints, options) {

return selection
}

// get range offsets within levels to render lods appropriate for zoom level
// TODO: it is possible to store minSize of a point to optimize neede level calc
function lod (lox, loy, hix, hiy, maxLevel) {
let ranges = []

for (let level = 0; level < maxLevel; level++) {
let levelGroups = groups[level]
let from = offsets[level][0]

let levelGroupStart = group(lox, loy, level)
let levelGroupEnd = group(hix, hiy, level)

// FIXME: utilize sublevels to speed up search range here
let startOffset = search.ge(levelGroups, levelGroupStart)
let endOffset = search.gt(levelGroups, levelGroupEnd, startOffset, levelGroups.length - 1)

ranges[level] = [startOffset + from, endOffset + from]
}

return ranges
}

// get group id closest to the x,y coordinate, corresponding to a level
function group (x, y, level) {
let group = 1

let cx = .5, cy = .5
let diam = .5

for (let i = 0; i < level; i++) {
group <<= 2

group += x < cx ? (y < cy ? 0 : 1) : (y < cy ? 2 : 3)

diam *= .5

cx += x < cx ? -diam : diam
cy += y < cy ? -diam : diam
}

return group
}
}


Expand Down
13 changes: 0 additions & 13 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,6 @@ t('quad: max depth', t => {
t.end()
})

t('quad: lod method', t => {
let points = [0,0, 1,1, 2,2, 3,3, 4,4, 5,5, 6,6, 7,7]

let index = cluster(points)

t.deepEqual(index.range({lod: true, d: 1e-10}), [[0,1], [1,3], [3,6], [6,8]])
t.deepEqual(index.range({lod: true, level: 400}), [[0,1], [1,3], [3,6], [6,8]])
t.deepEqual(index.range({lod: true}), [[0,1], [1,3], [3,6], [6,8]])
t.deepEqual(index.range([1,6], {lod: true}), [[0,1], [1,2], [3,4], [6,7]])

t.end()
})

t('quad: selection', t => {
let points = [0,0, 1,1, 2,2, 3,3, 4,4, 5,5, 6,6, 7,7]

Expand Down