Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasneirynck committed Jul 7, 2021
1 parent 5f3ba8e commit ff94926
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,22 @@ export class TiledVectorLayer extends VectorLayer {
this._source = source as ITiledSingleLayerVectorSource;
}

getMetaFromTiles(): TileMetaFeature[] {
_getMetaFromTiles(): TileMetaFeature[] {
return this._descriptor.__metaFromTiles || [];
}

getCustomIconAndTooltipContent(): CustomIconAndTooltipContent {
const tileMetas = this.getMetaFromTiles();
const tileMetas = this._getMetaFromTiles();
if (!tileMetas.length) {
return NO_RESULTS_ICON_AND_TOOLTIPCONTENT;
}

const totalFeatures: number = tileMetas.reduce((acc: number, tileMeta: Feature) => {
const totalFeaturesCount: number = tileMetas.reduce((acc: number, tileMeta: Feature) => {
const count = tileMeta && tileMeta.properties ? tileMeta.properties[KBN_FEATURE_COUNT] : 0;
return count + acc;
}, 0);

if (totalFeatures === 0) {
if (totalFeaturesCount === 0) {
return NO_RESULTS_ICON_AND_TOOLTIPCONTENT;
}

Expand All @@ -93,9 +93,17 @@ export class TiledVectorLayer extends VectorLayer {
icon: this.getCurrentStyle().getIcon(),
tooltipContent: isIncomplete
? i18n.translate('xpack.maps.tiles.resultsTrimmedMsg', {
defaultMessage: `Layer shows incomplete results`,
defaultMessage: `Results limited to {count} documents.`,
values: {
count: totalFeaturesCount,
},
})
: null,
: i18n.translate('xpack.maps.tiles.resultsCompleteMsg', {
defaultMessage: `Found {count} documents.`,
values: {
count: totalFeaturesCount,
},
}),
areResultsTrimmed: isIncomplete,
};
}
Expand Down Expand Up @@ -340,7 +348,7 @@ export class TiledVectorLayer extends VectorLayer {
return null;
}

const metaFromTiles = this.getMetaFromTiles();
const metaFromTiles = this._getMetaFromTiles();
return await style.pluckStyleMetaFromTileMeta(metaFromTiles);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ test('Should read out ordinal type correctly', async () => {
});

describe('renderDataMappingPopover', () => {
test('Switch toggle should be enabled', () => {
test('Should render OrdinalDataMappingPopover', () => {
const colorStyle = makeProperty(
{
color: 'Blues',
Expand Down
15 changes: 13 additions & 2 deletions x-pack/plugins/maps/server/mvt/get_tile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ import { pluckRangeFieldMeta } from '../../common/pluck_range_field_meta';
import { FieldMeta, TileMetaFeature } from '../../common/descriptor_types';
import { pluckCategoryFieldMeta } from '../../common/pluck_category_field_meta';

// heuristic. largest color-palette has 30 colors. 1 color is used for 'other'.
const TERM_COUNT = 30 - 1;

function isAbortError(error: Error) {
return error.message === 'Request aborted' || error.message === 'Aborted';
}
Expand Down Expand Up @@ -132,7 +135,7 @@ export async function getGridTile({
}
});

const categoryMeta = pluckCategoryFieldMeta(features, fieldName, 20);
const categoryMeta = pluckCategoryFieldMeta(features, fieldName, TERM_COUNT);

if (!fieldMeta[fieldName]) {
fieldMeta[fieldName] = {};
Expand Down Expand Up @@ -341,10 +344,18 @@ export async function getTile({

const fieldMeta: FieldMeta = {};
fieldNames.forEach((fieldName: string) => {
if (
fieldName === '_index' ||
fieldName === '_id' ||
fieldName === FEATURE_ID_PROPERTY_NAME
) {
return;
}

const rangeMeta = pluckRangeFieldMeta(features, fieldName, (rawValue: unknown) => {
return typeof rawValue === 'number' ? rawValue : NaN;
});
const categoryMeta = pluckCategoryFieldMeta(features, fieldName, 20);
const categoryMeta = pluckCategoryFieldMeta(features, fieldName, TERM_COUNT);

if (!fieldMeta[fieldName]) {
fieldMeta[fieldName] = {};
Expand Down
2 changes: 1 addition & 1 deletion x-pack/test/api_integration/apis/maps/get_tile.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default function ({ getService }) {
__kbn_metadata_feature__: true,
__kbn_vector_shape_type_counts__: '{"POINT":2,"LINE":0,"POLYGON":0}',
fieldMeta:
'{"machine.os.raw":{"categories":{"categories":[{"key":"ios","count":1},{"count":1}]}},"bytes":{"range":{"min":9252,"max":9583,"delta":331},"categories":{"categories":[{"key":9252,"count":1},{"key":9583,"count":1}]}},"_index":{"categories":{"categories":[{"key":"logstash-2015.09.20","count":2}]}},"_id":{"categories":{"categories":[{"key":"AU_x3_BsGFA8no6Qjjug","count":1},{"key":"AU_x3_g3GFA8no6QjkGu","count":1}]}},"__kbn__feature_id__":{"categories":{"categories":[{"key":"logstash-2015.09.20:AU_x3_BsGFA8no6Qjjug:0","count":1},{"key":"logstash-2015.09.20:AU_x3_g3GFA8no6QjkGu:0","count":1}]}}}',
'{"machine.os.raw":{"categories":{"categories":[{"key":"ios","count":1},{"count":1}]}},"bytes":{"range":{"min":9252,"max":9583,"delta":331},"categories":{"categories":[{"key":9252,"count":1},{"key":9583,"count":1}]}}}',
});
expect(metadataFeature.loadGeometry()).to.eql([
[
Expand Down

0 comments on commit ff94926

Please sign in to comment.