Thursday, May 14, 2009

Zoltar Available on iTunes

Actually it's been available for about a week now but Apple didn't list it. I've run into a big problem with the iTunes store that a lot of other developers have been having. The result is that I've only had a few downloads, and Zoltar is much higher quality than most apps I see out there.

I hate to ask, but for anyone who follows this blog and has an iPhone, please go to the iTunes store and give Zoltar a great review. I'll buy you a beer the next time I see you!

SQLite C++ wrapper, so you don't have to

SQLite is great. It is small, fast and easy to set up. However, if you are writing software that needs it, you're in for a bit of learning. You will need to learn what API calls to make and when to make them, usually by going over example code and using trial and error. I am introducing an open source SQLite C++ wrapper that will allow you to use the database without having to learn the SQLite API. It may save you several days of work.

The wrapper is just two C++ files, has a MIT style license and is platform independent. You will still need to link in SQLite 3.0 and learn the quirky SQLite SQL syntax.

You can download it here.

Creating a database and table
#include "sdsqlite.h"

void create_db(void)
sd::sqlite database("mydb.db");
database << "create table if not exists work (first_name text, last_name text, hours real)";

Database insertion
#include "sdsqlite.h"

struct work_data { char* first; char* last; float hours; };

work_data wdata[] = {
{"Joe", "Smith", 2.5},

void insert_rows(void)
sd::sqlite database("mydb.db"); // open the db with the table already created

sd::sql insert_query(database); // build an sql query
insert_query << "insert into work (first_name, last_name, hours) VALUES(?, ?, ?)";

database << "begin transaction";// create a transaction for speed

// insert data (sdsqlite will auto-detect data type and execure query)
for(int i=0;i<sizeof(wdata)/sizeof(work_data);++i)
insert_query << wdata[i].first << wdata[i].last << wdata[i].hours;

database << "commit transaction";// complete transaction
catch(sd::db_error& err)
// do something with error

Database extraction
#include "sdsqlite.h"

void extract_name(const std::string& name)
sd::sqlite database("mydb.db"); // open the db with the table already created

// select all names that begin with the contents of the "name" variable
sd::sql selquery(database);
selquery << "select first_name, last_name, hours from work where first_name like ?" << name+"%";

// extract the matching rows
float hours;
std::string first, last;
selquery >> first >> last >> hours;

// do something with the data
catch(sd::db_error& err)
// do something with error

Thursday, April 30, 2009

Zoltar the iPhone Fortune Teller

I've been taking a break from EarthBrowser for the past couple of months and working on an iPhone app. The result is Zoltar the Fortune Teller.

Apple is now reviewing it for release in the iTunes store. I've heard it takes anywhere from a couple of days to several weeks if they don't send it back for fixes. Hopefully it will be available in the next week or so. I'll do another post when it is up.

You select a card from one of five categories and Zoltar will do a divination on his magic crystal ball. He then will speak your fortune to you from a set of over 100 fortunes based in part on the minor arcana of the Tarot deck. You can rotate him around and zoom in close with a swipe or pinch on the iPhone screen. I created the music and am the voice of Zoltar and put some spooky echo effects so it sounds pretty cool.

It was a really fun project which allowed me to test the limits of the iPhone hardware. The model of Zoltar was created by my cousin in 3d Studio Max and has over 10,000 polygons. Even so it renders at about 30 frames per second which is really good for such a small processor.

The 3d game engine that powers EarthBrowser was originally ported from C++/OpenGL into ActionScript. Since then I have made many improvements and I've re-ported it back to C++. Have I said lately how much I like OpenGL since I don't have to write my own 3d graphics library like I do in Flash? I built bindings into the Lua scripting language for ease of development. Lua has a strange syntax but it is lightweight and fast and gets the job done.

Thursday, March 12, 2009

iPhone OS 3.0

Engadget is reporting that version 3.0 of the iPhone OS will be announced on March 17th.

I'm excited to hear what is going to come out in the new OS, but rumors are that there will be a micropayments model, which if true will be huge. However it seems to me that typing in your iTunes password for each micropayment would be a bit too unpleasant.

Wednesday, March 11, 2009

iPhone vs. Flash Player smackdown

Developing for the closed iPhone ecosystem is similar in many ways to Flash development. The graphics capabilities alone make it a superior platform. It doesn't have to be that way. I'm proposing three bold moves that would enable Flash to extend it's current lead in the RIA space and attract even more developers to the platform.

1) Explicit 3D graphics card support
Adobe can sandbox it all they like, but access to native high speed 3D rendering is one of the things that is making the iPhone such a hot platform. All that is really needed is to be able to pass on projection matrices, interleaved vertex buffer data, lighting and material settings to a graphics card and let it do it's thing. Make it detectable so developers can have a fallback if it's not available. Instantly web games become 1000% more possible.

