[76] | 1 | /* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for |
---|
| 2 | * full list of contributors). Published under the Clear BSD license. |
---|
| 3 | * See http://svn.openlayers.org/trunk/openlayers/license.txt for the |
---|
| 4 | * full text of the license. */ |
---|
| 5 | |
---|
| 6 | /** |
---|
| 7 | * @requires OpenLayers/Util.js |
---|
| 8 | * @requires OpenLayers/Console.js |
---|
| 9 | */ |
---|
| 10 | |
---|
| 11 | /** |
---|
| 12 | * Class: OpenLayers.Format |
---|
| 13 | * Base class for format reading/writing a variety of formats. Subclasses |
---|
| 14 | * of OpenLayers.Format are expected to have read and write methods. |
---|
| 15 | */ |
---|
| 16 | OpenLayers.Format = OpenLayers.Class({ |
---|
| 17 | |
---|
| 18 | /** |
---|
| 19 | * Property: options |
---|
| 20 | * {Object} A reference to options passed to the constructor. |
---|
| 21 | */ |
---|
| 22 | options: null, |
---|
| 23 | |
---|
| 24 | /** |
---|
| 25 | * APIProperty: externalProjection |
---|
| 26 | * {<OpenLayers.Projection>} When passed a externalProjection and |
---|
| 27 | * internalProjection, the format will reproject the geometries it |
---|
| 28 | * reads or writes. The externalProjection is the projection used by |
---|
| 29 | * the content which is passed into read or which comes out of write. |
---|
| 30 | * In order to reproject, a projection transformation function for the |
---|
| 31 | * specified projections must be available. This support may be |
---|
| 32 | * provided via proj4js or via a custom transformation function. See |
---|
| 33 | * {<OpenLayers.Projection.addTransform>} for more information on |
---|
| 34 | * custom transformations. |
---|
| 35 | */ |
---|
| 36 | externalProjection: null, |
---|
| 37 | |
---|
| 38 | /** |
---|
| 39 | * APIProperty: internalProjection |
---|
| 40 | * {<OpenLayers.Projection>} When passed a externalProjection and |
---|
| 41 | * internalProjection, the format will reproject the geometries it |
---|
| 42 | * reads or writes. The internalProjection is the projection used by |
---|
| 43 | * the geometries which are returned by read or which are passed into |
---|
| 44 | * write. In order to reproject, a projection transformation function |
---|
| 45 | * for the specified projections must be available. This support may be |
---|
| 46 | * provided via proj4js or via a custom transformation function. See |
---|
| 47 | * {<OpenLayers.Projection.addTransform>} for more information on |
---|
| 48 | * custom transformations. |
---|
| 49 | */ |
---|
| 50 | internalProjection: null, |
---|
| 51 | |
---|
| 52 | /** |
---|
| 53 | * APIProperty: data |
---|
| 54 | * {Object} When <keepData> is true, this is the parsed string sent to |
---|
| 55 | * <read>. |
---|
| 56 | */ |
---|
| 57 | data: null, |
---|
| 58 | |
---|
| 59 | /** |
---|
| 60 | * APIProperty: keepData |
---|
| 61 | * {Object} Maintain a reference (<data>) to the most recently read data. |
---|
| 62 | * Default is false. |
---|
| 63 | */ |
---|
| 64 | keepData: false, |
---|
| 65 | |
---|
| 66 | /** |
---|
| 67 | * Constructor: OpenLayers.Format |
---|
| 68 | * Instances of this class are not useful. See one of the subclasses. |
---|
| 69 | * |
---|
| 70 | * Parameters: |
---|
| 71 | * options - {Object} An optional object with properties to set on the |
---|
| 72 | * format |
---|
| 73 | * |
---|
| 74 | * Valid options: |
---|
| 75 | * keepData - {Boolean} If true, upon <read>, the data property will be |
---|
| 76 | * set to the parsed object (e.g. the json or xml object). |
---|
| 77 | * |
---|
| 78 | * Returns: |
---|
| 79 | * An instance of OpenLayers.Format |
---|
| 80 | */ |
---|
| 81 | initialize: function(options) { |
---|
| 82 | OpenLayers.Util.extend(this, options); |
---|
| 83 | this.options = options; |
---|
| 84 | }, |
---|
| 85 | |
---|
| 86 | /** |
---|
| 87 | * APIMethod: destroy |
---|
| 88 | * Clean up. |
---|
| 89 | */ |
---|
| 90 | destroy: function() { |
---|
| 91 | }, |
---|
| 92 | |
---|
| 93 | /** |
---|
| 94 | * Method: read |
---|
| 95 | * Read data from a string, and return an object whose type depends on the |
---|
| 96 | * subclass. |
---|
| 97 | * |
---|
| 98 | * Parameters: |
---|
| 99 | * data - {string} Data to read/parse. |
---|
| 100 | * |
---|
| 101 | * Returns: |
---|
| 102 | * Depends on the subclass |
---|
| 103 | */ |
---|
| 104 | read: function(data) { |
---|
| 105 | OpenLayers.Console.userError(OpenLayers.i18n("readNotImplemented")); |
---|
| 106 | }, |
---|
| 107 | |
---|
| 108 | /** |
---|
| 109 | * Method: write |
---|
| 110 | * Accept an object, and return a string. |
---|
| 111 | * |
---|
| 112 | * Parameters: |
---|
| 113 | * object - {Object} Object to be serialized |
---|
| 114 | * |
---|
| 115 | * Returns: |
---|
| 116 | * {String} A string representation of the object. |
---|
| 117 | */ |
---|
| 118 | write: function(object) { |
---|
| 119 | OpenLayers.Console.userError(OpenLayers.i18n("writeNotImplemented")); |
---|
| 120 | }, |
---|
| 121 | |
---|
| 122 | CLASS_NAME: "OpenLayers.Format" |
---|
| 123 | }); |
---|