Skip to main content

Various updates from me (J2ME, JSON, travels - and blueMarine, of course)

Posted by fabriziogiudici on July 14, 2008 at 3:34 AM PDT

Ok, you haven't read new posts here for some time now. I've been pretty busy: an important deadline first and later five consecutive days of holidays (!) chasing the Rhône river from the glacier to the mouth - my first self-choosen photo "assignment", which turned out into about 2,000 photos that I have now to decimate - unfortunately, they ate all the free space on my hard disk and I had to temporarily sacrifice the 20G partition for OpenSolaris (not working yet, to tell the truth).

In any case, I had recently to deal with J2ME for business and this ended up in resuming the work on windRose, my open source navigator for palm devices, which hadn't been updated in two years (since version 0.4.1, rough to use but trusted enough to record all of my travels in the meantime). The new windRose 0.5.4 has less rough corners and some new features, such as maps (OpenStreetMap and Microsoft Visual Earth), waypoints and even weather information. Maps have been tested during the Rhône trip, with me just finish the coding of the offline pre-fetcher for the map tiles the night before leaving, and the following morning downloading them during the first part of the travel, before passing the Switzerland border - you know, in Europe you still can't afford mobile internet connections abroad. No, don't worry, I wasn't driving at the time :-)

There should be another stabilization release for windRose before July (some issues, especially with performance, have been fixed last night), just in time for supporting me during the usual August travels (and also provide the basis for some new idea about photography, travels and geotagging that I've got in mind). I'm starting to get quite satisfied with it, and as soon as I add the capability of directly exporting track data in PCX format (instead of the open but proprietary XML format I'm using now) it should become really usable by people.

What saddens me is the bad luck that the Java platform had with Palm OS. As you probably know, PalmSource (acquired by Access) stopped distributing the IBM J9 runtime at the beginning of this year (Fred Gnuechtel from IBM explains why in this comment to Markus Brosch's blog). It's another clear example of why open source is important - otherwise even when some big companies such as Palm and IBM are involved you still risk to be dropped all of a sudden. The last hope for Java on Palm OS is with the porting of phoneME that Terence Barr talked about a week ago; but I have already said that I'm tired of Palm stuff. They haven't been doing anything clever for years. My next phone will be probably a Nokia and I've started some work to ensure that windRose is able to run on other platforms (thanks also to my friend Emmanuele Sordini which will help with testing).

In the meantime, the blueMarine project goes on, in spite of a big mistake of mine: I didn't make new public releases since last October, and these are nine months. About 2500 code commits in the meantime, but if you don't go public people will start doubting that the project is alive (the good thing is that people often talk about blueMarine whenever the discussion comes to Linux and photography). "Release often" is one of the mandatory tasks for a successful open source project and I missed it. Trying to recover as soon as possible.

To finish this post with something technical, adding the weather functionalities to windRose lead me to confrontate with JSON. Generally speaking, XML is fine for me, so I don't find JSON so compelling. Probably you can appreciate the reduced verbosity on a mobile client, even though compression could be an alternative; but in the end the point is that GeoNames's weather service is only available in JSON format.

So, what API for JSON on J2ME? Well, seems to do the job fine. You take the sources and put them into a MIDP Library project in NetBeans, and you're ready to go (you just need to pull off a JSONWriter that depends on StringWriter, not available on MIDP).

This is the code to read METAR weather data from GeoNames's service:

        final String string = ... // read the HTTP response here
        final JSONObject jsonObject = new JSONObject(string);
        final JSONArray jsonWeatherObservations = jsonObject.getJSONArray("weatherObservations");

        for (int i = 0; i < jsonWeatherObservations.length(); i++)
            final JSONObject jsonWeatherObservation = jsonWeatherObservations.getJSONObject(i);
            final int humidity = jsonWeatherObservation.getInt("humidity");
            final int hpa = jsonWeatherObservation.getInt("hectoPascAltimeter");
            final String stationName = jsonWeatherObservation.getString("stationName");
            final double lat = jsonWeatherObservation.getDouble("lat");
            final double lon = jsonWeatherObservation.getDouble("lng");
            final int temperature = jsonWeatherObservation.getInt("temperature");
            final String clouds = jsonWeatherObservation.getString("clouds");
            final String weatherCondition = jsonWeatherObservation.getString("weatherCondition");
            final Coordinates coordinates = new Coordinates(lat, lon, 0);
            // put your data somewhere

Now, there are no APIs that solve the problem of the reliability of weather forecasts (I don't trust in them at all), but METAR are weather observations, not forecasts, and they should be fine.

That's all for this post. Hoping to get back before the end of July announcing the release of blueMarine 0.9.RC3. See you later.

Technorati Tags: , , , , , , ,


Hello Fabrizio, i'm try write JSON code on J2ME. I can read fine, but i need write JSON object from my J2ME device. Can you know how i can do that ? Thanks.