1 /* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD
2 * license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the
3 * full text of the license. */
6 * @requires OpenLayers/Util.js
7 * @requires OpenLayers/Console.js
11 * Class: OpenLayers.Format
12 * Base class for format reading/writing a variety of formats. Subclasses
13 * of OpenLayers.Format are expected to have read and write methods.
15 OpenLayers.Format = OpenLayers.Class({
19 * {Object} A reference to options passed to the constructor.
24 * APIProperty: externalProjection
25 * {<OpenLayers.Projection>} When passed a externalProjection and
26 * internalProjection, the format will reproject the geometries it
27 * reads or writes. The externalProjection is the projection used by
28 * the content which is passed into read or which comes out of write.
29 * In order to reproject, a projection transformation function for the
30 * specified projections must be available. This support may be
31 * provided via proj4js or via a custom transformation function. See
32 * {<OpenLayers.Projection.addTransform>} for more information on
33 * custom transformations.
35 externalProjection: null,
38 * APIProperty: internalProjection
39 * {<OpenLayers.Projection>} When passed a externalProjection and
40 * internalProjection, the format will reproject the geometries it
41 * reads or writes. The internalProjection is the projection used by
42 * the geometries which are returned by read or which are passed into
43 * write. In order to reproject, a projection transformation function
44 * for the specified projections must be available. This support may be
45 * provided via proj4js or via a custom transformation function. See
46 * {<OpenLayers.Projection.addTransform>} for more information on
47 * custom transformations.
49 internalProjection: null,
53 * {Object} When <keepData> is true, this is the parsed string sent to
59 * APIProperty: keepData
60 * {Object} Maintain a reference (<data>) to the most recently read data.
66 * Constructor: OpenLayers.Format
67 * Instances of this class are not useful. See one of the subclasses.
70 * options - {Object} An optional object with properties to set on the
74 * keepData - {Boolean} If true, upon <read>, the data property will be
75 * set to the parsed object (e.g. the json or xml object).
78 * An instance of OpenLayers.Format
80 initialize: function(options) {
81 OpenLayers.Util.extend(this, options);
82 this.options = options;
94 * Read data from a string, and return an object whose type depends on the
98 * data - {string} Data to read/parse.
101 * Depends on the subclass
103 read: function(data) {
104 OpenLayers.Console.userError(OpenLayers.i18n("readNotImplemented"));
109 * Accept an object, and return a string.
112 * object - {Object} Object to be serialized
115 * {String} A string representation of the object.
117 write: function(object) {
118 OpenLayers.Console.userError(OpenLayers.i18n("writeNotImplemented"));
121 CLASS_NAME: "OpenLayers.Format"