Friday, July 10, 2009

Adding Ant to Adobe Flash Builder 4 Beta

There are good instructions for getting Ant to run in Flex Builder 3 at http://iamjosh.wordpress.com/2008/08/11/adding-ant-to-flex-builder-3/ but I just installed Adobe Flash Builder 4 Beta (the June 2009 version) and things are a tiny bit different. Here are the steps I followed:

  1. In Adobe Flash Builder 4 Beta, go to Help -> Software Updates -> Find and Install...

  2. Select "Search for new features to install" and click Next.

  3. Pick "The Eclipse Project Updates" and click Finish.

  4. If prompted, for "Update Site Mirrors", select "Automatically select mirrors". Click "OK".

  5. In the search results, expand "The Eclipse Project Updates", then expand "Eclipse 3.4.2″.

  6. Select "Eclipse Java Development Tools 3.4.2.r342..." and click "Next".

  7. Accept the license agreement and click "Next".

  8. Click "Finish".

  9. Wait for download...

  10. When prompted for feature verification, select "Install All".

  11. Restart Flex Builder as suggested.

You will now have Ant support installed. All build.xml file will have a little ant icon and if you right-click the file and select "Run as", you will see two Ant options:

  • Ant Build - which also has a keyboard short-cut, but does anyone actually remembers shortcuts like Alt+shift+X,Q ?

  • Ant Build... - which allows you to specify which targets to execute.

Side note: Make sure your Flex workspace don't contain space and Ant should work just fine.

My first error "Unable to access jarfile C:\ArcGIS\FlexAPI2\api\${env.FLEX4_HOME}\lib\compc.jar" was easily fixed by adding a new environment property FLEX4_HOME and setting it to C:\PROGRA~1\Adobe\FLASHB~1\sdks\4.0.0\

Monday, November 24, 2008

Adding Ant to Flex Builder 4 (Gumbo)

There are good instructions for getting Ant to run in Flex Builder 3 at http://iamjosh.wordpress.com/2008/08/11/adding-ant-to-flex-builder-3/ but I just installed Flex Builder 4 (Adobe MAX Preview version) and things seem to have changed a tiny bit. Here are the steps I followed:

  1. In Flex Builder, go to Help -> Software Updates -> Find and Install...
  2. Select "Search for new features to install" and click Next.
  3. Pick "The Eclipse Project Updates" and click Finish.
  4. In the search results, expand "The Eclipse Project Updates", then expand "Eclipse 3.4.1″.
  5. Select "Eclipse Java Development Tools 3.4.1.r341..." and click "Next".
  6. Accept the license agreement and click "Next".
  7. Click "Finish".
  8. Wait for download...
  9. When prompted for feature verification, select "Install All".
  10. Restart Flex Builder as suggested.

You will now have Ant support installed. All build.xml file will have a little ant icon and if you right-click the file and select "Run as", you will see two Ant options:

  • Ant Build - which also has a keyboard short-cut, but does anyone actually remembers shortcuts like Alt+shift+X,Q ?

  • Ant Build... - which allows you to specify which targets to execute.


Side note: Make sure your Flex workspace don't contain space and Ant everything should work just fine.

Monday, September 18, 2006

KML faster than GPX

When using feeds from Motionbased, the KML is 5x faster then GPX because the format is that much more compact. So if you're not using the time stamps, course heading, or speed available in the GPX feed, then using KML feed is probably a good idea.

For example:

<trkpt lat="34.1" lon="-118.2">
    <ele>141.5<ele>
    <time>2006-09-12T05:31:20-07:00</time>
    <course>0.0</course>
    <speed>3.834404896762164</speed>
</trkpt>
<trkpt lat="34.3" lon="-118.4">
    <ele>141.5<ele>
    <time>2006-09-12T05:31:21-07:00</time>
    <course>0.0</course>
    <speed>3.834404896762164</speed>
</trkpt> ...
versus
<coordinates>-118.2,34.1,411.1 -118.4,34.3,411.1 ... </coordinates>

I updated my MB/AWX mashup with this and some other improvements: http://www.bjornman.com/mb-in-awx.html