2) A Javascript bridge a mile wide
ExternalInterface can get you where you need to go, with a lot of effort. Can you make it easier for us Adobe? I've taken the FABridge code, fixed some bugs (try passing the string \" from JS), and enabled the EarthBrowser plugin to be completely scriptable in Javascript. If Adobe could sit a few people down and nail down support for all browsers (including using VBScript to fake property getters and setters in IE7) then you could in effect create any Flash app completely in Javascript. This would open up a whole new world of possibilities for developers to create on the fly code that wouldn't have to be precompiled into a SWF. This would be HUGE.

3) An app store like iTunes
Along with great hardware, sleek design and serious developer tools the iPhone has a way for developers to monetize their creations. Adobe should do this for AIR apps and Flash plugins. Make a marketplace of website widgets and AIR apps that can be purchased for a few bucks. I have to administer my own servers and integrate a purchasing system with credit card companies, renew and manage a https certificates and deal with a lot of technical support not directly related to my software. It is a very small percentage of developers that are willing and able to spend the kind of time and money that it takes in order to sell stuff online. Apple has managed to create a system that does all of the heavy lifting of e-commerce and takes a healthy 30% cut for itself, but it's worth every percentage point.

Adobe has a spectacular platform that has a lot of room to grow. Flash market penetration is unreal and it is time for Adobe to get out of their overly cautious mindset and really create something new to help us developers create. Hire me, I'll direct the development.

Tuesday, March 03, 2009

Turned down for Where 2.0

I'm a little disappointed that my Where 2.0 proposal was rejected. I thought that demonstrating a virtual globe that supports KML and Shapefiles, can do coordinate projections on large datasets and be completely customized with Javascript and embedded on any website would be somewhat interesting. I find it interesting.

They have some interesting talks planned to be sure, I suppose if I were a sponsoring corporation they might have taken me more seriously. At least they offered me a 25% discount on the $1000+ registration fee to attend, but I don't think I'll take them up on that.

Oh well, back to my iPhone app that has nothing to do with geospatial.

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:
<coordinates>coord0 coord1 coord2 ...</coordinates>
<ebr:time>mjd0 mjd1 mjd2 ...</ebr:time>

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.

Friday, January 30, 2009

Free EarthBrowser 3D website traffic visualizer

Introducing the EarthBrowser Site Tracker. It shows where and when people visit your site from all over the world. Play your traffic back and forth with the timeline slider, zoom in and out and see aggregated website stats that are updated every 10 minutes.

It's free to put on any website, just customize it and copy/paste some text into your HTML and you are up and running, no signup necessary.

Here's a live version:

This is one of many new free tools that I'm going to be releasing that showcase the upcoming EarthBrowser Flash plugin. I'll be putting out another nice embed tool that will be customizable to show any set of orbiting satellites and will zoom from one to the next.

Friday, January 23, 2009

Is anyone else tired of the GIS Inauguration tie-ins?

Microsoft, Google, GeoEye, DigitalGlobe, AEgis, CNN and more have all jumped on the bandwagon. Shameless event tie-in marketing. Let's think of some other tremendously useful things to do with GIS.

What the world needs now are more Santa trackers.

Thursday, January 22, 2009

Simple solution for MOUSE_WHEEL events on Mac

Flash does not support the MOUSE_WHEEL event for Macs. I was hoping it would be supported in version 9, and again in Flash 10 but I'm still waiting. There have been a number of solutions out there, and the best one I've found is Gabriel Bucknall's MacMouseWheel code. It consists of an actionscript class and some javascript code that will work together to have the browser pass the mouse wheel events to your Flash code.

After reading an awesome article by Peter McBride called JavaScript and VBScript Injection in ActionScript 3, I've put together a single as3 class that fixes the MOUSE_WHEEL problem without the need for any external javascript code. It works on Safari, FireFox and Opera and probably Chrome when it becomes available on the Mac.

The trick was to inject the mouse handling javascript code using ExternalInterface. The code finds the DOM node for itself, intercepts and passes the mouse wheel events which are then disributed to the current InteractiveObject under the cursor.

