Changeset 74


Ignore:
Timestamp:
Jan 14, 2011, 2:30:07 PM (14 years ago)
Author:
reluc
Message:

Add comments to ZOO-api.js, need to be continue

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/zoo-api/js/ZOO-api.js

    r26 r74  
    2323 */
    2424
     25/**
     26 * Class: ZOO
     27 */
    2528ZOO = {
     29  /**
     30   * Constant: SERVICE_ACCEPTED
     31   * {Integer} used for
     32   */
    2633  SERVICE_ACCEPTED: 0,
     34  /**
     35   * Constant: SERVICE_STARTED
     36   * {Integer} used for
     37   */
    2738  SERVICE_STARTED: 1,
     39  /**
     40   * Constant: SERVICE_PAUSED
     41   * {Integer} used for
     42   */
    2843  SERVICE_PAUSED: 2,
     44  /**
     45   * Constant: SERVICE_SUCCEEDED
     46   * {Integer} used for
     47   */
    2948  SERVICE_SUCCEEDED: 3,
     49  /**
     50   * Constant: SERVICE_FAILED
     51   * {Integer} used for
     52   */
    3053  SERVICE_FAILED: 4,
     54  /**
     55   * Function: removeItem
     56   * Remove an object from an array. Iterates through the array
     57   *     to find the item, then removes it.
     58   *
     59   * Parameters:
     60   * array - {Array}
     61   * item - {Object}
     62   *
     63   * Return
     64   * {Array} A reference to the array
     65   */
    3166  removeItem: function(array, item) {
    3267    for(var i = array.length - 1; i >= 0; i--) {
     
    3772    return array;
    3873  },
     74  /**
     75   * Function: indexOf
     76   *
     77   * Parameters:
     78   * array - {Array}
     79   * obj - {Object}
     80   *
     81   * Returns:
     82   * {Integer} The index at, which the first object was found in the array.
     83   *           If not found, returns -1.
     84   */
    3985  indexOf: function(array, obj) {
    4086    for(var i=0, len=array.length; i<len; i++) {
     
    4490    return -1;   
    4591  },
     92  /**
     93   * Function: extend
     94   * Copy all properties of a source object to a destination object. Modifies
     95   *     the passed in destination object.  Any properties on the source object
     96   *     that are set to undefined will not be (re)set on the destination object.
     97   *
     98   * Parameters:
     99   * destination - {Object} The object that will be modified
     100   * source - {Object} The object with properties to be set on the destination
     101   *
     102   * Returns:
     103   * {Object} The destination object.
     104   */
    46105  extend: function(destination, source) {
    47106    destination = destination || {};
     
    55114    return destination;
    56115  },
     116  /**
     117   * Function: Class
     118   * Method used to create ZOO classes. Includes support for
     119   *     multiple inheritance.
     120   */
    57121  Class: function() {
    58122    var Class = function() {
     
    64128      if(typeof arguments[i] == "function") {
    65129        // get the prototype of the superclass
    66               parent = arguments[i].prototype;
     130        parent = arguments[i].prototype;
    67131      } else {
    68132        // in this case we're extending with the prototype
     
    75139    return Class;
    76140  },
     141  /**
     142   * Function: UpdateStatus
     143   * Method used to update the status of the process
     144   *
     145   * Parameters:
     146   * env - {Object} The environment object
     147   * value - {Float} the status value between 0 to 100
     148   */
    77149  UpdateStatus: function(env,value) {
    78150    return ZOOUpdateStatus(env,value);
     
    80152};
    81153
    82 };
    83 
     154/**
     155 * Class: ZOO.String
     156 * Contains convenience methods for string manipulation
     157 */
    84158ZOO.String = {
     159  /**
     160   * Function: startsWith
     161   * Test whether a string starts with another string.
     162   *
     163   * Parameters:
     164   * str - {String} The string to test.
     165   * sub - {Sring} The substring to look for.
     166   * 
     167   * Returns:
     168   * {Boolean} The first string starts with the second.
     169   */
    85170  startsWith: function(str, sub) {
    86171    return (str.indexOf(sub) == 0);
    87172  },
     173  /**
     174   * Function: contains
     175   * Test whether a string contains another string.
     176   *
     177   * Parameters:
     178   * str - {String} The string to test.
     179   * sub - {String} The substring to look for.
     180   *
     181   * Returns:
     182   * {Boolean} The first string contains the second.
     183   */
    88184  contains: function(str, sub) {
    89185    return (str.indexOf(sub) != -1);
    90186  },
     187  /**
     188   * Function: trim
     189   * Removes leading and trailing whitespace characters from a string.
     190   *
     191   * Parameters:
     192   * str - {String} The (potentially) space padded string.  This string is not
     193   *     modified.
     194   *
     195   * Returns:
     196   * {String} A trimmed version of the string with all leading and
     197   *     trailing spaces removed.
     198   */
    91199  trim: function(str) {
    92200    return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
    93201  },
     202  /**
     203   * Function: camelize
     204   * Camel-case a hyphenated string.
     205   *     Ex. "chicken-head" becomes "chickenHead", and
     206   *     "-chicken-head" becomes "ChickenHead".
     207   *
     208   * Parameters:
     209   * str - {String} The string to be camelized.  The original is not modified.
     210   *
     211   * Returns:
     212   * {String} The string, camelized
     213   *
     214   */
    94215  camelize: function(str) {
    95216    var oStringList = str.split('-');
     
    101222    return camelizedString;
    102223  },
     224  /**
     225   * Property: tokenRegEx
     226   * Used to find tokens in a string.
     227   * Examples: ${a}, ${a.b.c}, ${a-b}, ${5}
     228   */
    103229  tokenRegEx:  /\$\{([\w.]+?)\}/g,
     230  /**
     231   * Property: numberRegEx
     232   * Used to test strings as numbers.
     233   */
    104234  numberRegEx: /^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/,
     235  /**
     236   * Function: isNumeric
     237   * Determine whether a string contains only a numeric value.
     238   *
     239   * Examples:
     240   * (code)
     241   * ZOO.String.isNumeric("6.02e23") // true
     242   * ZOO.String.isNumeric("12 dozen") // false
     243   * ZOO.String.isNumeric("4") // true
     244   * ZOO.String.isNumeric(" 4 ") // false
     245   * (end)
     246   *
     247   * Returns:
     248   * {Boolean} String contains only a number.
     249   */
    105250  isNumeric: function(value) {
    106251    return ZOO.String.numberRegEx.test(value);
    107252  },
     253  /**
     254   * Function: numericIf
     255   * Converts a string that appears to be a numeric value into a number.
     256   *
     257   * Returns
     258   * {Number|String} a Number if the passed value is a number, a String
     259   *     otherwise.
     260   */
    108261  numericIf: function(value) {
    109262    return ZOO.String.isNumeric(value) ? parseFloat(value) : value;
     
    111264};
    112265
     266/**
     267 * Class: ZOO.Request
     268 * Contains convenience methods for working with ZOORequest which
     269 *     replace XMLHttpRequest. Because of we are not in a browser
     270 *     JavaScript environment, ZOO Project provides a method to
     271 *     query servers which is based on curl : ZOORequest.
     272 */
    113273ZOO.Request = {
     274  /**
     275   * Function: GET
     276   * Send an HTTP GET request.
     277   *
     278   * Parameters:
     279   * url - {String} The URL to request.
     280   * params - {Object} Params to add to the url
     281   *
     282   * Returns:
     283   * {String} Request result.
     284   */
    114285  Get: function(url,params) {
    115286    var paramsArray = [];
     
    140311    return ZOORequest('GET',url);
    141312  },
     313  /**
     314   * Function: POST
     315   * Send an HTTP POST request.
     316   *
     317   * Parameters:
     318   * url - {String} The URL to request.
     319   * body - {String} The request's body to send.
     320   * headers - {Object} A key-value object of headers to push to
     321   *     the request's head
     322   *
     323   * Returns:
     324   * {String} Request result.
     325   */
    142326  Post: function(url,body,headers) {
    143327    if(!(headers instanceof Array)) {
    144328      var headersArray = [];
    145       for (var hname in headers) {
     329      for (var name in headers) {
    146330        headersArray.push(name+': '+headers[name]);
    147331      }
     
    152336};
    153337
     338/**
     339 * Class: ZOO.Bounds
     340 * Instances of this class represent bounding boxes.  Data stored as left,
     341 *     bottom, right, top floats. All values are initialized to null,
     342 *     however, you should make sure you set them before using the bounds
     343 *     for anything.
     344 */
    154345ZOO.Bounds = ZOO.Class({
     346  /**
     347   * Property: left
     348   * {Number} Minimum horizontal coordinate.
     349   */
    155350  left: null,
     351  /**
     352   * Property: bottom
     353   * {Number} Minimum vertical coordinate.
     354   */
    156355  bottom: null,
     356  /**
     357   * Property: right
     358   * {Number} Maximum horizontal coordinate.
     359   */
    157360  right: null,
     361  /**
     362   * Property: top
     363   * {Number} Maximum vertical coordinate.
     364   */
    158365  top: null,
     366  /**
     367   * Constructor: ZOO.Bounds
     368   * Construct a new bounds object.
     369   *
     370   * Parameters:
     371   * left - {Number} The left bounds of the box.  Note that for width
     372   *        calculations, this is assumed to be less than the right value.
     373   * bottom - {Number} The bottom bounds of the box.  Note that for height
     374   *          calculations, this is assumed to be more than the top value.
     375   * right - {Number} The right bounds.
     376   * top - {Number} The top bounds.
     377   */
    159378  initialize: function(left, bottom, right, top) {
    160379    if (left != null)
     
    167386      this.top = parseFloat(top);
    168387  },
     388  /**
     389   * Method: clone
     390   * Create a cloned instance of this bounds.
     391   *
     392   * Returns:
     393   * {<ZOO.Bounds>} A fresh copy of the bounds
     394   */
    169395  clone:function() {
    170396    return new ZOO.Bounds(this.left, this.bottom,
    171397                          this.right, this.top);
    172398  },
     399  /**
     400   * Method: equals
     401   * Test a two bounds for equivalence.
     402   *
     403   * Parameters:
     404   * bounds - {<ZOO.Bounds>}
     405   *
     406   * Returns:
     407   * {Boolean} The passed-in bounds object has the same left,
     408   *           right, top, bottom components as this.  Note that if bounds
     409   *           passed in is null, returns false.
     410   */
    173411  equals:function(bounds) {
    174412    var equals = false;
     
    180418    return equals;
    181419  },
     420  /**
     421   * Method: toString
     422   *
     423   * Returns:
     424   * {String} String representation of bounds object.
     425   *          (ex.<i>"left-bottom=(5,42) right-top=(10,45)"</i>)
     426   */
    182427  toString:function() {
    183428    return ( "left-bottom=(" + this.left + "," + this.bottom + ")"
    184429              + " right-top=(" + this.right + "," + this.top + ")" );
    185430  },
     431  /**
     432   * APIMethod: toArray
     433   *
     434   * Returns:
     435   * {Array} array of left, bottom, right, top
     436   */
    186437  toArray: function() {
    187438    return [this.left, this.bottom, this.right, this.top];
    188439  },
     440  /**
     441   * Method: toBBOX
     442   *
     443   * Parameters:
     444   * decimal - {Integer} How many significant digits in the bbox coords?
     445   *                     Default is 6
     446   *
     447   * Returns:
     448   * {String} Simple String representation of bounds object.
     449   *          (ex. <i>"5,42,10,45"</i>)
     450   */
    189451  toBBOX:function(decimal) {
    190452    if (decimal== null)
     
    197459    return bbox;
    198460  },
     461  /**
     462   * Method: toGeometry
     463   * Create a new polygon geometry based on this bounds.
     464   *
     465   * Returns:
     466   * {<ZOO.Geometry.Polygon>} A new polygon with the coordinates
     467   *     of this bounds.
     468   */
    199469  toGeometry: function() {
    200470    return new ZOO.Geometry.Polygon([
     
    207477    ]);
    208478  },
     479  /**
     480   * Method: getWidth
     481   *
     482   * Returns:
     483   * {Float} The width of the bounds
     484   */
    209485  getWidth:function() {
    210486    return (this.right - this.left);
    211487  },
     488  /**
     489   * Method: getHeight
     490   *
     491   * Returns:
     492   * {Float} The height of the bounds (top minus bottom).
     493   */
    212494  getHeight:function() {
    213495    return (this.top - this.bottom);
    214496  },
     497  /**
     498   * Method: add
     499   *
     500   * Parameters:
     501   * x - {Float}
     502   * y - {Float}
     503   *
     504   * Returns:
     505   * {<ZOO.Bounds>} A new bounds whose coordinates are the same as
     506   *     this, but shifted by the passed-in x and y values.
     507   */
    215508  add:function(x, y) {
    216509    if ( (x == null) || (y == null) )
     
    219512                                 this.right + x, this.top + y);
    220513  },
     514  /**
     515   * Method: extend
     516   * Extend the bounds to include the point, lonlat, or bounds specified.
     517   *     Note, this function assumes that left < right and bottom < top.
     518   *
     519   * Parameters:
     520   * object - {Object} Can be Point, or Bounds
     521   */
    221522  extend:function(object) {
    222523    var bounds = null;
     
    244545    }
    245546  },
     547  /**
     548   * APIMethod: contains
     549   *
     550   * Parameters:
     551   * x - {Float}
     552   * y - {Float}
     553   * inclusive - {Boolean} Whether or not to include the border.
     554   *     Default is true.
     555   *
     556   * Returns:
     557   * {Boolean} Whether or not the passed-in coordinates are within this
     558   *     bounds.
     559   */
    246560  contains:function(x, y, inclusive) {
    247561     //set default
     
    262576     return contains;
    263577  },
     578  /**
     579   * Method: intersectsBounds
     580   * Determine whether the target bounds intersects this bounds.  Bounds are
     581   *     considered intersecting if any of their edges intersect or if one
     582   *     bounds contains the other.
     583   *
     584   * Parameters:
     585   * bounds - {<ZOO.Bounds>} The target bounds.
     586   * inclusive - {Boolean} Treat coincident borders as intersecting.  Default
     587   *     is true.  If false, bounds that do not overlap but only touch at the
     588   *     border will not be considered as intersecting.
     589   *
     590   * Returns:
     591   * {Boolean} The passed-in bounds object intersects this bounds.
     592   */
    264593  intersectsBounds:function(bounds, inclusive) {
    265594    if (inclusive == null)
     
    293622    return intersects;
    294623  },
     624  /**
     625   * Method: containsBounds
     626   * Determine whether the target bounds is contained within this bounds.
     627   *
     628   * bounds - {<ZOO.Bounds>} The target bounds.
     629   * partial - {Boolean} If any of the target corners is within this bounds
     630   *     consider the bounds contained.  Default is false.  If true, the
     631   *     entire target bounds must be contained within this bounds.
     632   * inclusive - {Boolean} Treat shared edges as contained.  Default is
     633   *     true.
     634   *
     635   * Returns:
     636   * {Boolean} The passed-in bounds object is contained within this bounds.
     637   */
    295638  containsBounds:function(bounds, partial, inclusive) {
    296639    if (partial == null)
     
    308651});
    309652
     653/**
     654 * Class: ZOO.Projection
     655 * Class for coordinate transforms between coordinate systems.
     656 *     Depends on the zoo-proj4js library. zoo-proj4js library
     657 *     is loaded by the ZOO Kernel with zoo-api.
     658 */
    310659ZOO.Projection = ZOO.Class({
     660  /**
     661   * Property: proj
     662   * {Object} Proj4js.Proj instance.
     663   */
    311664  proj: null,
     665  /**
     666   * Property: projCode
     667   * {String}
     668   */
    312669  projCode: null,
     670  /**
     671   * Constructor: OpenLayers.Projection
     672   * This class offers several methods for interacting with a wrapped
     673   *     zoo-pro4js projection object.
     674   *
     675   * Parameters:
     676   * projCode - {String} A string identifying the Well Known Identifier for
     677   *    the projection.
     678   * options - {Object} An optional object to set additional properties.
     679   *
     680   * Returns:
     681   * {<ZOO.Projection>} A projection object.
     682   */
    313683  initialize: function(projCode, options) {
    314684    ZOO.extend(this, options);
     
    318688    }
    319689  },
     690  /**
     691   * Method: getCode
     692   * Get the string SRS code.
     693   *
     694   * Returns:
     695   * {String} The SRS code.
     696   */
    320697  getCode: function() {
    321698    return this.proj ? this.proj.srsCode : this.projCode;
    322699  },
     700  /**
     701   * Method: getUnits
     702   * Get the units string for the projection -- returns null if
     703   *     zoo-proj4js is not available.
     704   *
     705   * Returns:
     706   * {String} The units abbreviation.
     707   */
    323708  getUnits: function() {
    324709    return this.proj ? this.proj.units : null;
    325710  },
     711  /**
     712   * Method: toString
     713   * Convert projection to string (getCode wrapper).
     714   *
     715   * Returns:
     716   * {String} The projection code.
     717   */
    326718  toString: function() {
    327719    return this.getCode();
    328720  },
     721  /**
     722   * Method: equals
     723   * Test equality of two projection instances.  Determines equality based
     724   *     soley on the projection code.
     725   *
     726   * Returns:
     727   * {Boolean} The two projections are equivalent.
     728   */
    329729  equals: function(projection) {
    330730    if (projection && projection.getCode)
     
    333733      return false;
    334734  },
     735  /* Method: destroy
     736   * Destroy projection object.
     737   */
    335738  destroy: function() {
    336739    this.proj = null;
     
    339742  CLASS_NAME: 'ZOO.Projection'
    340743});
     744/**
     745 * Method: transform
     746 * Transform a point coordinate from one projection to another.  Note that
     747 *     the input point is transformed in place.
     748 *
     749 * Parameters:
     750 * point - {{ZOO.Geometry.Point> | Object} An object with x and y
     751 *     properties representing coordinates in those dimensions.
     752 * sourceProj - {OpenLayers.Projection} Source map coordinate system
     753 * destProj - {OpenLayers.Projection} Destination map coordinate system
     754 *
     755 * Returns:
     756 * point - {object} A transformed coordinate.  The original point is modified.
     757 */
    341758ZOO.Projection.transform = function(point, source, dest) {
    342759    if (source.proj && dest.proj)
     
    345762};
    346763
     764/**
     765 * Class: ZOO.Format
     766 * Base class for format reading/writing a variety of formats. Subclasses
     767 *     of ZOO.Format are expected to have read and write methods.
     768 */
    347769ZOO.Format = ZOO.Class({
     770  /**
     771   * Property: options
     772   * {Object} A reference to options passed to the constructor.
     773   */
    348774  options:null,
     775  /**
     776   * Property: externalProjection
     777   * {<ZOO.Projection>} When passed a externalProjection and
     778   *     internalProjection, the format will reproject the geometries it
     779   *     reads or writes. The externalProjection is the projection used by
     780   *     the content which is passed into read or which comes out of write.
     781   *     In order to reproject, a projection transformation function for the
     782   *     specified projections must be available. This support is provided
     783   *     via zoo-proj4js.
     784   */
    349785  externalProjection: null,
     786  /**
     787   * Property: internalProjection
     788   * {<ZOO.Projection>} When passed a externalProjection and
     789   *     internalProjection, the format will reproject the geometries it
     790   *     reads or writes. The internalProjection is the projection used by
     791   *     the geometries which are returned by read or which are passed into
     792   *     write.  In order to reproject, a projection transformation function
     793   *     for the specified projections must be available. This support is
     794   *     provided via zoo-proj4js.
     795   */
    350796  internalProjection: null,
     797  /**
     798   * Property: data
     799   * {Object} When <keepData> is true, this is the parsed string sent to
     800   *     <read>.
     801   */
    351802  data: null,
     803  /**
     804   * Property: keepData
     805   * {Object} Maintain a reference (<data>) to the most recently read data.
     806   *     Default is false.
     807   */
    352808  keepData: false,
     809  /**
     810   * Constructor: ZOO.Format
     811   * Instances of this class are not useful.  See one of the subclasses.
     812   *
     813   * Parameters:
     814   * options - {Object} An optional object with properties to set on the
     815   *           format
     816   *
     817   * Valid options:
     818   * keepData - {Boolean} If true, upon <read>, the data property will be
     819   *     set to the parsed object (e.g. the json or xml object).
     820   *
     821   * Returns:
     822   * An instance of ZOO.Format
     823   */
    353824  initialize: function(options) {
    354825    ZOO.extend(this, options);
    355826    this.options = options;
    356827  },
     828  /**
     829   * Method: destroy
     830   * Clean up.
     831   */
    357832  destroy: function() {
    358833  },
     834  /**
     835   * Method: read
     836   * Read data from a string, and return an object whose type depends on the
     837   * subclass.
     838   *
     839   * Parameters:
     840   * data - {string} Data to read/parse.
     841   *
     842   * Returns:
     843   * Depends on the subclass
     844   */
    359845  read: function(data) {
    360846  },
     847  /**
     848   * Method: write
     849   * Accept an object, and return a string.
     850   *
     851   * Parameters:
     852   * object - {Object} Object to be serialized
     853   *
     854   * Returns:
     855   * {String} A string representation of the object.
     856   */
    361857  write: function(data) {
    362858  },
    363859  CLASS_NAME: 'ZOO.Format'
    364860});
     861/**
     862 * Class: ZOO.Format.WKT
     863 * Class for reading and writing Well-Known Text. Create a new instance
     864 * with the <ZOO.Format.WKT> constructor.
     865 *
     866 * Inherits from:
     867 *  - <ZOO.Format>
     868 */
    365869ZOO.Format.WKT = ZOO.Class(ZOO.Format, {
     870  /**
     871   * Constructor: ZOO.Format.WKT
     872   * Create a new parser for WKT
     873   *
     874   * Parameters:
     875   * options - {Object} An optional object whose properties will be set on
     876   *           this instance
     877   *
     878   * Returns:
     879   * {<ZOO.Format.WKT>} A new WKT parser.
     880   */
    366881  initialize: function(options) {
    367882    this.regExes = {
     
    374889    ZOO.Format.prototype.initialize.apply(this, [options]);
    375890  },
     891  /**
     892   * Method: read
     893   * Deserialize a WKT string and return a vector feature or an
     894   *     array of vector features.  Supports WKT for POINT,
     895   *     MULTIPOINT, LINESTRING, MULTILINESTRING, POLYGON,
     896   *     MULTIPOLYGON, and GEOMETRYCOLLECTION.
     897   *
     898   * Parameters:
     899   * wkt - {String} A WKT string
     900   *
     901   * Returns:
     902   * {<ZOO.Feature.Vector>|Array} A feature or array of features for
     903   *     GEOMETRYCOLLECTION WKT.
     904   */
    376905  read: function(wkt) {
    377906    var features, type, str;
     
    401930    return features;
    402931  },
     932  /**
     933   * Method: write
     934   * Serialize a feature or array of features into a WKT string.
     935   *
     936   * Parameters:
     937   * features - {<ZOO.Feature.Vector>|Array} A feature or array of
     938   *            features
     939   *
     940   * Returns:
     941   * {String} The WKT string representation of the input geometries
     942   */
    403943  write: function(features) {
    404944    var collection, geometry, type, data, isCollection;
     
    432972    return pieces.join('');
    433973  },
     974  /**
     975   * Object with properties corresponding to the geometry types.
     976   * Property values are functions that do the actual data extraction.
     977   */
    434978  extract: {
     979    /**
     980     * Return a space delimited string of point coordinates.
     981     * @param {<ZOO.Geometry.Point>} point
     982     * @returns {String} A string of coordinates representing the point
     983     */
    435984    'point': function(point) {
    436985      return point.x + ' ' + point.y;
    437986    },
     987    /**
     988     * Return a comma delimited string of point coordinates from a multipoint.
     989     * @param {<ZOO.Geometry.MultiPoint>} multipoint
     990     * @returns {String} A string of point coordinate strings representing
     991     *                  the multipoint
     992     */
    438993    'multipoint': function(multipoint) {
    439994      var array = [];
     
    443998      return array.join(',');
    444999    },
     1000    /**
     1001     * Return a comma delimited string of point coordinates from a line.
     1002     * @param {<ZOO.Geometry.LineString>} linestring
     1003     * @returns {String} A string of point coordinate strings representing
     1004     *                  the linestring
     1005     */
    4451006    'linestring': function(linestring) {
    4461007      var array = [];
     
    4501011      return array.join(',');
    4511012    },
     1013    /**
     1014     * Return a comma delimited string of linestring strings from a multilinestring.
     1015     * @param {<ZOO.Geometry.MultiLineString>} multilinestring
     1016     * @returns {String} A string of of linestring strings representing
     1017     *                  the multilinestring
     1018     */
    4521019    'multilinestring': function(multilinestring) {
    4531020      var array = [];
     
    4591026      return array.join(',');
    4601027    },
     1028    /**
     1029     * Return a comma delimited string of linear ring arrays from a polygon.
     1030     * @param {<ZOO.Geometry.Polygon>} polygon
     1031     * @returns {String} An array of linear ring arrays representing the polygon
     1032     */
    4611033    'polygon': function(polygon) {
    4621034      var array = [];
     
    4681040      return array.join(',');
    4691041    },
     1042    /**
     1043     * Return an array of polygon arrays from a multipolygon.
     1044     * @param {<ZOO.Geometry.MultiPolygon>} multipolygon
     1045     * @returns {Array} An array of polygon arrays representing
     1046     *                  the multipolygon
     1047     */
    4701048    'multipolygon': function(multipolygon) {
    4711049      var array = [];
     
    4781056    }
    4791057  },
     1058  /**
     1059   * Object with properties corresponding to the geometry types.
     1060   * Property values are functions that do the actual parsing.
     1061   */
    4801062  parse: {
     1063    /**
     1064     * Return point feature given a point WKT fragment.
     1065     * @param {String} str A WKT fragment representing the point
     1066     * @returns {<ZOO.Feature>} A point feature
     1067     */
    4811068    'point': function(str) {
    4821069       var coords = ZOO.String.trim(str).split(this.regExes.spaces);
     
    4851072            );
    4861073    },
     1074    /**
     1075     * Return a multipoint feature given a multipoint WKT fragment.
     1076     * @param {String} A WKT fragment representing the multipoint
     1077     * @returns {<ZOO.Feature>} A multipoint feature
     1078     */
    4871079    'multipoint': function(str) {
    4881080       var points = ZOO.String.trim(str).split(',');
     
    4951087           );
    4961088    },
     1089    /**
     1090     * Return a linestring feature given a linestring WKT fragment.
     1091     * @param {String} A WKT fragment representing the linestring
     1092     * @returns {<ZOO.Feature>} A linestring feature
     1093     */
    4971094    'linestring': function(str) {
    4981095      var points = ZOO.String.trim(str).split(',');
     
    5051102          );
    5061103    },
     1104    /**
     1105     * Return a multilinestring feature given a multilinestring WKT fragment.
     1106     * @param {String} A WKT fragment representing the multilinestring
     1107     * @returns {<ZOO.Feature>} A multilinestring feature
     1108     */
    5071109    'multilinestring': function(str) {
    5081110      var line;
     
    5171119          );
    5181120    },
     1121    /**
     1122     * Return a polygon feature given a polygon WKT fragment.
     1123     * @param {String} A WKT fragment representing the polygon
     1124     * @returns {<ZOO.Feature>} A polygon feature
     1125     */
    5191126    'polygon': function(str) {
    5201127       var ring, linestring, linearring;
     
    5311138           );
    5321139    },
     1140    /**
     1141     * Return a multipolygon feature given a multipolygon WKT fragment.
     1142     * @param {String} A WKT fragment representing the multipolygon
     1143     * @returns {<ZOO.Feature>} A multipolygon feature
     1144     * @private
     1145     */
    5331146    'multipolygon': function(str) {
    5341147      var polygon;
     
    5431156          );
    5441157    },
     1158    /**
     1159     * Return an array of features given a geometrycollection WKT fragment.
     1160     * @param {String} A WKT fragment representing the geometrycollection
     1161     * @returns {Array} An array of ZOO.Feature
     1162     */
    5451163    'geometrycollection': function(str) {
    5461164      // separate components of the collection with |
     
    5561174  CLASS_NAME: 'ZOO.Format.WKT'
    5571175});
     1176/**
     1177 * Class: ZOO.Format.JSON
     1178 * A parser to read/write JSON safely. Create a new instance with the
     1179 *     <ZOO.Format.JSON> constructor.
     1180 *
     1181 * Inherits from:
     1182 *  - <OpenLayers.Format>
     1183 */
    5581184ZOO.Format.JSON = ZOO.Class(ZOO.Format, {
    5591185  indent: "    ",
Note: See TracChangeset for help on using the changeset viewer.

Search

Context Navigation

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png