From 53963b0f6b5bcaab47c11ccb9ac3f34ffabeb560 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Fri, 8 Nov 2013 03:08:39 +0100 Subject: [PATCH] Add MultiLineString GeoJSON reading --- src/ol/reader/geojson/geojson.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/ol/reader/geojson/geojson.js b/src/ol/reader/geojson/geojson.js index 0bfe22a3ad..8eebad661d 100644 --- a/src/ol/reader/geojson/geojson.js +++ b/src/ol/reader/geojson/geojson.js @@ -8,6 +8,7 @@ goog.require('goog.asserts'); goog.require('goog.json'); goog.require('ol.Feature'); goog.require('ol.geom.LineString'); +goog.require('ol.geom.MultiLineString'); goog.require('ol.geom.Point'); goog.require('ol.geom.Polygon'); @@ -42,6 +43,17 @@ ol.reader.GeoJSON.readLineStringGeometry_ = function(geometry) { }; +/** + * @param {GeoJSONGeometry} geometry Geometry. + * @private + * @return {ol.geom.MultiLineString} MultiLineString. + */ +ol.reader.GeoJSON.readMultiLineStringGeometry_ = function(geometry) { + goog.asserts.assert(geometry.type == 'MultiLineString'); + return new ol.geom.MultiLineString(geometry.coordinates); +}; + + /** * @param {GeoJSONGeometry} geometry Geometry. * @private @@ -135,7 +147,8 @@ ol.reader.GeoJSON.readString = function(string, callback, opt_obj) { ol.reader.GeoJSON.GEOMETRY_READERS_ = { 'Point': ol.reader.GeoJSON.readPointGeometry_, 'LineString': ol.reader.GeoJSON.readLineStringGeometry_, - 'Polygon': ol.reader.GeoJSON.readPolygonGeometry_ + 'Polygon': ol.reader.GeoJSON.readPolygonGeometry_, + 'MultiLineString': ol.reader.GeoJSON.readMultiLineStringGeometry_ };