Thread: Help with a Python script

Page 2 of 2 First 12
1. No Profile Picture
Contributing User
Devshed Newbie (0 - 499 posts)

Join Date
Jun 2005
Posts
30
Rep Power
14
Originally Posted by Shiner_Man
map simply applies a function(here it is the lambda function) to each item in the sequence. I think that lambda takes out the decimal but I'm not sure off the top of my head.

self is used in functions which appear inside classes(which are then called methods). In this case, I think whoever wrote this had that part of code in a method somewhere but put it into the script for some reason. Since all this code isn't in a method, the self part is useless(and causes and error).
You're right. From what I can tell, it does the following:

Code:
```points = [33.823,-84.151,33.822,-84.149,33.823,-84.147]

points = map(lambda x: int(x/1.0E-5), points)```
The resulting array should look like this:

points = [3382300, -8415100, 3382200, -8414900, 3382300, -8414700]

This way it deals with only whole numbers instead of decimals.
2. No Profile Picture
Contributing User
Devshed Newbie (0 - 499 posts)

Join Date
Jan 2004
Location
Atlantic City, NJ
Posts
327
Rep Power
17
Originally Posted by Absolut9
You're right. From what I can tell, it does the following:

Code:
```points = [33.823,-84.151,33.822,-84.149,33.823,-84.147]

points = map(lambda x: int(x/1.0E-5), points)```
The resulting array should look like this:

points = [3382300, -8415100, 3382200, -8414900, 3382300, -8414700]

This way it deals with only whole numbers instead of decimals.
and from there it goes bonkers! hehe...seriously I don't know what all that bit shifting is done for.
3. No Profile Picture
Contributing User
Devshed Newbie (0 - 499 posts)

Join Date
Jun 2005
Posts
30
Rep Power
14
Originally Posted by Shiner_Man
and from there it goes bonkers! hehe...seriously I don't know what all that bit shifting is done for.
There's really no rhyme or reason to it, it's just how Google encodes their lat/long points to input into an XML file. If you look at maps.google.com, and how they do driving directions, they use points to draw on tueir map. Those points can be from anything.. geometric points or lat/long points. In this case, we're using lat/long points to draw on the map. I'll be sure to show a final version when I can!

I think I might have this ported over to PHP here soon enough... Working out some errors.
Page 2 of 2 First 12