(The old mashup using GPX instead of KML is now available as http://www.bjornman.com/mb-in-awx-using-gpx.html)

The only tricky part with using KML was the irritating bug in the Mozilla/Firefox xml parser where it only gets the first 4096 character with "firstChild.data". Since an activity is often a lot longer, only the first 112 locations showed on the map. Since newer Mozilla/Firefox (though not IE) supports the "textContent" from W3C DOM Level 3, I fixed it by trying both ways of getting at the full "coordinates".

Friday, September 08, 2006

Showing MotionBased Activities in ArcWeb Explorer

Using RSS and GPX feeds from MotionBased (MB) and displaying them on maps from ArcWeb Explorer is easy. At least if you understand GeoRSS and GPX xml formats, know JavaScript, and one of the JavaScript map API's, like ArcWeb Explorer JavaScript API. The latter being free - at least for "personal, non-commercial, and non-governmental use".

What is Motionbased? ... it's a really cool "web application that translates GPS data into functional analysis and online mapping for endurance and outdoor athletes". For me that means that each time I run or bike, I bring along my GPS toy and then upload the GPS data to Motionbased when I get home.

Motionbased provides user's most recent activities in GeoRSS feeds, so it's easy to display them on the map. They also provide the activities as GPX - "the de-facto XML standard for lightweight interchange of GPS data". This makes it easy to show the exact tracks of every individual activity on a map. Whether you use the API's from Google Maps, Yahoo Maps, Ask.com or ArcWeb Explorer (AWX).

http://www.bjornman.com/mb-in-awx.html?mb=bjorn is the application I created using AWX. It reads the RSS feed with the most recent activities for a user and displays them as markers on the map. You can then click on the activities to read more about it and see the heart rate profile (if available), and to show the exact GPS route of that activity. After clicking the links above the map or the "Show Route" in the marker the GPX data will be downloaded, parsed by the browser and displayed on the map. In addition to being shown above the map, the activities are also listed inside the "Find" box. From there you can drag and drop one or more activities onto the map for it to zoom in to those. Note too that after displaying the route, the marker is updated to show elevation and heart rate profiles.

You can specify any user on the URL line, for example:

Go play!

Sunday, September 03, 2006

Parsing GeoRSS

The main problem with GeoRSS is that there are several GeoRSS standards for specifying locations. This makes it hard both for those creating the GeoRSS feeds and those doing something with those feeds. See for example Aaron's blog and the GeoRSS response.

Simple GeoRSS - http://georss.org/simple.html
<georss:point>45.256 -71.92</georss:point>

GeoRSS GML - http://georss.org/gml.html
<georss:where>
  <gml:Point>
    <gml:pos>45.256 -71.92</gml:pos>
  </gml:Point>
</georss:where>

W3C "formal" - http://www.w3.org/2003/01/geo/
<geo:Point>
  <geo:lat>55.701</geo:lat>
  <geo:long>12.552</geo:long>
</geo:Point>

W3C "casual" - http://www.w3.org/2003/01/geo/
<geo:lat>55.701</geo:lat>
<geo:long>12.552</geo:long>

So far it seems to me that the latter one - "W3C casual" is the most widely used.

I wanted to be able to map a georss feed onto a map myself (and work on my javascript skills). I could have used some of the built-in GeoRSS support, but I wanted more control of both display of the the markers as well as being able to display them outside the map.

Here's the sample javascript I came up with to parse any of these georss feeds:
var items = xmlDoc.documentElement.getElementsByTagName("item");
for( var i = 0; i < items.length; i++ )
{
  var itemtags = items.item(i).getElementsByTagName("*");
  for ( var j = 0; j < itemtags.length; j++ )
  {
    var tag = itemtags[j].nodeName;
    if (tag == 'geo:lat') {
      var lat = itemtags[j].firstChild.data;
    } else if (tag == 'geo:long') {
      var lon = itemtags[j].firstChild.data;
    } else if (tag == 'georss:point') {
      var ptArr=itemtags[j].firstChild.data.split(" ");
      var lat = ptArr[0];
      var lon = ptArr[1];
    } else if (tag == 'gml:pos') {
      var ptArr=itemtags[j].firstChild.data.split(" ");
      var lat = ptArr[0];
      var lon = ptArr[1];
    }
  }
}

[See a live sample]

It seems simple, maybe I'm missing something?