diff --git a/externs/olx.js b/externs/olx.js index 5babe3e053..5cc76deff0 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -3704,206 +3704,6 @@ olx.source.ClusterOptions.prototype.projection; olx.source.ClusterOptions.prototype.source; -/** - * @typedef {{attributions: (Array.|undefined), - * format: ol.format.Feature, - * logo: (string|olx.LogoOptions|undefined), - * projection: ol.proj.ProjectionLike}} - * @api - */ -olx.source.FormatVectorOptions; - - -/** - * Attributions. - * @type {Array.|undefined} - * @api - */ -olx.source.FormatVectorOptions.prototype.attributions; - - -/** - * Format. - * @type {ol.format.Feature} - * @api - */ -olx.source.FormatVectorOptions.prototype.format; - - -/** - * Logo. - * @type {string|olx.LogoOptions|undefined} - * @api - */ -olx.source.FormatVectorOptions.prototype.logo; - - -/** - * Projection. - * @type {ol.proj.ProjectionLike} - * @api - */ -olx.source.FormatVectorOptions.prototype.projection; - - -/** - * @typedef {{attributions: (Array.|undefined), - * defaultProjection: ol.proj.ProjectionLike, - * logo: (string|olx.LogoOptions|undefined), - * object: (GeoJSONFeature|GeoJSONFeatureCollection|undefined), - * projection: ol.proj.ProjectionLike, - * text: (string|undefined), - * url: (string|undefined), - * urls: (Array.|undefined)}} - * @api - */ -olx.source.GeoJSONOptions; - - -/** - * Attributions. - * @type {Array.|undefined} - * @api - */ -olx.source.GeoJSONOptions.prototype.attributions; - - -/** - * Default projection. - * @type {ol.proj.ProjectionLike} - * @api - */ -olx.source.GeoJSONOptions.prototype.defaultProjection; - - -/** - * Logo. - * @type {string|olx.LogoOptions|undefined} - * @api - */ -olx.source.GeoJSONOptions.prototype.logo; - - -/** - * GeoJSON feature or feature collection. - * @type {GeoJSONFeature|GeoJSONFeatureCollection|undefined} - * @api - */ -olx.source.GeoJSONOptions.prototype.object; - - -/** - * Destination projection. If provided, features will be transformed to this - * projection. If not provided, features will not be transformed. - * @type {ol.proj.ProjectionLike} - * @api - */ -olx.source.GeoJSONOptions.prototype.projection; - - -/** - * Text. - * @type {string|undefined} - * @api - */ -olx.source.GeoJSONOptions.prototype.text; - - -/** - * URL. - * @type {string|undefined} - * @api - */ -olx.source.GeoJSONOptions.prototype.url; - - -/** - * URLs. - * @type {Array.|undefined} - * @api - */ -olx.source.GeoJSONOptions.prototype.urls; - - -/** - * @typedef {{attributions: (Array.|undefined), - * doc: (Document|undefined), - * logo: (string|olx.LogoOptions|undefined), - * node: (Node|undefined), - * projection: ol.proj.ProjectionLike, - * text: (string|undefined), - * url: (string|undefined), - * urls: (Array.|undefined)}} - * @api - */ -olx.source.GPXOptions; - - -/** - * Attributions. - * @type {Array.|undefined} - * @api - */ -olx.source.GPXOptions.prototype.attributions; - - -/** - * Document. - * @type {Document|undefined} - * @api - */ -olx.source.GPXOptions.prototype.doc; - - -/** - * Logo. - * @type {string|olx.LogoOptions|undefined} - * @api - */ -olx.source.GPXOptions.prototype.logo; - - -/** - * Node. - * @type {Node|undefined} - * @api - */ -olx.source.GPXOptions.prototype.node; - - -/** - * Destination projection. If provided, features will be transformed to this - * projection. If not provided, features will not be transformed. - * @type {ol.proj.ProjectionLike} - * @api - */ -olx.source.GPXOptions.prototype.projection; - - -/** - * Text. - * @type {string|undefined} - * @api - */ -olx.source.GPXOptions.prototype.text; - - -/** - * URL. - * @type {string|undefined} - * @api - */ -olx.source.GPXOptions.prototype.url; - - -/** - * URLs. - * @type {Array.|undefined} - * @api - */ -olx.source.GPXOptions.prototype.urls; - - /** * @typedef {{preemptive: (boolean|undefined), * url: string}} @@ -4140,129 +3940,6 @@ olx.source.TileVectorOptions.prototype.url; olx.source.TileVectorOptions.prototype.urls; -/** - * @typedef {{attributions: (Array.|undefined), - * defaultProjection: ol.proj.ProjectionLike, - * logo: (string|olx.LogoOptions|undefined), - * object: (GeoJSONObject|undefined), - * projection: ol.proj.ProjectionLike, - * text: (string|undefined), - * url: (string|undefined)}} - * @api - */ -olx.source.TopoJSONOptions; - - -/** - * Attributions. - * @type {Array.|undefined} - * @api - */ -olx.source.TopoJSONOptions.prototype.attributions; - - -/** - * Default projection. - * @type {ol.proj.ProjectionLike} - * @api - */ -olx.source.TopoJSONOptions.prototype.defaultProjection; - - -/** - * Logo. - * @type {string|olx.LogoOptions|undefined} - * @api - */ -olx.source.TopoJSONOptions.prototype.logo; - - -/** - * Object. - * @type {GeoJSONObject|undefined} - * @api - */ -olx.source.TopoJSONOptions.prototype.object; - - -/** - * Destination projection. If provided, features will be transformed to this - * projection. If not provided, features will not be transformed. - * @type {ol.proj.ProjectionLike} - * @api - */ -olx.source.TopoJSONOptions.prototype.projection; - - -/** - * Text. - * @type {string|undefined} - * @api - */ -olx.source.TopoJSONOptions.prototype.text; - - -/** - * URL. - * @type {string|undefined} - * @api - */ -olx.source.TopoJSONOptions.prototype.url; - - -/** - * @typedef {{altitudeMode: (ol.format.IGCZ|undefined), - * projection: ol.proj.ProjectionLike, - * text: (string|undefined), - * url: (string|undefined), - * urls: (Array.|undefined)}} - * @api - */ -olx.source.IGCOptions; - - -/** - * Altitude mode. Possible values are `barometric`, `gps`, and `none`. Default - * is `none`. - * @type {ol.format.IGCZ|undefined} - * @api - */ -olx.source.IGCOptions.prototype.altitudeMode; - - -/** - * Destination projection. If provided, features will be transformed to this - * projection. If not provided, features will not be transformed. - * @type {ol.proj.ProjectionLike} - * @api - */ -olx.source.IGCOptions.prototype.projection; - - -/** - * Text. - * @type {string|undefined} - * @api - */ -olx.source.IGCOptions.prototype.text; - - -/** - * URL. - * @type {string|undefined} - * @api - */ -olx.source.IGCOptions.prototype.url; - - -/** - * URLs. - * @type {Array.|undefined} - * @api - */ -olx.source.IGCOptions.prototype.urls; - - /** * @typedef {{url: (string|undefined), * displayDpi: (number|undefined), @@ -4362,103 +4039,6 @@ olx.source.ImageMapGuideOptions.prototype.imageLoadFunction; olx.source.ImageMapGuideOptions.prototype.params; -/** - * @typedef {{attributions: (Array.|undefined), - * defaultStyle: (Array.|undefined), - * doc: (Document|undefined), - * extractStyles: (boolean|undefined), - * logo: (string|olx.LogoOptions|undefined), - * node: (Node|undefined), - * projection: ol.proj.ProjectionLike, - * text: (string|undefined), - * url: (string|undefined), - * urls: (Array.|undefined)}} - * @api - */ -olx.source.KMLOptions; - - -/** - * Attributions. - * @type {Array.|undefined} - * @api - */ -olx.source.KMLOptions.prototype.attributions; - - -/** - * Default style. - * @type {Array.|undefined} - * @api - */ -olx.source.KMLOptions.prototype.defaultStyle; - - -/** - * Document. - * @type {Document|undefined} - * @api - */ -olx.source.KMLOptions.prototype.doc; - - -/** - * Extract styles from the KML document. Default is `true`. - * @type {boolean|undefined} - * @api - */ -olx.source.KMLOptions.prototype.extractStyles; - - -/** - * Logo. - * @type {string|olx.LogoOptions|undefined} - * @api - */ -olx.source.KMLOptions.prototype.logo; - - -/** - * Node. - * @type {Node|undefined} - * @api - */ -olx.source.KMLOptions.prototype.node; - - -/** - * Destination projection. If provided, features will be transformed to this - * projection. If not provided, features will not be transformed. - * @type {ol.proj.ProjectionLike} - * @api - */ -olx.source.KMLOptions.prototype.projection; - - -/** - * Text. - * @type {string|undefined} - * @api - */ -olx.source.KMLOptions.prototype.text; - - -/** - * URL. - * @type {string|undefined} - * @api - */ -olx.source.KMLOptions.prototype.url; - - -/** - * URLs. - * @type {Array.|undefined} - * @api - */ -olx.source.KMLOptions.prototype.urls; - - /** * @typedef {{layer: string, * tileLoadFunction: (ol.TileLoadFunctionType|undefined), @@ -4583,84 +4163,6 @@ olx.source.OSMOptions.prototype.url; olx.source.OSMOptions.prototype.wrapX; -/** - * @typedef {{attributions: (Array.|undefined), - * doc: (Document|undefined), - * logo: (string|olx.LogoOptions|undefined), - * node: (Node|undefined), - * projection: ol.proj.ProjectionLike, - * text: (string|undefined), - * url: (string|undefined), - * urls: (Array.|undefined)}} - * @api - */ -olx.source.OSMXMLOptions; - - -/** - * Attributions. - * @type {Array.|undefined} - * @api - */ -olx.source.OSMXMLOptions.prototype.attributions; - - -/** - * Document. - * @type {Document|undefined} - * @api - */ -olx.source.OSMXMLOptions.prototype.doc; - - -/** - * Logo. - * @type {string|olx.LogoOptions|undefined} - * @api - */ -olx.source.OSMXMLOptions.prototype.logo; - - -/** - * Node. - * @type {Node|undefined} - * @api - */ -olx.source.OSMXMLOptions.prototype.node; - - -/** - * Projection. - * @type {ol.proj.ProjectionLike} - * @api - */ -olx.source.OSMXMLOptions.prototype.projection; - - -/** - * Text. - * @type {string|undefined} - * @api - */ -olx.source.OSMXMLOptions.prototype.text; - - -/** - * URL. - * @type {string|undefined} - * @api - */ -olx.source.OSMXMLOptions.prototype.url; - - -/** - * URLs. - * @type {Array.|undefined} - * @api - */ -olx.source.OSMXMLOptions.prototype.urls; - - /** * @typedef {{attributions: (Array.|undefined), * canvasFunction: ol.CanvasFunctionType, @@ -5068,66 +4570,6 @@ olx.source.ImageStaticOptions.prototype.projection; olx.source.ImageStaticOptions.prototype.url; -/** - * @typedef {{attributions: (Array.|undefined), - * format: ol.format.Feature, - * loader: function(this: ol.source.ServerVector, ol.Extent, number, ol.proj.Projection), - * strategy: (function(ol.Extent, number): Array.|undefined), - * logo: (string|olx.LogoOptions|undefined), - * projection: ol.proj.ProjectionLike}} - * @api - */ -olx.source.ServerVectorOptions; - - -/** - * Attributions. - * @type {Array.|undefined} - * @api - */ -olx.source.ServerVectorOptions.prototype.attributions; - - -/** - * Format. - * @type {ol.format.Feature} - * @api - */ -olx.source.ServerVectorOptions.prototype.format; - - -/** - * Loading function. - * @type {function(this: ol.source.ServerVector, ol.Extent, number, ol.proj.Projection)} - * @api - */ -olx.source.ServerVectorOptions.prototype.loader; - - -/** - * Loading strategy. An {@link ol.loadingstrategy} or a custom function. - * Default is {@link ol.loadingstrategy.bbox}. - * @type {function(ol.Extent, number): Array.|undefined} - * @api - */ -olx.source.ServerVectorOptions.prototype.strategy; - - -/** - * Logo. - * @type {string|olx.LogoOptions|undefined} - * @api - */ -olx.source.ServerVectorOptions.prototype.logo; - - -/** - * Projection. - * @type {ol.proj.ProjectionLike} - * @api - */ -olx.source.ServerVectorOptions.prototype.projection; - /** * @typedef {{attributions: (Array.|undefined), * params: (Object.|undefined), @@ -5489,111 +4931,6 @@ olx.source.VectorOptions.prototype.projection; olx.source.VectorOptions.prototype.state; -/** - * @typedef {{arrayBuffer: (ArrayBuffer|undefined), - * attributions: (Array.|undefined), - * doc: (Document|undefined), - * format: ol.format.Feature, - * logo: (string|olx.LogoOptions|undefined), - * node: (Node|undefined), - * object: (Object|undefined), - * projection: ol.proj.ProjectionLike, - * text: (string|undefined), - * url: (string|undefined), - * urls: (Array.|undefined)}} - * @api - */ -olx.source.StaticVectorOptions; - - -/** - * Array buffer. - * @type {ArrayBuffer|undefined} - * @api - */ -olx.source.StaticVectorOptions.prototype.arrayBuffer; - - -/** - * Attributions. - * @type {Array.|undefined} - * @api - */ -olx.source.StaticVectorOptions.prototype.attributions; - - -/** - * Document. - * @type {Document|undefined} - * @api - */ -olx.source.StaticVectorOptions.prototype.doc; - - -/** - * Format. - * @type {ol.format.Feature} - * @api - */ -olx.source.StaticVectorOptions.prototype.format; - - -/** - * Logo. - * @type {string|olx.LogoOptions|undefined} - * @api - */ -olx.source.StaticVectorOptions.prototype.logo; - - -/** - * Node. - * @type {Node|undefined} - * @api - */ -olx.source.StaticVectorOptions.prototype.node; - - -/** - * Object. - * @type {Object|undefined} - * @api - */ -olx.source.StaticVectorOptions.prototype.object; - - -/** - * Projection. - * @type {ol.proj.ProjectionLike} - * @api - */ -olx.source.StaticVectorOptions.prototype.projection; - - -/** - * Text. - * @type {string|undefined} - * @api - */ -olx.source.StaticVectorOptions.prototype.text; - - -/** - * URL. - * @type {string|undefined} - * @api - */ -olx.source.StaticVectorOptions.prototype.url; - - -/** - * URLs. - * @type {Array.|undefined} - * @api - */ -olx.source.StaticVectorOptions.prototype.urls; - - /** * @typedef {{attributions: (Array.|undefined), * crossOrigin: (string|null|undefined), diff --git a/src/ol/loadingstrategy.jsdoc b/src/ol/loadingstrategy.jsdoc index baecef7850..7c917fb648 100644 --- a/src/ol/loadingstrategy.jsdoc +++ b/src/ol/loadingstrategy.jsdoc @@ -1,5 +1,4 @@ /** * Strategies for loading vector data. - * @see ol.source.ServerVector * @namespace ol.loadingstrategy */ diff --git a/src/ol/source/formatvectorsource.js b/src/ol/source/formatvectorsource.js deleted file mode 100644 index 8e3fd638d8..0000000000 --- a/src/ol/source/formatvectorsource.js +++ /dev/null @@ -1,127 +0,0 @@ -// FIXME consider delaying feature reading so projection can be provided by -// consumer (e.g. the view) - -goog.provide('ol.source.FormatVector'); - -goog.require('goog.asserts'); -goog.require('goog.dispose'); -goog.require('goog.events'); -goog.require('goog.net.EventType'); -goog.require('goog.net.XhrIo'); -goog.require('goog.net.XhrIo.ResponseType'); -goog.require('goog.userAgent'); -goog.require('ol.format.FormatType'); -goog.require('ol.has'); -goog.require('ol.source.State'); -goog.require('ol.source.Vector'); -goog.require('ol.xml'); - - - -/** - * @classdesc - * Abstract base class; normally only used for creating subclasses and not - * instantiated in apps. - * Base class for vector sources in one of the supported formats. - * - * @constructor - * @extends {ol.source.Vector} - * @param {olx.source.FormatVectorOptions} options Options. - */ -ol.source.FormatVector = function(options) { - - goog.base(this, { - attributions: options.attributions, - logo: options.logo, - projection: options.projection - }); - - /** - * @protected - * @type {ol.format.Feature} - */ - this.format = options.format; - -}; -goog.inherits(ol.source.FormatVector, ol.source.Vector); - - -/** - * @param {goog.Uri|string} url URL. - * @param {function(this: T, Array.)} success Success Callback. - * @param {function(this: T)} error Error callback. - * @param {T} thisArg Value to use as `this` when executing `success` or - * `error`. - * @template T - */ -ol.source.FormatVector.prototype.loadFeaturesFromURL = - function(url, success, error, thisArg) { - var xhrIo = new goog.net.XhrIo(); - var type = this.format.getType(); - var responseType; - // FIXME maybe use ResponseType.DOCUMENT? - if (type == ol.format.FormatType.BINARY && - ol.has.ARRAY_BUFFER) { - responseType = goog.net.XhrIo.ResponseType.ARRAY_BUFFER; - } else { - responseType = goog.net.XhrIo.ResponseType.TEXT; - } - xhrIo.setResponseType(responseType); - goog.events.listen(xhrIo, goog.net.EventType.COMPLETE, - /** - * @param {Event} event Event. - * @private - * @this {ol.source.FormatVector} - */ - function(event) { - var xhrIo = event.target; - goog.asserts.assertInstanceof(xhrIo, goog.net.XhrIo, - 'event.target/xhrIo is an instance of goog.net.XhrIo'); - if (xhrIo.isSuccess()) { - var type = this.format.getType(); - /** @type {ArrayBuffer|Document|Node|Object|string|undefined} */ - var source; - if (type == ol.format.FormatType.BINARY && - ol.has.ARRAY_BUFFER) { - source = xhrIo.getResponse(); - goog.asserts.assertInstanceof(source, ArrayBuffer, - 'source is an instance of ArrayBuffer'); - } else if (type == ol.format.FormatType.JSON) { - source = xhrIo.getResponseText(); - } else if (type == ol.format.FormatType.TEXT) { - source = xhrIo.getResponseText(); - } else if (type == ol.format.FormatType.XML) { - if (!goog.userAgent.IE) { - source = xhrIo.getResponseXml(); - } - if (!goog.isDefAndNotNull(source)) { - source = ol.xml.parse(xhrIo.getResponseText()); - } - } else { - goog.asserts.fail('unexpected format type'); - } - if (goog.isDefAndNotNull(source)) { - success.call(thisArg, this.readFeatures(source)); - } else { - this.setState(ol.source.State.ERROR); - goog.asserts.fail('undefined or null source'); - } - } else { - error.call(thisArg); - } - goog.dispose(xhrIo); - }, false, this); - xhrIo.send(url); -}; - - -/** - * @param {ArrayBuffer|Document|Node|Object|string} source Source. - * @return {Array.} Features. - * @api - */ -ol.source.FormatVector.prototype.readFeatures = function(source) { - var format = this.format; - var projection = this.getProjection(); - return format.readFeatures(source, {featureProjection: projection}); -}; diff --git a/src/ol/source/geojsonsource.js b/src/ol/source/geojsonsource.js deleted file mode 100644 index b1f11c89c7..0000000000 --- a/src/ol/source/geojsonsource.js +++ /dev/null @@ -1,37 +0,0 @@ -goog.provide('ol.source.GeoJSON'); - -goog.require('ol.format.GeoJSON'); -goog.require('ol.source.StaticVector'); - - - -/** - * @classdesc - * Static vector source in GeoJSON format - * - * @constructor - * @extends {ol.source.StaticVector} - * @fires ol.source.VectorEvent - * @param {olx.source.GeoJSONOptions=} opt_options Options. - * @api - */ -ol.source.GeoJSON = function(opt_options) { - - var options = goog.isDef(opt_options) ? opt_options : {}; - - goog.base(this, { - attributions: options.attributions, - extent: options.extent, - format: new ol.format.GeoJSON({ - defaultDataProjection: options.defaultProjection - }), - logo: options.logo, - object: options.object, - projection: options.projection, - text: options.text, - url: options.url, - urls: options.urls - }); - -}; -goog.inherits(ol.source.GeoJSON, ol.source.StaticVector); diff --git a/src/ol/source/gpxsource.js b/src/ol/source/gpxsource.js deleted file mode 100644 index 7f45499be7..0000000000 --- a/src/ol/source/gpxsource.js +++ /dev/null @@ -1,36 +0,0 @@ -goog.provide('ol.source.GPX'); - -goog.require('ol.format.GPX'); -goog.require('ol.source.StaticVector'); - - - -/** - * @classdesc - * Static vector source in GPX format - * - * @constructor - * @extends {ol.source.StaticVector} - * @fires ol.source.VectorEvent - * @param {olx.source.GPXOptions=} opt_options Options. - * @api - */ -ol.source.GPX = function(opt_options) { - - var options = goog.isDef(opt_options) ? opt_options : {}; - - goog.base(this, { - attributions: options.attributions, - doc: options.doc, - extent: options.extent, - format: new ol.format.GPX(), - logo: options.logo, - node: options.node, - projection: options.projection, - text: options.text, - url: options.url, - urls: options.urls - }); - -}; -goog.inherits(ol.source.GPX, ol.source.StaticVector); diff --git a/src/ol/source/igcsource.js b/src/ol/source/igcsource.js deleted file mode 100644 index ebe220bad7..0000000000 --- a/src/ol/source/igcsource.js +++ /dev/null @@ -1,33 +0,0 @@ -goog.provide('ol.source.IGC'); - -goog.require('ol.format.IGC'); -goog.require('ol.source.StaticVector'); - - - -/** - * @classdesc - * Static vector source in IGC format - * - * @constructor - * @extends {ol.source.StaticVector} - * @fires ol.source.VectorEvent - * @param {olx.source.IGCOptions=} opt_options Options. - * @api - */ -ol.source.IGC = function(opt_options) { - - var options = goog.isDef(opt_options) ? opt_options : {}; - - goog.base(this, { - format: new ol.format.IGC({ - altitudeMode: options.altitudeMode - }), - projection: options.projection, - text: options.text, - url: options.url, - urls: options.urls - }); - -}; -goog.inherits(ol.source.IGC, ol.source.StaticVector); diff --git a/src/ol/source/kmlsource.js b/src/ol/source/kmlsource.js deleted file mode 100644 index 13c30f7f8e..0000000000 --- a/src/ol/source/kmlsource.js +++ /dev/null @@ -1,38 +0,0 @@ -goog.provide('ol.source.KML'); - -goog.require('ol.format.KML'); -goog.require('ol.source.StaticVector'); - - - -/** - * @classdesc - * Static vector source in KML format - * - * @constructor - * @extends {ol.source.StaticVector} - * @fires ol.source.VectorEvent - * @param {olx.source.KMLOptions=} opt_options Options. - * @api - */ -ol.source.KML = function(opt_options) { - - var options = goog.isDef(opt_options) ? opt_options : {}; - - goog.base(this, { - attributions: options.attributions, - doc: options.doc, - format: new ol.format.KML({ - extractStyles: options.extractStyles, - defaultStyle: options.defaultStyle - }), - logo: options.logo, - node: options.node, - projection: options.projection, - text: options.text, - url: options.url, - urls: options.urls - }); - -}; -goog.inherits(ol.source.KML, ol.source.StaticVector); diff --git a/src/ol/source/osmxmlsource.js b/src/ol/source/osmxmlsource.js deleted file mode 100644 index d1ba44f49b..0000000000 --- a/src/ol/source/osmxmlsource.js +++ /dev/null @@ -1,35 +0,0 @@ -goog.provide('ol.source.OSMXML'); - -goog.require('ol.format.OSMXML'); -goog.require('ol.source.StaticVector'); - - - -/** - * @classdesc - * Static vector source in OSMXML format - * - * @constructor - * @extends {ol.source.StaticVector} - * @fires ol.source.VectorEvent - * @param {olx.source.OSMXMLOptions=} opt_options Options. - * @api - */ -ol.source.OSMXML = function(opt_options) { - - var options = goog.isDef(opt_options) ? opt_options : {}; - - goog.base(this, { - attributions: options.attributions, - doc: options.doc, - format: new ol.format.OSMXML(), - logo: options.logo, - node: options.node, - projection: options.projection, - text: options.text, - url: options.url, - urls: options.urls - }); - -}; -goog.inherits(ol.source.OSMXML, ol.source.StaticVector); diff --git a/src/ol/source/servervectorsource.js b/src/ol/source/servervectorsource.js deleted file mode 100644 index 8d36a4c0bc..0000000000 --- a/src/ol/source/servervectorsource.js +++ /dev/null @@ -1,126 +0,0 @@ -// FIXME cache expiration - -goog.provide('ol.source.ServerVector'); - -goog.require('goog.object'); -goog.require('ol.extent'); -goog.require('ol.loadingstrategy'); -goog.require('ol.source.FormatVector'); -goog.require('ol.structs.RBush'); - - - -/** - * @classdesc - * A vector source in one of the supported formats, using a custom function to - * read in the data from a remote server. - * - * @constructor - * @extends {ol.source.FormatVector} - * @param {olx.source.ServerVectorOptions} options Options. - * @api - */ -ol.source.ServerVector = function(options) { - - goog.base(this, { - attributions: options.attributions, - format: options.format, - logo: options.logo, - projection: options.projection - }); - - /** - * @private - * @type {ol.structs.RBush.<{extent: ol.Extent}>} - */ - this.loadedExtents_ = new ol.structs.RBush(); - - /** - * @private - * @type {function(this: ol.source.ServerVector, ol.Extent, number, - * ol.proj.Projection)} - */ - this.loader_ = options.loader; - - /** - * @private - * @type {function(ol.Extent, number): Array.} - */ - this.strategy_ = goog.isDef(options.strategy) ? - options.strategy : ol.loadingstrategy.bbox; - - /** - * @private - * @type {Object.} - */ - this.loadedFeatures_ = {}; - -}; -goog.inherits(ol.source.ServerVector, ol.source.FormatVector); - - -/** - * @inheritDoc - */ -ol.source.ServerVector.prototype.addFeaturesInternal = function(features) { - /** @type {Array.} */ - var notLoadedFeatures = []; - var i, ii; - for (i = 0, ii = features.length; i < ii; ++i) { - var feature = features[i]; - var featureId = feature.getId(); - if (!goog.isDef(featureId)) { - notLoadedFeatures.push(feature); - } else if (!(featureId in this.loadedFeatures_)) { - notLoadedFeatures.push(feature); - this.loadedFeatures_[featureId] = true; - } - } - goog.base(this, 'addFeaturesInternal', notLoadedFeatures); -}; - - -/** - * @inheritDoc - * @api stable - */ -ol.source.ServerVector.prototype.clear = function(opt_fast) { - goog.object.clear(this.loadedFeatures_); - this.loadedExtents_.clear(); - goog.base(this, 'clear', opt_fast); -}; - - -/** - * @inheritDoc - */ -ol.source.ServerVector.prototype.loadFeatures = - function(extent, resolution, projection) { - var loadedExtents = this.loadedExtents_; - var extentsToLoad = this.strategy_(extent, resolution); - var i, ii; - for (i = 0, ii = extentsToLoad.length; i < ii; ++i) { - var extentToLoad = extentsToLoad[i]; - var alreadyLoaded = loadedExtents.forEachInExtent(extentToLoad, - /** - * @param {{extent: ol.Extent}} object Object. - * @return {boolean} Contains. - */ - function(object) { - return ol.extent.containsExtent(object.extent, extentToLoad); - }); - if (!alreadyLoaded) { - this.loader_.call(this, extentToLoad, resolution, projection); - loadedExtents.insert(extentToLoad, {extent: extentToLoad.slice()}); - } - } -}; - - -/** - * @function - * @param {ArrayBuffer|Document|Node|Object|string} source Source. - * @return {Array.} Features. - * @api - */ -ol.source.ServerVector.prototype.readFeatures; diff --git a/src/ol/source/staticvectorsource.js b/src/ol/source/staticvectorsource.js deleted file mode 100644 index 30b5e330e7..0000000000 --- a/src/ol/source/staticvectorsource.js +++ /dev/null @@ -1,83 +0,0 @@ -goog.provide('ol.source.StaticVector'); - -goog.require('ol.source.FormatVector'); -goog.require('ol.source.State'); - - - -/** - * @classdesc - * A vector source that uses one of the supported formats to read the data from - * a file or other static source. - * - * @constructor - * @extends {ol.source.FormatVector} - * @fires ol.source.VectorEvent - * @param {olx.source.StaticVectorOptions} options Options. - * @api - */ -ol.source.StaticVector = function(options) { - - goog.base(this, { - attributions: options.attributions, - format: options.format, - logo: options.logo, - projection: options.projection - }); - - if (goog.isDef(options.arrayBuffer)) { - this.addFeaturesInternal(this.readFeatures(options.arrayBuffer)); - } - - if (goog.isDef(options.doc)) { - this.addFeaturesInternal(this.readFeatures(options.doc)); - } - - if (goog.isDef(options.node)) { - this.addFeaturesInternal(this.readFeatures(options.node)); - } - - if (goog.isDef(options.object)) { - this.addFeaturesInternal(this.readFeatures(options.object)); - } - - if (goog.isDef(options.text)) { - this.addFeaturesInternal(this.readFeatures(options.text)); - } - - if (goog.isDef(options.url) || goog.isDef(options.urls)) { - this.setState(ol.source.State.LOADING); - if (goog.isDef(options.url)) { - this.loadFeaturesFromURL(options.url, - this.onFeaturesLoadedSuccess_, this.onFeaturesLoadedError_, this); - } - if (goog.isDef(options.urls)) { - var urls = options.urls; - var i, ii; - for (i = 0, ii = urls.length; i < ii; ++i) { - this.loadFeaturesFromURL(urls[i], - this.onFeaturesLoadedSuccess_, this.onFeaturesLoadedError_, this); - } - } - } - -}; -goog.inherits(ol.source.StaticVector, ol.source.FormatVector); - - -/** - * @private - */ -ol.source.StaticVector.prototype.onFeaturesLoadedError_ = function() { - this.setState(ol.source.State.ERROR); -}; - - -/** - * @param {Array.} features Features. - * @private - */ -ol.source.StaticVector.prototype.onFeaturesLoadedSuccess_ = function(features) { - this.addFeaturesInternal(features); - this.setState(ol.source.State.READY); -}; diff --git a/src/ol/source/topojsonsource.js b/src/ol/source/topojsonsource.js deleted file mode 100644 index 8eec88abd1..0000000000 --- a/src/ol/source/topojsonsource.js +++ /dev/null @@ -1,36 +0,0 @@ -goog.provide('ol.source.TopoJSON'); - -goog.require('ol.format.TopoJSON'); -goog.require('ol.source.StaticVector'); - - - -/** - * @classdesc - * Static vector source in TopoJSON format - * - * @constructor - * @extends {ol.source.StaticVector} - * @fires ol.source.VectorEvent - * @param {olx.source.TopoJSONOptions=} opt_options Options. - * @api - */ -ol.source.TopoJSON = function(opt_options) { - - var options = goog.isDef(opt_options) ? opt_options : {}; - - goog.base(this, { - attributions: options.attributions, - extent: options.extent, - format: new ol.format.TopoJSON({ - defaultDataProjection: options.defaultProjection - }), - logo: options.logo, - object: options.object, - projection: options.projection, - text: options.text, - url: options.url - }); - -}; -goog.inherits(ol.source.TopoJSON, ol.source.StaticVector); diff --git a/test/spec/ol/source/servervectorsource.test.js b/test/spec/ol/source/servervectorsource.test.js deleted file mode 100644 index 17dd0786b3..0000000000 --- a/test/spec/ol/source/servervectorsource.test.js +++ /dev/null @@ -1,68 +0,0 @@ -goog.provide('ol.test.source.ServerVector'); - - -describe('ol.source.ServerVector', function() { - - describe('when empty', function() { - - var vectorSource; - beforeEach(function() { - vectorSource = new ol.source.ServerVector({}); - }); - - describe('#addFeatures', function() { - - it('adds features with the same id only once', function() { - var addfeatureSpy = sinon.spy(); - vectorSource.on('addfeature', addfeatureSpy); - features = []; - var i; - var feature; - for (i = 0; i < 5; i++) { - feature = new ol.Feature(); - feature.setId(0); - features.push(feature); - } - vectorSource.addFeatures(features); - expect(vectorSource.getFeatures().length).to.be(1); - expect(addfeatureSpy.callCount).to.be(1); - }); - - it('adds features all features with distinct ids', function() { - var addfeatureSpy = sinon.spy(); - vectorSource.on('addfeature', addfeatureSpy); - features = []; - var i; - var feature; - for (i = 0; i < 5; i++) { - feature = new ol.Feature(); - feature.setId(i); - features.push(feature); - } - vectorSource.addFeatures(features); - expect(vectorSource.getFeatures().length).to.be(5); - expect(addfeatureSpy.callCount).to.be(5); - }); - - it('adds features without ids', function() { - var addfeatureSpy = sinon.spy(); - vectorSource.on('addfeature', addfeatureSpy); - features = []; - var i; - for (i = 0; i < 10; i++) { - features.push(new ol.Feature()); - } - vectorSource.addFeatures(features); - expect(vectorSource.getFeatures().length).to.be(10); - expect(addfeatureSpy.callCount).to.be(10); - }); - - }); - - }); - -}); - - -goog.require('ol.Feature'); -goog.require('ol.source.ServerVector');