_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q22000 | getTableColumnStyle | train | function getTableColumnStyle(tableColumn, tableStyle) {
var tableColumnStyle;
if (defined(tableColumn) && defined(tableStyle.columns)) {
if (defined(tableStyle.columns[tableColumn.id])) {
tableColumnStyle = clone(tableStyle.columns[tableColumn.id]);
} else {
// Also support column indices as key... | javascript | {
"resource": ""
} |
q22001 | getFractionalValue | train | function getFractionalValue(legendHelper, value) {
var extremes = getExtremes(
legendHelper.tableColumn,
legendHelper.tableColumnStyle
);
var f =
extremes.maximum === extremes.minimum
? 0
: (value - extremes.minimum) / (extremes.maximum - extremes.minimum);
if (legendHelper.tableColumnSt... | javascript | {
"resource": ""
} |
q22002 | RegionDataValue | train | function RegionDataValue(
regionCodes,
columnHeadings,
table,
singleSelectValues
) {
this.regionCodes = regionCodes;
this.columnHeadings = columnHeadings;
this.table = table;
this.singleSelectValues = singleSelectValues;
} | javascript | {
"resource": ""
} |
q22003 | loadTableFromCsv | train | function loadTableFromCsv(item, csvString) {
var tableStyle = item._tableStyle;
var options = {
idColumnNames: item.idColumns,
isSampled: item.isSampled,
initialTimeSource: item.initialTimeSource,
displayDuration: tableStyle.displayDuration,
replaceWithNullValues: tableStyle.replaceWithNullValue... | javascript | {
"resource": ""
} |
q22004 | train | function(options) {
if (!defined(options) || !defined(options.regionProvider)) {
throw new DeveloperError("options.regionProvider is required.");
}
FunctionParameter.call(this, options);
this._regionProvider = options.regionProvider;
this.singleSelect = defaultValue(options.singleSelect, false);
knoc... | javascript | {
"resource": ""
} | |
q22005 | recolorBillboard | train | function recolorBillboard(img, color) {
var canvas = document.createElement("canvas");
canvas.width = img.width;
canvas.height = img.height;
// Copy the image contents to the canvas
var context = canvas.getContext("2d");
context.drawImage(img, 0, 0);
var image = context.getImageData(0, 0, canvas.width, c... | javascript | {
"resource": ""
} |
q22006 | printWindow | train | function printWindow(windowToPrint) {
const deferred = when.defer();
let printInProgressCount = 0;
const timeout = setTimeout(function() {
deferred.reject(
new TerriaError({
title: "Error printing",
message:
"Printing did not start within 10 seconds. Maybe this web browser doe... | javascript | {
"resource": ""
} |
q22007 | train | function(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
TableColumnStyle.call(this, options);
/**
* The name of the variable (column) to be used for region mapping.
* @type {String}
*/
this.regionVariable = options.regionVariable;
/**
* The identifier of a region type, a... | javascript | {
"resource": ""
} | |
q22008 | prefilterAddresses | train | function prefilterAddresses(addressList) {
var addressesPlusInd = { skipIndices: [], nullAddresses: 0, addresses: [] };
for (var i = 0; i < addressList.length; i++) {
var address = addressList[i];
if (address === null) {
addressesPlusInd.skipIndices.push(i);
addressesPlusInd.nullAddresses++;
... | javascript | {
"resource": ""
} |
q22009 | train | function(
terria,
tableStructure,
tableStyle,
name,
isUpdating
) {
this._guid = createGuid(); // Used internally to give features a globally unique id.
this._name = name;
this._isUpdating = isUpdating || false;
this._hasFeaturePerRow = undefined; // If this changes, need to remove old features.
this... | javascript | {
"resource": ""
} | |
q22010 | hostInDomains | train | function hostInDomains(host, domains) {
if (!defined(domains)) {
return false;
}
host = host.toLowerCase();
for (var i = 0; i < domains.length; i++) {
if (host.match("(^|\\.)" + domains[i] + "$")) {
return true;
}
}
return false;
} | javascript | {
"resource": ""
} |
q22011 | train | function(clock) {
this.clock = clock;
this._layerStack = [];
knockout.track(this, ["_layerStack"]);
/**
* The highest time-series layer, or undefined if there are no time series layers.
*/
knockout.defineProperty(this, "topLayer", {
get: function() {
if (this._layerStack.length) {
r... | javascript | {
"resource": ""
} | |
q22012 | triggerResize | train | function triggerResize() {
try {
window.dispatchEvent(new Event("resize"));
} catch (e) {
var evt = window.document.createEvent("UIEvents");
evt.initUIEvent("resize", true, false, window, 0);
window.dispatchEvent(evt);
}
} | javascript | {
"resource": ""
} |
q22013 | objectToLowercase | train | function objectToLowercase(obj) {
var result = {};
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
result[key.toLowerCase()] = obj[key];
}
}
return result;
} | javascript | {
"resource": ""
} |
q22014 | combineFilters | train | function combineFilters(filters) {
var allFilters, returnFn;
allFilters = filters
.filter(function(filter) {
return defined(filter);
})
.reduce(function(filtersSoFar, thisFilter) {
if (thisFilter._filterIndex) {
// If a filter is an instance of this function just pull that filter's ... | javascript | {
"resource": ""
} |
q22015 | propertyGetTimeValues | train | function propertyGetTimeValues(properties, currentTime) {
// properties itself may be a time-varying "property" with a getValue function.
// If not, check each of its properties for a getValue function; if it exists, use it to get the current value.
if (!defined(properties)) {
return;
}
var result = {};
... | javascript | {
"resource": ""
} |
q22016 | gmlToGeoJson | train | function gmlToGeoJson(xml) {
if (typeof xml === "string") {
var parser = new DOMParser();
xml = parser.parseFromString(xml, "text/xml");
}
var result = [];
var featureCollection = xml.documentElement;
var featureMembers = featureCollection.getElementsByTagNameNS(
gmlNamespace,
"featureMembe... | javascript | {
"resource": ""
} |
q22017 | gml2coord | train | function gml2coord(posList) {
var pnts = posList.split(/[ ,]+/).filter(isNotEmpty);
var coords = [];
for (var i = 0; i < pnts.length; i += 2) {
coords.push([parseFloat(pnts[i + 1]), parseFloat(pnts[i])]);
}
return coords;
} | javascript | {
"resource": ""
} |
q22018 | train | function(terria) {
if (!defined(terria)) {
throw new DeveloperError("terria is required");
}
this._terria = terria;
this._shareKeyIndex = {};
this._group = new CatalogGroup(terria);
this._group.name = "Root Group";
this._group.preserveOrder = true;
/**
* Gets or sets a flag indicating whether ... | javascript | {
"resource": ""
} | |
q22019 | train | function(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
/**
* All data values less than or equal to this are considered equal for the purpose of display.
* @type {Float}
*/
this.minDisplayValue = options.minDisplayValue;
/**
* Minimum y value to display in charts; if not sp... | javascript | {
"resource": ""
} | |
q22020 | train | function(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
Concept.call(this, options.name || options.id);
/**
* Gets or sets the name of the concept item. This property is observable.
* @type {String}
*/
this.id = options.id;
/**
* Gets the list of absCodes contained in t... | javascript | {
"resource": ""
} | |
q22021 | buildConceptTree | train | function buildConceptTree(parent, filter, concept, codes) {
// Use natural sort for fields with included ages or incomes.
codes.sort(function(a, b) {
return naturalSort(
a.description.replace(",", ""),
b.description.replace(",", "")
);
});
var anyActive = false;
for (var i = 0; i < codes.l... | javascript | {
"resource": ""
} |
q22022 | loadConceptIdsAndConceptNameMap | train | function loadConceptIdsAndConceptNameMap(item) {
if (!defined(item._loadConceptIdsAndNameMapPromise)) {
var parameters = {
method: "GetDatasetConcepts",
datasetid: item.datasetId,
format: "json"
};
var datasetConceptsUrl = item._baseUrl + "?" + objectToQuery(parameters);
var loadData... | javascript | {
"resource": ""
} |
q22023 | loadConcepts | train | function loadConcepts(item) {
if (!defined(item._loadConceptsPromise)) {
var absConcepts = [];
var promises = item._conceptIds
.filter(function(conceptId) {
return item.conceptsNotToLoad.indexOf(conceptId) === -1;
})
.map(function(conceptId) {
var parameters = {
met... | javascript | {
"resource": ""
} |
q22024 | getHumanReadableConceptName | train | function getHumanReadableConceptName(conceptNameMap, concept) {
if (!defined(conceptNameMap[concept.name])) {
return concept.name; // Default to the name given in the file.
}
if (typeof conceptNameMap[concept.name] === "string") {
return conceptNameMap[concept.name];
} else {
var codeMap = conceptNa... | javascript | {
"resource": ""
} |
q22025 | getActiveRegionTypeCode | train | function getActiveRegionTypeCode(item) {
// We always put the region first, and at most one is active.
var activeRegions = item._concepts[0].activeItems;
if (activeRegions.length === 1) {
return activeRegions[0].code;
}
} | javascript | {
"resource": ""
} |
q22026 | loadDataFiles | train | function loadDataFiles(item) {
// An array of arrays, indexed by activeItemsPerConcept[conceptIndex][codeIndex].
var activeCodesPerConcept = item._concepts.map(function(concept) {
return concept.activeItems;
});
// If any one of the concepts has no active selection, there will be no files to load.
for (v... | javascript | {
"resource": ""
} |
q22027 | buildValueColumns | train | function buildValueColumns(item, tableStructures, activeCombinations) {
// The tableStructures are from the raw data files, one per activeCombinations.
return tableStructures.map(function(tableStructure, index) {
var columnNames = tableStructure.getColumnNames();
// Check that the data is not blank, and tha... | javascript | {
"resource": ""
} |
q22028 | train | function(name, options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
DisplayVariablesConcept.call(this, name, {
getColorCallback: options.getColorCallback,
requireSomeActive: defaultValue(options.requireSomeActive, false)
});
this.displayVariableTypes = defaultValue(
options.displa... | javascript | {
"resource": ""
} | |
q22029 | castToScalar | train | function castToScalar(value, state) {
if (state.rowNum === 1) {
// Don't cast column names
return value;
} else {
var hasDot = /\./;
var leadingZero = /^0[0-9]/;
var numberWithThousands = /^[1-9]\d?\d?(,\d\d\d)+(\.\d+)?$/;
if (numberWithThousands.test(value)) {
value ... | javascript | {
"resource": ""
} |
q22030 | finishFromIndex | train | function finishFromIndex(timeColumn, index) {
if (!defined(timeColumn.displayDuration)) {
return timeColumn.finishJulianDates[index];
} else {
return JulianDate.addMinutes(
timeColumn.julianDates[index],
timeColumn.displayDuration,
endScratch
);
}
} | javascript | {
"resource": ""
} |
q22031 | calculateAvailability | train | function calculateAvailability(timeColumn, index, endTime) {
var startJulianDate = timeColumn.julianDates[index];
if (defined(startJulianDate)) {
var finishJulianDate = finishFromIndex(timeColumn, index);
return new TimeInterval({
start: timeColumn.julianDates[index],
stop: finishJulianDate,
... | javascript | {
"resource": ""
} |
q22032 | calculateTimeIntervals | train | function calculateTimeIntervals(timeColumn) {
// First we find the last time for all of the data (this is an optomisation for the calculateAvailability operation.
const endTime = timeColumn.values.reduce(function(latest, value, index) {
const current = finishFromIndex(timeColumn, index);
if (
!defined... | javascript | {
"resource": ""
} |
q22033 | createClock | train | function createClock(timeColumn, tableStructure) {
var availabilityCollection = new TimeIntervalCollection();
timeColumn._timeIntervals
.filter(function(availability) {
return defined(availability && availability.start);
})
.forEach(function(availability) {
availabilityCollection.addInterval... | javascript | {
"resource": ""
} |
q22034 | getIndexOfColumn | train | function getIndexOfColumn(tableStructure, column) {
for (var i = 0; i < tableStructure.columns.length; i++) {
if (tableStructure.columns[i] === column) {
return i;
}
}
} | javascript | {
"resource": ""
} |
q22035 | getColumnWithNameOrId | train | function getColumnWithNameOrId(nameOrId, columns) {
for (var i = 0; i < columns.length; i++) {
if (columns[i].name === nameOrId || columns[i].id === nameOrId) {
return columns[i];
}
}
} | javascript | {
"resource": ""
} |
q22036 | getIdColumns | train | function getIdColumns(idColumnNames, columns) {
if (!defined(idColumnNames)) {
return [];
}
return idColumnNames.map(name => getColumnWithNameIdOrIndex(name, columns));
} | javascript | {
"resource": ""
} |
q22037 | getIdMapping | train | function getIdMapping(idColumnNames, columns) {
var idColumns = getIdColumns(idColumnNames, columns);
if (idColumns.length === 0) {
return {};
}
return idColumns[0].values.reduce(function(result, value, rowNumber) {
var idString = getIdStringForRowNumber(idColumns, rowNumber);
if (!defined(result[id... | javascript | {
"resource": ""
} |
q22038 | getSortedColumns | train | function getSortedColumns(tableStructure, sortColumn, compareFunction) {
// With help from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
var mappedArray = sortColumn.julianDatesOrValues.map(function(value, i) {
return { index: i, value: value };
});
if (!defined... | javascript | {
"resource": ""
} |
q22039 | getColumnOptions | train | function getColumnOptions(name, tableStructure, columnNumber) {
var columnOptions = defaultValue.EMPTY_OBJECT;
if (defined(tableStructure.columnOptions)) {
columnOptions = defaultValue(
tableStructure.columnOptions[name],
defaultValue(
tableStructure.columnOptions[columnNumber],
defa... | javascript | {
"resource": ""
} |
q22040 | areColumnsEqualLength | train | function areColumnsEqualLength(columns) {
if (columns.length <= 1) {
return true;
}
var firstLength = columns[0].values.length;
var columnsWithTheSameLength = columns.slice(1).filter(function(column) {
return column.values.length === firstLength;
});
return columnsWithTheSameLength.length === column... | javascript | {
"resource": ""
} |
q22041 | train | function(name, options) {
const that = this;
name = defaultValue(name, "Display Variable");
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
VariableConcept.call(this, name, options);
/**
* Gets or sets a flag for whether more than one checkbox can be selected at a time.
* Default false.
... | javascript | {
"resource": ""
} | |
q22042 | getNestedNodes | train | function getNestedNodes(concept, condition) {
if (condition(concept)) {
return concept;
}
if (!concept.items) {
return [];
}
return concept.items.map(child => getNestedNodes(child, condition));
} | javascript | {
"resource": ""
} |
q22043 | train | function(options) {
if (!defined(options) || !defined(options.regionProvider)) {
throw new DeveloperError("options.regionProvider is required.");
}
FunctionParameter.call(this, options);
this._regionProvider = options.regionProvider;
} | javascript | {
"resource": ""
} | |
q22044 | setClockCurrentTime | train | function setClockCurrentTime(clock, initialTimeSource, stopTime) {
if (!defined(clock)) {
return;
}
// This is our default. Start at the nearest instant in time.
var now = JulianDate.now();
_setTimeIfInRange(clock, now, stopTime);
initialTimeSource = defaultValue(initialTimeSource, "present");
switc... | javascript | {
"resource": ""
} |
q22045 | stripDuplicates | train | function stripDuplicates(results) {
var i;
var placeshash = {};
var stripped = [];
for (i = 0; i < results.length; i++) {
var lat = Number(results[i].location.split(",")[0]).toFixed(1);
var lng = Number(results[i].location.split(",")[1]).toFixed(1);
var hash = results[i].name + "_" + lat + " " + ln... | javascript | {
"resource": ""
} |
q22046 | train | function(options) {
SearchProviderViewModel.call(this);
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
this.terria = options.terria;
var url = defaultValue(
options.url,
this.terria.configParameters.gnafSearchUrl
);
this.name = NAME;
this.gnafApi = defaultValue(
options.gnafApi... | javascript | {
"resource": ""
} | |
q22047 | getShareData | train | function getShareData(terria) {
const initSources = terria.initSources.slice();
addUserAddedCatalog(terria, initSources);
addSharedMembers(terria, initSources);
addViewSettings(terria, initSources);
addFeaturePicking(terria, initSources);
addLocationMarker(terria, initSources);
return {
version: "0.... | javascript | {
"resource": ""
} |
q22048 | addUserAddedCatalog | train | function addUserAddedCatalog(terria, initSources) {
const localDataFilterRemembering = rememberRejections(
CatalogMember.itemFilters.noLocalData
);
const userAddedCatalog = terria.catalog.serializeToJson({
itemFilter: combineFilters([
localDataFilterRemembering.filter,
CatalogMember.itemFilte... | javascript | {
"resource": ""
} |
q22049 | addSharedMembers | train | function addSharedMembers(terria, initSources) {
const catalogForSharing = flattenCatalog(
terria.catalog.serializeToJson({
itemFilter: combineFilters([CatalogMember.itemFilters.noLocalData]),
propertyFilter: combineFilters([
CatalogMember.propertyFilters.sharedOnly,
function(property)... | javascript | {
"resource": ""
} |
q22050 | addViewSettings | train | function addViewSettings(terria, initSources) {
const cameraExtent = terria.currentViewer.getCurrentExtent();
// Add an init source with the camera position.
const initialCamera = {
west: CesiumMath.toDegrees(cameraExtent.west),
south: CesiumMath.toDegrees(cameraExtent.south),
east: CesiumMath.toDegr... | javascript | {
"resource": ""
} |
q22051 | addFeaturePicking | train | function addFeaturePicking(terria, initSources) {
if (
defined(terria.pickedFeatures) &&
terria.pickedFeatures.features.length > 0
) {
const positionInRadians = Ellipsoid.WGS84.cartesianToCartographic(
terria.pickedFeatures.pickPosition
);
const pickedFeatures = {
providerCoords: te... | javascript | {
"resource": ""
} |
q22052 | addLocationMarker | train | function addLocationMarker(terria, initSources) {
if (defined(terria.locationMarker)) {
const position = terria.locationMarker.entities.values[0].position.getValue();
const positionDegrees = Ellipsoid.WGS84.cartesianToCartographic(position);
initSources.push({
locationMarker: {
name: terria... | javascript | {
"resource": ""
} |
q22053 | rememberRejections | train | function rememberRejections(filterFn) {
const rejections = [];
return {
filter: function(item) {
const allowed = filterFn(item);
if (!allowed) {
rejections.push(item);
}
return allowed;
},
rejections: rejections
};
} | javascript | {
"resource": ""
} |
q22054 | getAncestors | train | function getAncestors(member) {
var parent = member.parent;
var ancestors = [];
while (defined(parent) && defined(parent.parent)) {
ancestors = [parent].concat(ancestors);
parent = parent.parent;
}
return ancestors;
} | javascript | {
"resource": ""
} |
q22055 | getBetterFileName | train | function getBetterFileName(dataUrlType, itemName, format) {
let name = itemName;
const extension = "." + format;
// Only add the extension if it's not already there.
if (name.indexOf(extension) !== name.length - extension.length) {
name = name + extension;
}
// For local files, the file already exists o... | javascript | {
"resource": ""
} |
q22056 | applyReplacements | train | function applyReplacements(regionProvider, s, replacementsProp) {
if (!defined(s)) {
return undefined;
}
var r;
if (typeof s === "number") {
r = String(s);
} else {
r = s.toLowerCase().trim();
}
var replacements = regionProvider[replacementsProp];
if (replacements === undefined || replacemen... | javascript | {
"resource": ""
} |
q22057 | findRegionIndex | train | function findRegionIndex(regionProvider, code, disambigCode) {
if (!defined(code) || code === "") {
// Note a code of 0 is ok
return -1;
}
var processedCode = applyReplacements(
regionProvider,
code,
"dataReplacements"
);
var id = regionProvider._idIndex[processedCode];
if (!defined(id))... | javascript | {
"resource": ""
} |
q22058 | getSourceData | train | function getSourceData(node, children) {
const sourceData = node.attribs["data"];
if (sourceData) {
return sourceData;
}
if (Array.isArray(children) && children.length > 0) {
return children[0];
}
return children;
} | javascript | {
"resource": ""
} |
q22059 | tableStructureFromStringData | train | function tableStructureFromStringData(stringData) {
// sourceData can be either json (starts with a '[') or csv format (contains a true line feed or '\n'; \n is replaced with a real linefeed).
if (!defined(stringData) || stringData.length < 2) {
return;
}
// We prevent ALT, LON and LAT from being ... | javascript | {
"resource": ""
} |
q22060 | readJson | train | function readJson(file) {
return when(
readText(file),
function(result) {
try {
return JSON.parse(result);
} catch (e) {
if (e instanceof SyntaxError) {
return json5.parse(result);
} else {
throw e;
}
}
},
function(e) {
throw ... | javascript | {
"resource": ""
} |
q22061 | train | function(options) {
FunctionParameter.call(this, options);
this.regionParameter = options.regionParameter;
this.value = "";
this._subtype = undefined;
} | javascript | {
"resource": ""
} | |
q22062 | train | function(
terria,
viewState,
fileOrUrl,
dataType,
confirmConversion
) {
function tryConversionService(newItem) {
if (terria.configParameters.conversionServiceBaseUrl === false) {
// Don't allow conversion service. Duplicated in OgrCatalogItem.js
terria.error.raiseEvent(
new TerriaErr... | javascript | {
"resource": ""
} | |
q22063 | drawTick | train | function drawTick(y) {
barGroup.appendChild(
svgElement(
legend,
"line",
{
x1: legend.itemWidth,
x2: legend.itemWidth + 5,
y1: y,
y2: y
},
"tick-mark"
)
);
} | javascript | {
"resource": ""
} |
q22064 | train | function(code, name, concept) {
Concept.call(this, name);
/**
* Gets or sets the value of the abs code.
* @type {String}
*/
this.code = code;
/**
* Gets the list of abs codes contained in this group. This property is observable.
* @type {AbsCode[]}
*/
this.items = [];
/**
* Gets or s... | javascript | {
"resource": ""
} | |
q22065 | disposeSubscription | train | function disposeSubscription(component) {
if (defined(component.__observeModelChangeSubscriptions)) {
for (
let i = 0;
i < component.__observeModelChangeSubscriptions.length;
++i
) {
component.__observeModelChangeSubscriptions[i].dispose();
}
component.__observeModelChangeSubsc... | javascript | {
"resource": ""
} |
q22066 | train | function(options) {
FunctionParameter.call(this, options);
this._regionProviderPromise = undefined;
this._regionProviderList = undefined;
this.validRegionTypes = options.validRegionTypes;
// Track this so that defaultValue can update once regionProviderList is known.
knockout.track(this, ["_regionProvide... | javascript | {
"resource": ""
} | |
q22067 | train | function(terria) {
this._terria = terria;
this._eventSubscriptions = new EventHelper();
/**
* Gets the list of items that we are "now viewing". It is recommended that you use
* the methods on this instance instead of manipulating the list of items directly.
* This property is observable.
* @type {Ca... | javascript | {
"resource": ""
} | |
q22068 | parseCustomHtmlToReact | train | function parseCustomHtmlToReact(html, context) {
if (!defined(html) || html.length === 0) {
return html;
}
return htmlToReactParser.parseWithInstructions(
html,
isValidNode,
getProcessingInstructions(context || {})
);
} | javascript | {
"resource": ""
} |
q22069 | train | function(observations, seriesKey, dimIdx, attrIdx) {
if (observations === undefined || observations === null) return;
// process each observation in object.
for (var key in observations) {
// convert key from string to an array of numbers
var obsDimIdx = key.split(KEY_SEPARATOR).map(Number);
... | javascript | {
"resource": ""
} | |
q22070 | train | function(dvi, di) {
var dim = msg.structure.dimensions.series[di];
var pos = dimPosition(dim);
seriesKey[pos] = obsKey[pos] = dim.values[dvi].id;
} | javascript | {
"resource": ""
} | |
q22071 | train | function(series) {
if (series === undefined || series === null) return;
for (var key in series) {
// Convert key from string into array of numbers
var serDimIdx = key.split(KEY_SEPARATOR).map(Number);
// Update series and obs keys
serDimIdx.forEach(updateSeriesAndObsKeys);
var va... | javascript | {
"resource": ""
} | |
q22072 | train | function(c, i, array) {
if (c === undefined || c === null) return;
// c is the component, type is dimension|attribute,
// level is dataset|series|observation, i is index,
// array is the component array
failed += !iterator.call(context, c, type, level, i, array);
} | javascript | {
"resource": ""
} | |
q22073 | train | function(v, i) {
if (v === undefined || v === null) return;
failed += !iterator.call(context, v, type, level, i);
} | javascript | {
"resource": ""
} | |
q22074 | updateFromJson | train | function updateFromJson(target, json, options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
var promises = [];
for (var propertyName in target) {
if (
target.hasOwnProperty(propertyName) &&
shouldBeUpdated(target, propertyName, json)
) {
if (target.updaters && target.u... | javascript | {
"resource": ""
} |
q22075 | shouldBeUpdated | train | function shouldBeUpdated(target, propertyName, json) {
return (
json[propertyName] !== undefined && // Must have a value to update to
propertyName.length > 0 && // Must have a name to update
propertyName[0] !== "_" && // Must not be a private property
(propertyName !== "id" || !defined(target.id))
)... | javascript | {
"resource": ""
} |
q22076 | removeCurrentTimeSubscription | train | function removeCurrentTimeSubscription(catalogItem) {
if (defined(catalogItem._removeCurrentTimeChange)) {
catalogItem._removeCurrentTimeChange();
catalogItem._removeCurrentTimeChange = undefined;
}
} | javascript | {
"resource": ""
} |
q22077 | updateCurrentTime | train | function updateCurrentTime(catalogItem, updatedTime) {
if (defined(catalogItem.clock)) {
catalogItem.clock.currentTime = JulianDate.clone(updatedTime);
}
} | javascript | {
"resource": ""
} |
q22078 | useOwnClockChanged | train | function useOwnClockChanged(catalogItem) {
// If we are changing the state, copy the time from the clock that was in use to the clock that will be in use.
if (catalogItem._lastUseOwnClock !== catalogItem.useOwnClock) {
// Check that both clocks are defined before syncing the time (they may not both be defined d... | javascript | {
"resource": ""
} |
q22079 | describeWithoutUnderscores | train | function describeWithoutUnderscores(properties, nameProperty) {
var html = "";
for (var key in properties) {
if (properties.hasOwnProperty(key)) {
if (key === nameProperty || simpleStyleIdentifiers.indexOf(key) !== -1) {
continue;
}
var value = properties[key];
if (typeof value =... | javascript | {
"resource": ""
} |
q22080 | reprojectPointList | train | function reprojectPointList(pts, code) {
if (!(pts[0] instanceof Array)) {
return Reproject.reprojectPoint(pts, code, "EPSG:4326");
}
var pts_out = [];
for (var i = 0; i < pts.length; i++) {
pts_out.push(Reproject.reprojectPoint(pts[i], code, "EPSG:4326"));
}
return pts_out;
} | javascript | {
"resource": ""
} |
q22081 | filterValue | train | function filterValue(obj, prop, func) {
for (var p in obj) {
if (obj.hasOwnProperty(p) === false) {
continue;
} else if (p === prop) {
if (func && typeof func === "function") {
func(obj, prop);
}
} else if (typeof obj[p] === "object") {
filterValue(obj[p], prop, func);
... | javascript | {
"resource": ""
} |
q22082 | filterArray | train | function filterArray(pts, func) {
if (!(pts[0] instanceof Array) || !(pts[0][0] instanceof Array)) {
pts = func(pts);
return pts;
}
var result = new Array(pts.length);
for (var i = 0; i < pts.length; i++) {
result[i] = filterArray(pts[i], func); //at array of arrays of points
}
return result;
} | javascript | {
"resource": ""
} |
q22083 | train | function(terria) {
CatalogFunction.call(this, terria);
this.url = undefined;
this.name = "Spatial Detailing";
this.description =
"Predicts the characteristics of fine-grained regions by learning and exploiting correlations of coarse-grained data with Census characteristics.";
this._regionTypeToPredictPa... | javascript | {
"resource": ""
} | |
q22084 | findSelectedData | train | function findSelectedData(data, x) {
// For each chart line (pointArray), find the point with the closest x to the mouse.
const closestXPoints = data.map(line =>
line.points.reduce((previous, current) =>
Math.abs(current.x - x) < Math.abs(previous.x - x) ? current : previous
)
);
// Of those, find... | javascript | {
"resource": ""
} |
q22085 | train | function(corsProxy, overrideUrl) {
this.url = corsProxy.getURLProxyIfNecessary(
defaultValue(overrideUrl, DATA61_GNAF_SEARCH_URL)
);
this.bulk_url = corsProxy.getURLProxyIfNecessary(
defaultValue(overrideUrl, DATA61_GNAF_BULK_SEARCH_URL)
);
} | javascript | {
"resource": ""
} | |
q22086 | convertLuceneHit | train | function convertLuceneHit(locational, item) {
var jsonInfo = JSON.parse(item.json);
return {
score: item.score,
locational: locational,
name: item.d61Address
.slice(0, 3)
.filter(function(string) {
return string.length > 0;
})
.join(", "),
flatNumber: sanitiseAddress... | javascript | {
"resource": ""
} |
q22087 | buildRequestData | train | function buildRequestData(searchTerm, maxResults) {
var requestData = {
numHits: maxResults,
fuzzy: {
maxEdits: 2,
minLength: 5,
prefixLength: 2
}
};
if (searchTerm instanceof Array) {
requestData["addresses"] = searchTerm.map(processAddress);
} else {
requestData["addr"] ... | javascript | {
"resource": ""
} |
q22088 | addBoundingBox | train | function addBoundingBox(requestData, rectangle) {
requestData["box"] = {
minLat: CesiumMath.toDegrees(rectangle.south),
maxLon: CesiumMath.toDegrees(rectangle.east),
maxLat: CesiumMath.toDegrees(rectangle.north),
minLon: CesiumMath.toDegrees(rectangle.west)
};
} | javascript | {
"resource": ""
} |
q22089 | splitIntoBatches | train | function splitIntoBatches(arrayToSplit, batchSize) {
var arrayBatches = [];
var minSlice = 0;
var finish = false;
for (var maxSlice = batchSize; maxSlice < Infinity; maxSlice += batchSize) {
if (maxSlice >= arrayToSplit.length) {
maxSlice = arrayToSplit.length;
finish = true;
}
arrayBatc... | javascript | {
"resource": ""
} |
q22090 | supportsWebGL | train | function supportsWebGL() {
if (defined(result)) {
return result;
}
//Check for webgl support and if not, then fall back to leaflet
if (!window.WebGLRenderingContext) {
// Browser has no idea what WebGL is. Suggest they
// get a new browser by presenting the user with link to
// http://get.webgl... | javascript | {
"resource": ""
} |
q22091 | getParentIds | train | function getParentIds(catalogMember, parentIds) {
parentIds = defaultValue(parentIds, []);
if (defined(catalogMember.parent)) {
return getParentIds(
catalogMember.parent,
parentIds.concat([catalogMember.uniqueId])
);
}
return parentIds;
} | javascript | {
"resource": ""
} |
q22092 | createDataSourceForLatLong | train | function createDataSourceForLatLong(item, tableStructure) {
// Create the TableDataSource and save it to item._dataSource.
item._dataSource = new TableDataSource(
item.terria,
tableStructure,
item._tableStyle,
item.name,
item.polling.seconds > 0
);
item._dataSource.changedEvent.addEventListe... | javascript | {
"resource": ""
} |
q22093 | train | function(terria, map) {
GlobeOrMap.call(this, terria);
/**
* Gets or sets the Leaflet {@link Map} instance.
* @type {Map}
*/
this.map = map;
this.scene = new LeafletScene(map);
/**
* Gets or sets whether this viewer _can_ show a splitter.
* @type {Boolean}
*/
this.canShowSplitter = true... | javascript | {
"resource": ""
} | |
q22094 | updateOneLayer | train | function updateOneLayer(item, currZIndex) {
if (defined(item.imageryLayer) && defined(item.imageryLayer.setZIndex)) {
if (item.supportsReordering) {
item.imageryLayer.setZIndex(currZIndex.reorderable++);
} else {
item.imageryLayer.setZIndex(currZIndex.fixed++);
}
}
} | javascript | {
"resource": ""
} |
q22095 | nextLayerFromIndex | train | function nextLayerFromIndex(index) {
const imageryProvider = catalogItem.createImageryProvider(
catalogItem.intervals.get(index).data
);
imageryProvider.enablePickFeatures = false;
catalogItem._nextLayer = ImageryLayerCatalogItem.enableLayer(
catalogItem,
imageryProvider,
0.0
... | javascript | {
"resource": ""
} |
q22096 | addItem | train | function addItem(resource, rootCkanGroup, itemData, extras, parent) {
var item =
rootCkanGroup.terria.catalog.shareKeyIndex[
parent.uniqueId + "/" + resource.id
];
var alreadyExists = defined(item);
if (!alreadyExists) {
item = createItemFromResource(
resource,
rootCkanGroup,
... | javascript | {
"resource": ""
} |
q22097 | getEsriGeometry | train | function getEsriGeometry(featureData, geometryType, spatialReference) {
if (defined(featureData.features)) {
// This is a FeatureCollection.
return {
type: "FeatureCollection",
crs: esriSpatialReferenceToCrs(featureData.spatialReference),
features: featureData.features.map(function(subFeatur... | javascript | {
"resource": ""
} |
q22098 | train | function(
element,
toolName,
options,
interactionTypes
) {
// If interactionTypes was passed in via options
if (interactionTypes === undefined && Array.isArray(options)) {
interactionTypes = options;
options = null;
}
const tool = getToolForElement(element, toolName);
if (tool) {
_resolv... | javascript | {
"resource": ""
} | |
q22099 | _resolveGenericInputConflicts | train | function _resolveGenericInputConflicts(
interactionType,
tool,
element,
options
) {
const interactionTypeFlag = `is${interactionType}Active`;
const activeToolWithActiveInteractionType = store.state.tools.find(
t =>
t.element === element &&
t.mode === 'active' &&
t.options[interactionTy... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.