-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
[Chore]: Technical: Translate geojson-layer #1757
Changes from 6 commits
31dc997
2c4cc4c
9235b65
cf9edad
deb7409
e5e4d4a
6634a18
46440a8
6f7deb4
11ceeca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,12 +21,22 @@ | |
import uniq from 'lodash.uniq'; | ||
import {DATA_TYPES} from 'type-analyzer'; | ||
|
||
import Layer, {colorMaker} from '../base-layer'; | ||
import Layer, {colorMaker, LayerBaseConfig, LayerColumn} from '../base-layer'; | ||
import {GeoJsonLayer as DeckGLGeoJsonLayer} from '@deck.gl/layers'; | ||
import {getGeojsonDataMaps, getGeojsonBounds, getGeojsonFeatureTypes} from './geojson-utils'; | ||
import GeojsonLayerIcon from './geojson-layer-icon'; | ||
import {GEOJSON_FIELDS, HIGHLIGH_COLOR_3D, CHANNEL_SCALES} from 'constants/default-settings'; | ||
import {LAYER_VIS_CONFIGS} from 'layers/layer-factory'; | ||
import {GEOJSON_FIELDS, HIGHLIGH_COLOR_3D, CHANNEL_SCALES} from '../../constants/default-settings'; | ||
import { | ||
LAYER_VIS_CONFIGS, | ||
VisConfigNumber, | ||
VisConfigColorSelect, | ||
VisConfigColorRange, | ||
VisConfigRange, | ||
VisConfigBoolean | ||
} from '../layer-factory'; | ||
import {DataContainerInterface} from '../../utils/table-utils/data-container-interface'; | ||
import {Merge, RGBColor} from '../../reducers'; | ||
import {ColorRange} from '../../constants/color-ranges'; | ||
|
||
const SUPPORTED_ANALYZER_TYPES = { | ||
[DATA_TYPES.GEOMETRY]: true, | ||
|
@@ -60,15 +70,70 @@ export const geojsonVisConfigs = { | |
wireframe: 'wireframe' | ||
}; | ||
|
||
export const geoJsonRequiredColumns = ['geojson']; | ||
export const featureAccessor = ({geojson}) => dc => d => dc.valueAt(d.index, geojson.fieldIdx); | ||
export type GeoJsonVisConfigSettings = { | ||
opacity: VisConfigNumber; | ||
strokeOpacity: VisConfigNumber; | ||
thickness: VisConfigNumber; | ||
strokeColor: VisConfigColorSelect; | ||
colorRange: VisConfigColorRange; | ||
strokeColorRange: VisConfigColorRange; | ||
radius: VisConfigNumber; | ||
|
||
sizeRange: VisConfigRange; | ||
radiusRange: VisConfigRange; | ||
heightRange: VisConfigRange; | ||
elevationScale: VisConfigNumber; | ||
enableElevationZoomFactor: VisConfigBoolean; | ||
stroked: VisConfigBoolean; | ||
filled: VisConfigBoolean; | ||
enable3d: VisConfigBoolean; | ||
wireframe: VisConfigBoolean; | ||
}; | ||
|
||
export type GeoJsonLayerColumnsConfig = { | ||
geojson: LayerColumn; | ||
}; | ||
|
||
export type GeoJsonLayerVisConfig = { | ||
opacity: number; | ||
strokeOpacity: number; | ||
thickness: number; | ||
strokeColor: RGBColor; | ||
colorRange: ColorRange; | ||
strokeColorRange: ColorRange; | ||
radius: number; | ||
|
||
sizeRange: [number, number]; | ||
radiusRange: [number, number]; | ||
heightRange: [number, number]; | ||
elevationScale: number; | ||
enableElevationZoomFactor: boolean; | ||
stroked: boolean; | ||
filled: boolean; | ||
enable3d: boolean; | ||
wireframe: boolean; | ||
}; | ||
|
||
export type GeoJsonLayerConfig = Merge< | ||
LayerBaseConfig, | ||
{columns: GeoJsonLayerColumnsConfig; visConfig: GeoJsonLayerVisConfig} | ||
>; | ||
|
||
export const geoJsonRequiredColumns: ['geojson'] = ['geojson']; | ||
export const featureAccessor = ({geojson}: GeoJsonLayerColumnsConfig) => ( | ||
dc: DataContainerInterface | ||
) => d => dc.valueAt(d.index, geojson.fieldIdx); | ||
|
||
// access feature properties from geojson sub layer | ||
export const defaultElevation = 500; | ||
export const defaultLineWidth = 1; | ||
export const defaultRadius = 1; | ||
|
||
export default class GeoJsonLayer extends Layer { | ||
declare config: GeoJsonLayerConfig; | ||
declare visConfigSettings: GeoJsonVisConfigSettings; | ||
dataToFeature: {properties?: {radius?: number}}[]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
constructor(props) { | ||
super(props); | ||
|
||
|
@@ -78,10 +143,13 @@ export default class GeoJsonLayer extends Layer { | |
} | ||
|
||
get type() { | ||
return GeoJsonLayer.type; | ||
} | ||
static get type(): 'geojson' { | ||
return 'geojson'; | ||
} | ||
|
||
get name() { | ||
get name(): 'Polygon' { | ||
return 'Polygon'; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ import wktParser from 'wellknown'; | |
import normalize from '@mapbox/geojson-normalize'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please types below to type the functions in this file import {KeplerTable} from '../../utils';
import {Feature, BBox} from 'geojson';
import {LayerColumns} from '../index';
type GetFeature = (d: any) => Feature;
type GeojsonDataMaps = Array<Feature | null>;
export enum FeatureTypes {
Point = 'Point',
MultiPoint = 'MultiPoint',
LineString = 'LineString',
MultiLineString = 'MultiLineString',
Polygon = 'Polygon',
MultiPolygon = 'MultiPolygon'
}
type FeatureTypeMap = {
[key in FeatureTypes]: boolean;
};
export function parseGeoJsonRawFeature(rawFeature: unknown): Feature | null;
export function getGeojsonDataMaps(
allData: KeplerTable['allData'],
getFeature: GetFeature
): GeojsonDataMaps;
export function getGeojsonBounds(features: Feature[]): BBox | null;
export function getGeojsonFeatureTypes(allFeatures: Feature[]): FeatureTypeMap;
export function parseGeometryFromString(geoString: string): Feature | null; There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. KeplerTable does not contain property allData |
||
import bbox from '@turf/bbox'; | ||
|
||
import {getSampleData} from 'utils/data-utils'; | ||
import {getSampleData} from '../../utils/data-utils'; | ||
|
||
export function parseGeoJsonRawFeature(rawFeature) { | ||
if (typeof rawFeature === 'object') { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is meant by LayerRadiusConfig?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can add this to base-layer