Tuesday, May 29, 2007

Algorithm for drawing a circle

A starting location with longitude, clong, and latitude, clat all in decimal degrees.
The radius, r, in km of the final circle.
Points that define the circle are 0, pi/10, 2pi/10, 3pi/10, 4pi/10, 5pi/10, 6pi/10, 7pi/10, 8pi/10, 9pi/10, pi, 11pi/10, 12pi/10, 13pi/10, 14pi/10, 15pi/10, 16pi/10, 17pi/10, 18pi/10, 19pi/10, angles from the central point with radius, r.

For each of 20 points that define the circle:
theta, the angle in radians, that changes from the horizontal for each point.

1. Calculate (x, y), the cartesian point that is x km east, y km north relative to the central point.
*a. x = r*cos(theta)
*b. y = r*sin(theta)

2. Calculate y'', the latitude of the point in decimal degrees.
*a. y' = y/111.12km/degree
*b. y'' = clat + y'

3. Calculate x'', the longitude of the point in decimal degrees.
*a. x' = x/[(111.320 + .373*sin(y''))*cos(y'')]/degree
*b. x'' = clong + x'

--tested this --
This doesn't quite work. The 'circle' isn't so much a circle but a flat heart shaped thing. If I use clat instead of y'' in the calculation of x', it looks more symmetrical, but it is still a bit stretched in the vertical direction. Here's the KML. Hmmm...

latitude longitude facts

1 minute of latitude = 1852 meters (very close approximation)
1 degree of latitude = 111.12 km
1 degree of longitude = (111.320 + 0.373sin²φ)cosφ km, where φ is latitude
(information from wikipedia)
For 21 points (last points overlap), each point is 18 degrees away from one another.

note to self: escape characters in html


< = &lt;
> = &gt;

Playing around with Google Earth


You can easily move placemarks by accessing their 'properties' then clicking and dragging. You can NOT easily move polygons in the same manner. Maybe that should be a design consideration.

Found a great application that makes all sorts of graphs in GE, called GE-Graph.
He (?) makes the circles as groups of 21 points (first and last the same), so not a true circle.

If you want multiple placemarks within the same file, they must be enclosed by a <Document></Document> tag. Otherwise, GE complains about having too many 'roots'.

Within the <Document> tag you can define a lot of styles using <style id="foo"></style> then reference those styles in the document using <styleUrl>#foo</styleUrl>.

Within a <Placemark> you can only have one point, polygon, etc. Otherwise, it only shows the last one. Unfortunately you can't click on polygon's to view their properties or description. It seems like the easiest way is to create two placemarks for each location. One that is a point, that the user can click on easily, the other the pie chart. Put these data in different folders (<Folder></Folder>) so you can easily turn off the labels.

Friday, May 25, 2007

Learning to use Subversion

Here are some pages I found useful in getting TortoiseSVN set up on my machine and talking to my source code repository hosted by google.

Explicit, simple instructions with screen shots.
Somewhat more complicated instructions, but more detailed
Google's hosting page walkthrough.
Manual for TortoiseSVN.

Set up code repository with google

Set up code repository with google. It was pretty easy to set up, but of course has no content yet. I'm not totally sure how to get set up using subversion yet.

Friday, May 18, 2007

Exploring PHP

I finished working through the simple PHP tutorial today. It was pretty helpful. Here are my notes:

Hint: "It's not working!?! Why?!?"
  • Check: Is Apache turned on? duh...
php tag:
  • <?php to start a php tag
  • ?> to end the tag
  • Use the tag within an html file to jump in and out of php.
  • Can jump in and out of php/html within a php block even.
Variable info:
  • Variables always start with a '$'.
  • Can see all reserved variables through phpinfo().
  • Variables can be pretty much the same types (bool, int, string, etc.) that they could be in C++, but you don't need to declare them that way. Also some mixed types and type casting is allowed.
Helpful functions:
  • strpos($haystack, 'needle'); //finds the string needle within the variable haystack. Returns the position, or FALSE.
  • int count (mixed $var [, int $mode] ); //Returns the number of elements in var, which is typically an array, since anything else will have one element.
  • PHP can access html form info easily. See tutorial for help.
Things to explore:
  • It seems like you can use php alone as well, without html surrounding it. Is that true?
    • For instance, <?php phpinfo(); ?> works fine in its own file.
  • What is "Model View Controller"? It sounds like a way of organizing your code to make it more readable and understandable.
  • The PHP manual is pretty helpful and has a lot of examples and documentation for functions, global variables, etc. I'm impressed with how easy it is to understand.

Wednesday, May 16, 2007

Wiki updates

I edited the EvoViz site and added PhylogeoViz to the list of programs. I've got to come up with a better name. Phylogeoviz is pretty boring. Ah well, that can come later on in development. I also added the detailed project plan to the wiki.

Tuesday, May 15, 2007

Detailed project plan

Here's my preliminary weekly project plan. Dates refer to the beginning of that work week. Any comments are appreciated!

Now til Start:
  • Phase 0: Getting development environment set up
    • Set up homepage, wiki, repositories, etc.
May 28
  • Phase 1: Exploratory phase
    • Learn how to embed maps on a webpage.
    • Learn the relationship between Google Earth and Google Maps.
    • How are they the same, how are they different? What can you do with one that you can't do with the other?
    • Explore KML and general XML.
    • Explore Google Earth and Google Maps APIs.
    • Create a pie chart using KML.
