You are here
WEEK 4
Week 4 for me has been rather interesting, because I have now reached the stage where I am making scripts in Python for Google Earth. Since this is my first time using Python, I found it to be quite difficult, because it is indeed different from many programming languages that I have used before. It is a good thing that I have taken a class of Data Structures before, where now I can see where that comes into relation with Python. I started my week by installing the Apache server to my laptop. After I was done with that, I installed Python and then the modules (mod-python). I have to say that it was very annoying trying to get this to work in a Microsoft sort of environment, because there was this whole issue of file versions and the amount of programs available for programming in Python in a Microsoft Environment seem limited. A Linux machine would have made this a bit easier. The module, which is very critical for getting Python to work on the Apache server, was difficult to find because there seem to be none for the newest Python edition (in Microsoft that is). I had to downgrade to Python2.5 in order to use some module oddly named Psycopg2. It sounds strange, but it actually works! For what I’m seeing, I was very lucky to get that module, because there seemed to be no other modules that would have worked for Python2.5 and also as of now, the website seems to be down. All the other modules available are for older versions of Python which I can’t get a hold of.
So now the fun part came, which was learning Python in a short amount of time, and to make things better, I had to refresh my mind on all the SQL I’ve ever dealt with in the past, because I was going to start using it with Python. I’ve used Oracle before, and the database at CMOP uses PostGreSQL, they seem to be the same to when it comes to getting Queries. As for Python, the closest thing I could’ve thought for it was PHP, but even comparing it to that, it’s very different. After having got the hang of Python though, I have to say that it is pretty neat, and it is easier than what it seems. One just has to learn it, and not think of C++ or Java. Below is my first KML file that I created using Python.
Each of these points comes from the Grays Harbor mission. However as you might notice, or maybe not, there is an excessive amount of those beasts listed. The reason for that is because I accidentally used the wrong Query, where it shows every single point that The Glider sent to the database during its mission. Believe me, retrieving all of those points from the database made a total slow down on my system, it also caused Google Earth to nearly crash. All I can say is that this Python script grabbed around 110,000 points from the database for this mission. When I tried to connect each of those points with lines, I found out that lines did not show up at all on Google Earth. The reason for this was because Google Earth is only limited on using 60,658 points for making lines. I found this out the hard way….
After having shown my mentor this, he told me that I used the wrong table, so he gave me a new Query, which was much nicer and smaller, which by the way only consisted of around 200 points. What a difference! This next picture belongs to the zigzag mission, and notice how nicely these lines connect.
So now that I have the lines, what’s next? Well my next step will be to place the glider on there to follow the path. Sounds simple? I don’t think so. But it can be done. And there are many other improvements to be done with the code, because it is said to be "hard coded", and that is not convenient because soon I will retire from this and I won't be around to make changes to the code.