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"><<a href="mailto:seileef@gmail.com">seileef@gmail.com</a>></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's not possible, but if<br>
anyone has any ideas about it, that'd be great.<br>
<br>
Thanks,<br>
Tom<br>
<br>
<br>
Tom B wrote:<br>
><br>
> OK, this has been pretty straightforward (thanks for the tips, Gregor).<br>
> The one issue I'm having is calculating the latitude value of the tiles'<br>
> centers while accounting for the change in distance per latitude degree<br>
> while traveling north-south. The code I'm using now calculates a<br>
> "latitude degrees per pixel" value, which is an alright approximation for<br>
> the whole map at very high zoom levels, but at lower zoom levels it isn't<br>
> accurate, and the resulting tile rows begin to drift apart. I have very<br>
> little GIS experience, so I'm a bit lost on where to start with<br>
> calculating these centers accurately.<br>
><br>
> Any ideas of how to approach this? I'm guessing that trig-related<br>
> expressions will be involved.<br>
><br>
> To show how this is currently set up, my code is:<br>
><br>
> // $width and $height - the pixel dimensions of the map<br>
> // $bounds - the EPSG:4326 BBOX of the map<br>
> function add_gmaps_layer($image, $width, $height, $bounds, $zoom, $key,<br>
> $temp_dir){<br>
> $base_url =<br>
> '<a href="http://maps.google.com/staticmap?key=%27.$key.%27&sensor=false&size=640x640&zoom=%27.$zoom" target="_blank">http://maps.google.com/staticmap?key='.$key.'&sensor=false&size=640x640&zoom='.$zoom</a>;<br>
> $num_cols = ceil($width/640);<br>
> $num_rows = ceil($height/640);<br>
> list($left, $bottom, $right, $top) = split(',', $bounds);<br>
> $lon_per_px = abs($right-$left)/$width;<br>
> $lat_per_px = abs($top-$bottom)/$height;<br>
> for($i=0; $i<$num_cols; $i++){<br>
> for($j=0; $j<$num_rows; $j++){<br>
> // Calculate the tile's center, relative to the bottom right corner of<br>
> the map<br>
> $center_x = 320 + ($i*640);<br>
> $center_y = 320 + ($j*640);<br>
> // Calculate the lon, lat of the tile<br>
> $center_lon = $right - ($center_x*$lon_per_px);<br>
> $center_lat = $bottom + ($center_y*$lat_per_px);<br>
> $url = $base_url.'&center='.$center_lat.','.$center_lon;<br>
> $x = $width - (($i+1)*640);<br>
> $y = $height - (($j+1)*640);<br>
> // Blit the tile onto the main image width a displacement of $x, $y<br>
> $image = blit_from_url($image, $url, $x, $y, $temp_dir);<br>
> }<br>
> }<br>
> return $image;<br>
> }<br>
><br>
><br>
> Gregor at HostGIS wrote:<br>
>><br>
>> Tom B wrote:<br>
>>> Has anyone had a chance to try this out? Gregor, any luck with getting<br>
>>> R&D<br>
>>> funding, by any chance? If not, I might go ahead and take a crack at<br>
>>> it,<br>
>>> since it is something our map will eventually need.<br>
>><br>
>> The customer wasn't up for it when I presented it to him, so I have<br>
>> nothing to show on this. Sorry.<br>
>><br>
>> The way I figure to render it, would be:<br>
>><br>
>> Take image width, divide by 640 rounding up.<br>
>> Take image height, divide by 640 rounding up.<br>
>> foreach w in width:<br>
>> foreach h in height:<br>
>> figure up center latlng (320,320) based on bbox and pixel position<br>
>> figure URL<br>
>> fetch image<br>
>> blit it onto the canvas<br>
>><br>
>> I have existing code in the Wiki ("Printing" page) for doing this in<br>
>> PHP, using URLs that are provided by the client. That at least shows the<br>
>> blitting and alpha code.<br>
>><br>
>> --<br>
>> HostGIS, Open Source solutions for the global GIS community<br>
>> Greg Allensworth - SysAdmin, Programmer, GIS Person, Security<br>
>> Network+ Server+ A+ Security+<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>
>><br>
>><br>
><br>
><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>