+teamalizelos Posted March 23, 2015 Share Posted March 23, 2015 Original post can be found here: http://forums.Groundspeak.com/GC/index.php?showtopic=319986 I am posting here with a better Topic Title in case any others would find themselves using this I can compile to a .exe and maybe take the time to do a GUI Frontend for a stand alone windows application. Start of original post: I know my post here is old just got back into geocaching more and revived my old code to work with gpsbabel under windows. To have the code work under linux just remove the .exe from the os.system calls. The reason for creating the code is to have multiple pocket queries on my Driving Garmin NUVI with POI icon data and the short name showing up rather than the cache name as GCXXXXX etc. To use: 1. Download all your pocket queries to one folder 2. Extract the zip files in that same folder 3. Change line C:\\Users\\' + currentuser + '\\Desktop\\geocaching if needed (If you store the pocket queries in a folder on your desktop named geocaching and using windows you likely can skip this step) 4. Have a bmp file in the same directory you are running the script from that is no larger than 24x24 pixels 5. Run the script 6. Copy the remaining Geocaching.gpi to Garmin in path of Garmin\Poi (I had to create the folder Poi in Garmin folder) If enough people would be at all interested in using this script I may put forth the effort to create a GUI Frontend to where you can click browse to go to the folder that your gpx data is located and also a browse feature for the bmp icon and allow this to be optional. Thanks a ton for the hard work to the developer(s) of gpsbabel which acted as a swiss army knife in accomplishing what I was wanting to do with the script. Maybe there is a command line switch already but in the past I was unable to get this working to display the cache names on my Garmin NUVI hence why I decided to code a script in the first place. I believe the previous version of gpsbabel I was using this feature was not working properly so I coded around it. import re import os import fnmatch import getpass currentuser = getpass.getuser() matches = [] for root, dirnames, filenames in os.walk('C:\\Users\\' + currentuser + '\\Desktop\\geocaching'): for filename in fnmatch.filter(filenames, '*.gpx'): if not re.match('.*-wpts.gpx', filename): matches.append(os.path.join(root, filename)) mystring = "" for match in range(len(matches)): mystring+=str(" -f \"" + matches[match] + "\"") finalstring = mystring.replace('\\', '/') os.system("gpsbabel.exe -i gpx" + finalstring + " -x duplicate,location,shortname -o gpx -F 1.gpx") name = re.compile("^\s+<name>.*<\/name>") urlname = re.compile("^\s+<urlname.*<\/urlname>") filehandler1 = open('1.gpx', 'r') filehandler2 = open('final.gpx', 'w') for line in filehandler1: if name.match(line): newline = line.replace('<name>', '<urlname>') finalline = newline.replace('</name>', '</urlname>') filehandler2.write(finalline) elif urlname.match(line): newline = line.replace('<urlname>', '<name>') finalline = newline.replace('</urlname>', '</name>') filehandler2.write(finalline) else: filehandler2.write(line) filehandler1.close() filehandler2.close() os.system("gpsbabel.exe -i gpx -f final.gpx -o garmin_gpi,category=Geocaching,bitmap=geocaching.bmp -F Geocaching.gpi") os.remove("1.gpx") os.remove("final.gpx") print "Done" Quote Link to comment
+Red90 Posted March 23, 2015 Share Posted March 23, 2015 I'm guessing 99% of the cachers would use GSAK if they wanted to do something like that. Very simple with no special coding in GSAK. Quote Link to comment
+Walts Hunting Posted March 24, 2015 Share Posted March 24, 2015 I'm guessing 99% of the cachers would use GSAK if they wanted to do something like that. Very simple with no special coding in GSAK. Agreed. Quote Link to comment
+teamalizelos Posted March 24, 2015 Author Share Posted March 24, 2015 if memory serves correct gsak can be confusing and also to use some of the features you have to pay for them my code would be click browse to icon click and browse to directory where gpx data is stored click run and being 100% free seems better imo Quote Link to comment
+Walts Hunting Posted March 24, 2015 Share Posted March 24, 2015 For a task as simple as this gsak is not confusing at all. True for one simple task your script works bur gsak does so much more. Cost is cheap if you look at all the money you spend on caching. About half a tank of gas. Quote Link to comment
+teamalizelos Posted March 24, 2015 Author Share Posted March 24, 2015 cool the community has spoken then, lol I will just keep the code for personal use and if anyone knows how to get a working python instance on windows, linux, or mac my code is reusable on all three. GSAK I know for a fact will not run on Linux without a Virtual machine Quote Link to comment
+Walts Hunting Posted March 24, 2015 Share Posted March 24, 2015 True it won't. But given the amount of people that run linux it doesn't seem to be an issue that had ever been raised Quote Link to comment
robertlipe Posted March 25, 2015 Share Posted March 25, 2015 I may be close to a conflict of interest on this one, but as a moderator, I see no reason to discourage someone from sharing a (free) tool they've created to make geocaching easier for others. If I hadn't been unhappy with gpsutil and created GPSBabel and given it away, I'll be so cocky as to say that the state of Geocaching apps would be very different. Just because it's not useful to you or you're terrified of regularly expressions doesn't mean it's not useful to others. Please be respectful of posters that have created and are sharing something for others. Let's not organize book burnings just because you're not interested in the book. P.S. I think you can leave the ".exe" out and it'll work without changes on any of the OSes... Quote Link to comment
+Walts Hunting Posted March 26, 2015 Share Posted March 26, 2015 I don’t think I am guilty of what you imply. I did not discourage him from publishing it but after someone else pointed out that there are already programs that do it I supported that. That occurs almost daily on this forum. Most often mentioned is GSAK which I wasn’t the first to mention. I don’t understand “not useful to you or you're terrified of regularly expressions “ did it get changed by auto correct or something. I think all my comments were respectful but you seem to think that content you disagree with is not respectful. It seems to me the book burning was in two statements. “if memory serves correct gsak can be confusing and also to use some of the features you have to pay for them” And “GSAK I know for a fact will not run on Linux without a Virtual machine” Both of these statements were burnings of GSAK which I responded to in a respectful manner pointing out facts and explaining that GSAK isn’t always that confusing. Given that 125 people have viewed this topic and no one has raised his hand and said “Please send a copy to me when you have it done” seems to validate my sentiments. The great void of silence on the subject speaks for itself. Quote Link to comment
+Red90 Posted March 26, 2015 Share Posted March 26, 2015 I agree. Robert's reaction is excessive. People were just providing help and viewpoints. Quote Link to comment
+MartyBartfast Posted March 26, 2015 Share Posted March 26, 2015 People were just providing help and viewpoints. I don't see anything helpfull in the responses; viewpoints yes, help no. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.