Tuesday, February 10, 2009

C++ vs AS3

I've been working on an iPhone app for the past week or so and I'm pretty happy to be coding in C++ again I must say. C++ is not perfect by any means, in fact strong binding is a constant thorn in my side after the free and easy ways of Actionscript. Here are a few pros and cons that immediately stood out in moving between the two.

    Pro C++:
  • Variable declaration ("int x" is much better than "var x:int")
  • Enums
  • Templates in general and template meta-programming specifically
  • #defines and conditional compilation
  • Speed of execution

    Pro Actionscript 3:
  • Dynamic typing
  • Static constants of any type
  • Built in associative arrays
  • Built in UTF8 string support
  • Size of compiled code
  • Platform neutrality


In general I prefer C++. Perhaps because it's closer to the hardware and more things are possible, but you really have to know what you are doing to not spin your wheels too much. I *really* miss built in associative arrays and the awesome set of standard objects available in Flash however.

Tuesday, February 03, 2009

New KML extensions?

There appears to be a few new KML extensions with the new Google Earth 5.0 release. As someone who has to keep up with my own implementation of the KML standard, this is of great interest to me. The new extensions seem to mostly be geared toward creating animated tours, a laudable goal. I think that is a great improvement in providing the ability for everyone to create more eye candy using GE. For some reason they just added a new namespace "gx" rather than putting out a new version of the spec. I guess this makes sense since the core functionality didn't change much and they can roll the new elements into the main spec in a future version.

The <gx:TimeSpan> and <gx:TimeStamp> tags are what most interest me. The spec quotes that they are merely copies of their standard KML namesakes, but that they "allow for the inclusion of time values in AbstractViews" and "Time values are used to control historical imagery, sunlight, and visibility of time-stamped Features". I don't know why they had to add copies in a different namespace when they could have just allowed the non gx versions to be included in the <Camera> and <LookAt> tags. What I think this all means is that you can now control the timeline of visible features using the <Camera> tag. A huge improvement. however I've spent a year or two going down the road of trying to create dynamic animations using static control values to hardwired algorithms. It will get you down the road a little ways, but it is a totally inflexible and brittle way of defining 3D animation.

I am a little disappointed that they didn't include time coordinates as I suggested last summer. I think that I mentioned at the time that I had no interest in spending time getting that feature through the appropriate committees to make it happen, but I think that at this point I probably would, even though I have less time available now. The time coordinates I proposed, based on modified julian date, are tremendously useful.

As an example, the new EarthBrowser Site Tracker uses them to define the animated visitor hits. Basically each visitor hit looks like this:
<Placemark>
<name>...</name>
<LineString>
<coordinates>coord0 coord1 coord2 ...</coordinates>
<ebr:time>mjd0 mjd1 mjd2 ...</ebr:time>
<ebr:fade>.0625</ebr:fade>
</LineString>
</Placemark>


The interesting parts are the <ebr:time> and <ebr:fade> tags. What they specify are the modified julian date time value at which each coordinate in the LineString occurs. This provides an easy way to animate a single placemark by using linear interpolation to calculate intermediate locations for smooth animation and also provides the ability to show a cool time based fade effect. The <ebr:fade> specifies that after 1.5 hours the line trace should fade. I use these two KML extensions with the Satellite orbits in the latest version of EarthBrowser and also in the site tracker tool. To do something roughly equivalent in current KML, you would have to provide thousands of Placemarks each with their own TimeSpan and geometry, there would be no smooth animation or fade effect and it would take many megabytes for each placemark. With these two simple extensions I can display some really interesting features with effects in a single placemark with a very small footprint. If anyone from the OGC or Google is interested in contacting me about helping these extensions get through to the next spec, please post a comment or send me an email.

Interesting EarthBrowser Site Tracker discoveries

Last week I released the EarthBrowser Site Tracker, a free tool that gives an animated 3D global view of traffic to any website. I've been monitoring my own site traffic with it and have noticed some very interesting trends about my site, and perhaps some insight into the people who visit. It seems that I get slightly more European visitors than US visitors. Perhaps that is because EarthBrowser is in about 15 different languages and a lot of software is only in English. More people seem to visit a few hours after daybreak, perhaps when they get to their jobs, but in EuropeI've noticed that there seems to be a burst of visitors about an hour after nightfall.

The code was pretty simple and written in roughly 100 lines of Javascript which basically puts up the time slider, zoom scroller and loads the data file. I have some plans on improving the actual analysis and visualization of the data. I'd like to do trends such as visitors per country, browser language preferences, top countries and states and other fairly simple breakdowns of generic statistical data. But that will have to wait for a month or so, as will the open Javascript/Flex EarthBrowser API.

I am learning yet another new platform to program on. I got myself an iPod Touch, which is like an iPhone without the phone. I've just started porting some of my OpenGL framework from a mothballed version of EarthBrowser to OpenGL ES for a couple of new projects, one I'm doing as a contract. The new apps are really cool and a lot of people are going to love them. I'm not so impressed with most of the iPhone apps I've seen so far sadly, Google Earth is by far the best. Perhaps it is just hard to find good apps when there are tens of thousands out there, hopefully mine will be compelling enough to get some attention.