From 0413397fe795be22e23e36e2be80d8b079493e36 Mon Sep 17 00:00:00 2001 From: David Manthey Date: Fri, 3 Jun 2016 09:55:05 -0400 Subject: [PATCH 1/2] Remove the plane feature. Nothing uses it any more. --- src/d3/index.js | 1 - src/d3/planeFeature.js | 146 --------------------------------- src/gl/index.js | 1 - src/gl/planeFeature.js | 180 ----------------------------------------- src/index.js | 1 - src/planeFeature.js | 143 -------------------------------- 6 files changed, 472 deletions(-) delete mode 100644 src/d3/planeFeature.js delete mode 100644 src/gl/planeFeature.js delete mode 100644 src/planeFeature.js diff --git a/src/d3/index.js b/src/d3/index.js index f614f615cf..1068e29a4a 100644 --- a/src/d3/index.js +++ b/src/d3/index.js @@ -11,7 +11,6 @@ module.exports = { lineFeature: require('./lineFeature'), object: require('./object'), pathFeature: require('./pathFeature'), - planeFeature: require('./planeFeature'), pointFeature: require('./pointFeature'), quadFeature: require('./quadFeature'), renderer: require('./d3Renderer'), diff --git a/src/d3/planeFeature.js b/src/d3/planeFeature.js deleted file mode 100644 index 992ec9d131..0000000000 --- a/src/d3/planeFeature.js +++ /dev/null @@ -1,146 +0,0 @@ -var inherit = require('../inherit'); -var registerFeature = require('../registry').registerFeature; -var planeFeature = require('../planeFeature'); - -////////////////////////////////////////////////////////////////////////////// -/** - * Create a plane feature given a lower left corner point - * and and upper right corner point - * - * @class geo.d3.planeFeature - * @extends geo.planeFeature -* @param lowerleft - * @param upperright - * @returns {geo.d3.planeFeature} - */ -////////////////////////////////////////////////////////////////////////////// -var d3_planeFeature = function (arg) { - 'use strict'; - if (!(this instanceof d3_planeFeature)) { - return new d3_planeFeature(arg); - } - - var object = require('./object'); - var timestamp = require('../timestamp'); - - planeFeature.call(this, arg); - object.call(this); - - var m_this = this, - m_style = {}, - s_update = this._update, - s_init = this._init, - m_buildTime = timestamp(); - - ////////////////////////////////////////////////////////////////////////////// - /** - * Normalize a coordinate as an object {x: ..., y: ...} - * - * @private - * @returns {Object} - */ - ////////////////////////////////////////////////////////////////////////////// - function normalize(pt) { - if (Array.isArray(pt)) { - return { - x: pt[0], - y: pt[1] - }; - } - return pt; - } - - ////////////////////////////////////////////////////////////////////////////// - /** - * Build the feature object and pass to the renderer for drawing. - * - * @private - * @returns {geo.d3.planeFeature} - */ - ////////////////////////////////////////////////////////////////////////////// - this._build = function () { - var ul = normalize(m_this.upperLeft()), - lr = normalize(m_this.lowerRight()), - renderer = m_this.renderer(), - s = m_this.style(); - - delete s.fill_color; - delete s.color; - delete s.opacity; - /* - if (!s.screenCoordinates) { - origin = renderer.layer().map().worldToDisplay(origin); - ul = renderer.layer().map().worldToDisplay(ul); - lr = renderer.layer().map().worldToDisplay(lr); - } - */ - m_style.id = m_this._d3id(); - m_style.style = s; - m_style.attributes = { - x: ul.x, - y: ul.y, - width: Math.abs(lr.x - ul.x), - height: Math.abs(lr.y - ul.y), - reference: s.reference - }; - if (s.image) { - m_style.append = 'image'; - m_style.attributes['xlink:href'] = s.image; - } else { - m_style.append = 'rect'; - } - m_style.data = [0]; - m_style.classes = ['d3PlaneFeature']; - if (s.parentId) { - m_style.parentId = s.parentId; - } - - renderer._drawFeatures(m_style); - m_buildTime.modified(); - return m_this; - }; - - ////////////////////////////////////////////////////////////////////////////// - /** - * Redraw the plane feature if necessary. - * - * @private - * @returns {geo.d3.planeFeature} - */ - ////////////////////////////////////////////////////////////////////////////// - this._update = function () { - s_update.call(m_this); - - if (m_this.dataTime().getMTime() >= m_buildTime.getMTime()) { - m_this._build(); - } - return m_this; - }; - - ////////////////////////////////////////////////////////////////////////////// - /** - * Initializes the plane feature style (over-riding the parent default). - * - * @private - * @returns {geo.d3.planeFeature} - */ - ////////////////////////////////////////////////////////////////////////////// - this._init = function (arg) { - s_init.call(m_this, arg || {}); - m_this.style({ - stroke: function () { return false; }, - fill: function () { return true; }, - fillColor: function () { return {r: 0.3, g: 0.3, b: 0.3}; }, - fillOpacity: function () { return 0.5; } - }); - return m_this; - }; - - this._init(); - return this; -}; - -inherit(d3_planeFeature, planeFeature); - -registerFeature('d3', 'plane', d3_planeFeature); -module.exports = d3_planeFeature; diff --git a/src/gl/index.js b/src/gl/index.js index 0d2126d15b..1fa5da165d 100644 --- a/src/gl/index.js +++ b/src/gl/index.js @@ -7,7 +7,6 @@ module.exports = { ellipsoid: require('./ellipsoid'), geomFeature: require('./geomFeature'), lineFeature: require('./lineFeature'), - planeFeature: require('./planeFeature'), pointFeature: require('./pointFeature'), polygonFeature: require('./polygonFeature'), quadFeature: require('./quadFeature'), diff --git a/src/gl/planeFeature.js b/src/gl/planeFeature.js deleted file mode 100644 index dce37cea69..0000000000 --- a/src/gl/planeFeature.js +++ /dev/null @@ -1,180 +0,0 @@ -var inherit = require('../inherit'); -var registerFeature = require('../registry').registerFeature; -var planeFeature = require('../planeFeature'); - -////////////////////////////////////////////////////////////////////////////// -/** - * Create a plane feature given a lower left corner point - * and and upper right corner point - * @class geo.gl.planeFeature - * @extends geo.planeFeature - * @param lowerleft - * @param upperright - * @returns {geo.gl.planeFeature} - */ -////////////////////////////////////////////////////////////////////////////// -var gl_planeFeature = function (arg) { - 'use strict'; - if (!(this instanceof gl_planeFeature)) { - return new gl_planeFeature(arg); - } - planeFeature.call(this, arg); - - var transform = require('../transform'); - var vgl = require('vgl'); - - var m_this = this, - s_exit = this._exit, - m_actor = null, - m_onloadCallback = arg.onload === undefined ? null : arg.onload; - - //////////////////////////////////////////////////////////////////////////// - /** - * Gets the coordinates for this plane - * - * @returns {Array} [[origin], [upper left] [lower right]] - */ - //////////////////////////////////////////////////////////////////////////// - this.coords = function () { - return [m_this.origin(), m_this.upperLeft(), m_this.lowerRight()]; - }; - - //////////////////////////////////////////////////////////////////////////// - /** - * Build this feature - * - * @override - */ - //////////////////////////////////////////////////////////////////////////// - this._build = function () { - var or = m_this.origin(), - ul = m_this.upperLeft(), - lr = m_this.lowerRight(), - /// img could be a source or an Image - img = m_this.style().image, - image = null, - texture = null, - gcs = m_this.gcs(), - map_gcs = m_this.layer().map().gcs(); - - if (gcs !== map_gcs) { - or = transform.transformCoordinates(gcs, map_gcs, or); - ul = transform.transformCoordinates(gcs, map_gcs, ul); - lr = transform.transformCoordinates(gcs, map_gcs, lr); - } - - m_this.buildTime().modified(); - - if (m_actor) { - m_this.renderer().contextRenderer().removeActor(m_actor); - } - - if (img && img instanceof Image) { - image = img; - } else if (img) { - image = new Image(); - image.src = img; - } - - if (!image) { - m_actor = vgl.utils.createPlane(or[0], or[1], or[2], - ul[0], ul[1], ul[2], - lr[0], lr[1], lr[2]); - - m_actor.material().shaderProgram().uniform('opacity').set( - m_this.style().opacity !== undefined ? m_this.style().opacity : 1); - - m_this.renderer().contextRenderer().addActor(m_actor); - - } else { - m_actor = vgl.utils.createTexturePlane(or[0], or[1], or[2], - lr[0], lr[1], lr[2], - ul[0], ul[1], ul[2], true); - - m_actor.material().shaderProgram().uniform('opacity').set( - m_this.style().opacity !== undefined ? m_this.style().opacity : 1); - - texture = vgl.texture(); - m_this.visible(false); - - m_this.renderer().contextRenderer().addActor(m_actor); - - /* An image is already loaded if .complete is true and .naturalWidth - * and .naturalHeight are defined and non-zero (not falsy seems to be - * sufficient). */ - if (image.complete && image.naturalWidth && image.naturalHeight) { - texture.setImage(image); - m_actor.material().addAttribute(texture); - /// NOTE Currently we assume that we want to show the feature as - /// soon as the image gets loaded. However, there might be a case - /// where we want to lock down the visibility. We will deal with that - /// later. - m_this.visible(true); - - if (m_onloadCallback) { - m_onloadCallback.call(m_this); - } - } else { - image.onload = function () { - texture.setImage(image); - m_actor.material().addAttribute(texture); - /// NOTE Currently we assume that we want to show the feature as - /// soon as the image gets loaded. However, there might be a case - /// where we want to lock down the visibility. We will deal with that - /// later. - m_this.visible(true); - - if (m_onloadCallback) { - m_onloadCallback.call(m_this); - } - - if (m_this.drawOnAsyncResourceLoad()) { - m_this._update(); - m_this.layer().draw(); - } - }; - } - } - }; - - //////////////////////////////////////////////////////////////////////////// - /** - * Update - * - * @override - */ - //////////////////////////////////////////////////////////////////////////// - this._update = function () { - if (m_this.buildTime().getMTime() <= m_this.dataTime().getMTime()) { - m_this._build(); - } - - if (m_this.updateTime().getMTime() <= m_this.getMTime()) { - m_actor.setVisible(m_this.visible()); - m_actor.material().setBinNumber(m_this.bin()); - m_actor.material().shaderProgram().uniform('opacity').set( - m_this.style().opacity !== undefined ? m_this.style().opacity : 1); - } - - m_this.updateTime().modified(); - }; - - //////////////////////////////////////////////////////////////////////////// - /** - * Destroy - */ - //////////////////////////////////////////////////////////////////////////// - this._exit = function () { - m_this.renderer().contextRenderer().removeActor(m_actor); - s_exit(); - }; - - return this; -}; - -inherit(gl_planeFeature, planeFeature); - -// Now register it -registerFeature('vgl', 'plane', gl_planeFeature); - -module.exports = gl_planeFeature; diff --git a/src/index.js b/src/index.js index 32592c6f55..03bc977142 100644 --- a/src/index.js +++ b/src/index.js @@ -52,7 +52,6 @@ module.exports = $.extend({ object: require('./object'), osmLayer: require('./osmLayer'), pathFeature: require('./pathFeature'), - planeFeature: require('./planeFeature'), pointFeature: require('./pointFeature'), polygonFeature: require('./polygonFeature'), quadFeature: require('./quadFeature'), diff --git a/src/planeFeature.js b/src/planeFeature.js deleted file mode 100644 index 823b738a91..0000000000 --- a/src/planeFeature.js +++ /dev/null @@ -1,143 +0,0 @@ -var inherit = require('./inherit'); -var polygonFeature = require('./polygonFeature'); - -////////////////////////////////////////////////////////////////////////////// -/** - * Create a new instance of class planeFeature - * - * @class geo.planeFeature - * @extends geo.polygonFeature - * @returns {geo.planeFeature} - */ -////////////////////////////////////////////////////////////////////////////// -var planeFeature = function (arg) { - 'use strict'; - if (!(this instanceof planeFeature)) { - return new planeFeature(arg); - } - arg = arg || {}; - - // Defaults - arg.ul = arg.ul === undefined ? [0.0, 1.0, 0.0] : arg.ul; - arg.lr = arg.lr === undefined ? [1.0, 0.0, 0.0] : arg.lr; - arg.depth = arg.depth === undefined ? 0.0 : arg.depth; - - polygonFeature.call(this, arg); - - var m_this = this, - m_origin = [arg.ul.x, arg.lr.y, arg.depth], - m_upperLeft = [arg.ul.x, arg.ul.y, arg.depth], - m_lowerRight = [arg.lr.x, arg.lr.y, arg.depth], - m_defaultDepth = arg.depth, - m_drawOnAsyncResourceLoad = arg.drawOnAsyncResourceLoad === undefined ? - true : false, - s_init = this._init; - - //////////////////////////////////////////////////////////////////////////// - /** - * Get/Set origin - * - * @returns {geo.planeFeature} - */ - //////////////////////////////////////////////////////////////////////////// - this.origin = function (val) { - if (val === undefined) { - return m_origin; - } else if (val instanceof Array) { - if (val.length > 3 || val.length < 2) { - throw 'Origin point requires point in 2 or 3 dimension'; - } - m_origin = val.slice(0); - if (m_origin.length === 2) { - m_origin[2] = m_defaultDepth; - } - } - m_this.dataTime().modified(); - m_this.modified(); - return m_this; - }; - - //////////////////////////////////////////////////////////////////////////// - /** - * Get/Set pt1 - * - * @returns {geo.planeFeature} - */ - //////////////////////////////////////////////////////////////////////////// - this.upperLeft = function (val) { - if (val === undefined) { - return m_upperLeft; - } else if (val instanceof Array) { - if (val.length > 3 || val.length < 2) { - throw 'Upper left point requires point in 2 or 3 dimension'; - } - m_upperLeft = val.slice(0); - if (m_upperLeft.length === 2) { - m_upperLeft[2] = m_defaultDepth; - } - } - m_this.dataTime().modified(); - m_this.modified(); - return m_this; - }; - - //////////////////////////////////////////////////////////////////////////// - /** - * Get/Set origin - * - * @returns {geo.planeFeature} - */ - //////////////////////////////////////////////////////////////////////////// - this.lowerRight = function (val) { - if (val === undefined) { - return m_lowerRight; - } else if (val instanceof Array) { - if (val.length > 3 || val.length < 2) { - throw 'Lower right point requires point in 2 or 3 dimension'; - } - m_lowerRight = val.slice(0); - if (m_lowerRight.length === 2) { - m_lowerRight[2] = m_defaultDepth; - } - m_this.dataTime().modified(); - } - m_this.dataTime().modified(); - m_this.modified(); - return m_this; - }; - - //////////////////////////////////////////////////////////////////////////// - /** - * Get/Set if draw should happen as soon as a async resource is loaded - */ - //////////////////////////////////////////////////////////////////////////// - this.drawOnAsyncResourceLoad = function (val) { - if (val === undefined) { - return m_drawOnAsyncResourceLoad; - } else { - m_drawOnAsyncResourceLoad = val; - return m_this; - } - }; - - //////////////////////////////////////////////////////////////////////////// - /** - * Initialize - */ - //////////////////////////////////////////////////////////////////////////// - this._init = function (arg) { - var style = null; - s_init.call(m_this, arg); - style = m_this.style(); - if (style.image === undefined) { - style.image = null; - } - m_this.style(style); - }; - - this._init(arg); - return this; -}; - -inherit(planeFeature, polygonFeature); -module.exports = planeFeature; From f094c833243600262afe561f30efba5510796f90 Mon Sep 17 00:00:00 2001 From: David Manthey Date: Mon, 6 Jun 2016 12:35:18 -0400 Subject: [PATCH 2/2] Convert the Selenium glTwoRenderers test to use a quad. Remove the Selenium glPlane test. --- .../selenium-tests/glPlane/include.css | 3 -- .../selenium-tests/glPlane/include.html | 1 - .../selenium-tests/glPlane/include.js | 44 ------------------- .../selenium-tests/glPlane/testGlPlane.py | 44 ------------------- .../selenium-tests/glTwoRenderers/include.js | 11 ++--- 5 files changed, 6 insertions(+), 97 deletions(-) delete mode 100644 testing/test-cases/selenium-tests/glPlane/include.css delete mode 100644 testing/test-cases/selenium-tests/glPlane/include.html delete mode 100644 testing/test-cases/selenium-tests/glPlane/include.js delete mode 100644 testing/test-cases/selenium-tests/glPlane/testGlPlane.py diff --git a/testing/test-cases/selenium-tests/glPlane/include.css b/testing/test-cases/selenium-tests/glPlane/include.css deleted file mode 100644 index 355579c9fd..0000000000 --- a/testing/test-cases/selenium-tests/glPlane/include.css +++ /dev/null @@ -1,3 +0,0 @@ -body { - overflow: hidden; -} diff --git a/testing/test-cases/selenium-tests/glPlane/include.html b/testing/test-cases/selenium-tests/glPlane/include.html deleted file mode 100644 index f1756fd785..0000000000 --- a/testing/test-cases/selenium-tests/glPlane/include.html +++ /dev/null @@ -1 +0,0 @@ -
diff --git a/testing/test-cases/selenium-tests/glPlane/include.js b/testing/test-cases/selenium-tests/glPlane/include.js deleted file mode 100644 index 10834bd479..0000000000 --- a/testing/test-cases/selenium-tests/glPlane/include.js +++ /dev/null @@ -1,44 +0,0 @@ -window.startTest = function (done) { - 'use strict'; - - var mapOptions = { - node: '#map', - clampBounds: false, - gcs: 'EPSG:4326' - }, - myMap = geo.map(mapOptions), - layer = myMap.createLayer('feature'); - - function resizeCanvas() { - $('#map').width('100%'); - $('#map').height('100%'); - updateAndDraw($('#map').width(), $('#map').height()); - } - - // Resize the canvas to fill browser window dynamically - window.addEventListener('resize', resizeCanvas, false); - - resizeCanvas(); - - function updateAndDraw(width, height) { - myMap.resize(0, 0, width, height); - myMap.draw(); - } - - var opacity = new RegExp('[\\?&]opacity=([^&#]*)').exec(location.search); - if (opacity !== null) { - opacity = decodeURIComponent(opacity[1].replace(/\+/g, ' ')); - } - layer.createFeature('plane') - .origin([0.0, 0.0]) - .upperLeft([0, 90]) - .lowerRight([180, 0]) - .style({ - image: '/data/land_shallow_topo_2048.png', - opacity: opacity ? opacity : undefined - }); - myMap.bounds({left: 0, right: 180, bottom: 0, top: 90}); - myMap.draw(); - - myMap.onIdle(done); -}; diff --git a/testing/test-cases/selenium-tests/glPlane/testGlPlane.py b/testing/test-cases/selenium-tests/glPlane/testGlPlane.py deleted file mode 100644 index 79d801a80c..0000000000 --- a/testing/test-cases/selenium-tests/glPlane/testGlPlane.py +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env python - -import unittest - -from selenium_test import FirefoxTest, ChromeTest,\ - setUpModule, tearDownModule - - -class glPlaneBase(object): - testCase = ('glPlane',) - testRevision = 4 - - def loadPage(self, opacity=None): - self.resizeWindow(640, 480) - if opacity is None: - self.loadURL('glPlane/index.html') - else: - self.loadURL('glPlane/index.html?opacity=' + str(opacity)) - self.wait() - self.resizeWindow(640, 480) - - def testGlPlane(self): - self.loadPage() - - testName = 'drawGlPlane' - self.screenshotTest(testName) - - def testGlPlaneOpacity(self): - self.loadPage(0.4) - - testName = 'drawGlPlaneOpacity' - self.screenshotTest(testName) - - -class FirefoxOSM(glPlaneBase, FirefoxTest): - testCase = glPlaneBase.testCase + ('firefox',) - - -class ChromeOSM(glPlaneBase, ChromeTest): - testCase = glPlaneBase.testCase + ('chrome',) - - -if __name__ == '__main__': - unittest.main() diff --git a/testing/test-cases/selenium-tests/glTwoRenderers/include.js b/testing/test-cases/selenium-tests/glTwoRenderers/include.js index 1d8a1b2ad8..6e4a3ed5ea 100644 --- a/testing/test-cases/selenium-tests/glTwoRenderers/include.js +++ b/testing/test-cases/selenium-tests/glTwoRenderers/include.js @@ -4,11 +4,12 @@ window.startTest = function (done) { var myMap = geo.map({node: '#map', clampBounds: false, gcs: 'EPSG:4326'}); window.gjsmap = myMap; var layer2 = myMap.createLayer('feature'); - layer2.createFeature('plane') - .origin([-180, -90]) - .upperLeft([-180, 90]) - .lowerRight([180, -90]) - .style('image', '/data/land_shallow_topo_2048.png'); + layer2.createFeature('quad') + .data([{ + ul: {x: -180, y: 90}, + lr: {x: 180, y: -90}, + image: '/data/land_shallow_topo_2048.png' + }]) layer2.name = 'layer2'; myMap.center({x: -40, y: 0}); myMap.zoom(3.5);