Skip to content

Commit

Permalink
Merge branch 'master' into igr/duckdb-demo-branch
Browse files Browse the repository at this point in the history
  • Loading branch information
igorDykhta committed Feb 6, 2025
2 parents 9a38508 + f8fbf24 commit 24cbbed
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 18 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ Ref: http://keepachangelog.com/en/0.3.0/
- 1f9757b8 [feat] Pass in custom transformRequest function (#2534)
- b644f203 [Fix] layer popover mapIndex (#2535)
- 4b3c950f [fix] Fix sample maps (#2529)
- 55fb2426 [chore]] Update COC to OpenJS (#2496)
- 55fb2426 [chore] Update COC to OpenJS (#2496)
- 0959de6a [Feat]Support Zoom to layer in layer panel (#2516)
- ac0d3575 [Chore] docs: Add GeoArrow to supported formats (#2503)
- 084d807f [Chore] Bump path-parse from 1.0.6 to 1.0.7 (#1569)
Expand Down
2 changes: 1 addition & 1 deletion bindings/kepler.gl-jupyter/js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "keplergl-jupyter",
"version": "0.3.6",
"version": "0.3.7",
"description": "This is a simple jupyter widget for kepler.gl, an advanced geo-spatial visualization tool, to render large-scale interactive maps.",
"author": "Shan He",
"license": "MIT",
Expand Down
4 changes: 2 additions & 2 deletions bindings/kepler.gl-jupyter/keplergl/_version.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: MIT
# Copyright contributors to the kepler.gl project

version_info = (0, 3, 6, 'final', 0)
version_info = (0, 3, 7, 'final', 0)

_specifier_ = {'alpha': 'a', 'beta': 'b', 'candidate': 'rc', 'final': ''}

Expand All @@ -17,4 +17,4 @@
#
# The major version needs to match that of the JS package.
# Note: this follows the semver format, which is used to match the JS package version in keplergl-plugin.js
EXTENSION_SPEC_VERSION = '0.3.6'
EXTENSION_SPEC_VERSION = '0.3.7'
11 changes: 10 additions & 1 deletion bindings/kepler.gl-jupyter/keplergl/keplergl.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,16 @@ def _df_to_dict(df):
- dictionary: a dictionary variable that can be used in Kepler.gl
'''
return df.to_dict('split')
df_copy = df.copy()
# Convert all columns that aren't JSON serializable to strings
for col in df_copy.columns:
try:
# just check the first item in the colum
json.dumps(df_copy[col].iloc[0] if len(df_copy) > 0 else None)
except (TypeError, OverflowError):
df_copy[col] = df_copy[col].astype(str)

return df_copy.to_dict('split')


def _df_to_arrow(df: pd.DataFrame):
Expand Down
30 changes: 30 additions & 0 deletions examples/demo-app/esbuild.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,31 @@ const getThirdPartyLibraryAliases = useKeplerNodeModules => {
};
};

// Env variables required for demo app
const requiredEnvVariables = [
'MapboxAccessToken',
'DropboxClientId',
'MapboxExportToken',
'CartoClientId',
'FoursquareClientId',
'FoursquareDomain',
'FoursquareAPIURL',
'FoursquareUserMapsURL'
];

/**
* Check for all required env variables to be present
*/
const checkEnvVariables = () => {
const missingVars = requiredEnvVariables.filter(key => !process.env[key]);

if (missingVars.length > 0) {
console.warn(`⚠️ Warning: Missing environment variables: ${missingVars.join(', ')}`);
} else {
console.log('✅ All required environment variables are set.');
}
};

const NODE_ENV = JSON.stringify(process.env.NODE_ENV || 'production');
const config = {
platform: 'browser',
Expand Down Expand Up @@ -240,6 +265,9 @@ function openURL(url) {
.catch(e => {
console.error(e);
process.exit(1);
})
.then(() => {
checkEnvVariables();
});
}

Expand All @@ -258,6 +286,8 @@ function openURL(url) {
}
})
.then(async ctx => {
checkEnvVariables();

await ctx.watch();
await ctx.serve({
servedir: 'dist',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export default class FoursquareProvider extends Provider {
clientId,
scope: FOURSQUARE_AUTH_SCOPE,
authorizationParams: {
prompt: 'login',
redirect_uri: window.location.origin,
audience: FOURSQUARE_AUTH_AUDIENCE
},
Expand Down
2 changes: 1 addition & 1 deletion src/layers/src/base-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ class Layer implements KeplerLayer {
// key = 'lat'
const {pair, fieldPairKey} = this.columnPairs?.[key] || {};

if (typeof fieldPairKey === 'string' && !pair[fieldPairKey]) {
if (typeof fieldPairKey === 'string' && !fieldPairs[fieldPairKey]) {
// do not allow `key: undefined` to creep into the `updatedColumn` object
return this.config.columns;
}
Expand Down
2 changes: 2 additions & 0 deletions src/layers/src/geojson-layer/geojson-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,8 @@ export default class GeoJsonLayer extends Layer {
...columnConfig,
columnMode: COLUMN_MODE_TABLE
});
} else {
return this;
}
}

Expand Down
18 changes: 6 additions & 12 deletions src/layers/src/heatmap-layer/heatmap-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright contributors to the kepler.gl project

import {createSelector} from 'reselect';
import {CHANNEL_SCALES, SCALE_FUNC, ALL_FIELD_TYPES} from '@kepler.gl/constants';
import {CHANNEL_SCALES, ALL_FIELD_TYPES} from '@kepler.gl/constants';
import MapboxGLLayer, {MapboxLayerGLConfig} from '../mapboxgl-layer';
import HeatmapLayerIcon from './heatmap-layer-icon';
import {LayerBaseConfigPartial, LayerWeightConfig, VisualChannels} from '../base-layer';
Expand Down Expand Up @@ -110,20 +110,14 @@ const DEFAULT_COLUMN_MODE = COLUMN_MODE_POINTS;
* ]
*/
const heatmapDensity = (colorRange: ColorRange): (string | number)[] => {
const scaleFunction = SCALE_FUNC.quantize;

const colors: HexColor[] = ['#000000', ...colorRange.colors];

const scale = scaleFunction<HexColor>().domain([0, 1]).range(colors);
const colorDensity: (string | number)[] = [];
colors.forEach((color, index) => {
colorDensity.push(index / colors.length);
colorDensity.push(`rgb(${hexToRgb(color).join(',')})`);
});

const colorDensity = scale.range().reduce((bands: (string | number)[], level) => {
const invert = scale.invertExtent(level);
return [
...bands,
invert[0], // first value in the range
`rgb(${hexToRgb(level).join(',')})` // color
];
}, []);
colorDensity[1] = 'rgba(0,0,0,0)';
return colorDensity;
};
Expand Down
2 changes: 2 additions & 0 deletions src/layers/src/trip-layer/trip-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,8 @@ export default class TripLayer extends Layer {
...columnConfig,
columnMode: COLUMN_MODE_TABLE
});
} else {
return this;
}
}

Expand Down

0 comments on commit 24cbbed

Please sign in to comment.