Skip to content

Commit

Permalink
[Chore]: Technical: Translate s2-geometry-layer (#1765)
Browse files Browse the repository at this point in the history
* Renamed js files

Signed-off-by: Maksim Suslov <maksim.suslov@actionengine.com>

* Added types

Signed-off-by: Maksim Suslov <maksim.suslov@actionengine.com>

* Declared required types

Signed-off-by: Maksim Suslov <maksim.suslov@actionengine.com>

* Applied suggested changes

Signed-off-by: Maksim Suslov <maksim.suslov@actionengine.com>
  • Loading branch information
HeimEndyd committed Apr 5, 2022
1 parent 1834292 commit 0b3f2c0
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 7 deletions.
6 changes: 5 additions & 1 deletion src/layers/base-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,11 @@ export type LayerHeightConfig = {
heightDomain: VisualChannelDomain;
heightScale: VisualChannelScale;
};

export type LayerStrokeColorConfig = {
strokeColorField: VisualChannelField;
strokeColorDomain: VisualChannelDomain;
strokeColorScale: VisualChannelScale;
};
export type LayerWeightConfig = {
weightField: VisualChannelField;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,85 @@ import {S2Layer} from '@deck.gl/geo-layers';
import {HIGHLIGH_COLOR_3D, CHANNEL_SCALES} from 'constants/default-settings';
import {LAYER_VIS_CONFIGS} from 'layers/layer-factory';
import {createDataContainer} from 'utils/table-utils';
import Layer from '../base-layer';
import {ColorRange} from '../../constants/color-ranges';
import {Merge, RGBColor} from '../../reducers';
import {DataContainerInterface} from '../../utils/table-utils/data-container-interface';
import Layer, {
LayerBaseConfig,
LayerColorConfig,
LayerColumn,
LayerSizeConfig,
LayerStrokeColorConfig,
LayerHeightConfig
} from '../base-layer';
import {
VisConfigBoolean,
VisConfigColorRange,
VisConfigColorSelect,
VisConfigNumber,
VisConfigRange
} from '../layer-factory';
import S2LayerIcon from './s2-layer-icon';
import {getS2Center} from './s2-utils';

export type S2GeometryLayerVisConfigSettings = {
opacity: VisConfigNumber;
colorRange: VisConfigColorRange;
filled: VisConfigBoolean;
thickness: VisConfigNumber;
strokeColor: VisConfigColorSelect;
strokeColorRange: VisConfigColorRange;
sizeRange: VisConfigRange;
stroked: VisConfigBoolean;
enable3d: VisConfigBoolean;
elevationScale: VisConfigNumber;
enableElevationZoomFactor: VisConfigBoolean;
heightRange: VisConfigRange;
wireframe: VisConfigBoolean;
};

export type S2GeometryLayerColumnsConfig = {
token: LayerColumn;
};

export type S2GeometryLayerVisConfig = {
opacity: number;
colorRange: ColorRange;
filled: boolean;
thickness: number;
strokeColor: RGBColor;
strokeColorRange: ColorRange;
sizeRange: [number, number];
stroked: boolean;
enable3d: boolean;
elevationScale: number;
enableElevationZoomFactor: boolean;
heightRange: [number, number];
wireframe: boolean;
};

export type S2GeometryLayerVisualChannelConfig = LayerColorConfig &
LayerSizeConfig &
LayerStrokeColorConfig &
LayerHeightConfig;
export type S2GeometryLayerConfig = Merge<
LayerBaseConfig,
{columns: S2GeometryLayerColumnsConfig; visConfig: S2GeometryLayerVisConfig}
> &
S2GeometryLayerVisualChannelConfig;

const zoomFactorValue = 8;

export const S2_TOKEN_FIELDS = {
export const S2_TOKEN_FIELDS: {
token: ['s2', 's2_token'];
} = {
token: ['s2', 's2_token']
};

export const s2RequiredColumns = ['token'];
export const S2TokenAccessor = ({token}) => dc => d => dc.valueAt(d.index, token.fieldIdx);
export const s2RequiredColumns: ['token'] = ['token'];
export const S2TokenAccessor = ({token}: S2GeometryLayerColumnsConfig) => (
dc: DataContainerInterface
) => d => dc.valueAt(d.index, token.fieldIdx);

export const defaultElevation = 500;
export const defaultLineWidth = 1;
Expand Down Expand Up @@ -70,17 +137,20 @@ export const S2VisConfigs = {
};

export default class S2GeometryLayer extends Layer {
dataToFeature: any;
declare visConfigSettings: S2GeometryLayerVisConfigSettings;
declare config: S2GeometryLayerConfig;
constructor(props) {
super(props);
this.registerVisConfig(S2VisConfigs);
this.getPositionAccessor = dataContainer => S2TokenAccessor(this.config.columns)(dataContainer);
}

get type() {
get type(): 's2' {
return 's2';
}

get name() {
get name(): 'S2' {
return 'S2';
}

Expand Down
File renamed without changes.

0 comments on commit 0b3f2c0

Please sign in to comment.