Constraining gen-tile to lat lng bounds?

7 views
Skip to first unread message

Gene

unread,
Dec 22, 2010, 8:04:24 AM12/22/10
to gheat
Hi

I'm testing gheat for a project and have it running well locally.

But there are some issues to get it working on the production server
(aspen & pygame installs)

The data doesnt change often and so I've tried running the modified
gen-tile.py - figuring I can just upload changed tiles with cron or
somesuch

But...
running gen-tile from command line means it checks every possible tile
at each zoom level, and spends almost all its time (6+ hours now)
spewing out lots of 'skipping empty tile' messages.

I know pretty much what the lat, lng bounds are for the data sets. How
to constrain gen-tile to those limits?

I had a look thru the code but my python / geo / math knowledge isnt
up to the job :-(

I'm grateful for any input towards a solution.

G.

Steven Lehrburger

unread,
Dec 23, 2010, 10:13:08 AM12/23/10
to gh...@googlegroups.com
Hey,

I'm much more familiar with an old fork of gheat than gheat itself, but I took a look at gen-tile.py, and might be able to help.

Do you know what zoom level you want? I think the zoom levels (on line 34 in that file) correspond to those used by Google Maps, where the lowest number is the most zoomed out, so you might be able to get some guidance from there. Many, many tiles are needed at higher zoom levels, as one might expect.

You shold also play around with the latitude and longitude parameters passed to ll2px - i.e. try changing the "-90" and "180" in line 35. I'm not sure which corner of the rectangular map that represents, but then you could also change the numcols and numrows on the next line so that you're only drawing a few 256px by 256px tiles in either direction to the opposite corner, rather than the entire rest of the map.

Does that make any sense? Hopefully I am not completely wrong about any of that, but please correct me if so!

Cheers,
Steven




--
You received this message because you are subscribed to the Google Groups "gheat" group.
To post to this group, send email to gh...@googlegroups.com.
To unsubscribe from this group, send email to gheat+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gheat?hl=en.


Gene

unread,
Dec 23, 2010, 12:08:04 PM12/23/10
to gheat
Hi Steven

thanks for reply

On Dec 23, 3:13 pm, Steven Lehrburger <lehrbur...@gmail.com> wrote:

> Do you know what zoom level you want?
yes approx between 8 -> 15

> Many, many tiles are needed at higher zoom levels, as one might
> expect.

yep - millions and millions :-(

> You shold also play around with the latitude and longitude parameters passed
> to ll2px - i.e. try changing the "-90" and "180" in line 35.

I saw that and the light immediately went on...
but.... if I want say -40, 40 how to stop it running on to the other
end of the world so to speak?

> I'm not sure
> which corner of the rectangular map that represents, but then you could also
> change the numcols and numrows on the next line so that you're only drawing
> a few 256px by 256px tiles in either direction to the opposite corner,
> rather than the entire rest of the map.
>
> Does that make any sense? Hopefully I am not completely wrong about any of
> that, but please correct me if so!

yes - generating tiles corner to corner makes good sense.
In the meanwhile, I figured maybe I have to do something like this in
the for loop (line 30?) in gen-tile.py:

for zoom in range(zoom_levels)
db_open
db_exec (select ( max(lat), max(lng) ), ( min(lat), min(lng) ) ) as
bounding_box
convert the bounding_box lat/lng coordinates to pixels #[ I guess this
happens with ll2px but arent sure about this?]
convert pixel positions to tiles
identify mincol maxcol tile minrow maxrow tile

for x(mincol -> maxcol)
for y.(minrow -> maxrow)

So... same question: does that make any sense?
omg I hate (=dont know!) python! How to do it in python?


> On Wed, Dec 22, 2010 at 8:04 AM, Gene <gne...@yahoo.co.uk> wrote:
> > Hi
>
> > I'm testing gheat for a project and have it running well locally.
>
> > But there are some issues to get it working on the production server
> > (aspen & pygame installs)
>
> > The data doesnt change often and so I've tried running the modified
> > gen-tile.py - figuring I can just upload changed tiles with cron or
> > somesuch
>
> > But...
> > running gen-tile from command line means it checks every possible tile
> > at each zoom level, and spends almost all its time (6+ hours now)
> > spewing out lots of 'skipping empty tile' messages.
>
> > I know pretty much what the lat, lng bounds are for the data sets. How
> > to constrain gen-tile to those limits?
>
> > I had a look thru the code but my python / geo / math knowledge isnt
> > up to the job :-(
>
> > I'm grateful for any input towards a solution.
>
> > G.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "gheat" group.
> > To post to this group, send email to gh...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > gheat+un...@googlegroups.com <gheat%2Bunsu...@googlegroups.com>.

Steven Lehrburger

unread,
Dec 27, 2010, 2:59:44 AM12/27/10
to gh...@googlegroups.com
Hey,

(Sorry for the delay! I've been traveling for the holidays :))

Try experimenting with setting numcols and numcols to prevent it from running to the other side of the world. If they're both set equal to 1, for example, you should only get one tile as output. Or try setting minrows/maxrows/mincols/maxcols to smaller positive integers that should result in more predictable behavior.

I think you're right about ll2px converting between latlong coordinates and pixel coordinates (it's worth noting explicitly that there's a *third* coordinate system on these maps, which is the current location in terms of the number of 256px by 256px tiles you are from the corner). There's also px2ll, if I remember correctly?

The code you had seemed to make sense? What was the problem you're having with it? If it's still making too many tiles try printing mincol/maxcol/minrow/maxrow to make sure they have the values you expect.

I <3 Python! You should be able to code it up in a relatively normal declarative fashion, to get it working, and worry about making it "pythonic" when you've got it working and are more comfortable with the language. 

Cheers,
Steven



To unsubscribe from this group, send email to gheat+un...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages