Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasneirynck committed Sep 22, 2020
1 parent 5ad5585 commit debec1e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,6 @@ export class ESGeoGridSource extends AbstractESAggSource {
];
}

getMetricFields() {
return super.getMetricFields();
}

getFieldNames() {
return this.getMetricFields().map((esAggMetricField) => esAggMetricField.getName());
}
Expand All @@ -139,11 +135,12 @@ export class ESGeoGridSource extends AbstractESAggSource {
}

getGeoGridPrecision(zoom) {
const delta = this._getGeoGridPrecisionResolutionDelta();
if (delta === null) {
if (this._descriptor.resolution === GRID_RESOLUTION.SUPER_FINE) {
// The target-precision needs to be determined server side.
return NaN;
}
const targetGeotileLevel = Math.ceil(zoom) + delta;

const targetGeotileLevel = Math.ceil(zoom) + this._getGeoGridPrecisionResolutionDelta();
return Math.min(targetGeotileLevel, MAX_GEOTILE_LEVEL);
}

Expand All @@ -160,11 +157,6 @@ export class ESGeoGridSource extends AbstractESAggSource {
return 4;
}

if (this._descriptor.resolution === GRID_RESOLUTION.SUPER_FINE) {
// The target-precision needs to be determined server side.
return null;
}

throw new Error(
i18n.translate('xpack.maps.source.esGrid.resolutionParamErrorMessage', {
defaultMessage: `Grid resolution param not recognized: {resolution}`,
Expand Down Expand Up @@ -267,7 +259,9 @@ export class ESGeoGridSource extends AbstractESAggSource {

_addNonCompositeAggregationsToSearchSource(
searchSource,
{ indexPattern, precision, bufferedExtent }
indexPattern,
precision,
bufferedExtent
) {
searchSource.setField('aggs', {
[GEOTILE_GRID_AGG_NAME]: {
Expand Down Expand Up @@ -300,11 +294,12 @@ export class ESGeoGridSource extends AbstractESAggSource {
registerCancelCallback,
bufferedExtent,
}) {
this._addNonCompositeAggregationsToSearchSource(searchSource, {
this._addNonCompositeAggregationsToSearchSource(
searchSource,
indexPattern,
precision,
bufferedExtent,
});
bufferedExtent
);

const esResponse = await this._runEsQuery({
requestId: this.getId(),
Expand Down Expand Up @@ -368,11 +363,12 @@ export class ESGeoGridSource extends AbstractESAggSource {
const indexPattern = await this.getIndexPattern();
const searchSource = await this.makeSearchSource(searchFilters, 0);

this._addNonCompositeAggregationsToSearchSource(searchSource, {
this._addNonCompositeAggregationsToSearchSource(
searchSource,
indexPattern,
precision: -1, // This needs to be set server-side
bufferedExtent: null, //this needs to be stripped server-side
});
null, // needs to be set server-side
null // needs to be stripped server-side
);

const dsl = await searchSource.getSearchRequestBody();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ const defaultProps = {
};

describe('resolution editor', () => {
test('should omit super-fine option', async () => {
test('should omit super-fine option', () => {
const component = shallow(<ResolutionEditor {...defaultProps} />);
expect(component).toMatchSnapshot();
});
test('should add super-fine option', async () => {
test('should add super-fine option', () => {
const component = shallow(<ResolutionEditor {...defaultProps} includeSuperFine={true} />);
expect(component).toMatchSnapshot();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,8 @@ export class UpdateSourceEditor extends Component {
this.props.currentLayerType === LAYER_TYPE.VECTOR ||
this.props.currentLayerType === LAYER_TYPE.TILED_VECTOR
) {
if (resolution === GRID_RESOLUTION.SUPER_FINE) {
newLayerType = LAYER_TYPE.TILED_VECTOR;
} else {
newLayerType = LAYER_TYPE.VECTOR;
}
newLayerType =
resolution === GRID_RESOLUTION.SUPER_FINE ? LAYER_TYPE.TILED_VECTOR : LAYER_TYPE.VECTOR;
} else if (this.props.currentLayerType === LAYER_TYPE.HEATMAP) {
if (resolution === GRID_RESOLUTION.SUPER_FINE) {
throw new Error('Heatmap does not support SUPER_FINE resolution');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,8 @@ export class HeatmapStyle implements IStyle {
radius = 64;
} else if (resolution === GRID_RESOLUTION.MOST_FINE) {
radius = 32;
} else if (resolution === GRID_RESOLUTION.SUPER_FINE) {
radius = 8;
} else {
// SUPER_FINE or any other is not supported.
const errorMessage = i18n.translate('xpack.maps.style.heatmap.resolutionStyleErrorMessage', {
defaultMessage: `Resolution param not recognized: {resolution}`,
values: { resolution },
Expand Down

0 comments on commit debec1e

Please sign in to comment.