Remove experimental ol.format code

This commit is contained in:
Tom Payne
2013-12-04 17:09:55 +01:00
parent ed5b8b6512
commit 6d96fbf44d
5 changed files with 0 additions and 338 deletions

View File

@@ -1,17 +0,0 @@
goog.provide('ol.format');
/**
* @param {function(Object, function(this: S, ol.Feature): T, S=)} reader
* Reader.
* @param {Object} object Object.
* @return {Array.<ol.Feature>}
* @template S,T
*/
ol.format.readAllFromObject = function(reader, object) {
var features = [];
reader(object, function(feature) {
features.push(feature);
});
return features;
};

View File

@@ -1,3 +0,0 @@
@exportClass ol.format.GeoJSON ol.format.GeoJSONOptions
@exportProperty ol.format.GeoJSON.prototype.readObject
@exportProperty ol.format.GeoJSON.prototype.readString

View File

@@ -1,171 +0,0 @@
// FIXME coordinate order
// FIXME reprojection
// FIXME support other geometry types
goog.provide('ol.format.GeoJSON');
goog.require('goog.asserts');
goog.require('goog.json');
goog.require('ol.Feature');
goog.require('ol.format.IReader');
goog.require('ol.geom.LineString');
goog.require('ol.geom.MultiLineString');
goog.require('ol.geom.MultiPolygon');
goog.require('ol.geom.Point');
goog.require('ol.geom.Polygon');
/**
* @constructor
* @implements {ol.format.IReader}
* @param {ol.format.GeoJSONOptions=} opt_options Options.
*/
ol.format.GeoJSON = function(opt_options) {
};
/**
* @param {GeoJSONGeometry} geometry Geometry.
* @private
* @return {ol.geom.Point} Point.
*/
ol.format.GeoJSON.readPointGeometry_ = function(geometry) {
goog.asserts.assert(geometry.type == 'Point');
return new ol.geom.Point(geometry.coordinates);
};
/**
* @param {GeoJSONGeometry} geometry Geometry.
* @private
* @return {ol.geom.LineString} LineString.
*/
ol.format.GeoJSON.readLineStringGeometry_ = function(geometry) {
goog.asserts.assert(geometry.type == 'LineString');
return new ol.geom.LineString(geometry.coordinates);
};
/**
* @param {GeoJSONGeometry} geometry Geometry.
* @private
* @return {ol.geom.MultiLineString} MultiLineString.
*/
ol.format.GeoJSON.readMultiLineStringGeometry_ = function(geometry) {
goog.asserts.assert(geometry.type == 'MultiLineString');
return new ol.geom.MultiLineString(geometry.coordinates);
};
/**
* @param {GeoJSONGeometry} geometry Geometry.
* @private
* @return {ol.geom.MultiPolygon} MultiPolygon.
*/
ol.format.GeoJSON.readMultiPolygonGeometry_ = function(geometry) {
goog.asserts.assert(geometry.type == 'MultiPolygon');
return new ol.geom.MultiPolygon(geometry.coordinates);
};
/**
* @param {GeoJSONGeometry} geometry Geometry.
* @private
* @return {ol.geom.Polygon} Polygon.
*/
ol.format.GeoJSON.readPolygonGeometry_ = function(geometry) {
goog.asserts.assert(geometry.type == 'Polygon');
return new ol.geom.Polygon(geometry.coordinates);
};
/**
* @param {GeoJSONObject} object Object.
* @param {function(this: S, ol.Feature): T} callback Callback.
* @param {S=} opt_obj Scope.
* @private
* @return {T} Callback result.
* @template S,T
*/
ol.format.GeoJSON.readFeature_ = function(object, callback, opt_obj) {
goog.asserts.assert(object.type == 'Feature');
var feature = /** @type {GeoJSONFeature} */ (object);
var geometryReader =
ol.format.GeoJSON.GEOMETRY_READERS_[feature.geometry.type];
goog.asserts.assert(goog.isDef(geometryReader));
var geometry = geometryReader(feature.geometry);
var f = new ol.Feature(geometry);
f.setId(feature.id);
if (goog.isDef(feature.properties)) {
f.setValues(feature.properties);
}
return callback.call(opt_obj, f);
};
/**
* @param {GeoJSONObject} object Object.
* @param {function(this: S, ol.Feature): T} callback Callback.
* @param {S=} opt_obj Scope.
* @private
* @return {T|undefined} Callback result.
* @template S,T
*/
ol.format.GeoJSON.readFeatureCollection_ = function(object, callback, opt_obj) {
goog.asserts.assert(object.type == 'FeatureCollection');
var featureCollection = /** @type {GeoJSONFeatureCollection} */ (object);
var features = featureCollection.features;
var i, ii;
for (i = 0, ii = features.length; i < ii; ++i) {
var result = ol.format.GeoJSON.readFeature_(features[i], callback, opt_obj);
if (result) {
return result;
}
}
return undefined;
};
/**
* @inheritDoc
*/
ol.format.GeoJSON.prototype.readObject = function(object, callback, opt_obj) {
var geoJSONObject = /** @type {GeoJSONObject} */ (object);
var objectReader = ol.format.GeoJSON.OBJECT_READERS_[geoJSONObject.type];
goog.asserts.assert(goog.isDef(objectReader));
return objectReader(geoJSONObject, callback, opt_obj);
};
/**
* @inheritDoc
*/
ol.format.GeoJSON.prototype.readString = function(string, callback, opt_obj) {
return this.readObject(goog.json.parse(string), callback, opt_obj);
};
/**
* @const
* @private
* @type {Object.<string, function(GeoJSONGeometry): ol.geom.Geometry>}
*/
ol.format.GeoJSON.GEOMETRY_READERS_ = {
'Point': ol.format.GeoJSON.readPointGeometry_,
'LineString': ol.format.GeoJSON.readLineStringGeometry_,
'Polygon': ol.format.GeoJSON.readPolygonGeometry_,
'MultiLineString': ol.format.GeoJSON.readMultiLineStringGeometry_,
'MultiPolygon': ol.format.GeoJSON.readMultiPolygonGeometry_
};
/**
* @const
* @private
* @type {Object.<string, function(GeoJSONObject, function(ol.Feature): *, *): *>}
*/
ol.format.GeoJSON.OBJECT_READERS_ = {
'Feature': ol.format.GeoJSON.readFeature_,
'FeatureCollection': ol.format.GeoJSON.readFeatureCollection_
};

View File

@@ -1,34 +0,0 @@
// FIXME add XML
// FIXME add IWriter
goog.provide('ol.format.IReader');
/**
* @interface
*/
ol.format.IReader = function() {
};
/**
* @param {Object} object Object.
* @param {function(this: S, ol.Feature): T} callback Callback.
* @param {S=} opt_obj Scope.
* @return {T|undefined} Callback result.
* @template S,T
*/
ol.format.IReader.prototype.readObject = function(object, callback, opt_obj) {
};
/**
* @param {string} string String.
* @param {function(this: S, ol.Feature): T} callback Callback.
* @param {S=} opt_obj Scope.
* @return {T|undefined} Callback result.
* @template S,T
*/
ol.format.IReader.prototype.readString = function(string, callback, opt_obj) {
};