Skip to content

Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.

[Bug] Fix multiple geojson layer found when properties contain object and array (#872)

Shan He84c886c2d5be
diff --git a/src/layers/geojson-layer/geojson-layer.js b/src/layers/geojson-layer/geojson-layer.js
index 9fdc0b775..dc5860884 100644
--- a/src/layers/geojson-layer/geojson-layer.js
+++ b/src/layers/geojson-layer/geojson-layer.js
@@ -20,6 +20,7 @@
import memoize from 'lodash.memoize';
import uniq from 'lodash.uniq';
+import {DATA_TYPES} from 'type-analyzer';
import Layer, {colorMaker} from '../base-layer';
import {GeoJsonLayer as DeckGLGeoJsonLayer} from 'deck.gl';
@@ -37,6 +38,12 @@ import {
CHANNEL_SCALES
} from 'constants/default-settings';
+const SUPPORTED_ANALYZER_TYPES = {
+ [DATA_TYPES.GEOMETRY]: true,
+ [DATA_TYPES.GEOMETRY_FROM_STRING]: true,
+ [DATA_TYPES.PAIR_GEOMETRY_FROM_STRING]: true
+};
+
export const geojsonVisConfigs = {
opacity: 'opacity',
thickness: {
@@ -138,7 +145,11 @@ export default class GeoJsonLayer extends Layer {
}
static findDefaultLayerProps({label, fields = []}) {
- const geojsonColumns = fields.filter(f => f.type === 'geojson').map(f => f.name);
+ const geojsonColumns = fields
+ .filter(
+ f => f.type === 'geojson' && SUPPORTED_ANALYZER_TYPES[f.analyzerType]
+ )
+ .map(f => f.name);
const defaultColumns = {
geojson: uniq([...GEOJSON_FIELDS.geojson, ...geojsonColumns])
@@ -152,7 +163,8 @@ export default class GeoJsonLayer extends Layer {
return {
props: foundColumns.map(columns => ({
label:
- (typeof label === 'string' && label.replace(/\.[^/.]+$/, '')) || this.type,
+ (typeof label === 'string' && label.replace(/\.[^/.]+$/, '')) ||
+ this.type,
columns,
isVisible: true
}))
@@ -240,7 +252,9 @@ export default class GeoJsonLayer extends Layer {
geojsonData = oldLayerData.data;
} else {
// filteredIndex is a reference of index in allData which can map to feature
- geojsonData = filteredIndex.map(i => this.dataToFeature[i]).filter(d => d);
+ geojsonData = filteredIndex
+ .map(i => this.dataToFeature[i])
+ .filter(d => d);
}
// fill color
@@ -274,7 +288,8 @@ export default class GeoJsonLayer extends Layer {
// point radius
const rScale =
- radiusField && this.getVisChannelScale(radiusScale, radiusDomain, radiusRange);
+ radiusField &&
+ this.getVisChannelScale(radiusScale, radiusDomain, radiusRange);
return {
data: geojsonData,
@@ -327,7 +342,6 @@ export default class GeoJsonLayer extends Layer {
/* eslint-enable complexity */
updateLayerMeta(allData) {
-
const getFeature = this.getPositionAccessor();
this.dataToFeature = getGeojsonDataMaps(allData, getFeature);
diff --git a/src/processors/data-processor.js b/src/processors/data-processor.js
index a00fdb519..273edd081 100644
--- a/src/processors/data-processor.js
+++ b/src/processors/data-processor.js
@@ -288,7 +288,8 @@ export function getFieldsFromData(data, fieldOrder) {
name,
format,
tableFieldIndex: index + 1,
- type: analyzerTypeToFieldType(type)
+ type: analyzerTypeToFieldType(type),
+ analyzerType: type
};
return orderedArray;
}, []);
@@ -567,6 +568,11 @@ export function validateInputData(data) {
return false;
}
+ if (!fields.every(field => field.analyzerType)) {
+ assert('field missing analyzerType');
+ return false;
+ }
+
// check time format is correct based on first 10 not empty element
if (f.type === ALL_FIELD_TYPES.timestamp) {
const sample = findNonEmptyRowsAtField(rows, i, 10)
@@ -593,7 +599,8 @@ export function validateInputData(data) {
const updatedFields = fields.map((f, i) => ({
...f,
type: meta[i].type,
- format: meta[i].format
+ format: meta[i].format,
+ analyzerType: meta[i].analyzerType
}));
return {fields: updatedFields, rows};
diff --git a/src/schemas/dataset-schema.js b/src/schemas/dataset-schema.js
index ad614dfea..7769d89d3 100644
--- a/src/schemas/dataset-schema.js
+++ b/src/schemas/dataset-schema.js
@@ -24,7 +24,6 @@ import {console as globalConsole} from 'global/window';
import {VERSIONS} from './versions';
import Schema from './schema';
import {getFieldsFromData, getSampleForTypeAnalyze} from 'processors/data-processor';
-import {ALL_FIELD_TYPES} from 'constants/default-settings';
// version v0
const fieldPropertiesV0 = {
@@ -35,7 +34,8 @@ const fieldPropertiesV0 = {
const fieldPropertiesV1 = {
name: null,
type: null,
- format: null
+ format: null,
+ analyzerType: null
};
class FieldSchema extends Schema {
@@ -82,7 +82,10 @@ class DatasetSchema extends Schema {
// recalculate field type
// because we have updated type-analyzer
// we need to add format to each field
- const needCalculateMeta = fields[0] && !fields[0].hasOwnProperty('format');
+ const needCalculateMeta = fields[0] && (
+ !fields[0].hasOwnProperty('format') ||
+ !fields[0].hasOwnProperty('analyzerType')
+ );
if (needCalculateMeta) {
const fieldOrder = fields.map(f => f.name);
@@ -90,18 +93,17 @@ class DatasetSchema extends Schema {
const sampleData = getSampleForTypeAnalyze({fields: fieldOrder, allData});
const meta = getFieldsFromData(sampleData, fieldOrder);
- updatedFields = fields.map((f, i) => ({
- ...f,
- // note here we add format to timestamp field
- format: f.type === ALL_FIELD_TYPES.timestamp ? meta[i].format : ''
+ updatedFields = meta.map((f, i) => ({
+ ...pick(meta[i], ['name', 'type', 'format']),
+ analyzerType: meta[i].analyzerType
}));
updatedFields.forEach((f, i) => {
- if (meta[i].type !== f.type) {
+ if (fields[i].type !== f.type) {
// if newly detected field type is different from saved type
// we log it but won't update it, cause we don't want to break people's map
globalConsole.warn(
- `detect ${f.name} type is now ${meta[i].type} instead of ${f.type}`
+ `detect ${f.name} type is now ${f.type} instead of ${fields[i].type}`
);
}
});
diff --git a/test/fixtures/geojson.js b/test/fixtures/geojson.js
index 5d5f1b39a..fc882e3c1 100644
--- a/test/fixtures/geojson.js
+++ b/test/fixtures/geojson.js
@@ -133,37 +133,43 @@ export const fields = [
type: 'geojson',
name: '_geojson',
format: '',
- tableFieldIndex: 1
+ tableFieldIndex: 1,
+ analyzerType: 'GEOMETRY'
},
{
type: 'integer',
name: 'OBJECTID',
format: '',
- tableFieldIndex: 2
+ tableFieldIndex: 2,
+ analyzerType: 'INT'
},
{
type: 'integer',
name: 'ZIP_CODE',
format: '',
- tableFieldIndex: 3
+ tableFieldIndex: 3,
+ analyzerType: 'INT'
},
{
type: 'integer',
name: 'ID',
format: '',
- tableFieldIndex: 4
+ tableFieldIndex: 4,
+ analyzerType: 'INT'
},
{
type: 'integer',
name: 'TRIPS',
format: '',
- tableFieldIndex: 5
+ tableFieldIndex: 5,
+ analyzerType: 'INT'
},
{
type: 'string',
name: 'RATE',
format: '',
- tableFieldIndex: 6
+ tableFieldIndex: 6,
+ analyzerType: 'STRING'
}
];
@@ -350,12 +356,12 @@ export const geoJsonWithStyle = {
// parsed fields and rows
export const geoStyleFields = [
- {name: '_geojson', format: '', tableFieldIndex: 1, type: 'geojson'},
- {name: 'fillColor', format: '', tableFieldIndex: 2, type: 'geojson'},
- {name: 'lineColor', format: '', tableFieldIndex: 3, type: 'geojson'},
- {name: 'lineWidth', format: '', tableFieldIndex: 4, type: 'integer'},
- {name: 'elevation', format: '', tableFieldIndex: 5, type: 'integer'},
- {name: 'radius', format: '', tableFieldIndex: 6, type: 'integer'}
+ {name: '_geojson', format: '', tableFieldIndex: 1, type: 'geojson', analyzerType: 'GEOMETRY'},
+ {name: 'fillColor', format: '', tableFieldIndex: 2, type: 'geojson', analyzerType: 'ARRAY'},
+ {name: 'lineColor', format: '', tableFieldIndex: 3, type: 'geojson', analyzerType: 'ARRAY'},
+ {name: 'lineWidth', format: '', tableFieldIndex: 4, type: 'integer', analyzerType: 'INT'},
+ {name: 'elevation', format: '', tableFieldIndex: 5, type: 'integer', analyzerType: 'INT'},
+ {name: 'radius', format: '', tableFieldIndex: 6, type: 'integer', analyzerType: 'INT'}
];
export const geoStyleRows = [
diff --git a/test/fixtures/state-saved-v0.js b/test/fixtures/state-saved-v0.js
index 2411c9bb6..7fc302069 100644
--- a/test/fixtures/state-saved-v0.js
+++ b/test/fixtures/state-saved-v0.js
@@ -804,57 +804,68 @@ export const expectedFields0 = [
{
name: 'song_name',
type: 'string',
- format: ''
+ format: '',
+ analyzerType: 'STRING'
},
{
name: 'begintrip_lat',
type: 'real',
- format: ''
+ format: '',
+ analyzerType: 'FLOAT'
},
{
name: 'begintrip_lng',
type: 'real',
- format: ''
+ format: '',
+ analyzerType: 'FLOAT'
},
{
name: 'timestamp_local',
type: 'timestamp',
- format: 'YYYY-M-DTHH:mm:ss.SSSS'
+ format: 'YYYY-M-DTHH:mm:ss.SSSS',
+ analyzerType: 'DATETIME'
},
{
name: 'counting',
type: 'real',
- format: ''
+ format: '',
+ analyzerType: 'FLOAT'
},
{
name: 'detail',
type: 'string',
- format: ''
+ format: '',
+ analyzerType: 'STRING'
},
{
name: 'dropoff_lat',
type: 'real',
- format: ''
+ format: '',
+ analyzerType: 'FLOAT'
},
{
name: 'dropoff_lng',
type: 'real',
- format: ''
+ format: '',
+ analyzerType: 'FLOAT'
},
{
name: 'dropoff_timestamp_local',
type: 'timestamp',
- format: 'YYYY-M-DTHH:mm:ss.SSSS'
+ format: 'YYYY-M-DTHH:mm:ss.SSSS',
+ analyzerType: 'DATETIME'
},
{
name: 'int_range',
type: 'integer',
- format: ''
+ format: '',
+ analyzerType: 'INT'
},
{
name: 'type_boolean',
type: 'boolean',
- format: ''
+ format: '',
+ analyzerType: 'BOOLEAN'
}
];
@@ -868,22 +879,26 @@ export const expectedFields1 = [
{
name: '_geojson',
type: 'geojson',
- format: ''
+ format: '',
+ analyzerType: 'GEOMETRY'
},
{
name: 'OBJECTID',
type: 'integer',
- format: ''
+ format: '',
+ analyzerType: 'INT'
},
{
name: 'ZIP_CODE',
type: 'integer',
- format: ''
+ format: '',
+ analyzerType: 'INT'
},
{
name: 'ID',
type: 'integer',
- format: ''
+ format: '',
+ analyzerType: 'INT'
}
];
@@ -1150,7 +1165,8 @@ mergedLayer2.config = {
type: 'string',
id: 'song_name',
format: '',
- tableFieldIndex: 1
+ tableFieldIndex: 1,
+ analyzerType: 'STRING'
},
colorScale: 'ordinal',
colorDomain: ['2.103.2', '2.107.3', '2.116.2', '2.117.1', '3.68.4'],
@@ -1162,7 +1178,8 @@ mergedLayer2.config = {
format: '',
id: 'int_range',
type: 'integer',
- tableFieldIndex: 10
+ tableFieldIndex: 10,
+ analyzerType: 'INT'
},
sizeDomain: [78, 694],
sizeScale: 'linear',
@@ -1226,7 +1243,8 @@ mergedLayer3.config = {
id: 'int_range',
type: 'integer',
format: '',
- tableFieldIndex: 10
+ tableFieldIndex: 10,
+ analyzerType: 'INT'
},
highlightColor: [252, 242, 26, 255],
isConfigActive: false,
@@ -1286,7 +1304,8 @@ mergedLayer4.config = {
id: 'ID',
type: 'integer',
format: '',
- tableFieldIndex: 4
+ tableFieldIndex: 4,
+ analyzerType: 'INT'
},
colorScale: 'quantize',
colorDomain: [94107, 94132],
diff --git a/test/fixtures/state-saved-v1-1.js b/test/fixtures/state-saved-v1-1.js
index 8e5f9b1ce..933141ecd 100644
--- a/test/fixtures/state-saved-v1-1.js
+++ b/test/fixtures/state-saved-v1-1.js
@@ -19,7 +19,6 @@
// THE SOFTWARE.
import GeojsonLayer from 'layers/geojson-layer/geojson-layer';
-import {Messages, Crosshairs} from 'components/common/icons';
import {DEFAULT_TEXT_LABEL, DEFAULT_COLOR_UI} from 'layers/layer-factory';
import {getDefaultInteraction} from 'utils/interaction-utils';
@@ -817,22 +816,22 @@ export const v0ExpectedInfo = {
};
export const v0ExpectedFields = [
- {name: 'a_zip', type: 'integer', format: ''},
- {name: 'simplified_shape_v2', type: 'geojson', format: ''},
- {name: 'simplified_shape', type: 'geojson', format: ''},
- {name: 'zip_area', type: 'real', format: ''},
- {name: 'avg_number', type: 'real', format: ''},
- {name: 'str_type', type: 'string', format: ''},
- {name: 'int_type', type: 'integer', format: ''},
- {name: 'real_type', type: 'real', format: ''},
- {name: 'c_m_r', type: 'integer', format: ''},
- {name: 'c_m_t', type: 'real', format: ''},
- {name: 'c_a_v', type: 'real', format: ''},
- {name: 'c_ch', type: 'real', format: ''},
- {name: 'c_ta', type: 'real', format: ''},
- {name: 'c_k_a', type: 'real', format: ''},
- {name: 'c_ltv', type: 'real', format: ''},
- {name: 'b_r_p', type: 'real', format: ''}
+ {name: 'a_zip', type: 'integer', format: '', analyzerType: 'INT'},
+ {name: 'simplified_shape_v2', type: 'geojson', format: '', analyzerType: 'PAIR_GEOMETRY_FROM_STRING'},
+ {name: 'simplified_shape', type: 'geojson', format: '', analyzerType: 'GEOMETRY_FROM_STRING'},
+ {name: 'zip_area', type: 'real', format: '', analyzerType: 'FLOAT'},
+ {name: 'avg_number', type: 'real', format: '', analyzerType: 'FLOAT'},
+ {name: 'str_type', type: 'string', format: '', analyzerType: 'STRING'},
+ {name: 'int_type', type: 'integer', format: '', analyzerType: 'INT'},
+ {name: 'real_type', type: 'real', format: '', analyzerType: 'FLOAT'},
+ {name: 'c_m_r', type: 'integer', format: '', analyzerType: 'INT'},
+ {name: 'c_m_t', type: 'real', format: '', analyzerType: 'FLOAT'},
+ {name: 'c_a_v', type: 'real', format: '', analyzerType: 'FLOAT'},
+ {name: 'c_ch', type: 'real', format: '', analyzerType: 'FLOAT'},
+ {name: 'c_ta', type: 'real', format: '', analyzerType: 'FLOAT'},
+ {name: 'c_k_a', type: 'real', format: '', analyzerType: 'FLOAT'},
+ {name: 'c_ltv', type: 'real', format: '', analyzerType: 'FLOAT'},
+ {name: 'b_r_p', type: 'real', format: '', analyzerType: 'FLOAT'}
];
export const mergedFilters = [
@@ -882,7 +881,8 @@ mergedLayer0.config = {
type: 'integer',
id: 'c_m_r',
format: '',
- tableFieldIndex: 9
+ tableFieldIndex: 9,
+ analyzerType: 'INT'
},
colorScale: 'quantize',
colorDomain: [45, 9642],
@@ -891,7 +891,8 @@ mergedLayer0.config = {
type: 'integer',
id: 'c_m_r',
format: '',
- tableFieldIndex: 9
+ tableFieldIndex: 9,
+ analyzerType: 'INT'
},
strokeColorScale: 'quantize',
strokeColorDomain: [45, 9642],
@@ -904,7 +905,8 @@ mergedLayer0.config = {
type: 'real',
id: 'c_a_v',
format: '',
- tableFieldIndex: 11
+ tableFieldIndex: 11,
+ analyzerType: 'FLOAT'
},
heightScale: 'linear',
heightDomain: [211.9244058, 858.5168842],
@@ -2703,7 +2705,8 @@ mergedLayer1.config = {
id: 'c_ta',
type: 'real',
format: '',
- tableFieldIndex: 13
+ tableFieldIndex: 13,
+ analyzerType: 'FLOAT'
},
sizeScale: 'linear',
sizeDomain: [0.970877074, 1],
diff --git a/test/fixtures/state-saved-v1-2.js b/test/fixtures/state-saved-v1-2.js
index 37948e0df..f6fba0227 100644
--- a/test/fixtures/state-saved-v1-2.js
+++ b/test/fixtures/state-saved-v1-2.js
@@ -5037,18 +5037,18 @@ export const v1expectedInfo_2 = {
};
export const v1expectedFields_2 = [
- {name: 'uuid', type: 'string', format: ''},
- {name: 'lat', type: 'real', format: ''},
- {name: 'lng', type: 'real', format: ''},
- {name: 'Latitude', type: 'real', format: ''},
- {name: 'Longitude', type: 'real', format: ''},
- {name: 'at_Latitude', type: 'real', format: ''},
- {name: 'at_Longitude', type: 'real', format: ''},
- {name: 'metric', type: 'real', format: ''},
- {name: 'epoch', type: 'timestamp', format: 'x'},
- {name: 'epoch_ms', type: 'timestamp', format: 'X'},
- {name: 'meta_data', type: 'real', format: ''},
- {name: 'start_ts', type: 'timestamp', format: 'x'},
- {name: 'end_ts', type: 'timestamp', format: 'x'},
- {name: 'time string', type: 'timestamp', format: 'YYYY/M/D H:m'}
+ {name: 'uuid', type: 'string', format: '', analyzerType: 'STRING'},
+ {name: 'lat', type: 'real', format: '', analyzerType: 'FLOAT'},
+ {name: 'lng', type: 'real', format: '', analyzerType: 'FLOAT'},
+ {name: 'Latitude', type: 'real', format: '', analyzerType: 'FLOAT'},
+ {name: 'Longitude', type: 'real', format: '', analyzerType: 'FLOAT'},
+ {name: 'at_Latitude', type: 'real', format: '', analyzerType: 'FLOAT'},
+ {name: 'at_Longitude', type: 'real', format: '', analyzerType: 'FLOAT'},
+ {name: 'metric', type: 'real', format: '', analyzerType: 'NUMBER'},
+ {name: 'epoch', type: 'timestamp', format: 'x', analyzerType: 'TIME'},
+ {name: 'epoch_ms', type: 'timestamp', format: 'X', analyzerType: 'TIME'},
+ {name: 'meta_data', type: 'integer', format: '', analyzerType: 'INT'},
+ {name: 'start_ts', type: 'timestamp', format: 'x', analyzerType: 'TIME'},
+ {name: 'end_ts', type: 'timestamp', format: 'x', analyzerType: 'TIME'},
+ {name: 'time string', type: 'timestamp', format: 'YYYY/M/D H:m', analyzerType: 'DATETIME'}
];
diff --git a/test/fixtures/state-saved-v1-3.js b/test/fixtures/state-saved-v1-3.js
index fd9705b3f..07dd92b0e 100644
--- a/test/fixtures/state-saved-v1-3.js
+++ b/test/fixtures/state-saved-v1-3.js
@@ -380,7 +380,8 @@ mergedLayer0.config = {
type: 'integer',
id: 'deliver_radius',
format: '',
- tableFieldIndex: 1
+ tableFieldIndex: 1,
+ analyzerType: 'INT'
},
colorDomain: [1000, 1000, 2000, 2000, 2000, 3000, 3000, 3000, 3000],
highlightColor: [252, 242, 26, 255],
@@ -394,7 +395,8 @@ mergedLayer0.config = {
type: 'integer',
id: 'deliver_radius',
format: '',
- tableFieldIndex: 1
+ tableFieldIndex: 1,
+ analyzerType: 'INT'
},
sizeScale: 'sqrt',
sizeDomain: [1000, 3000],
diff --git a/test/fixtures/state-saved-v1-4.js b/test/fixtures/state-saved-v1-4.js
index 52634566f..8d64b5b0a 100644
--- a/test/fixtures/state-saved-v1-4.js
+++ b/test/fixtures/state-saved-v1-4.js
@@ -238,7 +238,8 @@ mergedLayer0.config = {
type: 'string',
format: '',
id: 'name',
- tableFieldIndex: 8
+ tableFieldIndex: 8,
+ analyzerType: 'STRING'
},
color: [184, 15, 135, 255],
size: 27,
diff --git a/test/fixtures/test-csv-data.js b/test/fixtures/test-csv-data.js
index 22a01108e..dfdc77061 100644
--- a/test/fixtures/test-csv-data.js
+++ b/test/fixtures/test-csv-data.js
@@ -465,67 +465,78 @@ export const testFields = [
type: 'timestamp',
name: 'gps_data.utc_timestamp',
format: 'YYYY-M-D H:m:s',
- tableFieldIndex: 1
+ tableFieldIndex: 1,
+ analyzerType: 'DATETIME'
},
{
type: 'real',
name: 'gps_data.lat',
format: '',
- tableFieldIndex: 2
+ tableFieldIndex: 2,
+ analyzerType: 'FLOAT'
},
{
type: 'real',
name: 'gps_data.lng',
format: '',
- tableFieldIndex: 3
+ tableFieldIndex: 3,
+ analyzerType: 'FLOAT'
},
{
type: 'string',
name: 'gps_data.types',
format: '',
- tableFieldIndex: 4
+ tableFieldIndex: 4,
+ analyzerType: 'STRING'
},
{
type: 'timestamp',
name: 'epoch',
format: 'X',
- tableFieldIndex: 5
+ tableFieldIndex: 5,
+ analyzerType: 'TIME'
},
{
type: 'boolean',
name: 'has_result',
format: '',
- tableFieldIndex: 6
+ tableFieldIndex: 6,
+ analyzerType: 'BOOLEAN'
},
{
type: 'integer',
name: 'id',
format: '',
- tableFieldIndex: 7
+ tableFieldIndex: 7,
+ analyzerType: 'INT'
},
{
type: 'timestamp',
name: 'time',
format: 'YYYY-M-DTHH:mm:ss.SSSS',
- tableFieldIndex: 8
+ tableFieldIndex: 8,
+ analyzerType: 'DATETIME'
},
{
type: 'timestamp',
name: 'begintrip_ts_utc',
format: 'YYYY-M-D HH:mm:ssZZ',
- tableFieldIndex: 9
+ tableFieldIndex: 9,
+ analyzerType: 'DATETIME'
},
{
type: 'timestamp',
name: 'begintrip_ts_local',
format: 'YYYY-M-D HH:mm:ssZZ',
- tableFieldIndex: 10
+ tableFieldIndex: 10,
+ analyzerType: 'DATETIME'
},
{
type: 'date',
name: 'date',
format: 'YYYY-M-D',
- tableFieldIndex: 11
+ tableFieldIndex: 11,
+ analyzerType: 'DATE'
}
];
@@ -534,37 +545,43 @@ export const wktCsvFields = [
type: 'integer',
name: 'a_zip',
format: '',
- tableFieldIndex: 1
+ tableFieldIndex: 1,
+ analyzerType: 'INT'
},
{
type: 'geojson',
name: 'simplified_shape_v2',
format: '',
- tableFieldIndex: 2
+ tableFieldIndex: 2,
+ analyzerType: 'PAIR_GEOMETRY_FROM_STRING'
},
{
type: 'geojson',
name: 'simplified_shape',
format: '',
- tableFieldIndex: 3
+ tableFieldIndex: 3,
+ analyzerType: 'GEOMETRY_FROM_STRING'
},
{
type: 'real',
name: 'm_rate',
format: '',
- tableFieldIndex: 4
+ tableFieldIndex: 4,
+ analyzerType: 'FLOAT'
},
{
type: 'string',
name: 'c_zip_type',
format: '',
- tableFieldIndex: 5
+ tableFieldIndex: 5,
+ analyzerType: 'STRING'
},
{
type: 'real',
name: 'c_number',
format: '',
- tableFieldIndex: 6
+ tableFieldIndex: 6,
+ analyzerType: 'FLOAT'
}
];
diff --git a/test/fixtures/test-hex-id-data.js b/test/fixtures/test-hex-id-data.js
index 2776d4eeb..889a2810e 100644
--- a/test/fixtures/test-hex-id-data.js
+++ b/test/fixtures/test-hex-id-data.js
@@ -363,7 +363,8 @@ const fields = [
format: '',
tableFieldIndex: 1,
type: 'string',
- id: 'hex_id'
+ id: 'hex_id',
+ analyzerType: 'STRING'
},
{
name: 'value',
@@ -371,6 +372,7 @@ const fields = [
tableFieldIndex: 2,
type: 'integer',
id: 'value',
+ analyzerType: 'INT',
filterProps: {
domain: [1, 76],
step: 0.1,
diff --git a/test/node/reducers/vis-state-test.js b/test/node/reducers/vis-state-test.js
index c876c84ad..cf2e930f6 100644
--- a/test/node/reducers/vis-state-test.js
+++ b/test/node/reducers/vis-state-test.js
@@ -108,25 +108,33 @@ const expectedFields = [
name: 'start_point_lat',
id: 'start_point_lat',
type: 'real',
- tableFieldIndex: 1
+ tableFieldIndex: 1,
+ analyzerType: 'FLOAT',
+ format: ''
},
{
name: 'start_point_lng',
id: 'start_point_lng',
type: 'real',
- tableFieldIndex: 2
+ tableFieldIndex: 2,
+ analyzerType: 'FLOAT',
+ format: ''
},
{
name: 'end_point_lat',
id: 'end_point_lat',
type: 'real',
- tableFieldIndex: 3
+ tableFieldIndex: 3,
+ analyzerType: 'FLOAT',
+ format: ''
},
{
name: 'end_point_lng',
id: 'end_point_lng',
type: 'real',
- tableFieldIndex: 4
+ tableFieldIndex: 4,
+ analyzerType: 'FLOAT',
+ format: ''
}
];
@@ -2622,7 +2630,8 @@ test('#visStateReducer -> SET_FILTER_PLOT', t => {
name: 'id',
id: 'id',
format: '',
- tableFieldIndex: 7
+ tableFieldIndex: 7,
+ analyzerType: 'INT'
},
interval: null,
lineChart: {
diff --git a/test/node/utils/data-processor-test.js b/test/node/utils/data-processor-test.js
index ff3029749..f234241cf 100644
--- a/test/node/utils/data-processor-test.js
+++ b/test/node/utils/data-processor-test.js
@@ -155,10 +155,10 @@ test('Processor -> processCsvData: duplicated field name', t => {
const expectedResult = {
fields: [
- {name: 'column1', format: '', tableFieldIndex: 1, type: 'string'},
- {name: 'column1-0', format: '', tableFieldIndex: 2, type: 'string'},
- {name: 'column1-1', format: '', tableFieldIndex: 3, type: 'string'},
- {name: 'column2', format: '', tableFieldIndex: 4, type: 'string'}
+ {name: 'column1', format: '', tableFieldIndex: 1, type: 'string', analyzerType: 'STRING'},
+ {name: 'column1-0', format: '', tableFieldIndex: 2, type: 'string', analyzerType: 'STRING'},
+ {name: 'column1-1', format: '', tableFieldIndex: 3, type: 'string', analyzerType: 'STRING'},
+ {name: 'column2', format: '', tableFieldIndex: 4, type: 'string', analyzerType: 'STRING'}
],
rows: [['a', 'b', 'c', 'd'], ['c', 'd', 'e', 'f']]
};
@@ -252,10 +252,10 @@ test('Processor => processGeojson: parse rows', t => {
};
const expectedFields = [
- {name: '_geojson', format: '', tableFieldIndex: 1, type: 'geojson'},
- {name: 'TRIPS', format: '', tableFieldIndex: 2, type: 'integer'},
- {name: 'RATE', format: '', tableFieldIndex: 3, type: 'string'},
- {name: 'TIME', format: 'x', tableFieldIndex: 4, type: 'timestamp'}
+ {name: '_geojson', format: '', tableFieldIndex: 1, type: 'geojson', analyzerType: 'GEOMETRY'},
+ {name: 'TRIPS', format: '', tableFieldIndex: 2, type: 'integer', analyzerType: 'INT'},
+ {name: 'RATE', format: '', tableFieldIndex: 3, type: 'string', analyzerType: 'STRING'},
+ {name: 'TIME', format: 'x', tableFieldIndex: 4, type: 'timestamp', analyzerType: 'TIME'}
];
const expectedRows = [
@@ -464,7 +464,7 @@ test('Processor -> validateInputData', t => {
},
expected: {
rows: [[1], [2], [3]],
- fields: [{type: ALL_FIELD_TYPES.integer, format: '', name: 'column_0'}]
+ fields: [{type: ALL_FIELD_TYPES.integer, format: '', name: 'column_0', analyzerType: 'INT'}]
},
msg: 'should re generate field if not an object'
},
@@ -475,7 +475,7 @@ test('Processor -> validateInputData', t => {
},
expected: {
rows: [[1], [2], [3]],
- fields: [{type: ALL_FIELD_TYPES.integer, format: '', name: 'column_0'}]
+ fields: [{type: ALL_FIELD_TYPES.integer, format: '', name: 'column_0', analyzerType: 'INT'}]
},
msg: 'should reassign field name'
},
@@ -486,7 +486,9 @@ test('Processor -> validateInputData', t => {
},
expected: {
rows: [[1], [2], [3]],
- fields: [{type: ALL_FIELD_TYPES.integer, format: '', name: 'taro'}]
+ fields: [{
+ type: ALL_FIELD_TYPES.integer, format: '', name: 'taro', analyzerType: 'INT'
+ }]
},
msg: 'should reassign field type'
},
@@ -509,7 +511,8 @@ test('Processor -> validateInputData', t => {
{
type: ALL_FIELD_TYPES.timestamp,
format: 'YYYY-M-D H:m',
- name: 'taro'
+ name: 'taro',
+ analyzerType: 'DATETIME'
}
]
},
@@ -544,25 +547,29 @@ test('Processor -> processRowObject', t => {
name: 'a',
type: 'integer',
format: '',
- tableFieldIndex: 1
+ tableFieldIndex: 1,
+ analyzerType: 'INT'
},
{
name: 'b',
type: 'string',
format: '',
- tableFieldIndex: 2
+ tableFieldIndex: 2,
+ analyzerType: 'STRING'
},
{
name: 'c',
type: 'boolean',
format: '',
- tableFieldIndex: 3
+ tableFieldIndex: 3,
+ analyzerType: 'BOOLEAN'
},
{
name: 'd',
type: 'real',
format: '',
- tableFieldIndex: 4
+ tableFieldIndex: 4,
+ analyzerType: 'FLOAT'
}
]
},
diff --git a/test/node/utils/layer-utils-test.js b/test/node/utils/layer-utils-test.js
index f101cd516..4f7e13f7a 100644
--- a/test/node/utils/layer-utils-test.js
+++ b/test/node/utils/layer-utils-test.js
@@ -32,6 +32,7 @@ import {wktCsv} from 'test/fixtures/test-csv-data';
import {cmpLayers} from 'test/helpers/comparison-utils';
import {getNextColorMakerValue} from 'test/helpers/layer-utils';
import tripGeojson, {timeStampDomain, tripBounds} from 'test/fixtures/trip-geojson';
+import {geoJsonWithStyle} from 'test/fixtures/geojson';
test('layerUtils -> findDefaultLayer.1', t => {
const inputFields = [
@@ -592,6 +593,7 @@ test('layerUtils -> findDefaultLayer:GeojsonLayer', t => {
test('layerUtils -> findDefaultLayer:GeojsonLayer.wkt', t => {
const {fields, rows} = processCsvData(wktCsv);
+
const dataId = '0dj3h';
const label = 'some geometry file';
@@ -637,6 +639,25 @@ test('layerUtils -> findDefaultLayer:GeojsonLayer.wkt', t => {
t.end();
});
+test('layerUtils -> findDefaultLayer:GeojsonWithStyle', t => {
+ const {fields, rows} = processGeojson(geoJsonWithStyle);
+
+ const geojsonLayers = findDefaultLayer(
+ {
+ fields,
+ id: 'test',
+ dataId: 'taro',
+ label: 'chubby prince',
+ fieldPairs: [],
+ allData: rows
+ },
+ KeplerGlLayers
+ );
+
+ t.equal(geojsonLayers.length, 1, 'should find 1 layer');
+ t.end();
+});
+
test('layerUtils -> findDefaultLayer:IconLayer', t => {
const inputFields = [
{