From 4260368b3b4aad15251d666c5478dc42049bfa89 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Tue, 7 Apr 2015 14:19:51 -0600 Subject: [PATCH] Remove untested and unused binary feature format code --- src/ol/binary.js | 177 --------------------------- src/ol/format/binaryfeatureformat.js | 111 ----------------- 2 files changed, 288 deletions(-) delete mode 100644 src/ol/binary.js delete mode 100644 src/ol/format/binaryfeatureformat.js diff --git a/src/ol/binary.js b/src/ol/binary.js deleted file mode 100644 index 27e822d46d..0000000000 --- a/src/ol/binary.js +++ /dev/null @@ -1,177 +0,0 @@ -// FIXME Test on Internet Explorer with VBArray - -goog.provide('ol.binary.Buffer'); -goog.provide('ol.binary.IReader'); - -goog.require('goog.asserts'); -goog.require('goog.userAgent'); -goog.require('ol.has'); - - - -/** - * @constructor - * @param {ArrayBuffer|string} data Data. - */ -ol.binary.Buffer = function(data) { - - /** - * @private - * @type {ArrayBuffer|string} - */ - this.data_ = data; - -}; - - -/** - * @return {ol.binary.IReader} Reader. - */ -ol.binary.Buffer.prototype.getReader = function() { - var data = this.data_; - if (ol.has.ARRAY_BUFFER) { - var arrayBuffer; - if (data instanceof ArrayBuffer) { - arrayBuffer = data; - } else if (goog.isString(data)) { - // FIXME check what happens with Unicode - arrayBuffer = new ArrayBuffer(data.length); - var uint8View = new Uint8Array(arrayBuffer); - var i, ii; - for (i = 0, ii = data.length; i < ii; ++i) { - uint8View[i] = data.charCodeAt(i); - } - } else { - goog.asserts.fail('Unknown data type, should be string or ArrayBuffer'); - return null; - } - return new ol.binary.ArrayBufferReader(arrayBuffer); - } else { - goog.asserts.assert(goog.isString(data), 'Data should be a string'); - goog.asserts.assert( - goog.userAgent.IE && !goog.userAgent.isVersionOrHigher('10.0'), - 'In IE10 and above ArrayBuffer should be used instead'); - return new ol.binary.ArrayReader(new VBArray(data).toArray()); - } -}; - - - -/** - * @interface - */ -ol.binary.IReader = function() {}; - - -/** - * @return {boolean} At EOF. - */ -ol.binary.IReader.prototype.atEOF = function() {}; - - -/** - * @return {number} Byte. - */ -ol.binary.IReader.prototype.readByte = function() {}; - - - -/** - * @constructor - * @param {ArrayBuffer} arrayBuffer Array buffer. - * @implements {ol.binary.IReader} - */ -ol.binary.ArrayBufferReader = function(arrayBuffer) { - - /** - * @private - * @type {Uint8Array} - */ - this.uint8View_ = new Uint8Array(arrayBuffer); - - /** - * @private - * @type {number} - */ - this.length_ = this.uint8View_.length; - - /** - * @private - * @type {number} - */ - this.offset_ = 0; - -}; - - -/** - * @inheritDoc - */ -ol.binary.ArrayBufferReader.prototype.atEOF = function() { - return this.offset_ == this.length_; -}; - - -/** - * @inheritDoc - */ -ol.binary.ArrayBufferReader.prototype.readByte = function() { - if (this.offset_ < this.length_) { - return this.uint8View_[this.offset_++]; - } else { - goog.asserts.fail( - 'readByte fails because offset is larger than or equal to length'); - return 0; - } -}; - - - -/** - * @constructor - * @implements {ol.binary.IReader} - * @param {Array.} array Array. - */ -ol.binary.ArrayReader = function(array) { - - /** - * @private - * @type {Array.} - */ - this.array_ = array; - - /** - * @private - * @type {number} - */ - this.length_ = array.length; - - /** - * @private - * @type {number} - */ - this.offset_ = 0; - -}; - - -/** - * @inheritDoc - */ -ol.binary.ArrayReader.prototype.atEOF = function() { - return this.offset_ == this.length_; -}; - - -/** - * @inheritDoc - */ -ol.binary.ArrayReader.prototype.readByte = function() { - if (this.offset_ < this.length_) { - return this.array_[this.offset_++]; - } else { - goog.asserts.fail( - 'readByte fails because offset is larger than or equal to length'); - return 0; - } -}; diff --git a/src/ol/format/binaryfeatureformat.js b/src/ol/format/binaryfeatureformat.js deleted file mode 100644 index ff84c4dd2b..0000000000 --- a/src/ol/format/binaryfeatureformat.js +++ /dev/null @@ -1,111 +0,0 @@ -goog.provide('ol.format.BinaryFeature'); - -goog.require('goog.asserts'); -goog.require('ol.binary.Buffer'); -goog.require('ol.format.Feature'); -goog.require('ol.format.FormatType'); -goog.require('ol.has'); -goog.require('ol.proj'); - - - -/** - * @constructor - * @extends {ol.format.Feature} - */ -ol.format.BinaryFeature = function() { - goog.base(this); -}; -goog.inherits(ol.format.BinaryFeature, ol.format.Feature); - - -/** - * @param {ArrayBuffer|Document|Node|Object|string} source Source. - * @private - * @return {ol.binary.Buffer} Buffer. - */ -ol.format.BinaryFeature.getBuffer_ = function(source) { - if (ol.has.ARRAY_BUFFER && source instanceof ArrayBuffer) { - return new ol.binary.Buffer(source); - } else if (goog.isString(source)) { - return new ol.binary.Buffer(source); - } else { - goog.asserts.fail(); - return null; - } -}; - - -/** - * @inheritDoc - */ -ol.format.BinaryFeature.prototype.getType = function() { - return ol.format.FormatType.BINARY; -}; - - -/** - * @inheritDoc - */ -ol.format.BinaryFeature.prototype.readFeature = function(source) { - return this.readFeatureFromBuffer(ol.format.BinaryFeature.getBuffer_(source)); -}; - - -/** - * @inheritDoc - */ -ol.format.BinaryFeature.prototype.readFeatures = function(source) { - return this.readFeaturesFromBuffer( - ol.format.BinaryFeature.getBuffer_(source)); -}; - - -/** - * @param {ol.binary.Buffer} buffer Buffer. - * @protected - * @return {ol.Feature} Feature. - */ -ol.format.BinaryFeature.prototype.readFeatureFromBuffer = goog.abstractMethod; - - -/** - * @param {ol.binary.Buffer} buffer Buffer. - * @protected - * @return {Array.} Feature. - */ -ol.format.BinaryFeature.prototype.readFeaturesFromBuffer = goog.abstractMethod; - - -/** - * @inheritDoc - */ -ol.format.BinaryFeature.prototype.readGeometry = function(source) { - return this.readGeometryFromBuffer( - ol.format.BinaryFeature.getBuffer_(source)); -}; - - -/** - * @param {ol.binary.Buffer} buffer Buffer. - * @protected - * @return {ol.geom.Geometry} Geometry. - */ -ol.format.BinaryFeature.prototype.readGeometryFromBuffer = goog.abstractMethod; - - -/** - * @inheritDoc - */ -ol.format.BinaryFeature.prototype.readProjection = function(source) { - return this.readProjectionFromBuffer( - ol.format.BinaryFeature.getBuffer_(source)); -}; - - -/** - * @param {ol.binary.Buffer} buffer Buffer. - * @return {ol.proj.Projection} Projection. - */ -ol.format.BinaryFeature.prototype.readProjectionFromBuffer = - goog.abstractMethod;