June 4
  • Finish exploratory work if neccessary.
  • Phase 2: Finalize design
    • Page by page description of what the user sees.
    • How to input data. Are they going to upload files, input in a text box? What format?
    • How to export data. Format? Data persistence? Can users store data, results, maps, etc.?
    • What is the viewer? Google earth? Google maps?
    • How large are the pie charts going to be in comparison with the geography? How do we deal with the problem of overlapping pie charts?
    • How are we going to color the pie charts? What if there are large numbers of haplotypes, how do we color them all distinctly and usefully?
    • The results of these decisions will be a comprehensive design document posted on the wiki.
June 11
  • Implement the basic pie chart generation functionality. Functionality should include:
    • Basic import of data.
    • Basic KML output writer.
    • Function that draws a pie chart.
    • Function that plots objects (working up to pie charts, but starting with placemarks) on a map.
  • Write corresponding documentation.
June 18
  • Combine pie chart generation and chart plotting functionality.
  • Write the functions that allow adjustments to the output (e.g. changing pie sizes, allowing the user to change haplotype colors, etc).
  • Write corresponding documentation.
June 18
  • Work on a function that allows the user to move pie charts around spatially (and to save those movements).
  • Write corresponding documentation.
June 25
  • Write the functions that display the KML back to the browser.
  • Write corresponding documentation.
July 2
  • Prepare for Botany conference.
  • Get code submitted to Google for midterm code check in.
  • Get a prototype of the viewer available for download.
  • Make sure I'm meeting the midterm evaluation criteria
July 9
  • Work on bugs that arose from earlier code.
  • Revisit full data manager design. Finalize UI design.
July 16
  • Implement UI for the data import functionality.
  • Expand (?) data files that are acceptable (haplotype, genotype, etc.)
  • Write the corresponding documentation.
July 23
  • Implement UI for customizing data analysis.
    • Example: the user should be able to select what loci/alleles/populations to include/exclude in the analyses.
July 30
  • Implement UI for output data manipulation.
    • Example: the user should be able to change the relative pie sizes, move pies around, change haplotype colors, etc.
August 6
  • Implement functions that allow the user to save the map visualization (e.g. jpg) or to save the KML file.
August 13
  • Perform user tests.
  • Ensure that the viewer and the data manager are well integrated.
  • Deposit code with Google.
  • Update website with new product, and all documentation.
August 20
  • Done coding. Final evaluations.

Installing PHP

I downloaded and installed PHP 5.2.2. Unfortunately, nothing happened. Somehow, the installer hadn't updated Apache's httpd conf file (which is inside the conf directory) to load php correctly. I think for most people the installer sets this file up for you automatically. Anyways, the useful directions I followed are here, where basically you insert 3 lines into the httpd file. Now I have "hello world" going on! Yay!

Installing Apache

Well, that's harder than it looks. I downloaded Apache for me to practice with a web server. For some reason it installed but was unable to start. Turns out that the port it wanted to use (port 80) was already in use by another program (turn out that Skype was the culprit!). I turned off Skype's ability to use that port, and voila! I now am hosting a page that says, "It works!". Great!

Sunday, May 13, 2007

Goals for this week

Complete detailed project plan, submit it to David, post on wiki.
Focus on how to generate these KML files:
Install Apache and PHP on laptop.
Investigate PHP.
Investigate java as an alternative.
Set up code repository on google.

Wiki updates

I worked on adding the project to the Phylo SoC wiki, and creating the wiki home for the project. Was a bit more time intensive than I had expected. I put the overall project plan up, but haven't added the detailed timeline yet. I'll need to do that this week.

I also made this blog public.

Researching KML

So I'm on google earth's KML tutorial page. Some highlights and considerations:

Google Earth (GE) can draw some pretty cool polygons and such. However, the edges of these polygons are defined directly by lat/longs. I'm not sure how this will play into generating these coordinates per population as appropriate to the data. The pies would be defined by multiple points, not points all connected to some central point, so centering, etc may be tricky.

GE's KML seems pretty similar to html markup styles. I don't think it'll be too hard to learn. It looks like you can define global styles (<style id="">) that you then can call appropriately.

You can link to stuff on the network as well. Check out "Network Links" in the future. You can link to static stuff (images, another kml file, etc.), but you can link to dynamically generated stuff too. For instance, you can connect to a cgi script. Also, you can send info about the current use (page view, what's highlighted, etc.), then use that info to generate some new kml, then feed that back to the user's GE. This could be a way to incorporate user feedback into the system. But it sounds like it could be tricky.

Another trick: to add html markups, use the CDATA element. Example, add:
...all usual html coded stuff here...
Otherwise, you'll have to escape all the < and >.

Knowles recent paper

David sent me this recent paper from the Knowles camp that has some nice graphics associated with it. Judging from the pie chart designs, it looks like the graphics were created in Illustrator.

Monday, May 7, 2007

Google Earth Workshop - from CIT

Run by Andrea Novicki through the Center for Instructional Technology.

Interesting, inspiring workshop. Went over how to create placemarks, what polygon, paths, overlays are. Basically did a tour of the general functionality of Google Earth. Interesting features I didn't know about:
can do 3D polygons
can have timelines, show changes over time
can implement tours
has a "ruler" to measure distances along paths, etc

Most important new thing: can share maps through the google earth community. Lots of neat maps already available, you can share your work easily.