php port?

40 views
Skip to first unread message

Chad Whitacre

unread,
Nov 17, 2009, 2:10:03 PM11/17/09
to gh...@googlegroups.com
The maps are static and we rewrote all of your px2ll and ll2px functions in PHP.

So does that mean you have a PHP port of gheat that I can link to? :-)

Are you using any of the original Python in production?


chad



On Tue, Nov 17, 2009 at 2:06 PM, pro...@gmail.com <pro...@gmail.com> wrote:
Hi Chad,

Sorry for hijacking this thread, but I wanted to show you what I've been using gheat for. I generate maps like this one: http://trends.numberinvestigator.com/current-victims/archives/highres/2009-10-19-07-01-04.png
every hour. We track telemarketing calls received, and robocalls made and build maps and videos. The maps are static and we rewrote all of your px2ll and ll2px functions in PHP.

P





On Tue, Nov 17, 2009 at 2:51 PM, Chad Whitacre <ch...@zetaweb.com> wrote:
Hrm. Ok, glad you found a workaround. Sounds like ll2px needs some scrutiny though.


chad




On Mon, Nov 16, 2009 at 7:59 PM, Steven Lehrburger <lehrb...@gmail.com> wrote:
I took your (implicit/unintended?) suggestion and started playing
around with using px2ll instead of ll2px, and that seems to have done
the trick. The following three lines seem to be giving me what I need:

     self.georange = gmerc.px2ll(x * 256, y * 256, zoom)
     self.georange_next = gmerc.px2ll((x + 1) * 256, (y + 1) * 256,
zoom)
     self.zoom_step = [ self.georange_next[0] - self.georange[0],
self.georange_next[1] - self.georange[1]]

I might run into problems at the edges of the map, but it looks like
it's working for now. The problem was that Google doesn't seem to use
latitudes that range all the way from 90 to -90, since px2ll(0,0,0)
returns (85.051128779806604, -180.0), so that was probably breaking my
previous calculations.

Thanks, and I'll be sure to let you know when this is done :)

- Steven


