Merge pull request #729 from bartvde/wktsingleton

static read and write methods on ol.parser.WKT (r=@ahocevar)
This commit is contained in:
Bart van den Eijnden
2013-05-30 00:29:53 -07:00
2 changed files with 23 additions and 0 deletions

View File

@@ -1,3 +1,5 @@
@exportSymbol ol.parser.WKT
@exportProperty ol.parser.WKT.prototype.read
@exportProperty ol.parser.WKT.prototype.write
@exportProperty ol.parser.WKT.read
@exportProperty ol.parser.WKT.write

View File

@@ -21,6 +21,7 @@ goog.require('ol.parser.Parser');
ol.parser.WKT = function() {
};
goog.inherits(ol.parser.WKT, ol.parser.Parser);
goog.addSingletonGetter(ol.parser.WKT);
/**
@@ -343,3 +344,23 @@ ol.parser.WKT.prototype.read = function(str) {
ol.parser.WKT.prototype.write = function(geom) {
return this.encode_(geom);
};
/**
* Parse a WKT string.
* @param {string} str WKT string.
* @return {ol.geom.Geometry|undefined} Parsed geometry.
*/
ol.parser.WKT.read = function(str) {
return ol.parser.WKT.getInstance().read(str);
};
/**
* Write out a geometry as a WKT string.
* @param {ol.geom.Geometry} geom The geometry to encode.
* @return {string} WKT for the geometry.
*/
ol.parser.WKT.write = function(geom) {
return ol.parser.WKT.getInstance().write(geom);
};