Coveralls logob
Coveralls logo
  • Home
  • Features
  • Pricing
  • Docs
  • Sign In

uber / deck.gl / 13127

29 Aug 2019 - 17:33 coverage increased (+2.5%) to 83.552%
13127

Pull #3507

travis-ci-com

9181eb84f9c35729a3bad740fb7f9d93?size=18&default=identiconweb-flow
update the component-wrapping-rfc.md
Pull Request #3507: update the component-wrapping-rfc.md

3393 of 4570 branches covered (74.25%)

Branch coverage included in aggregate %.

7066 of 7948 relevant lines covered (88.9%)

3403.06 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.86
/modules/aggregation-layers/src/utils/scale-utils.js
1
// Copyright (c) 2015 - 2017 Uber Technologies, Inc.
2
//
3
// Permission is hereby granted, free of charge, to any person obtaining a copy
4
// of this software and associated documentation files (the "Software"), to deal
5
// in the Software without restriction, including without limitation the rights
6
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
// copies of the Software, and to permit persons to whom the Software is
8
// furnished to do so, subject to the following conditions:
9
//
10
// The above copyright notice and this permission notice shall be included in
11
// all copies or substantial portions of the Software.
12
//
13
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
// THE SOFTWARE.
20

21
import {log} from '@deck.gl/core';
22

23
// Linear scale maps continuous domain to continuous range
24
export function linearScale(domain, range, value) {
25
  return ((value - domain[0]) / (domain[1] - domain[0])) * (range[1] - range[0]) + range[0];
1×
26
}
27

28
// Quantize scale is similar to linear scales,
29
// except it uses a discrete rather than continuous range
30
export function quantizeScale(domain, range, value) {
31
  const domainRange = domain[1] - domain[0];
8×
32
  if (domainRange <= 0) {
9×
33
    log.warn('quantizeScale: invalid domain, returning range[0]')();
10×
34
    return range[0];
9×
35
  }
36
  const step = domainRange / range.length;
1×
37
  const idx = Math.floor((value - domain[0]) / step);
1×
UNCOV
38
  const clampIdx = Math.max(Math.min(idx, range.length - 1), 0);
!
39

40
  return range[clampIdx];
4,456×
41
}
42

43
// return a quantize scale function
44
export function getQuantizeScale(domain, range) {
45
  return value => quantizeScale(domain, range, value);
4,456×
46
}
47

48
// return a linear scale funciton
49
export function getLinearScale(domain, range) {
50
  return value =>
131×
51
    ((value - domain[0]) / (domain[1] - domain[0])) * (range[1] - range[0]) + range[0];
4,325×
52
}
Troubleshooting · Open an Issue · Sales · Support · ENTERPRISE · CAREERS · STATUS
BLOG · TWITTER · Legal & Privacy · Supported CI Services · What's a CI service? · Automated Testing

© 2019 Coveralls, LLC