Skip to content

Commit

Permalink
Merge pull request ngageoint#713 in WV/opensphere from ~JENKINS/opens…
Browse files Browse the repository at this point in the history
…phere:upscanMerge to master

* commit '69473feb724a1db6e5186ff98ec7ac02b87454a6':
  fix(csv): Set path to Papa Parse library.
  fix(LayerDefaults): When slider bars are reset the settings are checked for default values.
  fix(LayerDefaults): When slider bars are reset the settings are checked for default values.
  chore(resolver): Update resolver to support Electron preload scripts.
  fix(scaleline): Fix a jittery scaleline when in 3d mode.
  • Loading branch information
welchyd committed Apr 2, 2019
2 parents 3408158 + 69473fe commit 00c3ee5
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 11 deletions.
6 changes: 6 additions & 0 deletions externs/papaparse-3.1.2.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
var Papa = {};


/**
* @type {string}
*/
Papa.SCRIPT_PATH;


/**
* @type {number}
*/
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@
"opensphere-build-closure-helper": "^1.0.0",
"opensphere-build-docs": "^1.0.0",
"opensphere-build-index": "^1.0.0",
"opensphere-build-resolver": "^4.0.0",
"opensphere-build-resolver": "^5.0.0",
"opensphere-state-schema": "^2.1.0",
"postcss-cli": "^5.0.0",
"replace": "^0.3.0",
Expand Down
10 changes: 6 additions & 4 deletions src/os/control/scaleline.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,21 +82,23 @@ os.control.ScaleLine.prototype.updateElement_ = function() {
// However, it is wrong (see issue #7086 for Openlayers) for some projections.
var map = this.getMap();

var p2 = map.getPixelFromCoordinate(viewState.center);
if (!p2) {
var p1 = map.getPixelFromCoordinate(viewState.center);
if (!p1) {
this.hide();
return;
}

var p2 = p1.slice();
p2[0] += 1;

var c1 = map.getCoordinateFromPixel(p1);
var c2 = map.getCoordinateFromPixel(p2);
if (!c2) {
if (!c1 || !c2) {
this.hide();
return;
}

var c1 = ol.proj.toLonLat(viewState.center, os.map.PROJECTION);
c1 = ol.proj.toLonLat(c1, os.map.PROJECTION);
c2 = ol.proj.toLonLat(c2, os.map.PROJECTION);

var pointResolution = window.osasm ? osasm.geodesicInverse(c1, c2).distance : NaN;
Expand Down
16 changes: 15 additions & 1 deletion src/os/data/layersyncdescriptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,30 @@ os.data.LayerSyncDescriptor.prototype.getOptions = function() {
var options = this.getLayerOptions();
if (options) {
if (!goog.isArray(options)) {
options['defaults'] = this.extractConfigDefaults(options);
options = [options];
}

return options.map(this.applyLayerConfig, this);
}

return options;
};


/**
* @param {!Object<string, *>} options
* @return {!Object<string, *>}
*/
os.data.LayerSyncDescriptor.prototype.extractConfigDefaults = function(options) {
return {
'opacity': options['opacity'],
'brightness': options['brightness'],
'contrast': options['contrast'],
'saturation': options['saturation']
};
};


/**
* If the layer is being synchronized by this descriptor.
* @param {!os.layer.ILayer} layer The layer
Expand Down
7 changes: 2 additions & 5 deletions src/os/ui/file/csv/abstractcsvparser.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ goog.require('os.data.ColumnDefinition');
goog.require('os.file.mime.text');
goog.require('os.parse.AsyncParser');
goog.require('os.parse.BaseParserConfig');
goog.require('os.ui.file.csv');



Expand Down Expand Up @@ -36,11 +37,7 @@ os.ui.file.csv.AbstractCsvParser = function(config) {
*/
this.results = [];

if (!Modernizr.webworkers) {
// if workers aren't available, reduce Papa's default chunk size to prevent the browser from hanging
Papa.LocalChunkSize = 1024 * 1024 * 1; // 1 MB (default 10MB)
Papa.RemoteChunkSize = 1024 * 1024 * 1; // 1 MB (default 5MB)
}
os.ui.file.csv.configurePapaParse();
};
goog.inherits(os.ui.file.csv.AbstractCsvParser, os.parse.AsyncParser);

Expand Down
23 changes: 23 additions & 0 deletions src/os/ui/file/csv/csv.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
goog.provide('os.ui.file.csv');


/**
* Configure Papa Parse for use with OpenSphere.
*/
os.ui.file.csv.configurePapaParse = function() {
// Papa Parse locates the script path by looking up the last script element on the page. this is generally a fine
// assumption, unless a browser extension injects scripts at the end of the page. this locates the script by a more
// specific selector that should be less prone to false positives.
if (!Papa.SCRIPT_PATH) {
var papaScriptEl = /** @type {HTMLScriptElement} */ (document.querySelector('script[src*="papaparse"]'));
if (papaScriptEl) {
Papa.SCRIPT_PATH = papaScriptEl.src;
}
}

// if workers aren't available, reduce Papa's default chunk size to prevent the browser from hanging
if (!Modernizr.webworkers) {
Papa.LocalChunkSize = 1024 * 1024 * 1; // 1 MB (default 10MB)
Papa.RemoteChunkSize = 1024 * 1024 * 1; // 1 MB (default 5MB)
}
};
9 changes: 9 additions & 0 deletions src/os/ui/layer/defaultlayerui.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,15 @@ os.ui.layer.DefaultLayerUICtrl.prototype.onRefreshChange = function() {
*/
os.ui.layer.DefaultLayerUICtrl.prototype.reset = function(key) {
var defaultValue = this.defaults[key];
var nodes = this.getLayerNodes();
if (nodes && nodes[0].getLayer() != null && nodes[0].getLayer().getLayerOptions() &&
nodes[0].getLayer().getLayerOptions()['defaults']) {
var value = nodes[0].getLayer().getLayerOptions()['defaults'][key];
if (value != null) {
defaultValue = /** @type {number} */ (value);
}
}

if (defaultValue != null) {
var callback = this.getProperties()[key];
this.onSliderStop(callback, key, null, defaultValue);
Expand Down

0 comments on commit 00c3ee5

Please sign in to comment.