Wednesday, May 13, 2009

AIR/Flex vs. Silverlight Debate

Now that the ArcGIS Server development platform has finally come of age, many are asking: which platform do I use? There are a number a criteria that enter into this equation and I think others have done a good job of defining these so I will not be discussing them here. The intent of this post is simply to provide you with some of the resources I have found that evaluate at least the 2 RIA platforms ESRI is now providing: Flex and Silverlight. There is alot of chatter/bashing going on and it is often hard to sift through some of the biases so the following are the most resent/unbiased postings I could find. For what its worth, I think they are both great and good for one another. The harder they compete, the better off we all are. Heck, I hope we even start discussing JavaFX in the near future.

The Battle for the RIA Throne: Flex vs. Silverlight
Flash vs. Silverlight: What Suits Your Needs Best?
Video: Air/Flex Silverlight Debate: MS and Adobe evangelists go head to head.

Tuesday, May 12, 2009

USGS Report Released: Energy Resources in SouthWester Wyoming (WLCI)



The USGS Central Region Energy Resources Science Center (Author: Laura R.H. Biewick)recently released a report characterizing oil and gas production within the South Western Wyoming (Wyoming Landscape Conservation Initiative). The report contains a variety of geospatial data, maps and such that are free to the public.

Monday, May 11, 2009

Initial ArcGIS Server Flex API Map Viewer Rollout

The USGS Energy Program is beginning to rollout their latest online mapping application using ArcGIS Server and the Flex API. It is pretty vanilla right now but includes some nice features under the hood including:

1. URL parameter interface
2. Live Map classification widget
3. Separate Map Navigation
4. US Geologic Energy Resources Summary Widget
A whole set of nice features are in the oven including:

1. Metadata and static legend integration
2. Access to over 100 different services
3. Custom widgets based on content type.

Tuesday, April 21, 2009

Formatting Dates In Flex

If you have been working with any of the new AGS apis (at least Flex or DOJO in my experience), you have probably encountered one of these:

Mon Dec 31 17:00:00 MST 2001

This is the date string returned within a query result featureSet.

var assessmentDateString:String = featureSet.attributes[0][assessmentDateLabel];


Not very usable really. However, there is hope! Flex has a nice little class called DateFormatter. DateFormatter does alot of stuff but what is really handy is its ability to parse pretty much any date string into a real date object. The langref gives you all the details on how to do this but converting the date string above into an actual date is a simple as:

private function getFormattedDate(dateString:String):Date
{
var formatter:DateFormatter = new DateFormatter(); formatter.formatString = "EEE MMM DD H:NN:SS YYYY" var newDate:Date = new Date(formatter.format(dateString)); return newDate;
}


Take special notice that the formatString pattern does not try to match the "MST" portion of the date string. This portion is simply ignored. This is not because literal characters aren't allowed, just not caps. Lowercase along with punctuation and numbers can be used in the pattern if needed.

Thursday, April 16, 2009

Greg's Projects

Started a new stream regarding some of my personal projects. The main thrust right now being my basement finish (I am going to try and do it mostly myself). If interested in learning from my screw-ups, have a look.

Greg's Projects Blog

Saturday, March 28, 2009

ArcGIS Server Sample Flex Viewer: Capturing and Using Configuration Data


The Sample Flex Viewer (SFV) uses a simple xml file (config.xml) for application initialization and configuration. Application properties managed by this configuration file include, among others, UI attributes such as banner, title and logo, primary menu configuration, widget management, and layer management.



It is almost a certainty that any customization will require custom configuration settings, either populated by passing in URL parameters (in a future post) or by setting custom properties in the config.xml file. These data can be captured and used by making a few changes to core classes in the SFV. This example focuses on capturing a custom attribute added to one of the existing elements, in this case, the <mapservice> element.


The ultimate goal of this example is to provide some means of categorizing map services identified in the configuration file for display in multiple instances of the livemaps widget, each containing subsets of specific map services. We will do this by adding a custom attribute to the <mapservice> element called group.



<mapservice label="map label" type="dynamic, tiled, arcims, etc" visible="true/false" alpha="0..1" group="wlci">url</mapservice>



Now, getting the data. But first, we need some background. While we won’t be using it directly in this example, it is important to mention the configData class. The configData class does nothing more than provide a place to store the configuration data. It is a collection of arrays which correspond to application functional groups such as UI, menus, maps services, widgets etc. If your intent is to create an entirely new class of configuration data, let’s say for url parameters (more on that in a later post), you would provide the framework for that data in this class. Our example is a bit simpler, we are simply adding a new attribute to an existing class.


The class that does most of the legwork is the configManager. It begins by establishing and HTTPService connection (configService) to the config.xml file and then listens for a result (ResultEvent.RESULT). The important stuff occurs in the handler for this event. Within this handler, an instance of configData is created along with an xml dataset containing the contents of config.xml:



var configData:ConfigData = new ConfigData();

var configXML:XML = event.result as XML;



It then proceeds to parse out the functional collections of data as needed. The following illustrates how it parses out <mapservice> configuration data. This pattern can be used to obtain any attributes added to the mapservice element in the config file.


//================================================

//map

var configMap:Array = [];

