[Maps] Enable geo-point for mvt scaling type (#79733)
This commit is contained in:
parent
0a713d3750
commit
fd4eacd29f
|
@ -67,84 +67,6 @@ exports[`scaling form should disable clusters option when clustering is not supp
|
|||
>
|
||||
<EuiRadio
|
||||
checked={false}
|
||||
disabled={false}
|
||||
id="MVT"
|
||||
label="Use vector tiles"
|
||||
onChange={[Function]}
|
||||
/>
|
||||
</EuiToolTip>
|
||||
</div>
|
||||
</EuiFormRow>
|
||||
<EuiFormRow
|
||||
describedByIds={Array []}
|
||||
display="row"
|
||||
fullWidth={false}
|
||||
hasChildLabel={true}
|
||||
hasEmptyLabelSpace={false}
|
||||
labelType="label"
|
||||
>
|
||||
<EuiSwitch
|
||||
checked={true}
|
||||
compressed={true}
|
||||
label="Dynamically filter for data in the visible map area"
|
||||
onChange={[Function]}
|
||||
/>
|
||||
</EuiFormRow>
|
||||
</Fragment>
|
||||
`;
|
||||
|
||||
exports[`scaling form should disable mvt option when mvt is not supported 1`] = `
|
||||
<Fragment>
|
||||
<EuiTitle
|
||||
size="xs"
|
||||
>
|
||||
<h5>
|
||||
<FormattedMessage
|
||||
defaultMessage="Scaling"
|
||||
id="xpack.maps.esSearch.scaleTitle"
|
||||
values={Object {}}
|
||||
/>
|
||||
</h5>
|
||||
</EuiTitle>
|
||||
<EuiSpacer
|
||||
size="m"
|
||||
/>
|
||||
<EuiFormRow
|
||||
describedByIds={Array []}
|
||||
display="row"
|
||||
fullWidth={false}
|
||||
hasChildLabel={true}
|
||||
hasEmptyLabelSpace={false}
|
||||
labelType="label"
|
||||
>
|
||||
<div>
|
||||
<EuiRadio
|
||||
checked={true}
|
||||
id="LIMIT"
|
||||
label="Limit results to 10000."
|
||||
onChange={[Function]}
|
||||
/>
|
||||
<EuiRadio
|
||||
checked={false}
|
||||
id="TOP_HITS"
|
||||
label="Show top hits per entity."
|
||||
onChange={[Function]}
|
||||
/>
|
||||
<EuiRadio
|
||||
checked={false}
|
||||
disabled={false}
|
||||
id="CLUSTERS"
|
||||
label="Show clusters when results exceed 10000."
|
||||
onChange={[Function]}
|
||||
/>
|
||||
<EuiToolTip
|
||||
content="Simulated mvt disabled"
|
||||
delay="regular"
|
||||
position="left"
|
||||
>
|
||||
<EuiRadio
|
||||
checked={false}
|
||||
disabled={true}
|
||||
id="MVT"
|
||||
label="Use vector tiles"
|
||||
onChange={[Function]}
|
||||
|
@ -231,7 +153,6 @@ exports[`scaling form should render 1`] = `
|
|||
>
|
||||
<EuiRadio
|
||||
checked={false}
|
||||
disabled={false}
|
||||
id="MVT"
|
||||
label="Use vector tiles"
|
||||
onChange={[Function]}
|
||||
|
@ -318,7 +239,6 @@ exports[`scaling form should render top hits form when scaling type is TOP_HITS
|
|||
>
|
||||
<EuiRadio
|
||||
checked={false}
|
||||
disabled={false}
|
||||
id="MVT"
|
||||
label="Use vector tiles"
|
||||
onChange={[Function]}
|
||||
|
|
|
@ -95,11 +95,9 @@ exports[`should enable sort order select when sort field provided 1`] = `
|
|||
clusteringDisabledReason={null}
|
||||
filterByMapBounds={true}
|
||||
indexPatternId="indexPattern1"
|
||||
mvtDisabledReason={null}
|
||||
onChange={[Function]}
|
||||
scalingType="LIMIT"
|
||||
supportsClustering={false}
|
||||
supportsMvt={false}
|
||||
termFields={null}
|
||||
topHitsSize={1}
|
||||
topHitsSplitField="trackId"
|
||||
|
@ -205,11 +203,9 @@ exports[`should render update source editor 1`] = `
|
|||
clusteringDisabledReason={null}
|
||||
filterByMapBounds={true}
|
||||
indexPatternId="indexPattern1"
|
||||
mvtDisabledReason={null}
|
||||
onChange={[Function]}
|
||||
scalingType="LIMIT"
|
||||
supportsClustering={false}
|
||||
supportsMvt={false}
|
||||
termFields={null}
|
||||
topHitsSize={1}
|
||||
topHitsSplitField="trackId"
|
||||
|
|
|
@ -19,8 +19,6 @@ import {
|
|||
getTermsFields,
|
||||
getGeoTileAggNotSupportedReason,
|
||||
supportsGeoTileAgg,
|
||||
supportsMvt,
|
||||
getMvtDisabledReason,
|
||||
} from '../../../index_pattern_util';
|
||||
|
||||
function doesGeoFieldSupportGeoTileAgg(indexPattern, geoFieldName) {
|
||||
|
@ -149,7 +147,6 @@ export class CreateSourceEditor extends Component {
|
|||
return null;
|
||||
}
|
||||
|
||||
const mvtSupported = supportsMvt(this.state.indexPattern, this.state.geoFieldName);
|
||||
return (
|
||||
<Fragment>
|
||||
<EuiSpacer size="m" />
|
||||
|
@ -162,8 +159,6 @@ export class CreateSourceEditor extends Component {
|
|||
this.state.indexPattern,
|
||||
this.state.geoFieldName
|
||||
)}
|
||||
supportsMvt={mvtSupported}
|
||||
mvtDisabledReason={mvtSupported ? null : getMvtDisabledReason()}
|
||||
clusteringDisabledReason={
|
||||
this.state.indexPattern
|
||||
? getGeoTileAggNotSupportedReason(
|
||||
|
|
|
@ -614,7 +614,9 @@ export class ESSearchSource extends AbstractESSource {
|
|||
`/${GIS_API_PATH}/${MVT_GETTILE_API_PATH}`
|
||||
);
|
||||
|
||||
const urlTemplate = `${mvtUrlServicePath}?x={x}&y={y}&z={z}&geometryFieldName=${this._descriptor.geoField}&index=${indexPattern.title}&requestBody=${risonDsl}`;
|
||||
const geoField = await this._getGeoField();
|
||||
|
||||
const urlTemplate = `${mvtUrlServicePath}?x={x}&y={y}&z={z}&geometryFieldName=${this._descriptor.geoField}&index=${indexPattern.title}&requestBody=${risonDsl}&geoFieldType=${geoField.type}`;
|
||||
return {
|
||||
layerName: this.getLayerName(),
|
||||
minSourceZoom: this.getMinZoom(),
|
||||
|
|
|
@ -110,7 +110,7 @@ describe('ESSearchSource', () => {
|
|||
);
|
||||
const urlTemplateWithMeta = await esSearchSource.getUrlTemplateWithMeta(searchFilters);
|
||||
expect(urlTemplateWithMeta.urlTemplate).toBe(
|
||||
`rootdir/api/maps/mvt/getTile;?x={x}&y={y}&z={z}&geometryFieldName=bar&index=foobar-title-*&requestBody=(foobar:ES_DSL_PLACEHOLDER,params:('0':('0':index,'1':(fields:(),title:'foobar-title-*')),'1':('0':size,'1':1000),'2':('0':filter,'1':!()),'3':('0':query),'4':('0':index,'1':(fields:(),title:'foobar-title-*')),'5':('0':query,'1':(language:KQL,query:'tooltipField: foobar',queryLastTriggeredAt:'2019-04-25T20:53:22.331Z')),'6':('0':fields,'1':!(tooltipField,styleField)),'7':('0':source,'1':!(tooltipField,styleField))))`
|
||||
`rootdir/api/maps/mvt/getTile;?x={x}&y={y}&z={z}&geometryFieldName=bar&index=foobar-title-*&requestBody=(foobar:ES_DSL_PLACEHOLDER,params:('0':('0':index,'1':(fields:(),title:'foobar-title-*')),'1':('0':size,'1':1000),'2':('0':filter,'1':!()),'3':('0':query),'4':('0':index,'1':(fields:(),title:'foobar-title-*')),'5':('0':query,'1':(language:KQL,query:'tooltipField: foobar',queryLastTriggeredAt:'2019-04-25T20:53:22.331Z')),'6':('0':fields,'1':!(tooltipField,styleField)),'7':('0':source,'1':!(tooltipField,styleField))))&geoFieldType=geo_shape`
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -27,8 +27,6 @@ const defaultProps = {
|
|||
termFields: [],
|
||||
topHitsSplitField: null,
|
||||
topHitsSize: 1,
|
||||
supportsMvt: true,
|
||||
mvtDisabledReason: null,
|
||||
};
|
||||
|
||||
describe('scaling form', () => {
|
||||
|
@ -57,16 +55,4 @@ describe('scaling form', () => {
|
|||
|
||||
expect(component).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('should disable mvt option when mvt is not supported', async () => {
|
||||
const component = shallow(
|
||||
<ScalingForm
|
||||
{...defaultProps}
|
||||
supportsMvt={false}
|
||||
mvtDisabledReason={'Simulated mvt disabled'}
|
||||
/>
|
||||
);
|
||||
|
||||
expect(component).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -39,9 +39,7 @@ interface Props {
|
|||
onChange: (args: OnSourceChangeArgs) => void;
|
||||
scalingType: SCALING_TYPES;
|
||||
supportsClustering: boolean;
|
||||
supportsMvt: boolean;
|
||||
clusteringDisabledReason?: string | null;
|
||||
mvtDisabledReason?: string | null;
|
||||
termFields: IFieldType[];
|
||||
topHitsSplitField: string | null;
|
||||
topHitsSize: number;
|
||||
|
@ -197,7 +195,6 @@ export class ScalingForm extends Component<Props, State> {
|
|||
label={labelText}
|
||||
checked={this.props.scalingType === SCALING_TYPES.MVT}
|
||||
onChange={() => this._onScalingTypeChange(SCALING_TYPES.MVT)}
|
||||
disabled={!this.props.supportsMvt}
|
||||
/>
|
||||
);
|
||||
|
||||
|
@ -211,11 +208,7 @@ export class ScalingForm extends Component<Props, State> {
|
|||
</>
|
||||
);
|
||||
|
||||
return !this.props.supportsMvt ? (
|
||||
<EuiToolTip position="left" content={this.props.mvtDisabledReason}>
|
||||
{mvtRadio}
|
||||
</EuiToolTip>
|
||||
) : (
|
||||
return (
|
||||
<EuiToolTip position="left" content={enabledInfo}>
|
||||
{mvtRadio}
|
||||
</EuiToolTip>
|
||||
|
|
|
@ -17,8 +17,6 @@ import {
|
|||
getTermsFields,
|
||||
getSourceFields,
|
||||
supportsGeoTileAgg,
|
||||
supportsMvt,
|
||||
getMvtDisabledReason,
|
||||
} from '../../../index_pattern_util';
|
||||
import { SORT_ORDER } from '../../../../common/constants';
|
||||
import { ESDocField } from '../../fields/es_doc_field';
|
||||
|
@ -44,7 +42,6 @@ export class UpdateSourceEditor extends Component {
|
|||
termFields: null,
|
||||
sortFields: null,
|
||||
supportsClustering: false,
|
||||
supportsMvt: false,
|
||||
mvtDisabledReason: null,
|
||||
clusteringDisabledReason: null,
|
||||
};
|
||||
|
@ -99,12 +96,10 @@ export class UpdateSourceEditor extends Component {
|
|||
});
|
||||
});
|
||||
|
||||
const mvtSupported = supportsMvt(indexPattern, geoField.name);
|
||||
this.setState({
|
||||
supportsClustering: supportsGeoTileAgg(geoField),
|
||||
supportsMvt: mvtSupported,
|
||||
clusteringDisabledReason: getGeoTileAggNotSupportedReason(geoField),
|
||||
mvtDisabledReason: mvtSupported ? null : getMvtDisabledReason(),
|
||||
mvtDisabledReason: null,
|
||||
sourceFields: sourceFields,
|
||||
termFields: getTermsFields(indexPattern.fields), //todo change term fields to use fields
|
||||
sortFields: indexPattern.fields.filter(
|
||||
|
@ -215,9 +210,7 @@ export class UpdateSourceEditor extends Component {
|
|||
onChange={this.props.onChange}
|
||||
scalingType={this.props.scalingType}
|
||||
supportsClustering={this.state.supportsClustering}
|
||||
supportsMvt={this.state.supportsMvt}
|
||||
clusteringDisabledReason={this.state.clusteringDisabledReason}
|
||||
mvtDisabledReason={this.state.mvtDisabledReason}
|
||||
termFields={this.state.termFields}
|
||||
topHitsSplitField={this.props.topHitsSplitField}
|
||||
topHitsSize={this.props.topHitsSize}
|
||||
|
|
|
@ -82,17 +82,6 @@ export function supportsGeoTileAgg(field?: IFieldType): boolean {
|
|||
);
|
||||
}
|
||||
|
||||
export function supportsMvt(indexPattern: IndexPattern, geoFieldName: string): boolean {
|
||||
const field = indexPattern.fields.getByName(geoFieldName);
|
||||
return !!field && field.type === ES_GEO_FIELD_TYPE.GEO_SHAPE;
|
||||
}
|
||||
|
||||
export function getMvtDisabledReason() {
|
||||
return i18n.translate('xpack.maps.mbt.disabled', {
|
||||
defaultMessage: 'Display as vector tiles is only supported for geo_shape field-types.',
|
||||
});
|
||||
}
|
||||
// Returns filtered fields list containing only fields that exist in _source.
|
||||
export function getSourceFields(fields: IFieldType[]): IFieldType[] {
|
||||
return fields.filter((field) => {
|
||||
// Multi fields are not stored in _source and only exist in index.
|
||||
|
|
|
@ -50,6 +50,7 @@ describe('getTile', () => {
|
|||
info: () => {},
|
||||
} as unknown) as Logger,
|
||||
callElasticsearch: mockCallElasticsearch,
|
||||
geoFieldType: ES_GEO_FIELD_TYPE.GEO_SHAPE,
|
||||
});
|
||||
|
||||
compareTiles('./__tests__/pbf/0_0_0_docs.pbf', tile);
|
||||
|
|
|
@ -21,9 +21,8 @@ import {
|
|||
SUPER_FINE_ZOOM_DELTA,
|
||||
} from '../../common/constants';
|
||||
|
||||
import { hitsToGeoJson } from '../../common/elasticsearch_util';
|
||||
import { convertRegularRespToGeoJson, hitsToGeoJson } from '../../common/elasticsearch_util';
|
||||
import { flattenHit } from './util';
|
||||
import { convertRegularRespToGeoJson } from '../../common/elasticsearch_util';
|
||||
import { ESBounds, tile2lat, tile2long, tileToESBbox } from '../../common/geo_tile_utils';
|
||||
|
||||
export async function getGridTile({
|
||||
|
@ -107,6 +106,7 @@ export async function getTile({
|
|||
y,
|
||||
z,
|
||||
requestBody = {},
|
||||
geoFieldType,
|
||||
}: {
|
||||
x: number;
|
||||
y: number;
|
||||
|
@ -116,6 +116,7 @@ export async function getTile({
|
|||
callElasticsearch: (type: string, ...args: any[]) => Promise<unknown>;
|
||||
logger: Logger;
|
||||
requestBody: any;
|
||||
geoFieldType: ES_GEO_FIELD_TYPE;
|
||||
}): Promise<Buffer | null> {
|
||||
const geojsonBbox = tileToGeoJsonPolygon(x, y, z);
|
||||
|
||||
|
@ -181,7 +182,6 @@ export async function getTile({
|
|||
},
|
||||
];
|
||||
} else {
|
||||
// Perform actual search
|
||||
result = await callElasticsearch('search', esSearchQuery);
|
||||
|
||||
// Todo: pass in epochMillies-fields
|
||||
|
@ -192,7 +192,7 @@ export async function getTile({
|
|||
return flattenHit(geometryFieldName, hit);
|
||||
},
|
||||
geometryFieldName,
|
||||
ES_GEO_FIELD_TYPE.GEO_SHAPE,
|
||||
geoFieldType,
|
||||
[]
|
||||
);
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ export function initMVTRoutes({ router, logger }: { logger: Logger; router: IRou
|
|||
geometryFieldName: schema.string(),
|
||||
requestBody: schema.string(),
|
||||
index: schema.string(),
|
||||
geoFieldType: schema.string(),
|
||||
}),
|
||||
},
|
||||
},
|
||||
|
@ -56,6 +57,7 @@ export function initMVTRoutes({ router, logger }: { logger: Logger; router: IRou
|
|||
z: query.z as number,
|
||||
index: query.index as string,
|
||||
requestBody: requestBodyDSL as any,
|
||||
geoFieldType: query.geoFieldType as ES_GEO_FIELD_TYPE,
|
||||
});
|
||||
|
||||
return sendResponse(response, tile);
|
||||
|
|
|
@ -11,7 +11,7 @@ export default function ({ getService }) {
|
|||
it('should validate params', async () => {
|
||||
await supertest
|
||||
.get(
|
||||
`/api/maps/mvt/getTile?x=15&y=11&z=5&geometryFieldName=coordinates&index=logstash*&requestBody=(_source:(includes:!(coordinates)),docvalue_fields:!(),query:(bool:(filter:!((match_all:())),must:!(),must_not:!(),should:!())),script_fields:(),size:10000,stored_fields:!(coordinates))`
|
||||
`/api/maps/mvt/getTile?x=15&y=11&z=5&geometryFieldName=coordinates&index=logstash*&requestBody=(_source:(includes:!(coordinates)),docvalue_fields:!(),query:(bool:(filter:!((match_all:())),must:!(),must_not:!(),should:!())),script_fields:(),size:10000,stored_fields:!(coordinates))&geoFieldType=geo_point`
|
||||
)
|
||||
.set('kbn-xsrf', 'kibana')
|
||||
.expect(200);
|
||||
|
|
|
@ -29,7 +29,7 @@ export default function ({ getPageObjects, getService }) {
|
|||
|
||||
//Source should be correct
|
||||
expect(mapboxStyle.sources[VECTOR_SOURCE_ID].tiles[0]).to.equal(
|
||||
'/api/maps/mvt/getTile?x={x}&y={y}&z={z}&geometryFieldName=geometry&index=geo_shapes*&requestBody=(_source:(includes:!(geometry,prop1)),docvalue_fields:!(prop1),query:(bool:(filter:!((match_all:())),must:!(),must_not:!(),should:!())),script_fields:(),size:10000,stored_fields:!(geometry,prop1))'
|
||||
'/api/maps/mvt/getTile?x={x}&y={y}&z={z}&geometryFieldName=geometry&index=geo_shapes*&requestBody=(_source:(includes:!(geometry,prop1)),docvalue_fields:!(prop1),query:(bool:(filter:!((match_all:())),must:!(),must_not:!(),should:!())),script_fields:(),size:10000,stored_fields:!(geometry,prop1))&geoFieldType=geo_shape'
|
||||
);
|
||||
|
||||
//Should correctly load meta for style-rule (sigma is set to 1, opacity to 1)
|
||||
|
|
Loading…
Reference in a new issue