Skip to content

Commit

Permalink
fix table for geoarrow
Browse files Browse the repository at this point in the history
  • Loading branch information
lixun910 committed Oct 18, 2023
1 parent 4e42ad7 commit 9604569
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 14 deletions.
1 change: 0 additions & 1 deletion src/components/src/map-container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,6 @@ export default function MapContainerFactory(
// TODO this should be part of onLayerHover arguments, investigate
// @ts-ignore (does not fail with local yarn-test)
data.mapIndex = index;
console.log(data);
this.props.visStateActions.onLayerHover(data);
}, DEBOUNCE_MOUSE_MOVE_PROPAGATE);

Expand Down
15 changes: 15 additions & 0 deletions src/constants/src/default-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,10 @@ export const FIELD_TYPE_DISPLAY = {
label: 'geo',
color: BLUE2
},
[ALL_FIELD_TYPES.geoarrow]: {
label: 'geo',
color: BLUE2
},
[ALL_FIELD_TYPES.integer]: {
label: 'int',
color: YELLOW
Expand Down Expand Up @@ -746,6 +750,17 @@ export const FIELD_OPTS = {
tooltip: []
}
},
[ALL_FIELD_TYPES.geoarrow]: {
type: 'geometry',
scale: {
...notSupportedScaleOpts,
...notSupportAggrOpts
},
format: {
legend: d => '...',
tooltip: []
}
},
[ALL_FIELD_TYPES.object]: {
type: 'numerical',
scale: {},
Expand Down
19 changes: 7 additions & 12 deletions src/layers/src/arrow-layer/arrow-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,8 @@ import {
getBinaryGeometriesFromGeoArrowPolygon,
parseGeometryFromArrow
} from '@kepler.gl/utils';
import {Merge} from '@kepler.gl/types';

import {LayerColumn, LayerBaseConfig} from '../base-layer';
import GeoJsonLayer, {
SUPPORTED_ANALYZER_TYPES,
GeoJsonLayerVisConfig,
GeoJsonLayerVisualChannelConfig
} from '../geojson-layer/geojson-layer';
import GeoJsonLayer, {SUPPORTED_ANALYZER_TYPES} from '../geojson-layer/geojson-layer';

export default class ArrowLayer extends GeoJsonLayer {
binaryFeatures: BinaryFeatures[];
Expand Down Expand Up @@ -113,7 +107,6 @@ export default class ArrowLayer extends GeoJsonLayer {
// the objectInfo.layer id should be `${this.id}-${i}`
if (objectInfo?.picked) {
const deckLayerId = objectInfo?.layer?.props?.id;
console.log(deckLayerId);
return deckLayerId.startsWith(this.id);
}
return false;
Expand All @@ -122,16 +115,19 @@ export default class ArrowLayer extends GeoJsonLayer {
hasHoveredObject(objectInfo) {
// hover object returns the index of the object in the data array
if (this.isLayerHovered(objectInfo) && objectInfo.index >= 0 && this.dataContainer) {
console.time('getHoverData');
const {geojson} = this.config.columns;
const col = this.dataContainer.getColumn(geojson.fieldIdx);
const rawGeometry = col.get(objectInfo.index);
const hoveredFeature = parseGeometryFromArrow({
encoding: col.metadata?.get('ARROW:extension:name'),
data: rawGeometry
});
console.timeEnd('getHoverData');
return hoveredFeature;
return {
...hoveredFeature,
properties: {
index: objectInfo.index
}
};
}
return null;
}
Expand Down Expand Up @@ -174,7 +170,6 @@ export default class ArrowLayer extends GeoJsonLayer {

const pickable = interactionConfig.tooltip.enabled;
const hoveredObject = this.hasHoveredObject(objectHovered);
console.log(hoveredObject);

const deckLayers = data.data.map((d, i) => {
return new DeckGLGeoJsonLayer({
Expand Down
4 changes: 3 additions & 1 deletion src/layers/src/geojson-layer/geojson-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ export const defaultElevation = 500;
export const defaultLineWidth = 1;
export const defaultRadius = 1;

const defaultThresholdOfBigDataSet = 500000;

export default class GeoJsonLayer extends Layer {
declare config: GeoJsonLayerConfig;
declare visConfigSettings: GeoJsonVisConfigSettings;
Expand Down Expand Up @@ -387,7 +389,7 @@ export default class GeoJsonLayer extends Layer {
// set both fill and stroke to true
return this.updateLayerVisConfig({
filled: true,
stroked: false,
stroked: dataContainer.numRows() < defaultThresholdOfBigDataSet,
strokeColor: colorMaker.next().value
});
} else if (featureTypes && featureTypes.point) {
Expand Down
1 change: 1 addition & 0 deletions src/reducers/src/interaction-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ function autoFindTooltipFields(fields, maxDefaultTooltips) {
.split(' ')
.every(seg => !ptFields.includes(seg)) &&
type !== ALL_FIELD_TYPES.geojson &&
type !== ALL_FIELD_TYPES.geoarrow &&
type !== 'object'
);

Expand Down
1 change: 1 addition & 0 deletions src/utils/src/data-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ export const FIELD_DISPLAY_FORMAT: {
: Array.isArray(d)
? `[${String(d)}]`
: '',
[ALL_FIELD_TYPES.geoarrow]: d => d,
[ALL_FIELD_TYPES.object]: JSON.stringify,
[ALL_FIELD_TYPES.array]: JSON.stringify
};
Expand Down

0 comments on commit 9604569

Please sign in to comment.