Skip to content

Commit

Permalink
Remove outdated comment, add test
Browse files Browse the repository at this point in the history
  • Loading branch information
domoritz committed Apr 8, 2021
1 parent f73a071 commit 647b0f5
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 6 deletions.
1 change: 0 additions & 1 deletion src/compile/mark/encode/position-range.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ function pointPosition2OrSize(
: getOffset(baseChannel, model.markDef);

if (!channelDef && (channel === 'x2' || channel === 'y2') && (encoding.latitude || encoding.longitude)) {
// use geopoint output if there are lat2/long2 and there is no point position2 overriding lat2/long2.
const vgSizeChannel = getSizeChannel(channel);

const size = model.markDef[vgSizeChannel];
Expand Down
41 changes: 36 additions & 5 deletions test/compile/mark/encode/position-range.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@ import {rangePosition} from '../../../../src/compile/mark/encode';
import {parseUnitModelWithScaleAndLayoutSize} from '../../../util';

describe('compile/mark/encode/position-range', () => {
it('should return correctly for lat/lng with size', () => {
it('should return correct position for lat/lng with size', () => {
const model = parseUnitModelWithScaleAndLayoutSize({
data: {
url: 'data/zipcodes.csv',
format: {
type: 'csv'
}
url: 'data/zipcodes.csv'
},
mark: {
type: 'image',
Expand All @@ -36,4 +33,38 @@ describe('compile/mark/encode/position-range', () => {
expect(mixins[sizeChannel]).toEqual({value: 42});
});
});

it('should return correct position for lat/lng with without size', () => {
const model = parseUnitModelWithScaleAndLayoutSize({
data: {
values: [
{
latitude: 0,
longitude: 0,
latitude2: 30,
longitude2: 30
},
{
latitude: -10,
longitude: -10,
latitude2: 20,
longitude2: 20
}
]
},
mark: 'rect',
encoding: {
longitude: {field: 'longitude', type: 'quantitative'},
latitude: {field: 'latitude', type: 'quantitative'},
longitude2: {field: 'longitude2'},
latitude2: {field: 'latitude2'}
}
});

[X, Y].forEach(channel => {
const mixins = rangePosition(channel, model, {defaultPos: 'zeroOrMin', defaultPos2: 'zeroOrMin'});
expect(mixins[channel]['field']).toEqual(model.getName(channel));
expect(mixins[channel + '2']['field']).toEqual(model.getName(channel + '2'));
});
});
});

0 comments on commit 647b0f5

Please sign in to comment.