<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>server/altitudeprofile.proto</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -30,6 +30,13 @@ _ROUTE_POINTTYPE = descriptor.Descriptor(
       message_type=None, enum_type=None, containing_type=None,
       is_extension=False, extension_scope=None,
       options=None),
+    descriptor.FieldDescriptor(
+      name='alt', full_name='altitudeprofile.Route.PointType.alt', index=2,
+      number=3, type=2, cpp_type=6, label=1,
+      default_value=0,
+      message_type=None, enum_type=None, containing_type=None,
+      is_extension=False, extension_scope=None,
+      options=None),
   ],
   extensions=[
   ],</diff>
      <filename>example_route_server/altitudeprofile_pb2.py</filename>
    </modified>
    <modified>
      <diff>@@ -41,9 +41,10 @@
         &lt;td&gt;&lt;a href=&quot;server.py/demo?route=1&amp;input=xml&amp;output=gchart_url&amp;server=pg&quot;&gt;Google Chart URL&lt;/a&gt;&lt;/td&gt;
       &lt;/tr&gt;
       &lt;tr&gt;
-        &lt;td&gt;Protocol Buffers&lt;/td&gt;&lt;td&gt;Coming soon&lt;/td&gt;
-        &lt;td&gt;&lt;/td&gt;
-        &lt;td&gt;&lt;/td&gt;
+        &lt;td&gt;Protocol Buffers&lt;/td&gt;
+        &lt;td&gt;&lt;a href=&quot;server.py/demo?route=1&amp;input=protobuf&amp;output=xml&amp;server=pg&quot;&gt;xml&lt;/a&gt;&lt;/td&gt; 
+        &lt;td&gt;&lt;a href=&quot;server.py/demo?route=1&amp;input=protobuf&amp;output=gchart_url&amp;server=pg&quot;&gt;Google Chart URL&lt;/a&gt;&lt;/td&gt;
+        &lt;td&gt;&lt;a href=&quot;server.py/demo?route=1&amp;input=protobuf&amp;output=protobuf&amp;server=pg&quot;&gt;Protocol buffers&lt;/a&gt;&lt;/td&gt;
       &lt;/tr&gt;
       &lt;tr&gt;
         &lt;td&gt;HTTP/GET&lt;/td&gt;</diff>
      <filename>example_route_server/index.html</filename>
    </modified>
    <modified>
      <diff>@@ -79,6 +79,28 @@ def demo(req, route, input, output, server):
     req.write('&lt;head&gt;&lt;/head&gt;')
     req.write('&lt;body&gt;')
     req.write('&lt;p&gt;' + s +  '&lt;/p&gt;')
+
+  elif output_type == &quot;protobuf&quot;:
+    s = f.read()
+    f.close()
+    
+    req.content_type = 'text/html'
+    req.write('&lt;html&gt;')
+    req.write('&lt;head&gt;&lt;/head&gt;')
+    req.write('&lt;body&gt;')
+    req.write('&lt;p&gt;Extracting protocol buffer:&lt;/p&gt;')
+    req.write('&lt;p&gt;' + s + '&lt;/p&gt;')
+    
+    req.write('&lt;ul&gt;')
+    
+    route_res = altitudeprofile_pb2.Route()
+    route_res.ParseFromString(s)
+    
+    for point in route_res.point:
+      req.write('&lt;li&gt;lat=' + str(point.lat) + ' lon=' + str(point.lon) + ' alt=' + str(point.alt) + '&lt;/li&gt;')
+
+    req.write('&lt;/ul&gt;')
+    
   
   #return apache.OK
 
@@ -97,7 +119,7 @@ def fetchResult(url_server_root, input_type, route, output_type):
     # Get route altitude profile:
                 
 
-    return urllib.urlopen(url_server_root + &quot;profile/xml/protobuf/&quot;, route_pb_string)
+    return urllib.urlopen(url_server_root + &quot;profile/&quot; + output_type + &quot;/protobuf/&quot;, &quot;protobuf=&quot; + route_pb_string)
     
   elif input_type == &quot;xml&quot;:
     # Let's make an xlsRouteGeometry object...</diff>
      <filename>example_route_server/server.py</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,8 @@
 # from numpy import ones
 from math import floor, ceil
+import sys
+
+
 
 # Geopy: http://exogen.case.edu/projects/geopy/
 from geopy import distance, util
@@ -9,6 +12,8 @@ from pygooglechart import XYLineChart, Axis
 
 from xml.dom import minidom
 
+import altitudeprofile_pb2
+
 ##### Pages ######
 def page_main_get():
   return '&lt;p&gt;Welcome! Go to &lt;a href=&quot;http://sprovoost.nl/category/gsoc/&quot;&gt;my blog&lt;/a&gt; to learn more.&lt;/p&gt;'
