<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>example_route_server/example_request.xml</filename>
    </added>
    <added>
      <filename>server/.gitignore</filename>
    </added>
    <added>
      <filename>server/.project</filename>
    </added>
    <added>
      <filename>server/.pydevproject</filename>
    </added>
    <added>
      <filename>server/insert.sh</filename>
    </added>
    <added>
      <filename>server/truncate.py</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -4,4 +4,6 @@
 */*.pyc
 commit.msg
 server/database.py*
-server/tile.csv
+server/data/tile.csv
+server/USE_APP_ENGINE
+server/USE_POSTGRES</diff>
      <filename>.gitignore</filename>
    </modified>
    <modified>
      <diff>@@ -5,10 +5,7 @@
   &lt;body&gt;
     &lt;p&gt;Hi there. Pick a route to see its altitude profile. You can also view the route in Google Maps.&lt;/p&gt;
     &lt;ul&gt;
-      &lt;li&gt;Route 1 : Downtown Melbourne Swanston Street. See &lt;a href=&quot;http://maps.google.com/maps/ms?hl=en&amp;amp;ie=UTF8&amp;amp;oe=UTF8&amp;amp;msa=0&amp;amp;msid=100510881926257285904.00044ebd0efd56c9e5c33&quot; class=&quot;external text&quot; title=&quot;http://maps.google.com/maps/ms?hl=en&amp;amp;ie=UTF8&amp;amp;oe=UTF8&amp;amp;msa=0&amp;amp;msid=100510881926257285904.00044ebd0efd56c9e5c33&quot; rel=&quot;nofollow&quot;&gt;Google map&lt;/a&gt;. Just a walk down the street, two coordinates. 1.3 kilometers. Lots of high rise buildings in the neighborhood. Show profile (&lt;a href=&quot;index.html?type=xml&amp;route=1&quot;&gt;xml&lt;/a&gt;, &lt;a href=&quot;index.html?type=gchart&amp;route=1&quot;&gt;Google Chart&lt;/a&gt;)
-      &lt;li&gt;Route 2 : Melbourne: along the M3. See &lt;a href=&quot;http://maps.google.com/maps/ms?ie=UTF8&amp;amp;hl=en&amp;amp;msa=0&amp;amp;msid=100510881926257285904.00044ebd7c782bf7d26b1&amp;amp;ll=-37.792965,145.066051&amp;amp;spn=0.06457,0.160675&amp;amp;t=p&amp;amp;z=13&quot; class=&quot;external text&quot; title=&quot;http://maps.google.com/maps/ms?ie=UTF8&amp;amp;hl=en&amp;amp;msa=0&amp;amp;msid=100510881926257285904.00044ebd7c782bf7d26b1&amp;amp;ll=-37.792965,145.066051&amp;amp;spn=0.06457,0.160675&amp;amp;t=p&amp;amp;z=13&quot; rel=&quot;nofollow&quot;&gt;Google map&lt;/a&gt;. Show profile (&lt;a href=&quot;index.html?type=xml&amp;route=2&quot;&gt;xml&lt;/a&gt;, &lt;a href=&quot;index.html?type=gchart&amp;route=2&quot;&gt;Google Chart&lt;/a&gt;)
-      &lt;li&gt;Route 3 : Don Road. See &lt;a href=&quot;http://maps.google.com/maps?f=d&amp;amp;hl=en&amp;amp;geocode=6136499379036602369,-37.757051,145.588828&amp;amp;saddr=Old+Don+Rd+%40-37.757051,+145.588828&amp;amp;daddr=-37.702294,145.570564&amp;amp;mra=mi&amp;amp;mrsp=1,0&amp;amp;sz=13&amp;amp;sll=-37.71085,145.600777&amp;amp;sspn=0.064642,0.160675&amp;amp;ie=UTF8&amp;amp;ll=-37.728638,145.596657&amp;amp;spn=0.064627,0.160675&amp;amp;t=p&amp;amp;z=13&quot; class=&quot;external text&quot; title=&quot;http://maps.google.com/maps?f=d&amp;amp;hl=en&amp;amp;geocode=6136499379036602369,-37.757051,145.588828&amp;amp;saddr=Old+Don+Rd+%40-37.757051,+145.588828&amp;amp;daddr=-37.702294,145.570564&amp;amp;mra=mi&amp;amp;mrsp=1,0&amp;amp;sz=13&amp;amp;sll=-37.71085,145.600777&amp;amp;sspn=0.064642,0.160675&amp;amp;ie=UTF8&amp;amp;ll=-37.728638,145.596657&amp;amp;spn=0.064627,0.160675&amp;amp;t=p&amp;amp;z=13&quot; rel=&quot;nofollow&quot;&gt;Google map&lt;/a&gt; Show profile (&lt;a href=&quot;index.html?type=xml&amp;route=3&quot;&gt;xml&lt;/a&gt;, &lt;a href=&quot;index.html?type=gchart&amp;route=3&quot;&gt;Google Chart&lt;/a&gt;)
-      &lt;li&gt;Route 4 : Long straight road. See &lt;a href=&quot;http://maps.google.com/maps?f=d&amp;amp;hl=en&amp;amp;geocode=1130370581986007382,-30.088850,145.937740%3B10496179191282796778,-31.559080,147.188810&amp;amp;saddr=Mitchell+Hwy+%40-30.088850,+145.937740&amp;amp;daddr=-31.548112,147.200317+to:Mitchell+Hwy+%40-31.559080,+147.188810&amp;amp;mra=dpe&amp;amp;mrcr=0&amp;amp;mrsp=1&amp;amp;sz=8&amp;amp;via=1&amp;amp;sll=-30.859795,147.024536&amp;amp;sspn=2.244471,5.141602&amp;amp;ie=UTF8&amp;amp;t=p&amp;amp;z=8&quot; class=&quot;external text&quot; title=&quot;http://maps.google.com/maps?f=d&amp;amp;hl=en&amp;amp;geocode=1130370581986007382,-30.088850,145.937740%3B10496179191282796778,-31.559080,147.188810&amp;amp;saddr=Mitchell+Hwy+%40-30.088850,+145.937740&amp;amp;daddr=-31.548112,147.200317+to:Mitchell+Hwy+%40-31.559080,+147.188810&amp;amp;mra=dpe&amp;amp;mrcr=0&amp;amp;mrsp=1&amp;amp;sz=8&amp;amp;via=1&amp;amp;sll=-30.859795,147.024536&amp;amp;sspn=2.244471,5.141602&amp;amp;ie=UTF8&amp;amp;t=p&amp;amp;z=8&quot; rel=&quot;nofollow&quot;&gt;Google map&lt;/a&gt; Show profile (&lt;a href=&quot;index.html?type=xml&amp;route=4&quot;&gt;xml&lt;/a&gt;, &lt;a href=&quot;index.html?type=gchart&amp;route=4&quot;&gt;Google Chart&lt;/a&gt;)
+      &lt;li&gt;Route 1 : Downtown Heidelberg. Car route on &lt;a href=&quot;http://maps.google.com/maps?f=d&amp;hl=en&amp;geocode=17786583812122914276,49.414740,8.693260&amp;saddr=49.40779,8.681002&amp;daddr=Bergstra%C3%9Fe+%4049.414740,+8.693260&amp;mra=mi&amp;mrsp=0,1&amp;sz=15&amp;sll=49.411029,8.689027&amp;sspn=0.014128,0.037594&amp;ie=UTF8&amp;ll=49.410052,8.692503&amp;spn=0.014129,0.037594&amp;z=15&quot;&gt;Google maps&lt;/a&gt;. &lt;a href=&quot;index.html?type=ors&amp;route=1&quot;&gt;Walking route on OpenRouteService&lt;/a&gt; (xml). Altitude profile (&lt;a href=&quot;index.html?type=xml&amp;route=1&quot;&gt;xml&lt;/a&gt;, &lt;a href=&quot;index.html?type=gchart&amp;route=1&quot;&gt;Google Chart&lt;/a&gt;)
     &lt;/ul&gt;
     &lt;p&gt;More information &lt;a href=&quot;http://wiki.openstreetmap.org/index.php/Route_altitude_profiles_SRTM&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;
   &lt;/body&gt;</diff>
      <filename>example_route_server/www/index.html</filename>
    </modified>
    <modified>
      <diff>@@ -17,13 +17,13 @@ from google.appengine.ext import webapp
 
 ##### Database #####
 class Altitude(db.Model):
-  pos = db.IntegerProperty()
+  #pos = db.IntegerProperty()
   alt = db.IntegerProperty()
 
 ##### Pages ######
 class MainPage(webapp.RequestHandler):
   def get(self):
-    alts = Altitude.gql(&quot;ORDER BY pos DESC LIMIT 10&quot;)
+    alts = Altitude.gql(&quot;LIMIT 10&quot;)
     self.response.out.write(&quot;&quot;&quot;
       &lt;html&gt;
         &lt;body&gt;&quot;&quot;&quot;)
@@ -31,6 +31,8 @@ class MainPage(webapp.RequestHandler):
     for alt in alts:
       self.response.out.write(&quot;&lt;p&gt;&quot; + str(alt.alt) + &quot;&lt;/p&gt;&quot;)
 
+    alt = Altitude.get_by_key_name(&quot;P-19490696459&quot;)
+    self.response.out.write(&quot;&lt;p&gt;And fetch directly by keyname:&quot; + str(alt.alt) +  &quot;&lt;/p&gt;&quot;)
     self.response.out.write(&quot;&quot;&quot;       &lt;/body&gt;
       &lt;/html&gt;&quot;&quot;&quot;)
 </diff>
      <filename>server/altitude.py</filename>
    </modified>
    <modified>
      <diff>@@ -5,7 +5,31 @@ api_version: 1
 
 handlers:
 - url: /
-  script: altitude.py
+  script: src/altitude.py
 
 - url: /load
-  script: myloader.py
+  script: src/myloader.py
+  login: admin
+
+- url: /truncate
+  script: src/truncate.py
+  login: admin
+
+skip_files: |
+ ^(.*/)?(
+ (app\.yaml)|
+ (app\.yml)|
+ (index\.yaml)|
+ (index\.yml)|
+ (.*\.csv)|
+ (data/.*)|
+ (test/.*)|
+ (src/import-google-apps-engine\.sh)
+ (src/import-google-apps-engine\.py)
+ (#.*#)|
+ (.*~)|
+ (.*\.py[co])|
+ (.*/RCS/.*)|
+ (\..*)|
+ )$
+</diff>
      <filename>server/app.yaml</filename>
    </modified>
    <modified>
      <diff>@@ -8,21 +8,21 @@ from math import sqrt
 # Main functions
 
 def loadTile(filename):
-  srtm = gdal.Open('data/Australia/' + filename + '.hgt')
+  srtm = gdal.Open('data/Eurasia/' + filename + '.hgt')
   return gdal_array.DatasetReadAsArray(srtm)
 
 def posFromLatLon(lat,lon):
   return (lat * 360 + lon) * 1200 * 1200
 
-def writeTileCsvFile(tile, lat0, lon0):
+def writeTileCsvFile(tile, lat0, lon0, top_row = 1, bottom_row = 1200, left_col = 0, right_col = 1199 ):
   # Calculate begin position
   begin = posFromLatLon(lat0,lon0)
 
   # First we write the data into a temporary file.
-  f = open('tile.csv', 'w')
+  f = open('data/tile.csv', 'w')
   # We drop the top row and right column.
-  for row in range(1, len(tile)):
-    for col in range(0, len(tile) - 1):
+  for row in range(top_row, bottom_row + 1 ):
+    for col in range(left_col, right_col + 1):
       f.write(str(\
       begin + (row-1) * 1200 + col\
       ) + &quot;, &quot; + str(tile[row][col] ) + &quot;\n&quot;)
@@ -49,7 +49,47 @@ def getLatLonFromFileName(name):
   return [lat,lon]
 
 if __name__ == '__main__':
-  name = sys.argv[1]
+  # We will only upload 1 tile to the Google App Engine. This will take quite 
+  # a bit of time. For the offline data store, we will only &quot;upload&quot; the city 
+  # of Heidelberg; the offline data store is very slow.
+  
+  # For this we need tile N49E008. 
+  name = &quot;N49E008&quot;
   tile = loadTile(name)
   [lat,lon] = getLatLonFromFileName(name)
-  writeTileCsvFile(tile, lat, lon)
+
+  if not (&quot;online&quot; in sys.argv or &quot;offline&quot; in sys.argv):
+      print &quot;Online or offline?&quot;
+      exit()
+  
+  if sys.argv[1] == &quot;offline&quot;:
+      # If we are offline, we'll only look the center of Heidelberg.
+      # 49.39 --- 49.42
+      # 8.67 --- 8.71
+      # That corresponds to:
+      row_top = int((1.0 - 0.42) * 1200.)
+      row_bottom = int((1.0 - 0.39) * 1200.)
+      col_left = int(0.67 * 1200.)
+      col_right = int(0.71 * 1200.)
+      # So that 1813 records
+      writeTileCsvFile(tile, lat, lon, row_top, row_bottom, col_left, col_right)
+      print &quot;Now run this command to insert the data into your local datastore:&quot;
+      print &quot;/path/to/app-engine-sdk/bulkload_client.py --filename ../data/tile.csv --kind Altitude --url http://localhost:8080/load --batch_size 100 --cookie 'dev_appserver_login=test@example.com:True'&quot;
+
+  else:
+      # Because the bulk upload script does not support resume, we will upload
+      # the data row by row. sys.argv[2] represents the line number to insert.
+      # You should create a script to perform the upload. Start at 1, end at 1200.
+      row = int(sys.argv[2])
+      print &quot;About to make cvs for row &quot; + str(row) + &quot; of 1200...&quot;
+      row_top = row
+      row_bottom = row
+      col_left = 0
+      col_right = 1199
+      writeTileCsvFile(tile, lat, lon, row_top, row_bottom, col_left, col_right)
+
+      # To insert, you need to do something like this:
+      # /path/to/app-engine-sdk/bulkload_client.py --filename ../data/tile.csv --kind Altitude --url http://something.appspot.com/load --batch_size 100&quot;
+      
+      # You also need to add a --cookie argument: just surf to http://something.appspot.com/load
+      # to see how.</diff>
      <filename>server/import-google-apps-engine.py</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,6 @@
 from google.appengine.ext import bulkload
 from google.appengine.api import datastore_types
+from google.appengine.api import datastore
 from google.appengine.ext import search
 
 class AltitudeLoader(bulkload.Loader):
@@ -9,5 +10,12 @@ class AltitudeLoader(bulkload.Loader):
                           ('alt', int)
                           ])
 