var mapserviceList:XMLList = configXML..mapservice;

for (i = 0; i < mapserviceList.length(); i++) {


var msLabel:String = mapserviceList[i].@label;

var msType:String = mapserviceList[i].@type;

var msVisible:Boolean = true;

if (mapserviceList[i].@visible == "false")

msVisible = false;

var msAlpha:Number = 1;

if (!isNaN(mapserviceList[i].@alpha))

msAlpha = Number(mapserviceList[i].@alpha);

var msURL:String = mapserviceList[i];

var mapservice:Object =

{



label: msLabel,

type: msType,

visible: msVisible,

alpha: msAlpha,

url: msURL,



}

configMap.push(mapservice);



}

configData.configMap = configMap;



The previous block of code begins by creating an empty array for populating local data.



var mapserviceList:XMLList = configXML..mapservice;



creates an XMLList of all nodes in the DOM hierarchy called mapservice. The XMLList can then be examined just like an array, stepping through it by using a for statement. Attributes of the elements within the XMLList are then accessed explicitly via the attribute name. For example:



var msLabel:String = mapserviceList[i].@label;



retrieves the value assigned to the label attribute for that particular mapservice node. The value of the node itself is retrieved using the following syntax:



var msURL:String = mapserviceList[i];



For each node instance, a generic object of name/values pairs is then created containing each attribute value along with the value of the node itself. That object is then added to a local array for each node instance and then is assigned to the configData instance upon parsing completion.


For this example, recall that we have added a new attribute called group to each <mapservice> element. To retrieve that value, we simply need to create and assign a new local variable with the attribute value, add it to the generic name/value pairs object and we are golden.



//================================================

//map

...


for (i = 0; i < mapserviceList.length(); i++)

{



...

//retrieve newly added group attribute from mapservice entry

var msGroup:String = mapserviceList[i].@group;

...

var mapservice:Object =

{



...

//add newly added group attribute to mapservice object

group: msGroup,



}



configMap.push(mapservice);

}

configData.configMap = configMap;



Our configData instance now contains the newly added "group" attribute. Once it is completely populated, the CONFIG_LOADED event is dispatched which essentially notifies the application that the configData instance is now available for use. Using the data is even easier. All that is needed is to listen for the CONFIG_LOADED event:



SiteContainer.addEventListener(AppEvent.CONFIG_LOADED, config);



where config is a function whos argument is an event containing the data itself. It is then accessed via the following:



private function config(event:AppEvent):void

{



configData = event.data as ConfigData;



}

This is done by default in the MapManager.mxml component. Have a look at the function called config is this component and you will see that pattern for obtaining data from configData.

private function config (event:AppEvent):void

{

configData = event.data as ConfigData;

....

for (i = 0; i <donfigData.configMap.length; i++)

{

...

var url:String = confData.configMap[i].url;

...

}

}

A nice feature in the Sample Flex Viewer is that the BaseWidget class (that which we extend for all new widgets) exposes the configData object by default. This means we can then obtain data parsed from the config.xml file by the ConfigManager from any widget that extends the BaseWidget. To do this, we do something similar to what the MapManager component does.

for (var i:Number = 0; i <configData.configMap.length; i++)

{

...

var group:string = configData.configMap[i].group.toString();

...

}

Friday, February 27, 2009

What’s New in ArcGIS Server 9.3.1

I just returned from the ESRI Petroleum User’s Group (PUG) conference in Texas. The buzz this year was a little lower than those of an anticipated major release. The featured release during this gathering was 9.3.1. As I mentioned in a previous post, nary a word was mentioned regarding Desktop, it was all about “Web GIS.” Given my professional interest in this platform, this was ok with me. While many of the demos highlighted the various development platforms including the JS and FLEX API’s, a few included new features in 9.3.1. Probably the most anticipated, at least for AGS users, is increased performance for dynamic map serving. As far as I could tell, implementation of this new feature is actually done via a tool designed to help optimize the map document. The demo illustrating this improvement included a side-by-side comparison of the same dynamically generated map service, one that had been “optimized” using the new optimization tool and one that hadn’t. Each map display included a timer depicting load times. Anecdotally, map services which had been “optimized” using the new tool loaded about 3 times as fast. The optimization tool, utilized in ArcMap during the demo, looked at characteristics of the map document including whether the projection of the data frame matched that of the data, whether any data links were missing, scale dependent rendering, symbol level drawing and a couple of others that I missed. The workflow for tool use included an iterative process of optimization and map service preview. The demo was good and even generated a fair amount of applause. However, if faster dynamic map generation centers on checking the characteristics I listed above, don’t hold your breath. It seems to me that most folks are already looking at these sorts of things.


Other features mentioned but not demoed in the 9.3.1 release included the ability to publish to AGS directly from ArcMap and integration of Virtual Earth base data (not Google) directly into the ESRI platform including ArcMap. There was also some discussion about the new sharing framework via ArcGIS Online. While some may say “not another one” this one features content sharing and discovery definitely designed for a GIS pro and not so much for general consumers. Other notable discussions included AGX build 900 and the notion of what ESRI is calling a layer package (not sure if this is 9.3.1 or 9.4). The layer package is simply of was of packages data and cartography for sharing purposes.