Monday, July 6, 2009

ArcGIS Server Sample Flex Viewer: TwitterFeedWidget

I have been thinking about how Twitter could be used to enhance the capabilities/user experience of a web mapping system and came op with some decent stories. The first would be providing users with access to a feed dedicated to the application which contains information about it including updates, news, changes, downtimes, etc. The second would be users who wish to perform searches of Twitter content that may be related to the map and eventually, overlaying geolocated Tweets onto the map. These (and the fact that I just wanted to poke around the Twitter API) gave me enough of an excuse to start messing with the Twitter API. I ended up with a simple little widget that allows users to search for tweets within a specified geographic location, in this case, a circle. Nothing earth shattering but still maybe somewhat useful. Before giving you some of the nuts and bolts of this, I want to be sure and reference the materials I used:

Some Details on how it works.
It is really pretty simple. The user is able to draw a circle on the map and any tweets that originated from within that location based on the Twitter user's location property are returned as an ATOM Feed. The processes uses the Twitter API geocode parameter where a lat, long and radius of a circle are needed. The widget obtains the lat, long, and radius values from the circle tool. I added a coordinate transformation function to the Circle Tool component to convert the distance units (radius of the circle) to miles from decimal degrees. I used the Great Circle Distance Formula. The ATOM feed is parsed using the Flex XMLSyndication package and is validated using the Flex CoreLib Utility Package (see links above).

Proxy Server
As with any application making cross-domain asynchronous data requests, a proxy server is needed to "fool" the browser security settings. Flex has a nice framework for bypassing this. If the feed host contains a crossdomain.xml file that allows cross-domain access, you are good to go. However, Twitter locks this down (Twitter crossdomain.xml). I have included a proxy server implemented in Java within the package. It is NOT PRODUCTION quality but will get you started. There are other implementations that are easier out there. Have a look at the resources I sited for some other examples.

Known Issues and Limitations
Simply put, there are several limitations with this that make it, lets say, less than production quality. I hope to rectify these soon. These include:
  • I haven't tested the feed results very well. The widget catches feeds that are empty which is good but the way I did this is kind of sloppy. I won't go into it here but if you have questions, I can elaborate.
  • The coordinate transformation for the distance units (radius conversion from DD to miles) I am using is very rough but good enough for this use.
  • It doesn't play very nicely with the map action and map navigation state of the Sample Flex Viewer (SFV). Given that the draw circle component wasn't designed for use with the SFV, it isn't integrated very well with the event driven model the SFV uses. Not to say it isn't a nice component because it is. Using it in the Sample Flex Viewer is just a bit of a stretch. There are alot of issues with this but from a use perspective, users have to keep clicking on the draw circle tool after each use and then state defaults back to the default map navigation (pan). Another problem is if the user trys to change the map action or map navigation state (by selecting another component that does so), during the middle of component use, bad things happen. One of the reasons for this is that I didn't want to make changes to the core by adding custom events, etc. However, I am hopeful that I can improve this without making changes to the core and will look into it.
  • Improvement can be made to the tweet results listing (links to profile, user timeline, etc...).
  • Alot of other testing needs to occur as well. Just running out of time right now.

Wednesday, July 1, 2009

Keeping Your Grass Green (with little water)

This is an odd post and intended for all of you who follow this and aren't geogeeks (sorry nerds but this might interest you as well). This advise is for people with Kentucky Bluegrass lawns (Colorado). So many people have asked me how I keep my grass so healthy and claim I water like crazy. In fact, I am a huge conservationist and try to minimize waste. I promise I have only watered 3 times this year (as of July 1st, 2009). Here is a pic.

Granted, it was a wet Spring for us but I am certain these techniques still apply. Here is the secret:

  • First, assuming you have a lawn with a good foundation and good drainage (nice organics) and it is established, you need to fertilize. This is critical. I use all organic fertilizers. Once a month (more like 1 1/2 months), I apply:
    ---2 parts Richlawn Turffood Pro
    ---1 part Revive granules (kind of expensive but critical)

    I mix these up and apply with a standard spreader. I will leave the amounts to you based or your square footage. It is also critical that you apply the Fall season version of Richlawn in October.
  • Secondly, please mulch. Most modern mowers can mulch. If you don't have one, get one. Bagging grass is a tragedy. You are filling landfills with unneeded waste and the mulch actually helps the sod maintain hydration and ensures that it requires less fertilizer given that you are replenishing the nutrients. One issue is that you will have to mow more often (maybe twice a week if the grass is growing crazy). You can't mulch if your grass is too long.
  • Finally, you must integrate organic material into the subsurface before you lay sod. This is hard to do if you already have a mature landscape but worth mentioning. This means rototilling at least 4 inches of nice organic material into the crappy clay (Typical in Colorado).
That is about it. A couple of items worth mentioning: First, you will have to do this for a couple of years before your lawn responds, don't expect it to respond overnight. You need to train it. Secondly, don't water too much. Kentucky Bluegrass is very drought tolerant if you let it be. If you water too much, it will use the water. Stress it a bit.