@@ -17,12 +22,12 @@ def page_profile(db, utils, data, output_format, input_format):
   # Extract the route:
   route = []
   if input_format == &quot;protobuf&quot;:
-    # Doesn't work in app egine yet and completely untested
+    # Doesn't work in app egine yet, only with Apache
     route_pb = altitudeprofile_pb2.Route()
     route_pb.ParseFromString(data)
 
     for point in route_pb.point:
-      route += {'lat' : point.lat, 'lon' : point.lon} 
+      route.append({'lat' : point.lat, 'lon' : point.lon})
 
   elif input_format == &quot;xml&quot;:
     dom = minidom.parseString(data)
@@ -68,6 +73,21 @@ def page_profile(db, utils, data, output_format, input_format):
 
     return ['text/xml', xml]
 
+  elif output_format == &quot;protobuf&quot;:
+    profile = altitude_profile(db, route)
+
+    profile_pb = altitudeprofile_pb2.Route()
+
+    for p in profile:
+      point = profile_pb.point.add()
+      point.lat = p['lat']
+      point.lon = p['lon']
+      point.alt = p['alt']
+
+    profile_pb_string = route_pb.SerializeToString()
+
+    return ['text/html', profile_pb_string]
+
 def altitude_profile_gchart(db, route):
     # First calculate the altitude profile
     profile = altitude_profile(db, route)</diff>
      <filename>server/altitude.py</filename>
    </modified>
    <modified>
      <diff>@@ -1,12 +1,12 @@
 #!/usr/bin/python2.4
 # Generated by the protocol buffer compiler.  DO NOT EDIT!
 
-from protobuf import descriptor
-from protobuf import message
-from protobuf import reflection
-from protobuf import service
-from protobuf import service_reflection
-from protobuf import descriptor_pb2
+from google.protobuf import descriptor
+from google.protobuf import message
+from google.protobuf import reflection
+from google.protobuf import service
+from google.protobuf import service_reflection
+from google.protobuf import descriptor_pb2
 
 
 
@@ -30,6 +30,13 @@ _ROUTE_POINTTYPE = descriptor.Descriptor(
       message_type=None, enum_type=None, containing_type=None,
       is_extension=False, extension_scope=None,
       options=None),
+    descriptor.FieldDescriptor(
+      name='alt', full_name='altitudeprofile.Route.PointType.alt', index=2,
+      number=3, type=2, cpp_type=6, label=1,
+      default_value=0,
+      message_type=None, enum_type=None, containing_type=None,
+      is_extension=False, extension_scope=None,
+      options=None),
   ],
   extensions=[
   ],</diff>
      <filename>server/altitudeprofile_pb2.py</filename>
    </modified>
    <modified>
      <diff>@@ -4,6 +4,7 @@ import os
 sys.path += [os.path.dirname(__file__)]
 
 import web
+from os import environ
 
 sys.stdout = sys.stderr 
 
@@ -47,8 +48,13 @@ class main_page:
 
 class profile_page:  
   def POST(self, output_format, input_format):
-    # This assumes XML input
-    postdata = '&lt;?xml version=' + web.input()['&lt;?xml version']
+    # Determine whether the post request is a protocol buffer or
+    # an XML document. (I am sure there is a more elegant way)
+    try: 
+      postdata =  web.input()['protobuf']
+    except:
+      postdata = '&lt;?xml version=' + web.input()['&lt;?xml version']
+          
     res = altitude.page_profile(db, utils, postdata, output_format, input_format)
     header = res[0]
     body = res[1]</diff>
      <filename>server/apache.py</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>example_route_server/altitudeprofile.proto</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>6800152d806ee329134446629d2250546bf95ac5</id>
    </parent>
  </parents>
  <author>
    <name>sjors</name>
    <email>sjors@b9d5c4c9-76e1-0310-9c85-f3177eceb1e4</email>
  </author>
  <url>http://github.com/Sjors/openstreetmap-route-altitude-profile/commit/27008c88c5fbc48440909a04434560722031e296</url>
  <id>27008c88c5fbc48440909a04434560722031e296</id>
  <committed-date>2008-08-01T21:29:54-07:00</committed-date>
  <authored-date>2008-08-01T21:29:54-07:00</authored-date>
  <message>Protocol buffers are now supported on the Apache version.


git-svn-id: http://svn.openstreetmap.org/sites/other/route-altitude-profile/trunk@9427 b9d5c4c9-76e1-0310-9c85-f3177eceb1e4</message>
  <tree>e0ae55b776e5a47009cb155923d51e8c34e4e0b6</tree>
  <committer>
    <name>sjors</name>
    <email>sjors@b9d5c4c9-76e1-0310-9c85-f3177eceb1e4</email>
  </committer>
</commit>
