mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[Maps] Move elasticsearch_geo_utils to common (#75508)
This commit is contained in:
parent
3fb639f986
commit
954b5b5224
16 changed files with 29 additions and 39 deletions
|
@ -4,8 +4,12 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { MapExtent } from '../common/descriptor_types';
|
||||
import { MapExtent } from './descriptor_types';
|
||||
|
||||
export function scaleBounds(bounds: MapExtent, scaleFactor: number): MapExtent;
|
||||
|
||||
export function turfBboxToBounds(turfBbox: unknown): MapExtent;
|
||||
|
||||
export function clampToLatBounds(lat: number): number;
|
||||
|
||||
export function clampToLonBounds(lon: number): number;
|
|
@ -16,10 +16,12 @@ import {
|
|||
LON_INDEX,
|
||||
LAT_INDEX,
|
||||
} from '../common/constants';
|
||||
import { getEsSpatialRelationLabel } from '../common/i18n_getters';
|
||||
import { SPATIAL_FILTER_TYPE } from './kibana_services';
|
||||
import { getEsSpatialRelationLabel } from './i18n_getters';
|
||||
import { FILTERS } from '../../../../src/plugins/data/common';
|
||||
import turfCircle from '@turf/circle';
|
||||
|
||||
const SPATIAL_FILTER_TYPE = FILTERS.SPATIAL_FILTER;
|
||||
|
||||
function ensureGeoField(type) {
|
||||
const expectedTypes = [ES_GEO_FIELD_TYPE.GEO_POINT, ES_GEO_FIELD_TYPE.GEO_SHAPE];
|
||||
if (!expectedTypes.includes(type)) {
|
|
@ -4,14 +4,6 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
jest.mock('ui/new_platform');
|
||||
|
||||
jest.mock('./kibana_services', () => {
|
||||
return {
|
||||
SPATIAL_FILTER_TYPE: 'spatial_filter',
|
||||
};
|
||||
});
|
||||
|
||||
import {
|
||||
hitsToGeoJson,
|
||||
geoPointToGeometry,
|
||||
|
@ -22,7 +14,7 @@ import {
|
|||
makeESBbox,
|
||||
scaleBounds,
|
||||
} from './elasticsearch_geo_utils';
|
||||
import { indexPatterns } from '../../../../src/plugins/data/public';
|
||||
import _ from 'lodash';
|
||||
|
||||
const geoFieldName = 'location';
|
||||
|
||||
|
@ -173,19 +165,14 @@ describe('hitsToGeoJson', () => {
|
|||
});
|
||||
|
||||
describe('dot in geoFieldName', () => {
|
||||
const indexPatternMock = {
|
||||
fields: {
|
||||
getByName: (name) => {
|
||||
const fields = {
|
||||
['my.location']: {
|
||||
type: 'geo_point',
|
||||
},
|
||||
};
|
||||
return fields[name];
|
||||
},
|
||||
},
|
||||
// This essentially should test the implmentation of index-pattern.flattenHit, rather than anything in geo_utils.
|
||||
// Leaving this here for reference.
|
||||
const geoFieldName = 'my.location';
|
||||
const indexPatternFlattenHit = (hit) => {
|
||||
return {
|
||||
[geoFieldName]: _.get(hit._source, geoFieldName),
|
||||
};
|
||||
};
|
||||
const indexPatternFlattenHit = indexPatterns.flattenHitWrapper(indexPatternMock);
|
||||
|
||||
it('Should handle geoField being an object', () => {
|
||||
const hits = [
|
|
@ -41,7 +41,7 @@ import { ILayer } from '../classes/layers/layer';
|
|||
import { IVectorLayer } from '../classes/layers/vector_layer/vector_layer';
|
||||
import { DataMeta, MapExtent, MapFilters } from '../../common/descriptor_types';
|
||||
import { DataRequestAbortError } from '../classes/util/data_request';
|
||||
import { scaleBounds, turfBboxToBounds } from '../elasticsearch_geo_utils';
|
||||
import { scaleBounds, turfBboxToBounds } from '../../common/elasticsearch_geo_utils';
|
||||
|
||||
const FIT_TO_BOUNDS_SCALE_FACTOR = 0.1;
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ import {
|
|||
MapRefreshConfig,
|
||||
} from '../../common/descriptor_types';
|
||||
import { INITIAL_LOCATION } from '../../common/constants';
|
||||
import { scaleBounds } from '../elasticsearch_geo_utils';
|
||||
import { scaleBounds } from '../../common/elasticsearch_geo_utils';
|
||||
|
||||
export function setMapInitError(errorMessage: string) {
|
||||
return {
|
||||
|
|
|
@ -8,7 +8,7 @@ import _ from 'lodash';
|
|||
import { RENDER_AS } from '../../../../common/constants';
|
||||
import { getTileBoundingBox } from './geo_tile_utils';
|
||||
import { extractPropertiesFromBucket } from '../../util/es_agg_utils';
|
||||
import { clamp } from '../../../elasticsearch_geo_utils';
|
||||
import { clamp } from '../../../../common/elasticsearch_geo_utils';
|
||||
|
||||
const GRID_BUCKET_KEYS_TO_IGNORE = ['key', 'gridCentroid'];
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ import { getDataSourceLabel } from '../../../../common/i18n_getters';
|
|||
import { AbstractESAggSource, DEFAULT_METRIC } from '../es_agg_source';
|
||||
import { DataRequestAbortError } from '../../util/data_request';
|
||||
import { registerSource } from '../source_registry';
|
||||
import { makeESBbox } from '../../../elasticsearch_geo_utils';
|
||||
import { makeESBbox } from '../../../../common/elasticsearch_geo_utils';
|
||||
|
||||
export const MAX_GEOTILE_LEVEL = 29;
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import _ from 'lodash';
|
||||
import { DECIMAL_DEGREES_PRECISION } from '../../../../common/constants';
|
||||
import { clampToLatBounds } from '../../../elasticsearch_geo_utils';
|
||||
import { clampToLatBounds } from '../../../../common/elasticsearch_geo_utils';
|
||||
|
||||
const ZOOM_TILE_KEY_INDEX = 0;
|
||||
const X_TILE_KEY_INDEX = 1;
|
||||
|
|
|
@ -16,7 +16,7 @@ import { getDataSourceLabel } from '../../../../common/i18n_getters';
|
|||
import { convertToLines } from './convert_to_lines';
|
||||
import { AbstractESAggSource, DEFAULT_METRIC } from '../es_agg_source';
|
||||
import { registerSource } from '../source_registry';
|
||||
import { turfBboxToBounds } from '../../../elasticsearch_geo_utils';
|
||||
import { turfBboxToBounds } from '../../../../common/elasticsearch_geo_utils';
|
||||
import { DataRequestAbortError } from '../../util/data_request';
|
||||
|
||||
const MAX_GEOTILE_LEVEL = 29;
|
||||
|
|
|
@ -9,7 +9,7 @@ import React from 'react';
|
|||
|
||||
import { AbstractESSource } from '../es_source';
|
||||
import { getSearchService } from '../../../kibana_services';
|
||||
import { hitsToGeoJson } from '../../../elasticsearch_geo_utils';
|
||||
import { hitsToGeoJson } from '../../../../common/elasticsearch_geo_utils';
|
||||
import { UpdateSourceEditor } from './update_source_editor';
|
||||
import {
|
||||
SOURCE_TYPES,
|
||||
|
|
|
@ -11,7 +11,7 @@ import {
|
|||
getTimeFilter,
|
||||
getSearchService,
|
||||
} from '../../../kibana_services';
|
||||
import { createExtentFilter } from '../../../elasticsearch_geo_utils';
|
||||
import { createExtentFilter } from '../../../../common/elasticsearch_geo_utils';
|
||||
import _ from 'lodash';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import uuid from 'uuid/v4';
|
||||
|
|
|
@ -10,7 +10,7 @@ import { FormattedMessage } from '@kbn/i18n/react';
|
|||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
import { URL_MAX_LENGTH } from '../../../../../../../src/core/public';
|
||||
import { createSpatialFilterWithGeometry } from '../../../elasticsearch_geo_utils';
|
||||
import { createSpatialFilterWithGeometry } from '../../../../common/elasticsearch_geo_utils';
|
||||
import { GEO_JSON_TYPE } from '../../../../common/constants';
|
||||
import { GeometryFilterForm } from '../../../components/geometry_filter_form';
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ import {
|
|||
createSpatialFilterWithGeometry,
|
||||
getBoundingBoxGeometry,
|
||||
roundCoordinates,
|
||||
} from '../../../../elasticsearch_geo_utils';
|
||||
} from '../../../../../common/elasticsearch_geo_utils';
|
||||
import { DrawTooltip } from './draw_tooltip';
|
||||
|
||||
const DRAW_RECTANGLE = 'draw_rectangle';
|
||||
|
|
|
@ -19,7 +19,7 @@ import sprites1 from '@elastic/maki/dist/sprite@1.png';
|
|||
import sprites2 from '@elastic/maki/dist/sprite@2.png';
|
||||
import { DrawControl } from './draw_control';
|
||||
import { TooltipControl } from './tooltip_control';
|
||||
import { clampToLatBounds, clampToLonBounds } from '../../../elasticsearch_geo_utils';
|
||||
import { clampToLatBounds, clampToLonBounds } from '../../../../common/elasticsearch_geo_utils';
|
||||
import { getInitialView } from './get_initial_view';
|
||||
import { getPreserveDrawingBuffer } from '../../../kibana_services';
|
||||
|
||||
|
|
|
@ -5,14 +5,11 @@
|
|||
*/
|
||||
|
||||
import _ from 'lodash';
|
||||
import { esFilters } from '../../../../src/plugins/data/public';
|
||||
import { MapsLegacyConfigType } from '../../../../src/plugins/maps_legacy/public';
|
||||
import { MapsConfigType } from '../config';
|
||||
import { MapsPluginStartDependencies } from './plugin';
|
||||
import { CoreStart } from '../../../../src/core/public';
|
||||
|
||||
export const SPATIAL_FILTER_TYPE = esFilters.FILTERS.SPATIAL_FILTER;
|
||||
|
||||
let licenseId: string | undefined;
|
||||
export const setLicenseId = (latestLicenseId: string | undefined) => (licenseId = latestLicenseId);
|
||||
export const getLicenseId = () => licenseId;
|
||||
|
|
|
@ -32,7 +32,7 @@ import {
|
|||
SPATIAL_FILTERS_LAYER_ID,
|
||||
} from '../../common/constants';
|
||||
// @ts-ignore
|
||||
import { extractFeaturesFromFilters } from '../elasticsearch_geo_utils';
|
||||
import { extractFeaturesFromFilters } from '../../common/elasticsearch_geo_utils';
|
||||
import { MapStoreState } from '../reducers/store';
|
||||
import {
|
||||
DataRequestDescriptor,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue