Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Maps] Implement fields and bounds retrieval on GeoJsonFileSource #88294

Merged
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import { i18n } from '@kbn/i18n';
import uuid from 'uuid/v4';
import { Filter, IFieldType, IndexPattern, ISearchSource } from 'src/plugins/data/public';
import { AbstractVectorSource, BoundsFilters } from '../vector_source';
import { AbstractVectorSource, ESGlobalFilters } from '../vector_source';
import {
getAutocompleteService,
getIndexPatternService,
Expand Down Expand Up @@ -211,7 +211,7 @@ export class AbstractESSource extends AbstractVectorSource implements IESSource
}

async makeSearchSource(
searchFilters: VectorSourceRequestMeta | VectorJoinSourceRequestMeta | BoundsFilters,
searchFilters: VectorSourceRequestMeta | VectorJoinSourceRequestMeta | ESGlobalFilters,
limit: number,
initialSearchContext?: object
): Promise<ISearchSource> {
Expand Down Expand Up @@ -264,7 +264,7 @@ export class AbstractESSource extends AbstractVectorSource implements IESSource
}

async getBoundsForFilters(
boundsFilters: BoundsFilters,
boundsFilters: ESGlobalFilters,
registerCancelCallback: (callback: () => void) => void
): Promise<MapExtent | null> {
const searchSource = await this.makeSearchSource(boundsFilters, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
*/

import { Feature, FeatureCollection } from 'geojson';
import { AbstractVectorSource, GeoJsonWithMeta } from '../vector_source';
import { AbstractVectorSource, ESGlobalFilters, GeoJsonWithMeta } from '../vector_source';
import { EMPTY_FEATURE_COLLECTION, SOURCE_TYPES } from '../../../../common/constants';
import { GeojsonFileSourceDescriptor } from '../../../../common/descriptor_types';
import { GeojsonFileSourceDescriptor, MapExtent } from '../../../../common/descriptor_types';
import { registerSource } from '../source_registry';
import { IField } from '../../fields/field';
import { getFeatureCollectionBounds } from '../../util/get_feature_collection_bounds';

function getFeatureCollection(geoJson: Feature | FeatureCollection | null): FeatureCollection {
if (!geoJson) {
Expand Down Expand Up @@ -42,6 +43,18 @@ export class GeojsonFileSource extends AbstractVectorSource {
};
}

isBoundsAware(): boolean {
return true;
}

async getBoundsForFilters(
boundsFilters: ESGlobalFilters,
registerCancelCallback: (callback: () => void) => void
): Promise<MapExtent | null> {
const featureCollection = (this._descriptor as GeojsonFileSourceDescriptor).__featureCollection;
return getFeatureCollectionBounds(featureCollection, false);
}

async getGeoJsonWithMeta(): Promise<GeoJsonWithMeta> {
return {
data: (this._descriptor as GeojsonFileSourceDescriptor).__featureCollection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import uuid from 'uuid/v4';
import React from 'react';
import { GeoJsonProperties } from 'geojson';
import { AbstractSource, ImmutableSourceProperty, SourceEditorArgs } from '../source';
import { BoundsFilters, GeoJsonWithMeta, ITiledSingleLayerVectorSource } from '../vector_source';
import { ESGlobalFilters, GeoJsonWithMeta, ITiledSingleLayerVectorSource } from '../vector_source';
import {
FIELD_ORIGIN,
MAX_ZOOM,
Expand Down Expand Up @@ -179,7 +179,7 @@ export class MVTSingleLayerVectorSource
}

async getBoundsForFilters(
boundsFilters: BoundsFilters,
boundsFilters: ESGlobalFilters,
registerCancelCallback: (callback: () => void) => void
): Promise<MapExtent | null> {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export interface GeoJsonWithMeta {
meta?: GeoJsonFetchMeta;
}

export interface BoundsFilters {
export interface ESGlobalFilters {
applyGlobalQuery: boolean;
applyGlobalTime: boolean;
filters: Filter[];
Expand All @@ -47,7 +47,7 @@ export interface BoundsFilters {
export interface IVectorSource extends ISource {
getTooltipProperties(properties: GeoJsonProperties): Promise<ITooltipProperty[]>;
getBoundsForFilters(
boundsFilters: BoundsFilters,
boundsFilters: ESGlobalFilters,
registerCancelCallback: (callback: () => void) => void
): Promise<MapExtent | null>;
getGeoJsonWithMeta(
Expand Down Expand Up @@ -147,7 +147,7 @@ export class AbstractVectorSource extends AbstractSource implements IVectorSourc
}

async getBoundsForFilters(
boundsFilters: BoundsFilters,
boundsFilters: ESGlobalFilters,
registerCancelCallback: (callback: () => void) => void
): Promise<MapExtent | null> {
return null;
Expand Down