<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>lib/gm_plugin/encoder.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -39,3 +39,34 @@ Ym4r::GmPlugin::GPolygon.class_eval do
   end
 end
 
+Ym4r::GmPlugin::GPolylineEncoded.class_eval do
+  def self.from_georuby(line_string, color = nil, weight = nil, opacity = nil)
+    encoded_points = GMapPolylineEncoder.new.encode(
+      line_string.points.collect {|p| [p.y, p.x]})
+    GPolylineEncoded.new(
+      :points =&gt; encoded_points[:points],
+      :levels =&gt; encoded_points[:levels],
+      :num_levels =&gt; encoded_points[:numLevels],
+      :zoom_factor =&gt; encoded_points[:zoomFactor],
+      :color =&gt; color,
+      :weight =&gt; weight,
+      :opacity =&gt; opacity
+    )
+  end
+end
+
+Ym4r::GmPlugin::GPolygonEncoded.class_eval do
+  def self.from_georuby(ls_or_p, stroke_color=&quot;#000000&quot;,stroke_weight=1,stroke_opacity=1.0,color=&quot;#ff0000&quot;,opacity=1.0)
+    if ls_or_p.is_a?(GeoRuby::SimpleFeatures::LineString)
+      GPolygonEncoded.new(
+        GPolylineEncoded.from_georuby(ls_or_p, stroke_color, stroke_weight, stroke_opacity), 
+        color.nil?, color, opacity, stroke_weight &gt; 0)
+    else
+      polylines = ls_or_p.rings.collect do |line_string|
+        GPolylineEncoded.from_georuby(line_string, stroke_color, 
+          stroke_weight, stroke_opacity)
+      end
+      GPolygonEncoded.new(polylines, true, color, opacity, true)
+    end
+  end
+end</diff>
      <filename>lib/gm_plugin/helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -104,18 +104,20 @@ module Ym4r
       end
     end
 
-    #Encoded GPolyline class
+    #
+    # Encoded GPolyline class.  This class does NOT perform encoding. 
+    # Instead, you must pass it encoded points, levels, and a zoom_factor
+    # created using Ym4r::GmPlugin::GMapPolylineEncoder.
+    #
+    # For more info on encoding polylines, see
+    #  http://code.google.com/apis/maps/documentation/reference.html#GPolyline.fromEncoded
+    #  http://code.google.com/apis/maps/documentation/overlays.html#Encoded_Polylines
+    #
     class GPolylineEncoded 
       include MappingObject
       attr_accessor :points,:color,:weight,:opacity,:levels,:zoom_factor,:num_levels
 
       def initialize(options={})
-        #points = options[:points]
-        #if !points.empty? and points[0].is_a?(Array)
-        #  @points = points.collect { |pt| GLatLng.new(pt) }
-        #else
-        #@points = points
-          #end
         @points = options[:points]
         @color = options[:color]
         @weight = options[:weight]
@@ -163,7 +165,9 @@ module Ym4r
       end
     end
 
-    #Polygon. Not documented yet in the Google Maps API
+    # Wrapper for the Google Maps GPolygon class.  See the Google Maps API 
+    # docs: 
+    # http://code.google.com/apis/maps/documentation/reference.html#GPolygon
     class GPolygon
       include MappingObject
       
@@ -195,6 +199,13 @@ module Ym4r
       end
     end
 
+    #
+    # Wrapper class for Google Maps GPolygons created using the
+    # GPolygon.fromEncoded() factory method.  Unlike a regular GPolygon, it
+    # creates a polygon from a string of specially encoded points, allowing
+    # complex polygons with multiple rings to be rendered.  When creating a
+    # GPolygonEncoded, pass it GPolylineEncoded objects.
+    #
     class GPolygonEncoded 
       include MappingObject
       
@@ -220,7 +231,10 @@ module Ym4r
           x = &quot;{points: #{MappingObject.javascriptify_variable(p.points)},&quot; 
           x &lt;&lt; &quot;levels: #{MappingObject.javascriptify_variable(p.levels)},&quot;
           x &lt;&lt; &quot;zoomFactor: #{MappingObject.javascriptify_variable(p.zoom_factor)},&quot;
-          x &lt;&lt; &quot;numLevels: #{MappingObject.javascriptify_variable(p.num_levels)} &quot;
+          x &lt;&lt; &quot;numLevels: #{MappingObject.javascriptify_variable(p.num_levels)}&quot;
+          x &lt;&lt; &quot;, color: #{MappingObject.javascriptify_variable(p.color)}&quot; if p.color
+          x &lt;&lt; &quot;, weight: #{MappingObject.javascriptify_variable(p.weight)}&quot; if p.weight
+          x &lt;&lt; &quot;, opacity: #{MappingObject.javascriptify_variable(p.opacity)}&quot; if p.opacity
           x &lt;&lt; &quot;}&quot;
           polylines_for_polygon &lt;&lt; x
         end</diff>
      <filename>lib/gm_plugin/overlay.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,7 @@
 $:.unshift(File.dirname(__FILE__) + '/../lib')
 
-require File.expand_path(File.dirname(__FILE__) + &quot;/../../../../config/environment&quot;)
+# require File.expand_path(File.dirname(__FILE__) + &quot;/../../../../config/environment&quot;)
+require File.expand_path(&quot;/Users/kueda/tmp/inat2/config/environment&quot;)
 
 
 require 'ym4r_gm'
@@ -55,8 +56,6 @@ class TestGoogleMaps&lt; Test::Unit::TestCase
   end
 
   def test_google_maps_geocoding
-    
-
     placemarks = Geocoding.get(&quot;Rue Clovis Paris&quot;)
     assert_equal(Geocoding::GEO_SUCCESS,placemarks.status)
     assert_equal(1,placemarks.length)
@@ -70,10 +69,17 @@ class TestGoogleMaps&lt; Test::Unit::TestCase
     assert_equal(Geocoding::GEO_SUCCESS,placemarks.status)
     assert(placemarks.length &gt; 1)
     assert(placemarks[0].latitude != placemarks[1].latitude )
-    
-
   end
-
   
+  def test_gmap_polyline_encoder
+    points = [
+      [37.76, -122.20],
+      [37.77, -122.22],
+      [37.78, -122.19]
+    ]
+    
+    encoded_points = GMapPolylineEncoder.new.encode(points)
+    assert_equal(&quot;__neF~dzhVo}@~{Bo}@ozD&quot;, encoded_points[:points])
+  end
 end
 </diff>
      <filename>test/gm_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>5d5e2b7a55ef32612b4da25d1952bb713a7427bf</id>
    </parent>
  </parents>
  <author>
    <name>Ken-ichi Ueda</name>
    <email>kenichi.ueda@gmail.com</email>
  </author>
  <url>http://github.com/ewildgoose/ym4r_gm/commit/3db13163be7b6028c593d5d1be5c08cd444a532c</url>
  <id>3db13163be7b6028c593d5d1be5c08cd444a532c</id>
  <committed-date>2009-06-18T02:26:58-07:00</committed-date>
  <authored-date>2009-06-17T21:52:39-07:00</authored-date>
  <message>Added encoded polyline support by including Joel Rosenberg's GMapPolylineEncoder class.  Also added helper methods to create encoded polylines and encoded polylines from GeoRuby objects.
(cherry picked from commit f94c3d186e03ed0cfb044d4d77126c9ce6d87107)</message>
  <tree>4afd6344f89c73a2717494fb5657c701f952862d</tree>
  <committer>
    <name>Ed Wildgoose</name>
    <email>git@wildgooses.com</email>
  </committer>
</commit>
