Skip to content

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

3.0 KB
Raw Blame
// SPDX-License-Identifier: MIT
// Copyright contributors to the kepler.gl project

/* different option share same query type e.g. events,
and segments both use queryRunner */
import keyMirror from 'keymirror';

/** Compile-time CDN for the "Try sample data" tab thumbnail only (`icon-demo-map.jpg`). */
export const ASSETS_URL = 'https://d1a3f4spazzrp4.cloudfront.net/kepler.gl/';
/** Compile-time host of the default `samples.json` catalogue (not a URL prefix for sample rows). */
export const DATA_URL = 'https://raw.githubusercontent.com/keplergl/kepler.gl-data/master/';
export const MAP_URI = 'demo/map?mapUrl=';

/** Override via `config.json` `mapConfigUrl` (see runtime-config.js). */
let mapConfigUrlOverride = null;

/**
 * Sample gallery catalogue URL. Cache-busted by default; `mapConfigUrl` replaces the
 * catalogue only. Rows in that JSON must use absolute `dataUrl` / `configUrl` /
 * `imageUrl` (the app does not prefix {@link DATA_URL}).
 * @returns {string}
 */
export function getMapConfigUrl() {
  if (mapConfigUrlOverride) {
    return mapConfigUrlOverride;
  }
  return `${DATA_URL}samples.json?nocache=${new Date().getTime()}`;
}

/**
 * @param {string} url
 */
export function setMapConfigUrl(url) {
  mapConfigUrlOverride = url;
}

/**
 * I know this is already defined in Kepler core but it should be defined here
 * because it belongs to the demo app
 * @type {string}
 */
export const KEPLER_GL_WEBSITE = 'http://kepler.gl/';

export const QUERY_TYPES = keyMirror({
  file: null,
  sample: null
});

export const QUERY_OPTIONS = keyMirror({
  csv: null,
  geojson: null
});

export const LOADING_METHODS = keyMirror({
  remote: null,
  sample: null
});

export const LOADING_SAMPLE_LIST_ERROR_MESSAGE = 'Not able to load sample gallery';
export const LOADING_SAMPLE_ERROR_MESSAGE = 'Not able to load sample';
export const CORS_LINK = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS';

export const DEFAULT_FEATURE_FLAGS = {
  cloudStorage: true
};

/**
 * Public OAuth Web client ID for the Kepler.gl demo Google Drive provider.
 * Safe to ship in the client bundle (same as DropboxClientId). Override via
 * GoogleDriveClientId env for local/Netlify if needed.
 */
export const DEFAULT_GOOGLE_DRIVE_CLIENT_ID =
  '955797395662-m2aetl68gd71shdgtsmbbj2pvuk1psgc.apps.googleusercontent.com';

export const CLOUD_PROVIDERS_CONFIGURATION = {
  MAPBOX_TOKEN: process.env.MapboxAccessToken, // eslint-disable-line
  DROPBOX_CLIENT_ID: process.env.DropboxClientId, // eslint-disable-line
  EXPORT_MAPBOX_TOKEN: process.env.MapboxExportToken, // eslint-disable-line
  CARTO_CLIENT_ID: process.env.CartoClientId, // eslint-disable-line
  FOURSQUARE_CLIENT_ID: process.env.FoursquareClientId, // eslint-disable-line
  FOURSQUARE_DOMAIN: process.env.FoursquareDomain, // eslint-disable-line
  FOURSQUARE_API_URL: process.env.FoursquareAPIURL, // eslint-disable-line
  FOURSQUARE_USER_MAPS_URL: process.env.FoursquareUserMapsURL, // eslint-disable-line
  GOOGLE_DRIVE_CLIENT_ID: process.env.GoogleDriveClientId || DEFAULT_GOOGLE_DRIVE_CLIENT_ID // eslint-disable-line
};