On Nov 16, 5:28 pm, Steven Lehrburger <lehrbur...@gmail.com> wrote:
> (So maybe I've made a mistake somewhere, but if not, then I think
> ll2px is not returning the actual height of the map in pixels.)
>
> On Nov 16, 5:26 pm, Steven Lehrburger <lehrbur...@gmail.com> wrote:
>
> > Hi Chad, thanks for getting back to me so quickly!
>
> > First, I apologize, I misspoke in my first email and switched lat and
> > long - I meant "I'm getting a reasonable longitude for that tile from
> > ll2px, but I'm getting a latitude of ~37". Also, you're right, I
> > wasn't sufficiently specific about what I was doing - once I have the
> > width and height of the entire map at that zoom level in pixels (which
> > is all I'm using ll2px for), I'm dividing each by 256 to get the
> > number of rows and columns of tiles. I'm then using that to get the
> > number of degrees of latitude and longitude per tile, and the latitude
> > and longitude of the northern and western edges of the tile in which
> > I'm interested.
>
> > I have a python script that reproduces the problem athttp://dpaste.com/121311/,
> > which borrows heavily from but is not identical to code in gheatae/
> > tile.py on the gheat-ae project. Run "python gmerc_test.py  2412 3079
> > 13" from the command line and you should see output like:
> >      x, y and zoom = 2412, 3079 and 13
> >      width, height = 2097152, 2701322
> >      numcols, numrows = 8192, 10553
> >      zoom_step = [0.017056761110584667, 0.0439453125]
> >      georange = (37.482232540509813, -74.00390625)
> > It's the latitude (the first part) in georange that I'm expecting to
> > be ~40 instead of ~37. It *is* possible I'm calculating the georange
> > incorrectly, but I've thought it through over and over and I think
> > that's correct: if the 0,0 tile has a latitude of 90, I want to go
> > down/south from there by an amount for each tile equal to the number
> > of degrees per tile.
>
> > Thanks again,
> > Steven
>
> > On Nov 16, 4:13 pm, Chad Whitacre <c...@zetaweb.com> wrote:
>
> > > Steven,
>
> > > Sorry for the troubles. However, I'm confused about what "a reasonable
> > > latitude for that tile from ll2px" means, since ll2px returns pixel
> > > coordinates, not lat/lng. Do you mean px2ll here?
>
> > > Could you provide some example python code that reproduces the problem?
>
> > > Thanks!
>
> > > chad
>
> > > On Mon, Nov 16, 2009 at 2:11 PM, Steven Lehrburger <lehrbur...@gmail.com>wrote:
>
> > > > Hi everyone,
>
> > > > I'm a graduate student at NYU's Interactive Telecommunications Program, and
> > > > I'm working on a visualization of a Foursquare <http://foursquare.com/> (NYT
> > > > article)<http://www.nytimes.com/2009/10/19/technology/internet/19foursquare.html> user's checkin
> > > > data for my class <http://webremix.org/> on website mashups. I'm trying to
> > > > use what appears to be a relatively new port of gheat<http://code.google.com/p/gheat-ae/>for Google AppEngine, and I think I'm having trouble with thell2px(lat,
> > > > lng, zoom) function in gmerc.py. The function is the same in both
> > > > projects, and it looks like it's being called in both projects with
> > > > lat=-90, lng=180, and the current zoom level to get the width and height
> > > > of the entire map at that zoom level in pixels. That information is then
> > > > used by gheat-ae to determine the latitude and longitude bounds of the
> > > > current tile for querying the database of points to select only those items
> > > > that will be displayed on that tile of the map, and it's also used for
> > > > determining the pixel locations of each point for calculating their colors.
>
> > > > It appears, however, that the function isn't quite working. At zoom level
> > > > 13 the tile at x=2412 and y=3079 has a latitude of approximately 40.7 and a
> > > > longitude of approximately -74.0 (Google has a nice little Tile Detector<http://code.google.com/apis/maps/documentation/examples/tile-detector...>example, that location is in lower Manhattan near NYU). I'm getting a
> > > > reasonable latitude for that tile from ll2px, but I'm getting a longitude
> > > > of ~37, which is too far south (near Washington D.C.). Since ll2pxcalculates the latitude and the longitude differently it seems possible that
> > > > one would be off but not the other; could those constants at the top of
> > > > gmerc.py somehow have changed?
>
> > > > Really, ll2px is more general than I need - this width and height that it
> > > > returns is only used by gheat-ae to get the number of rows and columns of
> > > > tiles in the entire map at the current zoom level; there must be a simpler
> > > > way to do this that does not require a modified version of Google's
> > > > obfuscated JS?
>
> > > > Thoughts, anyone? If it's working for everyone else, then my problem might
> > > > be somewhere else; but my other stuff seems to be working ok...
>
> > > > Thanks!
>
> > > > Best,
> > > > Steven Lehrburger
> > > > NYU ITP c/o 2010
> > > >http://lehrblogger.com
>
> > > > --
> > > > 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>.
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/gheat?hl=.

--

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=.



--

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=.

--

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=.

pro...@gmail.com

unread,
Nov 17, 2009, 2:15:19 PM11/17/09
to gh...@googlegroups.com
Yes we are using the python in production and some dirty PHP code that calls the python scripts to generate the tiles and then overlays them using the ll2px and px2ll functions.
I am traveling at the moment but when I get back I will post some examples, code and ideas.

Pascal

Chad Whitacre

unread,
Nov 17, 2009, 3:57:35 PM11/17/09
to gh...@googlegroups.com
Thanks Pascal! I've put up a link on the project page:



chad

M

unread,
Dec 7, 2009, 11:27:14 AM12/7/09
to gheat
Pascal,

It sounds like your solution would work without Aspen, is that
correct? I don't think my ISP will allow me to run Aspen on their
servers and a php solution without any custom daemons would be great.

Will you please share what you have? I'm willing to take stuff in raw
form and make it work or learn from it.

Chad, gheat looks perfect for a community project I am working on to
map different types of crime in my town.

Thanks to you both!
Mark

Chad Whitacre

unread,
Dec 7, 2009, 4:44:28 PM12/7/09
to gh...@googlegroups.com
Mark,
 
It sounds like your solution would work without Aspen, is that
correct?  I don't think my ISP will allow me to run Aspen on their
servers and a php solution without any custom daemons would be great.

You might also look at JJ Guy's standalone port:


 
Chad, gheat looks perfect for a community project I am working on to
map different types of crime in my town.

Cool. If/when you get something up, let me know and I'll link it on the project page.



chad 

pro...@gmail.com

unread,
Dec 7, 2009, 7:19:29 PM12/7/09
to gh...@googlegroups.com
I guys,

I believe JJ Guy's standalone port generates KLM files.

Mark, I can't share all of the source code, however I can guide you with achieving the same result with PHP. You would need to have shell access to the server where you will be generating the heatmaps, and you need to make sure that you are able to load points and generate tiles with that TileGen.py script. If your ISP won't allow you to run Aspen, I'm not sure if they will allow you to run these python scripts properly at all. I remember that installing gheat on my server required full root access as I had to install many dependencies.
If you can get that to work, I will help you get the result you want using PHP as the frontend step by step.

To outline the process, you will need a blank map, then you will load up points, use tilegen to generate the tiles for the zoom level you want, and then the PHP script will load up the tiles and overlay them on top of your blank map, add any text overlays, and save the resulting file.
I will see what source code I can dig up if you can get around to installing gheat without aspen and you can call the python scripts from the command line.

Pascal.

--

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.

Chad Whitacre

unread,
Dec 7, 2009, 9:13:52 PM12/7/09
to gh...@googlegroups.com
Pascal,

I believe JJ Guy's standalone port generates KLM files.

Indeed, but it can also output straight PNGs. I believe you could use it instead of gen-tile.py in the setup you describe.

Anyway, sounds like you and Mark are on the right track.



chad

M

unread,
Dec 8, 2009, 7:26:40 AM12/8/09
to gheat
Pascal,

Excellent point about my hosting provider likely not providing
sufficient packages to install what I need without root access.

I did get gheat running on a home linux and will probably set up some
proxying to protect the url at my house by requiring login and then do
caching on the server side so I rarely try to get images from home.

Chad, Great work!! I was able to get gheat working in a lot less time
than I thought. At first I thought it wasn't working, but I was
zoomed in so close that they images were transparent! Next I need to
read up on the forum about what seems to be prevent calculations on
some dense areas and on how to load and run with multiple sets of data
without cloning the directly and running each dataset on its own port
(which isn't that hard).

I can't seem to find the right package/repository mix to get numpy on
opensuse 11.0 64bit as a prereq for Pygame, but probably not an issue
given that my small area will be cacheable and data changes infrequent
for now.

Thanks!
Mark

On Dec 7, 7:19 pm, "pro...@gmail.com" <pro...@gmail.com> wrote:
> I guys,
>
> I believe JJ Guy's standalone port generates KLM files.
>
> Mark, I can't share all of the source code, however I can guide you with
> achieving the same result with PHP. You would need to have shell access to
> the server where you will be generating the heatmaps, and you need to make
> sure that you are able to load points and generate tiles with that
> TileGen.py script. If your ISP won't allow you to run Aspen, I'm not sure if
> they will allow you to run these python scripts properly at all. I remember
> that installing gheat on my server required full root access as I had to
> install many dependencies.
> If you can get that to work, I will help you get the result you want using
> PHP as the frontend step by step.
>
> To outline the process, you will need a blank map, then you will load up
> points, use tilegen to generate the tiles for the zoom level you want, and
> then the PHP script will load up the tiles and overlay them on top of your
> blank map, add any text overlays, and save the resulting file.
> I will see what source code I can dig up if you can get around to installing
> gheat without aspen and you can call the python scripts from the command
> line.
>
> Pascal.
>
> On Mon, Dec 7, 2009 at 10:44 PM, Chad Whitacre <c...@zetaweb.com> wrote:
> > Mark,
>
> >> It sounds like your solution would work without Aspen, is that
> >> correct?  I don't think my ISP will allow me to run Aspen on their
> >> servers and a php solution without any custom daemons would be great.
>
> > You might also look at JJ Guy's standalone port:
>
> >    http://jjguy.com/heatmap/
>
> >> Chad, gheat looks perfect for a community project I am working on to
> >> map different types of crime in my town.
>
> > Cool. If/when you get something up, let me know and I'll link it on the
> > project page.
>
> > chad
>
> > --
> > 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>.

Chad Whitacre

unread,
Dec 8, 2009, 3:08:33 PM12/8/09
to gh...@googlegroups.com
Mark,
 
Chad, Great work!!  I was able to get gheat working in a lot less time
than I thought.

Thanks and glad to hear it. :)

Let us know if you get stuck ...



chad

pro...@gmail.com

unread,
Dec 8, 2009, 3:11:55 PM12/8/09
to gh...@googlegroups.com
Pygame was the hardest part for me.
I believe the issue you described with the transparency can be resolved by tweaking some of the settings. There is also a patch that was released in this group a while back that pushes the transparency to the client. It may work from what I understand of your use of gheat.

Pascal.

--

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.

john.m...@evariant.com

unread,
Jan 2, 2013, 11:00:49 AM1/2/13
to gh...@googlegroups.com
Im sorry, but did anyone ever get it ported to php? I cant use python :( If not Ill start writing a port if I have too :(

> > > > For more options, visit this group at
> > > >http://groups.google.com/group/gheat?hl=.

--

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=.


--

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=.

John Marczak

unread,
Jan 2, 2013, 2:53:22 PM1/2/13
to gh...@googlegroups.com

Does anyone have a download link?

To view this discussion on the web visit https://groups.google.com/d/msg/gheat/-/bsjKkuBB7C8J.


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.

Chad Whitacre

unread,
Jan 2, 2013, 3:31:31 PM1/2/13
to gh...@googlegroups.com
John,

All the ports I've heard about are linked on:


By download link do you mean this?




chad


For more options, visit this group at http://groups.google.com/group/gheat?hl=en.

John Marczak

unread,
Jan 2, 2013, 3:47:51 PM1/2/13
to gh...@googlegroups.com

Sorry, I meant  a PHP port download, but Im guessing since it isn’t listed it hasn’t been created, sorry about that lol  I thought I read in the post history that someone created one. I may do it and Ill be sure to post the source. Thanks J

Chad Whitacre

unread,
Jan 2, 2013, 3:53:16 PM1/2/13
to gh...@googlegroups.com
Thanks John, would love to link to it.


chad
Reply all
Reply to author
Forward
0 new messages