Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.
// SPDX-License-Identifier: MIT
// Copyright contributors to the kepler.gl project
export const mockPolygonFeature = {
type: 'Feature',
geometry: {
type: 'Polygon',
coordinates: [
[
[28.66601562502387, 15.343585399424173],
[28.66601562502387, 11.109477534559822],
[32.75292968752382, 11.109477534559822],
[32.75292968752382, 15.343585399424173],
[28.66601562502387, 15.343585399424173]
]
]
},
properties: {
renderType: 'Polygon',
isClosed: true,
bbox: {
xmin: 28.094726562479867,
xmax: null,
ymin: 10.872211827249156,
ymax: null
}
},
id: 'bf5be428-f522-4a52-8ea5-3e90e86aad51'
};
export const mockPolygonData = {
fields: [
{
name: 'start_point_lat',
type: 'real'
},
{
name: 'start_point_lng',
type: 'real'
},
{
name: 'end_point_lat',
type: 'real'
},
{
name: 'end_point_lng',
type: 'real'
}
],
data: [
[12.25, 30.5, 45.5, 32.5],
[12.25, 35.5, 45.5, 36.5],
[14.25, 30.5, 47.5, 32.5],
[14.25, 35.5, 47.5, 36.5]
],
layers: [
{
id: 'm1buc6o',
type: 'point',
config: {
dataId: 'puppy',
label: 'start point',
color: [227, 26, 26],
columns: {
lat: 'start_point_lat',
lng: 'start_point_lng',
altitude: null
},
isVisible: true,
visConfig: {
radius: 10,
fixedRadius: false,
opacity: 0.8,
outline: false,
thickness: 2,
strokeColor: null,
colorRange: {
name: 'Global Warming',
type: 'sequential',
category: 'Uber',
colors: ['#5A1846', '#900C3F', '#C70039', '#E3611C', '#F1920E', '#FFC300']
},
strokeColorRange: {
name: 'Global Warming',
type: 'sequential',
category: 'Uber',
colors: ['#5A1846', '#900C3F', '#C70039', '#E3611C', '#F1920E', '#FFC300']
},
radiusRange: [0, 50],
filled: true
},
textLabel: [
{
field: null,
color: [255, 255, 255],
size: 18,
offset: [0, 0],
anchor: 'start',
alignment: 'center'
}
]
},
visualChannels: {
colorField: null,
colorScale: 'quantile',
strokeColorField: null,
strokeColorScale: 'quantile',
sizeField: null,
sizeScale: 'linear'
}
},
{
id: 'jcotm1p',
type: 'point',
config: {
dataId: 'puppy',
label: 'end point',
color: [255, 203, 153],
columns: {
lat: 'end_point_lat',
lng: 'end_point_lng',
altitude: null
},
isVisible: true,
visConfig: {
radius: 10,
fixedRadius: false,
opacity: 0.8,
outline: false,
thickness: 2,
strokeColor: null,
colorRange: {
name: 'Global Warming',
type: 'sequential',
category: 'Uber',
colors: ['#5A1846', '#900C3F', '#C70039', '#E3611C', '#F1920E', '#FFC300']
},
strokeColorRange: {
name: 'Global Warming',
type: 'sequential',
category: 'Uber',
colors: ['#5A1846', '#900C3F', '#C70039', '#E3611C', '#F1920E', '#FFC300']
},
radiusRange: [0, 50],
filled: true
},
textLabel: [
{
field: null,
color: [255, 255, 255],
size: 18,
offset: [0, 0],
anchor: 'start',
alignment: 'center'
}
]
},
visualChannels: {
colorField: null,
colorScale: 'quantile',
strokeColorField: null,
strokeColorScale: 'quantile',
sizeField: null,
sizeScale: 'linear'
}
}
],
interactionConfig: {
tooltip: {
fieldsToShow: {
zgi2h4mkn: []
},
enabled: true
},
brush: {
size: 0.5,
enabled: false
}
}
};
/**
* Closed rectangular polygon in GeoJSON [lng, lat] order.
*/
export function rectPolygonFeature(id, west, south, east, north) {
return {
type: 'Feature',
geometry: {
type: 'Polygon',
coordinates: [
[
[west, south],
[east, south],
[east, north],
[west, north],
[west, south]
]
]
},
properties: {
renderType: 'Polygon',
isClosed: true
},
id
};
}
/**
* One dataset with two lon/lat pairs (start + end).
* start (lng, lat): (10,10), (12,10), (14,10), (12,14)
* end (lng, lat): (30,10), (32,10), (34,10), (32,14)
* Row format: [start_lat, start_lng, end_lat, end_lng]
*/
export const mockDualLonLatRows = [
[10, 10, 10, 30],
[10, 12, 10, 32],
[10, 14, 10, 34],
[14, 12, 14, 32]
];
// Covers start rows 0 and 1; none of the end points
export const mockStartRegionPolygon = rectPolygonFeature('start-region-poly', 9, 9, 13, 11);
// Covers end rows 1 and 2; none of the start points
export const mockEndRegionPolygon = rectPolygonFeature('end-region-poly', 31, 9, 35, 11);
// Overlaps mockStartRegionPolygon on start row 1 only
export const mockEastOverlapPolygon = rectPolygonFeature('east-overlap-poly', 11, 9, 15, 11);
// Disjoint from mockWestOnlyPolygon: start row 0 vs start row 2
export const mockWestOnlyPolygon = rectPolygonFeature('west-only-poly', 9, 9, 11, 11);
export const mockEastOnlyPolygon = rectPolygonFeature('east-only-poly', 13, 9, 15, 11);
export const mockPolygonFeature2 = {
type: 'Feature',
geometry: {
type: 'Polygon',
coordinates: [
[
[-122.447837, 37.768506],
[-122.402435, 37.798517],
[-122.379596, 37.776771],
[-122.400234, 37.755671],
[-122.447837, 37.768506]
]
]
},
properties: {},
id: '5afe6042-b0f7-4249-8a59-5911901912ad'
};