An example of initialization would be:

class awesomeapp extends Sprite {
public function awesomeapp() {
addEventListener(Event.ADDED_TO_STAGE, stage_init);
private function stage_init(e:Event):void {
addEventListener(MouseEvent.MOUSE_WHEEL, wheel_event);

Download the source (MIT license).

Friday, January 16, 2009

A 3D virtual globe for your website

It is nearly impossible to get people to download and install software, I know from experience. Even Google Earth is only installed on a few million computers. Installing software or browser plugins is not allowed in most corporate and government environments. If you want to display geospatial content on your website and not exclude most users, your only choice until now has been flat maps.

With EarthBrowser, you can have a true 3D virtual globe that is self-branded with a custom interface that fits your special data requirements right on your website. There is no installation required since Flash 9 has about 95% penetration. With just a few lines of javascript (or as part of a Flex app) you can make your site really stand out.


The first example of the EarthBrowser Flash plugin is up at with a simple interface that gives a hint at what is in the desktop AIR application and an easy way to download and install it. Download the free trial AIR app and take a look at all the great features. Chip in a few bucks if you like it and want to support my efforts to provide an alternative to the multi-billion dollar behemoths out there.

A small javascript program (about 350 lines) controls what data is visible and various aspects of the globe on that site. It lets you control the clock and camera elevation and toggle night shadows, clouds, doppler radar, earthquakes, snow depth and a set of 7 popular satellites which are all updated in realtime. Click on a satellite and it will zoom to it and smoothly animate the earth underneath in real-time using very accurate orbital elements (I've got permission to re-distribute satellite positional data from the US Space Command).

In my last post I mentioned that the demo app would not work on Internet Explorer due to problems with the JScript engine. Since Javascript is very close to Actionscript, I just made a few changes to the javascript code (adding ":*" after variable and function declarations) to make it compile into the Flash preloader. Now it works in Explorer too. However the special handling of mouse-wheel events isn't as nice so I'll have to hurry up on my VB getter/setter workaround I mentioned earlier.

The EarthBrowser plugin can read KML files and KMZ archives. It can also read Shapefiles and do coordinate projections using a ported version of the open source proj.4 library. There is a full set of GUI components including buttons, text input boxes, sliders, popups and scrolling lists that make creating a fully featured app simple. The desktop version is a pretty complex application but is written in under 4,000 lines of javascript. I'm working on the API documentation and am making a code repository so people can create and share their own components for use on the web or in the desktop version. As an example, adding one of the Free ESRI map layers to the globe takes about 3 lines of code.

I haven't mentioned it yet since I've not blogged in a while, but EarthBrowser did not win at the Adobe MAX show. Scrapblog won, they have a pretty cool app with a very well defined and active niche. It was a great experience and I met some really cool people. By the way, Ben Forta is *way* more impressive in person than his blog picture suggests.

Wednesday, January 14, 2009

EarthBrowser 3.1 written in Javascript

The new version of EarthBrowser which will be released later today has been written in Javascript. Can that be right? Yes and no. The entire control structure of the application has been re-written in less than 4000 lines of Javascript code using the new EarthBrowser plugin. However, all of the fast rendering and calculation code is still written in Flash (Actionscript 3).

Desktop Version
Version 3.1 has had a major facelift, is about twice as fast as the previous version and has some pretty cool new datasets like real-time satellites. This is a free update for all version 3 users of course, just starting up EarthBrowser will allow a seamless update once I put it out.

Online Version
The online version API is still not quite ready for release (I'm only one guy). However, later today when I release, please check out the EarthBrowser home page to see the first public demo of the online plugin. Right now it only works in Safari and Firefox. I've created a really simple 600 line demo application by simply copying some Javascript code from the desktop version and putting it up on the home page.

Writing your own modules
In November I alluded to being able to customize EarthBrowser with Javascript. I am working on creating a code repository with many examples on how to extend and customize EarthBrowser with your own data and user interface elements. The code will be portable and can be developed and tested on the desktop and then, if you like, posted to the web for the same functionality on your website.

I still need to fully document the API. Also I am working on support for Internet Explorer, which is tricky because Explorer does not have getter/setter methods. It uses it's own lame and non-standard JScript engine. However there is a trick I found in the Classical inheritance for Javascript code which uses Visual Basic to provide getter/setter functionality. A clever but lame hack, but it should work until Explorer 8 comes out and becomes mainstream.