Author: tonio
Date: 2010-04-29 15:58:25 +0200 (Thu, 29 Apr 2010)
New Revision: 29314

Modified:
   plugins/sfMapFishPlugin/branches/1.4/lib/GeoJSON/lib/Feature.class.php
   
plugins/sfMapFishPlugin/branches/1.4/lib/GeoJSON/lib/Geometry/Collection.class.php
Log:
[sfMapFishPlugin] Make Collection implements ArrayAccess, add GeoJson dump 
ability to Feature?\226?\128?\153s instance

Modified: plugins/sfMapFishPlugin/branches/1.4/lib/GeoJSON/lib/Feature.class.php
===================================================================
--- plugins/sfMapFishPlugin/branches/1.4/lib/GeoJSON/lib/Feature.class.php      
2010-04-29 10:19:04 UTC (rev 29313)
+++ plugins/sfMapFishPlugin/branches/1.4/lib/GeoJSON/lib/Feature.class.php      
2010-04-29 13:58:25 UTC (rev 29314)
@@ -37,8 +37,6 @@
    */
   private $bbox = null;
 
-
-
   /**
    * Constructor
    *
@@ -190,5 +188,26 @@
 
     return $r;
   }
+
+  /**
+   * Shortcut to dump feature as GeoJSON
+   *
+   * @return string The GeoJSON representation of the feature
+   */
+  public function __toString()
+  {
+    return $this->toGeoJSON();
+  }
+
+  /**
+   * Dumps Feature as GeoJSON
+   *
+   * @return string The GeoJSON representation of the feature
+   */
+  public function toGeoJSON()
+  {
+    return json_encode($this->getGeoInterface());
+  }
+
 }
 

Modified: 
plugins/sfMapFishPlugin/branches/1.4/lib/GeoJSON/lib/Geometry/Collection.class.php
===================================================================
--- 
plugins/sfMapFishPlugin/branches/1.4/lib/GeoJSON/lib/Geometry/Collection.class.php
  2010-04-29 10:19:04 UTC (rev 29313)
+++ 
plugins/sfMapFishPlugin/branches/1.4/lib/GeoJSON/lib/Geometry/Collection.class.php
  2010-04-29 13:58:25 UTC (rev 29314)
@@ -15,7 +15,7 @@
  * @author     Camptocamp <[email protected]>
  * @version
  */
-abstract class Collection extends Geometry implements Iterator
+abstract class Collection extends Geometry implements Iterator, ArrayAccess
 {
   protected $components = array();
 
@@ -62,7 +62,7 @@
     return $this->components;
   }
 
-  # Iterator Interface functions
+  // Iterator Interface functions
 
   public function rewind()
   {
@@ -89,6 +89,27 @@
     return $this->current() !== false;
   }
 
+  // ArrayAccess Interface functions
 
+  public function offsetExists($offset)
+  {
+      return isset($this->components[$offset]);
+  }
+
+  public function offsetGet($offset)
+  {
+      return $this->components[$offset];
+  }
+
+  public function offsetSet($offset, $value)
+  {
+      $this->components[$offset] = $value;
+  }
+
+  public function offsetUnset($offset)
+  {
+      unset($this->components[$offset]);
+  }
+
 }
 

-- 
You received this message because you are subscribed to the Google Groups 
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/symfony-svn?hl=en.

Reply via email to