Posts: 52
Threads: 8
Joined: Apr 2017
I've been trying to figure it out for the last 4 days - no luck!
Posts: 8,169
Threads: 160
Joined: Sep 2016
(May-23-2017, 09:53 PM)kendias Wrote: I've been trying to figure it out for the last 4 days - no luck!
1 2 3 4 5 6 7 8 9 10 |
Python 2.7 . 12 (default, Nov 19 2016 , 06 : 48 : 10 )
[GCC 5.4 . 0 20160609 ] on linux2
Type "help" , "copyright" , "credits" or "license" for more information.
>>> x = '5'
>>> type (x)
< type 'str' >
>>> y = 5
>>> type (y)
< type 'int' >
>>>
|
Posts: 52
Threads: 8
Joined: Apr 2017
May-24-2017, 01:50 PM
(This post was last modified: May-24-2017, 01:51 PM by kendias.)
Thanks Buran.
I am trying this script to convert from decimal to degrees to use on Google Maps but get errors:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
import webbrowser
import string
def to_degrees(lats, longs):
lat_deg = lats[ 0 : 2 ]
lat_mins = lats[ 2 : 4 ]
lat_secs = round ( float (lats[ 5 :]) * 60 / 10000 , 2 )
lat_str = lat_deg + u '°' + lat_mins + string.printable[ 68 ] + str (lat_secs) + string.printable[ 63 ]
lon_deg = longs[ 0 : 3 ]
lon_mins = longs[ 3 : 5 ]
lon_secs = round ( float (longs[ 6 :]) * 60 / 10000 , 2 )
lon_str = lon_deg + u '°' + lon_mins + string.printable[ 68 ] + str (lon_secs) + string.printable[ 63 ]
return [lat_str, lon_str]
to_degrees( 50 , 50 )
TypeErrorTraceback (most recent call last)
<ipython - input - 222 - 1cfff49fb11e > in <module>()
- - - - > 1 to_degrees( 50 , 50 )
c:\users\dell\appdata\local\temp\tmpxzjzal.py in to_degrees(lats, longs)
TypeError: 'int' object has no attribute '__getitem__'
|
Posts: 3,458
Threads: 101
Joined: Sep 2016
What's the actual traceback? There's no line number there, or any context.
Posts: 52
Threads: 8
Joined: Apr 2017
May-24-2017, 07:04 PM
(This post was last modified: May-24-2017, 07:04 PM by kendias.)
Here is the traceback. It was posted in the main body in my last post.
1 2 3 4 5 6 7 8 |
to_degrees( 50 , 50 )
TypeErrorTraceback (most recent call last)
<ipython - input - 222 - 1cfff49fb11e > in <module>()
- - - - > 1 to_degrees( 50 , 50 )
c:\users\dell\appdata\local\temp\tmpxzjzal.py in to_degrees(lats, longs)
TypeError: 'int' object has no attribute '__getitem__'
|
Posts: 566
Threads: 10
Joined: Apr 2017
(May-24-2017, 01:50 PM)kendias Wrote: Thanks Buran.
I am trying this script to convert from decimal to degrees to use on Google Maps but get errors:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
import webbrowser
import string
def to_degrees(lats, longs):
lat_deg = lats[ 0 : 2 ]
lat_mins = lats[ 2 : 4 ]
.........
to_degrees( 50 , 50 )
TypeErrorTraceback (most recent call last)
<ipython - input - 222 - 1cfff49fb11e > in <module>()
- - - - > 1 to_degrees( 50 , 50 )
c:\users\dell\appdata\local\temp\tmpxzjzal.py in to_degrees(lats, longs)
TypeError: 'int' object has no attribute '__getitem__'
|
You are tying to slice integers in your function - what did you expect? You are calling your function with wrong data - your arguments should have been strings in specified format
Test everything in a Python shell (iPython, Azure Notebook, etc.) - Someone gave you an advice you liked? Test it - maybe the advice was actually bad.
- Someone gave you an advice you think is bad? Test it before arguing - maybe it was good.
- You posted a claim that something you did not test works? Be prepared to eat your hat.
Posts: 52
Threads: 8
Joined: Apr 2017
May-25-2017, 06:43 PM
(This post was last modified: May-25-2017, 06:43 PM by kendias.)
Thanks.
Now using the data I get from my smartphone GPS to do the same job. Using an app to get the data into my computer. So, have to parse it (as before) to get GPS coordinates. Basically the serial function is replaced by wireless xmission. Sample data:
?><NodeId>1</NodeId><GPS><Latitude>43.75205871</Latitude><Longitude>-79.25402676</Longitude><Accuracy>10.0</Accuracy></GPS><TimeStamp>1495736446846</TimeStamp>
|