Hi,<br><br>check out gpsdrive.<br>They have quite a lot on calculating and downloading tiles not just from google.<br><br><a href="http://apps.sourceforge.net/mediawiki/gpsdrive/index.php?title=Creating_maps">http://apps.sourceforge.net/mediawiki/gpsdrive/index.php?title=Creating_maps</a><br>

<a href="http://gtm.tel.uva.es/ztep/maps/dmap.htm">http://gtm.tel.uva.es/ztep/maps/dmap.htm</a><br><br>Jan<br><br><br><div class="gmail_quote">On Wed, Jun 10, 2009 at 11:18 PM, Tom B <span dir="ltr">&lt;<a href="mailto:seileef@gmail.com">seileef@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
Hi,<br>
<br>
It turns outs that stitching together Google Static Maps images is indeed in<br>
violation of the Google Maps ToS.  See 10.2 of:<br>
<a href="http://code.google.com/apis/maps/terms.html" target="_blank">http://code.google.com/apis/maps/terms.html</a><br>
<br>
Does anyone happen to have any other ideas of how to achieve this goal<br>
without violating the ToS?  My guess is that it&#39;s not possible, but if<br>
anyone has any ideas about it, that&#39;d be great.<br>
<br>
Thanks,<br>
Tom<br>
<br>
<br>
Tom B wrote:<br>
&gt;<br>
&gt; OK, this has been pretty straightforward (thanks for the tips, Gregor).<br>
&gt; The one issue I&#39;m having is calculating the latitude value of the tiles&#39;<br>
&gt; centers while accounting for the change in distance per latitude degree<br>
&gt; while traveling north-south.  The code I&#39;m using now calculates a<br>
&gt; &quot;latitude degrees per pixel&quot; value, which is an alright approximation for<br>
&gt; the whole map at very high zoom levels, but at lower zoom levels it isn&#39;t<br>
&gt; accurate, and the resulting tile rows begin to drift apart.  I have very<br>
&gt; little GIS experience, so I&#39;m a bit lost on where to start with<br>
&gt; calculating these centers accurately.<br>
&gt;<br>
&gt; Any ideas of how to approach this?  I&#39;m guessing that trig-related<br>
&gt; expressions will be involved.<br>
&gt;<br>
&gt; To show how this is currently set up, my code is:<br>
&gt;<br>
&gt; // $width and $height - the pixel dimensions of the map<br>
&gt; // $bounds - the EPSG:4326 BBOX of the map<br>
&gt; function add_gmaps_layer($image, $width, $height, $bounds, $zoom, $key,<br>
&gt; $temp_dir){<br>
&gt;       $base_url =<br>
&gt; &#39;<a href="http://maps.google.com/staticmap?key=%27.$key.%27&amp;sensor=false&amp;size=640x640&amp;zoom=%27.$zoom" target="_blank">http://maps.google.com/staticmap?key=&#39;.$key.&#39;&amp;sensor=false&amp;size=640x640&amp;zoom=&#39;.$zoom</a>;<br>


&gt;       $num_cols = ceil($width/640);<br>
&gt;       $num_rows = ceil($height/640);<br>
&gt;       list($left, $bottom, $right, $top) = split(&#39;,&#39;, $bounds);<br>
&gt;       $lon_per_px = abs($right-$left)/$width;<br>
&gt;       $lat_per_px = abs($top-$bottom)/$height;<br>
&gt;       for($i=0; $i&lt;$num_cols; $i++){<br>
&gt;               for($j=0; $j&lt;$num_rows; $j++){<br>
&gt;                       // Calculate the tile&#39;s center, relative to the bottom right corner of<br>
&gt; the map<br>
&gt;                       $center_x = 320 + ($i*640);<br>
&gt;                       $center_y = 320 + ($j*640);<br>
&gt;                       // Calculate the lon, lat of the tile<br>
&gt;                       $center_lon = $right - ($center_x*$lon_per_px);<br>
&gt;                       $center_lat = $bottom + ($center_y*$lat_per_px);<br>
&gt;                       $url = $base_url.&#39;&amp;center=&#39;.$center_lat.&#39;,&#39;.$center_lon;<br>
&gt;                       $x = $width - (($i+1)*640);<br>
&gt;                       $y = $height - (($j+1)*640);<br>
&gt;                       // Blit the tile onto the main image width a displacement of $x, $y<br>
&gt;                       $image = blit_from_url($image, $url, $x, $y, $temp_dir);<br>
&gt;               }<br>
&gt;       }<br>
&gt;       return $image;<br>
&gt; }<br>
&gt;<br>
&gt;<br>
&gt; Gregor at HostGIS wrote:<br>
&gt;&gt;<br>
&gt;&gt; Tom B wrote:<br>
&gt;&gt;&gt; Has anyone had a chance to try this out?  Gregor, any luck with getting<br>
&gt;&gt;&gt; R&amp;D<br>
&gt;&gt;&gt; funding, by any chance?  If not, I might go ahead and take a crack at<br>
&gt;&gt;&gt; it,<br>
&gt;&gt;&gt; since it is something our map will eventually need.<br>
&gt;&gt;<br>
&gt;&gt; The customer wasn&#39;t up for it when I presented it to him, so I have<br>
&gt;&gt; nothing to show on this. Sorry.<br>
&gt;&gt;<br>
&gt;&gt; The way I figure to render it, would be:<br>
&gt;&gt;<br>
&gt;&gt; Take image width, divide by 640 rounding up.<br>
&gt;&gt; Take image height, divide by 640 rounding up.<br>
&gt;&gt; foreach w in width:<br>
&gt;&gt;    foreach h in height:<br>
&gt;&gt;      figure up center latlng (320,320) based on bbox and pixel position<br>
&gt;&gt;      figure URL<br>
&gt;&gt;      fetch image<br>
&gt;&gt;      blit it onto the canvas<br>
&gt;&gt;<br>
&gt;&gt; I have existing code in the Wiki (&quot;Printing&quot; page) for doing this in<br>
&gt;&gt; PHP, using URLs that are provided by the client. That at least shows the<br>
&gt;&gt; blitting and alpha code.<br>
&gt;&gt;<br>
&gt;&gt; --<br>
&gt;&gt; HostGIS, Open Source solutions for the global GIS community<br>
&gt;&gt; Greg Allensworth - SysAdmin, Programmer, GIS Person, Security<br>
&gt;&gt; Network+   Server+   A+   Security+<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; Users mailing list<br>
&gt;&gt; <a href="mailto:Users@openlayers.org">Users@openlayers.org</a><br>
&gt;&gt; <a href="http://openlayers.org/mailman/listinfo/users" target="_blank">http://openlayers.org/mailman/listinfo/users</a><br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
<font color="#888888"><br>
--<br>
View this message in context: <a href="http://n2.nabble.com/Saving-with-a-Google-Maps-base-layer-tp2736685p3058442.html" target="_blank">http://n2.nabble.com/Saving-with-a-Google-Maps-base-layer-tp2736685p3058442.html</a><br>


Sent from the OpenLayers Users mailing list archive at Nabble.com.<br>
<br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@openlayers.org">Users@openlayers.org</a><br>
<a href="http://openlayers.org/mailman/listinfo/users" target="_blank">http://openlayers.org/mailman/listinfo/users</a><br>
</font></blockquote></div><br>