Skip to content

Commit

Permalink
Merge pull request #127 from DavidLevinsky/master
Browse files Browse the repository at this point in the history
Faster hysteresis
  • Loading branch information
davidmtech authored Dec 21, 2018
2 parents aea5124 + 2cd8666 commit 7732fa2
Show file tree
Hide file tree
Showing 11 changed files with 259 additions and 319 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vts-browser-js",
"version": "2.16.10",
"version": "2.16.12",
"description": "JavaScript WebGL 3D maps rendering engine",
"main": "src/browser/index.js",
"scripts": {
Expand Down
11 changes: 7 additions & 4 deletions src/browser/ui/control/measure.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,8 @@ UIControlMeasure.prototype.onCompute = function(button) {
}

if (this.tool == 3) {
console.log(JSON.stringify(this.navCoords));

var geodata = map.createGeodata();
geodata.addPolygon3(this.navCoords, [], null, 'fix', {}, 'tmp-polygon');
geodata.processHeights('node-by-lod', 62, (function(){
Expand Down Expand Up @@ -799,12 +801,13 @@ UIControlMeasure.prototype.onMapUpdate = function() {
points2 = points2.concat(tmp);
}

for (i = 0, li = points2.length; i < li; i++) {
points3.push(map.convertCoordsFromNavToCanvas(points2[i], "fix"));
if (this.tool == 3 || this.tool == 4) {
tmp = map.getGeodesicLinePoints(this.navCoords[li], this.navCoords[0]);
points2 = points2.concat(tmp);
}

if (this.tool == 3 || this.tool == 4) {
points3.push(map.convertCoordsFromNavToCanvas(points2[0], "fix"));
for (i = 0, li = points2.length; i < li; i++) {
points3.push(map.convertCoordsFromNavToCanvas(points2[i], "fix"));
}

renderer.drawLineString({
Expand Down
4 changes: 2 additions & 2 deletions src/core/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ var Core = function(element, config, coreInterface) {
mapFeaturesPerSquareInch : 0.25, //0.6614,
mapFeaturesSortByTop : false,

mapFeaturesReduceMode : 'scr-count5',
mapFeaturesReduceMode : 'scr-count1', //have to be 'scr-count1' because of legacy https://rigel.mlwn.se/store/map-config/high-terrain/
mapFeaturesReduceParams : null,
mapFeaturesReduceFactor : 1,

Expand Down Expand Up @@ -532,7 +532,7 @@ string getCoreVersion()
*/

function getCoreVersion(full) {
return (full ? 'Core: ' : '') + '2.16.10';
return (full ? 'Core: ' : '') + '2.16.12';
}


Expand Down
9 changes: 7 additions & 2 deletions src/core/map/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,19 @@ MapConfig.prototype.parseViews = function() {
var views = this.mapConfig['namedViews'];
this.map.namedViews = [];

if (views != null) {
if (views) {
for (var key in views) {
this.map.addNamedView(key, new MapView(this.map, views[key]));
}
}

var view = this.mapConfig['view'];
if (view == null) {

if (typeof view === 'string') {
view = this.map.namedViews[view];
}

if (!view) {
return true;
}

Expand Down
25 changes: 22 additions & 3 deletions src/core/map/geodata-processor/processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,29 +122,33 @@ MapGeodataProcessor.prototype.setStylesheet = function(stylesheet, fontsOnly) {

this.busy = true;

var ppi = 96 * (window.devicePixelRatio || 1);
var config = this.map.config;
var params = config.mapFeaturesReduceParams;
var isDef = (function(val){ return (typeof val !== 'undefinde') });
var isDef = (function(val){ return (typeof val !== 'undefined') });

switch (config.mapFeaturesReduceMode) {
case 'scr-count1':
case 'scr-count2':
if (!params) {
params = [1,50,0];
} else {
params[0] = isDef(params[0]) ? params[0] : 1;
params[1] = isDef(params[1]) ? params[1] : 50;
params[2] = isDef(params[2]) ? params[2] : 0;
config.mapFeaturesSortByTop = true;
}
config.mapFeaturesSortByTop = (config.mapFeaturesReduceMode == 'scr-count2') ? true : false;
break;

case 'scr-count4':
if (!params) {
params = [0.18,0,0];
} else {
params[0] = isDef(params[0]) ? params[0] : 0.18;
params[1] = isDef(params[1]) ? params[1] : 0;
params[2] = isDef(params[2]) ? params[2] : 0;
config.mapFeaturesSortByTop = true;
}
config.mapFeaturesSortByTop = true;
break;

case 'scr-count5':
Expand All @@ -154,18 +158,33 @@ MapGeodataProcessor.prototype.setStylesheet = function(stylesheet, fontsOnly) {
params[0] = isDef(params[0]) ? params[0] : 2;
params[1] = isDef(params[1]) ? params[1] : 1;
params[2] = isDef(params[2]) ? params[2] : 0;
}
config.mapFeaturesSortByTop = true;
break;

case 'scr-count6':
if (!params) {
params = [0.5,0,0];
} else {
params[0] = (isDef(params[0]) ? params[0] : 0.5);
params[1] = isDef(params[1]) ? params[1] : 0;
params[2] = isDef(params[2]) ? params[2] : 0;
params[3] = ppi;
config.mapFeaturesSortByTop = true;
}
break;

}

config.mapFeaturesReduceFactor = params[2];

if (!config.mapFeaturesReduceParams) {
switch(config.mapFeaturesReduceMode) {
case 'scr-count1':
case 'scr-count2': config.mapFeaturesReduceParams = [1, 50, 0]; break;
case 'scr-count4': config.mapFeaturesReduceParams = [0.18, 0, 1]; break;
case 'scr-count5': config.mapFeaturesReduceParams = [2, 1, 1]; break;
case 'scr-count6': config.mapFeaturesReduceParams = [0.5, 0, 0, ppi]; break;
}
}

Expand Down
12 changes: 8 additions & 4 deletions src/core/map/geodata-processor/worker-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ function processLayerFeaturePass(type, feature, lod, layer, featureIndex, zIndex
}

function processFeatures(type, features, lod, featureType, group) {
var reduceParams = globals.reduceParams;

//loop layers
for (var key in globals.stylesheetLayers) {
Expand All @@ -67,19 +68,22 @@ function processFeatures(type, features, lod, featureType, group) {
if (importance) {
//importance = '$importance';
switch (globals.reduceMode) {
case 'scr-count1':
case 'scr-count2':
//layer['reduce'] = ['bottom',100,importance];
layer['reduce'] = ['top',100,importance];
layer['dynamic-reduce'] = ['scr-count2', globals.reduceParams[0], globals.reduceParams[1]];
layer['dynamic-reduce'] = ['scr-count2', reduceParams[0], reduceParams[1]];
break;
case 'scr-count4':
//layer['reduce'] = ['bottom',100,importance];
layer['dynamic-reduce'] = ['scr-count4',importance];
break;
case 'scr-count5':
//layer['reduce'] = ['bottom',100,importance];
layer['dynamic-reduce'] = ['scr-count5',importance];
break;
case 'scr-count6':
layer['dynamic-reduce'] = ['scr-count6',importance];
layer['label-no-overlap-margin'] = [reduceParams[0]*reduceParams[3], reduceParams[0]*reduceParams[3]];
break;

}
}
}
Expand Down
32 changes: 28 additions & 4 deletions src/core/map/geodata-processor/worker-style.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@

import {globals as globals_, simpleFmtCall as simpleFmtCall_, getHash as getHash_} from './worker-globals.js';
import {globals as globals_, simpleFmtCall as simpleFmtCall_, getHash as getHash_, clamp as clamp_} from './worker-globals.js';
import {areTextCharactersAvailable as areTextCharactersAvailable_, hasLatin as hasLatin_, isCJK as isCJK_ } from './worker-text.js';

//get rid of compiler mess
var globals = globals_;
var clamp = clamp_;
var simpleFmtCall = simpleFmtCall_;
var getHash = getHash_;
var hasLatin = hasLatin_, isCJK = isCJK_;
Expand Down Expand Up @@ -137,7 +138,7 @@ var getLayerPropertyValue = function(layer, key, feature, lod) {


var getLayerPropertyValueInner = function(layer, key, feature, lod, value, depth) {
var index = 0, i, li, finalValue, root, v1, v2;
var index = 0, i, li, finalValue, root, v1, v2, v3;
var tmpValue;


Expand Down Expand Up @@ -286,6 +287,8 @@ var getLayerPropertyValueInner = function(layer, key, feature, lod, value, depth
}
}

break;

case 'add':
case 'sub':
case 'mul':
Expand Down Expand Up @@ -314,6 +317,27 @@ var getLayerPropertyValueInner = function(layer, key, feature, lod, value, depth
}
}

break;

case 'clamp':

if (!Array.isArray(functionValue) || functionValue.length != 3) {
functionError = true;
} else {

v1 = getLayerPropertyValueInner(layer, key, feature, lod, functionValue[0], depth + 1);
v2 = getLayerPropertyValueInner(layer, key, feature, lod, functionValue[1], depth + 1);
v3 = getLayerPropertyValueInner(layer, key, feature, lod, functionValue[2], depth + 1);

if (typeof v1 !== 'number' || typeof v2 !== 'number' || typeof v3 !== 'number') {
functionError = true;
} else {
return clamp(v1, v2, v3);
}
}

break;

case 'sgn':
case 'sin':
case 'cos':
Expand Down Expand Up @@ -668,8 +692,8 @@ var validateValue = function(layerId, key, value, type, arrayLength, min, max) {
}

if (!((value[0] == 'tilt' || value[0] == 'tilt-cos' || value[0] == 'tilt-cos2' || value[0] == 'scr-count' || value[0] == 'scr-count2' ||
value[0] == 'scr-count3' || value[0] == 'scr-count4' || value[0] == 'scr-count5') &&
(typeof value[1] === 'number') && ((typeof value[2] === 'number') || value[0] == 'scr-count4' || value[0] == 'scr-count5'))) {
value[0] == 'scr-count3' || value[0] == 'scr-count4' || value[0] == 'scr-count5' || value[0] == 'scr-count6') &&
(typeof value[1] === 'number') && ((typeof value[2] === 'number') || value[0] == 'scr-count4' || value[0] == 'scr-count5' || value[0] == 'scr-count6'))) {
logError('wrong-property-value', layerId, key, value);
return getDefaultLayerPropertyValue(key);
}
Expand Down
1 change: 1 addition & 0 deletions src/core/map/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,7 @@ Map.prototype.setConfigParam = function(key, value) {
if (value == 'legacy') value = 'scr-count2';
if (value == 'gridcells') value = 'scr-count4';
if (value == 'singlepass') value = 'scr-count5';
if (value == 'margin') value = 'scr-count6';
this.config.mapFeaturesReduceMode = value;
break;

Expand Down
Loading

0 comments on commit 7732fa2

Please sign in to comment.