From 7b31ec26ea62f3a6b992c0594e6454684127bfee Mon Sep 17 00:00:00 2001 From: Bart van den Eijnden Date: Mon, 22 Jul 2013 17:51:12 +0200 Subject: [PATCH] fix up build --- src/objectliterals.jsdoc | 2 +- src/ol/layer/vectorlayer.js | 4 +-- src/ol/parser/featureparser.js | 2 +- src/ol/parser/geojson.js | 15 ++++++---- src/ol/parser/gpx.js | 31 ++++++++------------- src/ol/parser/kml.js | 50 ++++++++++++++++------------------ src/ol/parser/ogc/gml.js | 10 +++---- src/ol/source/vectorsource.js | 2 +- 8 files changed, 54 insertions(+), 62 deletions(-) diff --git a/src/objectliterals.jsdoc b/src/objectliterals.jsdoc index b6aaa4d5a4..70ef57ea1e 100644 --- a/src/objectliterals.jsdoc +++ b/src/objectliterals.jsdoc @@ -514,7 +514,7 @@ * @property {Object|string|undefined} data Data to parse. * @property {ol.Extent|undefined} extent Extent. * @property {string|undefined} logo Logo. - * @property {ol.parser.FeatureParser} parser Parser instance to parse data + * @property {ol.parser.Parser} parser Parser instance to parse data * provided as `data` or fetched from `url`. * @property {ol.ProjectionLike|undefined} projection Projection. EPSG:4326 * is assumed if not defined. TODO: Get projection from the parser instead diff --git a/src/ol/layer/vectorlayer.js b/src/ol/layer/vectorlayer.js index 01a5550035..f0746f61d7 100644 --- a/src/ol/layer/vectorlayer.js +++ b/src/ol/layer/vectorlayer.js @@ -418,7 +418,7 @@ ol.layer.Vector.prototype.groupFeaturesBySymbolizerLiteral = /** * @param {Object|Element|Document|string} data Feature data. - * @param {ol.parser.FeatureParser} parser Feature parser. + * @param {ol.parser.Parser} parser Feature parser. * @param {ol.Projection} projection This sucks. The layer should be a view in * one projection. */ @@ -462,7 +462,7 @@ ol.layer.Vector.prototype.parseFeatures = function(data, parser, projection) { this.addFeatures(features); }; - var options = {callback: callback}; + var options = {callback: callback}, result; if (goog.isString(data)) { if (goog.isFunction(parser.readFeaturesFromStringAsync)) { parser.readFeaturesFromStringAsync(data, goog.bind(addFeatures, this), diff --git a/src/ol/parser/featureparser.js b/src/ol/parser/featureparser.js index a249335789..ff27ede189 100644 --- a/src/ol/parser/featureparser.js +++ b/src/ol/parser/featureparser.js @@ -96,7 +96,7 @@ ol.parser.AsyncObjectFeatureParser = function() {}; /** * @param {Object} obj Object representing features. - * @param {function(Array.), ol.parser.ReadFeaturesMetadata} + * @param {function(Array., ol.parser.ReadFeaturesMetadata)} * callback Callback which is called * after parsing. * @param {ol.parser.ReadFeaturesOptions=} opt_options Feature reading options. diff --git a/src/ol/parser/geojson.js b/src/ol/parser/geojson.js index 8630f4b2cb..32b3857be6 100644 --- a/src/ol/parser/geojson.js +++ b/src/ol/parser/geojson.js @@ -16,6 +16,7 @@ goog.require('ol.geom.SharedVertices'); goog.require('ol.parser.Parser'); goog.require('ol.parser.ReadFeaturesOptions'); goog.require('ol.parser.StringFeatureParser'); +goog.require('ol.proj'); @@ -58,12 +59,13 @@ ol.parser.GeoJSON.read = function(str) { * Parse a GeoJSON feature collection. * @param {string} str GeoJSON feature collection. * @param {ol.parser.ReadFeaturesOptions=} opt_options Reader options. - * @return {Array.} Array of features. + * @return {ol.parser.ReadFeaturesResult} Features and metadata. */ -ol.parser.GeoJSON.prototype.readFeaturesFromString = +ol.parser.GeoJSON.prototype.readFeaturesWithMetadataFromString = function(str, opt_options) { var json = /** @type {GeoJSONFeatureCollection} */ (JSON.parse(str)); - return this.parseFeatureCollection_(json, opt_options); + return {features: this.parseFeatureCollection_(json, opt_options), + metadata: {projection: ol.proj.get('EPSG:4326')}}; }; @@ -72,11 +74,12 @@ ol.parser.GeoJSON.prototype.readFeaturesFromString = * @param {GeoJSONFeatureCollection} object GeoJSON feature collection decoded * from JSON. * @param {ol.parser.ReadFeaturesOptions=} opt_options Reader options. - * @return {Array.} Array of features. + * @return {ol.parser.ReadFeaturesResult} Features and metadata. */ -ol.parser.GeoJSON.prototype.readFeaturesFromObject = +ol.parser.GeoJSON.prototype.readFeaturesWithMetadataFromObject = function(object, opt_options) { - return this.parseFeatureCollection_(object, opt_options); + return {features: this.parseFeatureCollection_(object, opt_options), + metadata: {projection: ol.proj.get('EPSG:4326')}}; }; diff --git a/src/ol/parser/gpx.js b/src/ol/parser/gpx.js index 712102b81e..295c62d8e0 100644 --- a/src/ol/parser/gpx.js +++ b/src/ol/parser/gpx.js @@ -47,6 +47,7 @@ ol.parser.GPX = function(opt_options) { 'gpx': function(node, obj) { if (!goog.isDef(obj.features)) { obj.features = []; + obj.metadata = {projection: ol.proj.get('EPSG:4326')}; } this.readChildNodes(node, obj); }, @@ -233,17 +234,9 @@ ol.parser.GPX = function(opt_options) { goog.inherits(ol.parser.GPX, ol.parser.XML); -/** - * @inheritDoc - */ -ol.parser.GPX.prototype.getProjection = function() { - return ol.proj.get('EPSG:4326'); -}; - - /** * @param {string|Document|Element|Object} data Data to read. - * @return {Object} An object representing the document. + * @return {ol.parser.ReadFeaturesResult} An object representing the document. */ ol.parser.GPX.prototype.read = function(data) { if (goog.isString(data)) { @@ -252,7 +245,7 @@ ol.parser.GPX.prototype.read = function(data) { if (data && data.nodeType == 9) { data = data.documentElement; } - var obj = {}; + var obj = {features: [], metadata: {projection: ol.proj.get('EPSG:4326')}}; this.readNode(data, obj); return obj; }; @@ -262,12 +255,12 @@ ol.parser.GPX.prototype.read = function(data) { * Parse a GPX document provided as a string. * @param {string} str GPX document. * @param {ol.parser.ReadFeaturesOptions=} opt_options Reader options. - * @return {Array.} Array of features. + * @return {ol.parser.ReadFeaturesResult} Features and metadata. */ -ol.parser.GPX.prototype.readFeaturesFromString = +ol.parser.GPX.prototype.readFeaturesWithMetadataFromString = function(str, opt_options) { this.readFeaturesOptions_ = opt_options; - return this.read(str).features; + return this.read(str); }; @@ -275,24 +268,24 @@ ol.parser.GPX.prototype.readFeaturesFromString = * Parse a GPX document provided as a DOM structure. * @param {Element|Document} node Document or element node. * @param {ol.parser.ReadFeaturesOptions=} opt_options Feature reading options. - * @return {Array.} Array of features. + * @return {ol.parser.ReadFeaturesResult} Features and metadata. */ -ol.parser.GPX.prototype.readFeaturesFromNode = +ol.parser.GPX.prototype.readFeaturesWithMetadataFromNode = function(node, opt_options) { this.readFeaturesOptions_ = opt_options; - return this.read(node).features; + return this.read(node); }; /** * @param {Object} obj Object representing features. * @param {ol.parser.ReadFeaturesOptions=} opt_options Feature reading options. - * @return {Array.} Array of features. + * @return {ol.parser.ReadFeaturesResult} Features and metadata. */ -ol.parser.GPX.prototype.readFeaturesFromObject = +ol.parser.GPX.prototype.readFeaturesWithMetadataFromObject = function(obj, opt_options) { this.readFeaturesOptions_ = opt_options; - return this.read(obj).features; + return this.read(obj); }; diff --git a/src/ol/parser/kml.js b/src/ol/parser/kml.js index 91932449bd..021118d640 100644 --- a/src/ol/parser/kml.js +++ b/src/ol/parser/kml.js @@ -66,6 +66,7 @@ ol.parser.KML = function(opt_options) { 'kml': function(node, obj) { if (!goog.isDef(obj.features)) { obj.features = []; + obj.metadata = {projection: ol.proj.get('EPSG:4326')}; } if (!goog.isDef(obj.links)) { obj.links = []; @@ -822,7 +823,8 @@ goog.inherits(ol.parser.KML, ol.parser.XML); /** * @param {Object} obj Object representing features. - * @param {function(Array.)} callback Callback which is called + * @param {function(Array., ol.parser.ReadFeaturesMetadata)} + * callback Callback which is called * after parsing. * @param {ol.parser.ReadFeaturesOptions=} opt_options Feature reading options. */ @@ -834,15 +836,16 @@ ol.parser.KML.prototype.readFeaturesFromObjectAsync = /** - * @param {string} str KML document. - * @param {function(Array.)} callback Callback which is called + * @param {string} data String data. + * @param {function(Array., ol.parser.ReadFeaturesMetadata)} + * callback Callback which is called * after parsing. * @param {ol.parser.ReadFeaturesOptions=} opt_options Feature reading options. */ ol.parser.KML.prototype.readFeaturesFromStringAsync = - function(str, callback, opt_options) { + function(data, callback, opt_options) { this.readFeaturesOptions_ = opt_options; - this.read(str, callback); + this.read(data, callback); }; @@ -850,12 +853,12 @@ ol.parser.KML.prototype.readFeaturesFromStringAsync = * Parse a KML document provided as a string. * @param {string} str KML document. * @param {ol.parser.ReadFeaturesOptions=} opt_options Reader options. - * @return {Array.} Array of features. + * @return {ol.parser.ReadFeaturesResult} Features and metadata. */ -ol.parser.KML.prototype.readFeaturesFromString = +ol.parser.KML.prototype.readFeaturesWithMetadataFromString = function(str, opt_options) { this.readFeaturesOptions_ = opt_options; - return this.read(str).features; + return this.read(str); }; @@ -863,24 +866,24 @@ ol.parser.KML.prototype.readFeaturesFromString = * Parse a KML document provided as a DOM structure. * @param {Element|Document} node Document or element node. * @param {ol.parser.ReadFeaturesOptions=} opt_options Feature reading options. - * @return {Array.} Array of features. + * @return {ol.parser.ReadFeaturesResult} Features and metadata. */ -ol.parser.KML.prototype.readFeaturesFromNode = +ol.parser.KML.prototype.readFeaturesWithMetadataFromNode = function(node, opt_options) { this.readFeaturesOptions_ = opt_options; - return this.read(node).features; + return this.read(node); }; /** * @param {Object} obj Object representing features. * @param {ol.parser.ReadFeaturesOptions=} opt_options Feature reading options. - * @return {Array.} Array of features. + * @return {ol.parser.ReadFeaturesResult} Features and metadata. */ -ol.parser.KML.prototype.readFeaturesFromObject = +ol.parser.KML.prototype.readFeaturesWithMetadataFromObject = function(obj, opt_options) { this.readFeaturesOptions_ = opt_options; - return this.read(obj).features; + return this.read(obj); }; @@ -929,19 +932,12 @@ ol.parser.KML.prototype.parseLinks = function(deferreds, obj, done) { }; -/** - * @inheritDoc - */ -ol.parser.KML.prototype.getProjection = function() { - return ol.proj.get('EPSG:4326'); -}; - - /** * @param {string|Document|Element|Object} data Data to read. * @param {Function=} opt_callback Optional callback to call when reading * is done. - * @return {Object} An object representing the document. + * @return {ol.parser.ReadFeaturesResult} An object representing the + * document. */ ol.parser.KML.prototype.read = function(data, opt_callback) { if (goog.isString(data)) { @@ -950,7 +946,7 @@ ol.parser.KML.prototype.read = function(data, opt_callback) { if (data && data.nodeType == 9) { data = data.documentElement; } - var obj = {}; + var obj = {features: [], metadata: {projection: ol.proj.get('EPSG:4326')}}; this.readNode(data, obj); if (goog.isDef(opt_callback)) { var deferreds = []; @@ -964,15 +960,15 @@ ol.parser.KML.prototype.read = function(data, opt_callback) { var feature = obj.features[i]; this.applyStyle_(feature, obj['styles']); } - opt_callback.call(null, obj.features); + opt_callback.call(null, obj); }, function() { throw new Error('KML: parsing of NetworkLinks failed'); }, this); }); } else { - return obj; + return /* ol.parser.ReadFeaturesResult */(obj); } - return null; + return {features: null, metadata: {projection: ol.proj.get('EPSG:4326')}}; }; diff --git a/src/ol/parser/ogc/gml.js b/src/ol/parser/ogc/gml.js index f5c221655f..ea5a060894 100644 --- a/src/ol/parser/ogc/gml.js +++ b/src/ol/parser/ogc/gml.js @@ -455,7 +455,7 @@ goog.inherits(ol.parser.ogc.GML, ol.parser.XML); /** * @param {string|Document|Element|Object} data Data to read. - * @return {Object} An object representing the document. + * @return {ol.parser.ReadFeaturesResult} An object representing the document. */ ol.parser.ogc.GML.prototype.read = function(data) { if (typeof data == 'string') { @@ -464,7 +464,7 @@ ol.parser.ogc.GML.prototype.read = function(data) { if (data && data.nodeType == 9) { data = data.documentElement; } - var obj = {features: []}; + var obj = {features: [], metadata: {projection: null}}; this.readNode(data, obj, true); return obj; }; @@ -570,10 +570,10 @@ ol.parser.ogc.GML.prototype.createGeometry_ = function(container, * Parse a GML document provided as a string. * @param {string} str GML document. * @param {ol.parser.ReadFeaturesOptions=} opt_options Reader options. - * @return {Array.} Array of features. + * @return {ol.parser.ReadFeaturesResult} Features and metadata. */ -ol.parser.ogc.GML.prototype.readFeaturesFromString = +ol.parser.ogc.GML.prototype.readFeaturesWithMetadataFromString = function(str, opt_options) { this.readFeaturesOptions_ = opt_options; - return this.read(str).features; + return this.read(str); }; diff --git a/src/ol/source/vectorsource.js b/src/ol/source/vectorsource.js index 95a727f006..a53eb708cb 100644 --- a/src/ol/source/vectorsource.js +++ b/src/ol/source/vectorsource.js @@ -38,7 +38,7 @@ ol.source.Vector = function(options) { /** * @private - * @type {ol.parser.FeatureParser} + * @type {ol.parser.Parser} */ this.parser_ = goog.isDef(options.parser) ? options.parser : null;