Skip to content
Browse files

Feature parser interfaces

Parsers that read features from strings, objects, or dom elements should implement the right interface.  Among the read options is a callback that gets called after feature construction and before geometry construction.  This callback is called with the feature and the geometry type and returns a shared vertices structure.  The geometry is then constructed with this shared vertices structure before being added to the feature.
  • Loading branch information...
1 parent 9edf63f commit 9c8ec427138e558025803d955043b67830dc55d6 @tschaub tschaub committed Mar 4, 2013
Showing with 66 additions and 0 deletions.
  1. +66 −0 src/ol/parser/featureparser.js
View
66 src/ol/parser/featureparser.js
@@ -0,0 +1,66 @@
+goog.provide('ol.parser.DomFeatureParser');
+goog.provide('ol.parser.ObjectFeatureParser');
+goog.provide('ol.parser.ReadFeaturesOptions');
+goog.provide('ol.parser.StringFeatureParser');
+
+goog.require('ol.Feature');
+
+
+
+/**
+ * @interface
+ */
+ol.parser.DomFeatureParser = function() {};
+
+
+/**
+ * @param {Element|Document} node Document or element node.
+ * @param {ol.parser.ReadFeaturesOptions=} opt_options Feature reading options.
+ * @return {Array.<ol.Feature>} Array of features.
+ */
+ol.parser.DomFeatureParser.prototype.readFeaturesFromNode =
+ goog.abstractMethod;
+
+
+
+/**
+ * @interface
+ */
+ol.parser.ObjectFeatureParser = function() {};
+
+
+/**
+ * @param {Object} obj Object representing features.
+ * @param {ol.parser.ReadFeaturesOptions=} opt_options Feature reading options.
+ * @return {Array.<ol.Feature>} Array of features.
+ */
+ol.parser.ObjectFeatureParser.prototype.readFeaturesFromObject =
+ goog.abstractMethod;
+
+
+
+/**
+ * @interface
+ */
+ol.parser.StringFeatureParser = function() {};
+
+
+/**
+ * @param {string} data String data.
+ * @param {ol.parser.ReadFeaturesOptions=} opt_options Feature reading options.
+ * @return {Array.<ol.Feature>} Array of features.
+ */
+ol.parser.StringFeatureParser.prototype.readFeaturesFromString =
+ goog.abstractMethod;
+
+
+/**
+ * @typedef {function(ol.Feature, ol.geom.GeometryType):ol.geom.SharedVertices}
+ */
+ol.parser.ReadFeaturesCallback;
+
+
+/**
+ * @typedef {{callback: ol.parser.ReadFeaturesCallback}}
+ */
+ol.parser.ReadFeaturesOptions;

0 comments on commit 9c8ec42

Please sign in to comment.
Something went wrong with that request. Please try again.