+  def HandleEntity(self, entity):
+    name=&quot;P&quot; + str(entity['pos'])
+    del entity['pos']
+    newent = datastore.Entity('Altitude',name=name)
+    newent.update(entity)
+    return newent
+
 if __name__ == '__main__':
   bulkload.main(AltitudeLoader())</diff>
      <filename>server/myloader.py</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>server/data/.gitignore</filename>
    </removed>
    <removed>
      <filename>server/data/Australia/.gitignore</filename>
    </removed>
    <removed>
      <filename>server/import-google-apps-engine.sh</filename>
    </removed>
    <removed>
      <filename>server/test/test_server.py</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>e5e5e72b9f088a8bdb39774dc9e65715e4300997</id>
    </parent>
  </parents>
  <author>
    <name>Sjors</name>
    <email>sjors@sprovoost.nl</email>
  </author>
  <url>http://github.com/Sjors/openstreetmap-route-altitude-profile/commit/277f2e06179d57175c29d1f6274684892742e684</url>
  <id>277f2e06179d57175c29d1f6274684892742e684</id>
  <committed-date>2008-07-04T00:57:35-07:00</committed-date>
  <authored-date>2008-07-04T00:57:35-07:00</authored-date>
  <message>Work in progress: script can import a tile into the Datastore or downtown Heidelberg into offline store.</message>
  <tree>331196247409a7ef80d51688d2dad5224274f9e0</tree>
  <committer>
    <name>Sjors</name>
    <email>sjors@sprovoost.nl</email>
  </committer>
</commit>
