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] upgrade turf #73816

Merged
merged 4 commits into from
Jul 30, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
5 changes: 4 additions & 1 deletion x-pack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,12 @@
"@mapbox/mapbox-gl-rtl-text": "^0.2.3",
"@scant/router": "^0.1.0",
"@slack/webhook": "^5.0.0",
"@turf/bbox": "6.0.1",
"@turf/bbox-polygon": "6.0.1",
"@turf/boolean-contains": "6.0.1",
"@turf/circle": "6.0.1",
"@turf/distance": "6.0.1",
"@turf/helpers": "6.0.1",
"angular": "^1.7.9",
"angular-resource": "1.7.9",
"angular-sanitize": "1.7.9",
Expand Down Expand Up @@ -362,7 +366,6 @@
"tinymath": "1.2.1",
"topojson-client": "3.0.0",
"tslib": "^2.0.0",
"turf": "3.0.14",
"typescript-fsa": "^3.0.0",
"typescript-fsa-reducers": "^1.2.1",
"ui-select": "0.19.8",
Expand Down
6 changes: 3 additions & 3 deletions x-pack/plugins/maps/public/actions/data_request_actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
/* eslint-disable @typescript-eslint/consistent-type-definitions */

import { Dispatch } from 'redux';
// @ts-ignore
import turf from 'turf';
import bbox from '@turf/bbox';
import { multiPoint } from '@turf/helpers';
import { FeatureCollection } from 'geojson';
import { MapStoreState } from '../reducers/store';
import { LAYER_TYPE, SOURCE_DATA_REQUEST_ID } from '../../common/constants';
Expand Down Expand Up @@ -368,7 +368,7 @@ export function fitToDataBounds() {
return;
}

const dataBounds = turfBboxToBounds(turf.bbox(turf.multiPoint(corners)));
const dataBounds = turfBboxToBounds(bbox(multiPoint(corners)));

dispatch(setGotoWithBounds(scaleBounds(dataBounds, FIT_TO_BOUNDS_SCALE_FACTOR)));
};
Expand Down
10 changes: 5 additions & 5 deletions x-pack/plugins/maps/public/actions/map_actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
/* eslint-disable @typescript-eslint/consistent-type-definitions */

import { Dispatch } from 'redux';
// @ts-ignore
import turf from 'turf';
import uuid from 'uuid/v4';
import bboxPolygon from '@turf/bbox-polygon';
nreese marked this conversation as resolved.
Show resolved Hide resolved
import turfBooleanContains from '@turf/boolean-contains';
import uuid from 'uuid/v4';

import { Filter, Query, TimeRange } from 'src/plugins/data/public';
import { MapStoreState } from '../reducers/store';
import {
Expand Down Expand Up @@ -126,13 +126,13 @@ export function mapExtentChanged(newMapConstants: { zoom: number; extent: MapExt
if (extent) {
let doesBufferContainExtent = false;
if (buffer) {
const bufferGeometry = turf.bboxPolygon([
const bufferGeometry = bboxPolygon([
buffer.minLon,
buffer.minLat,
buffer.maxLon,
buffer.maxLat,
]);
const extentGeometry = turf.bboxPolygon([
const extentGeometry = bboxPolygon([
extent.minLon,
extent.minLat,
extent.maxLon,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

import React from 'react';
import uuid from 'uuid/v4';
import turf from 'turf';
import bbox from '@turf/bbox';
import { multiPoint } from '@turf/helpers';
nreese marked this conversation as resolved.
Show resolved Hide resolved

import { UpdateSourceEditor } from './update_source_editor';
import { i18n } from '@kbn/i18n';
Expand Down Expand Up @@ -216,7 +217,7 @@ export class ESPewPewSource extends AbstractESAggSource {
return null;
}

return turfBboxToBounds(turf.bbox(turf.multiPoint(corners)));
return turfBboxToBounds(bbox(multiPoint(corners)));
}

canFormatFeatureProperties() {
Expand Down
7 changes: 3 additions & 4 deletions x-pack/plugins/maps/public/classes/util/can_skip_fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
import _ from 'lodash';
// @ts-ignore
import turf from 'turf';
import bboxPolygon from '@turf/bbox-polygon';
nreese marked this conversation as resolved.
Show resolved Hide resolved
import turfBooleanContains from '@turf/boolean-contains';
import { isRefreshOnlyQuery } from './is_refresh_only_query';
import { ISource } from '../sources/source';
Expand All @@ -27,13 +26,13 @@ export function updateDueToExtent(prevMeta: DataMeta = {}, nextMeta: DataMeta =
return NO_SOURCE_UPDATE_REQUIRED;
}

const previousBufferGeometry = turf.bboxPolygon([
const previousBufferGeometry = bboxPolygon([
previousBuffer.minLon,
previousBuffer.minLat,
previousBuffer.maxLon,
previousBuffer.maxLat,
]);
const newBufferGeometry = turf.bboxPolygon([
const newBufferGeometry = bboxPolygon([
newBuffer.minLon,
newBuffer.minLat,
newBuffer.maxLon,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

// @ts-ignore
import turf from 'turf';
import turfBbox from '@turf/bbox';
import { FeatureCollection } from 'geojson';
import { MapExtent } from '../../../common/descriptor_types';
import { FEATURE_VISIBLE_PROPERTY_NAME } from '../../../common/constants';
Expand All @@ -28,7 +27,7 @@ export function getFeatureCollectionBounds(
return null;
}

const bbox = turf.bbox({
const bbox = turfBbox({
type: 'FeatureCollection',
features: visibleFeatures,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

/* eslint-disable @typescript-eslint/consistent-type-definitions */

// @ts-ignore
import turf from 'turf';
// @ts-ignore
// @ts-expect-error
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why, but these are the only modules without types so they needed ts-expect-error

import turfDistance from '@turf/distance';
// @ts-expect-error
import turfCircle from '@turf/circle';

type DrawCircleState = {
Expand Down Expand Up @@ -75,7 +75,7 @@ export const DrawCircle = {
// second click, finish draw
// @ts-ignore
this.updateUIClasses({ mouse: 'pointer' });
state.circle.properties.radiusKm = turf.distance(state.circle.properties.center, [
state.circle.properties.radiusKm = turfDistance(state.circle.properties.center, [
e.lngLat.lng,
e.lngLat.lat,
]);
Expand All @@ -90,7 +90,7 @@ export const DrawCircle = {
}

const mouseLocation = [e.lngLat.lng, e.lngLat.lat];
state.circle.properties.radiusKm = turf.distance(state.circle.properties.center, mouseLocation);
state.circle.properties.radiusKm = turfDistance(state.circle.properties.center, mouseLocation);
const newCircleFeature = turfCircle(
state.circle.properties.center,
state.circle.properties.radiusKm
Expand Down
Loading