Showing posts with label Geoweb. Show all posts
Showing posts with label Geoweb. Show all posts

Friday, June 24, 2011

A Real Life Geoprocessing Service In Action (ArcGIS Server 10)

As I have mentioned before, I'm an oldschool GIS guy.  Because of this, I have a hard time embracing "secular" web mapping toolkits.  Its kind of like the old days.  Yes, you can use GIS to just make maps but it is really about the data and analytic capabilities.  So translated into the geoweb, yes there are all kinds of toolkits to make webmaps but very few that expose the richness of the data and provide real analytic capabilities.  That is why a recent project I was lucky enough to be apart of was so exciting.  Web enabling rich GIS capabilities via a simple user interface and user experience using ArcGIS Server's Geoprocessing service.
The application is really simple, basically allowing users to dynamically calculate the amount of in-place oil shale amounts.  We have kind of been calling it the oil shale calculator.  However, the science and methodology for assessing the oil shale resources in the first place was far more complex and something that I can't take credit for but would like to acknowledge those who did (Johnson, R.C., Brownfield, M.E., and Mercier, T.J., (U.S. Geological Survey Oil Shale Assessment Team)).  Have a look at it if you are interested.

But for the sake of this post, the result of this work (at least the part that was used for this application) was basically a raster with gallons of in-place oil shale resources per cell and a model implementing the zonal stats function for doing the dynamic calculations (nice work Tracey!).  Here is the geoprocessing model.
Pretty simple really.  Basically, two input parameters.  A user defined polygon and the raster containing oil shale values.  The output being a sum based on the zonal statistics function.  This was actually modeled after one of the AGS samples.  When implementing this model, we ran into what I consider a bug.  First, the literature suggests that you can store the output table in memory(ArcGIS 10 only).  However, we found this was not the case.  We were forced to use a physical file system location, basically the scratch disk (bad:  output table=in_memory\results, good: output table=%scratchworkspace%\oilshale.dbf).

The application itself was pretty simple as well.  Have a look.  One gotcha we ran into here was that basically the REST API endpoint for this service actually expects 2 input parameters, not just one as is suggested by its Services Directory page.  The missing parameter that is actually required is the zone field parameter.  We called ours id. You can view the page source of the app to see how we manually included this parameter but a preview is below:

Wednesday, September 29, 2010

Participating with OneGeology: Experience, Lessons Learned and Other Tidbits

I recently had the opportunity to "stand up" a WMS representing a 1:5,000,000 scale geologic map of North America for integration into a platform called OneGeology.




OneGeology, whos mission statement is to:

"Make web-accessible the best available geological map data worldwide at a scale of about 1: 1 million, as a geological survey contribution to the International Year of Planet Earth." (see: http://onegeology.org/what_is/mission.html)

 aims to:
  • create dynamic digital geological map data for the world.
  • make existing geological map data accessible in whatever digital format is available in each country. The target scale is 1:1 million but the project will be pragmatic and accept a range of scales and the best available data.
  • transfer know-how to those who need it, adopting an approach that recognises that different nations have differing abilities to participate.
  • the initiative is truly multilateral and multinational and will be carried out under the umbrella of several global organisations.   (see:  http://onegeology.org/what_is/objective.html)

The process for contributing to this worthy effort was pretty interesting and I wanted to share this experience a bit.

To begin with, the map we were submitting was actually a replacement for an existing geologic map of North America which only covered the southern portion.  The previous WMS was served using Map Server while our new one was being powered with ArcGIS Server 9.3.1.  This was quite the test for AGS given the outstanding performance of Map Server with regard to WMS serving.  In an effort to boost performance without doing a bunch of map authoring and data processing, we performed a couple of interesting tricks that I outlined in some detail in a previous post.

Basically, participation with the OneGeology platform can occur at several tiers, each basically correlated to functionality.  Our participation was of the first tier, that being simply contributing a WMS.  This experience was not trivial.  Even though WMS is technically a "standard," there is still enough wiggle in the spec that a specific implementation is needed to ensure interoperability.  The folks at OneGeology have done a outstanding job with this and have documented, in detail, requirements for how WMS services need to be configured for integration into their system.  Our specific instances are here:

http://certmapper.cr.usgs.gov/arcgis/rest/services/one_geology_wms/USGS_Geologic_Map_of_North_America/MapServer -- raster one

http://certmapper.cr.usgs.gov/arcgis/rest/services/one_geology_wms/USGS_Geologic_Map_of_North_America_GFI/MapServer -- vector one for getFeatureInfo requests only

And finally the portal.  It is a really nice application and serves as a great demonstration of "mashing up" distributed data services that originate throughout the globe.  It is really pretty astonishing, given the wide range of participating organizations.
OneGeology Portal Depicting Geologic Map of North America






Tuesday, June 29, 2010

ArcGIS Server JavaScript API For Beginners: Populating DOJO FilteringSelect

The more I work with it, the more I like it, that is, the ArcGIS Server JavaScript API.  It has some real funkyness that is hard to get use to at first (loose or no typing, dynamic nature, callbacks, etc) but once you get going, it is pretty slick.  Given this, I am going put up a few posts in the coming weeks that illustrate very simple samples that I think are useful.  These aren't elegant, OO examples, just examples so all JS pros out there will probably find these post of little use.  They are based on the ArcGIS Server JavaScript API 2.0 (and ArcGIS 10).

Generally speaking, usability is often the single most important factor dictating the success or failure of your geoweb application. Make it simple and fool proof and guide the user through the workflow or task. If they get confused, you have failed. One component that can be used to help accomplish this is a pre-populated drop-down/search box that auto-completes. DOJO, the toolkit that the ArcGIS Server JavaScript API is built on, provides a lot of nice components for doing just this. One of these is dijit.form.FilteringSelect. It does a lot of cool stuff which assist in fool proof usability, much more that what is mentioned here. This post addresses how to populate a FilteringSelect dijit with the results of a query, in this case, the query of an ArcGIS Server map service layer’s field value. It is assumed that you know the very basics of using the ArcGIS Server JavaScript API, if not, have a look.

Instantiating a FilteringSelect dijit can be done declaratively or programmatically. In this case, we will declare it:

<body class="tundra">
    <input dojoType="dijit.form.FilteringSelect"
           id="lineid"
           searchAttr="name"
           name="widgetName"
           onChange="doSomething(this.value)">
</body>



where the id attribute is used to identify the component in the document, the onChange attribute defines the event handler when the component is changed and the searchAttr attribute, well, we will discuss that later. Remember to define your component before declaring it using dojo.require("dijit.form.FilteringSelect"). Now that the component has been declared, lets populate it. A best practice for initializing web maps along with selected stuff that goes along with them (such as our FilteringSelect component) is to define a function that is called when the the page is loaded. This is handled nicely using the dojo.addOnLoad() function. Something like:



    //Our main initialization function, called at just the right time
    function init () {
        //Create your query
        var queryTask = new esri.tasks.QueryTask(<query task rest endpoint>);
        //set the onComplete event handler, in this case, when the query is complete, call initLineID,
        //production code would handle handle the error callback as well
        dojo.connect(queryTask, "onComplete", initLineID);
       
        //build and execute your query
        var query = new esri.tasks.Query();
        query.outFields = [<name of the field you want>];
        query.text = "all";
        query.returnGeometry = true;
        queryTask.execute(query);

     }
     
     dojo.addOnLoad(init);


In the snippet above, we are basically building a query task and executing it.  For details on the queryTask works, have a look at the queryTask object (everything is an object is JS, another kind of weird thing to get use to).

Now the good stuff, populating the FilteringSelect component.  We first need to bind the completion event of the query to some logic that will populate the FilteringSelect component.  This is done using a handy little dojo function:

     dojo.connect(queryTask, "onComplete", initLineID);

which basically says once the queryTask fires the onComplete event, take the results and run with them in a function called initLineID.  Here is initLineID:

function initLineID(features) {
        var lineIdObjects = [];
        dojo.forEach(features.features, function(feature) {
            lineIdObjects.push({"name": feature.attributes.field_name});;
        });
       
        //Build the appropriate data object for our data component
        var data = {
              "identifier": "name",
              "items": lineIdObjects
        }
       
        //bind the data object to the datastore
        var lineDataStore = new dojo.data.ItemFileReadStore({data: data});
   
        //bind the data store to the FilteringSelect component
        dijit.byId("lineid").store = lineDataStore;
     }


Basically, we take the queryTask results, in this case referred to as "features" and refactor them into a ItemFileReadStore which is then bound to the FilteringSelect component.  Most of the UI components in DOJO work best consuming data from one of the DOJO data stores, in this case we are using the ItemFileReadStore.  ItemFileReadStores basically house JSON data formatted in a specific way.  Unfortunately, direct REST requests made to the ArcGIS Server Rest API don't return JSON formatted in this way which would have made things very easy but we will leave that for another time.

Because of this, we basically need to refactor our queryTask's returned features in a way that the ItemFileReadStore likes (see, "Reading JSON Data with DOJO").  We do this by creating an array object and populating it by stepping through each queryTask feature and adding it to the array as a name/value pair (one of the ItemFileReadStore format requirements).  We then build a generic object called "data" with 2 properties, "identifier" and "items".  The identifier property tells the ItemFileReadStore what handle to look for in the name/value pairs collection (our array).  In our case, we named each result record "name."  The second property called "items" is assigned our array.  Upon completion of this generic data object, we then simply bind it to the ItemFileReadStore using some named property.  In this case, we are calling it "data" as well.  Our final step is to find our FilteringSelect component in the document using the dojo.byId function and to assign its store property the ItemFileReadStore we created.  Thats it...

One final note on what I skipped earlier.  Remember that we assigned each of our queryTask feature values a attribute name called "name" and assigned our required "identifier" property and value of  "name" as well:
   
        var lineIdObjects = [];
        dojo.forEach(features.features, function(feature) {
            lineIdObjects.push({"name": feature.attributes.field_name});;
        });
       
        //Build the appropriate data object for our data component
        var data = {
              "identifier": "name",
              "items": lineIdObjects
        }


this is the handle that is used by the FilteringSelect component to find where to look for the data.  We tell the FilteringSelect component where to look for the data values using the searchAttr attribute:

    <body class="tundra">
    <input dojoType="dijit.form.FilteringSelect"
           id="lineid"
           searchAttr="name"
           name="widgetName"
           onChange="doSomething(this.value)">
     </body>


You can download this sample here



Monday, March 1, 2010

Using ArcGIS Explorer (900) for Presentations

I recently had the opportunity to present at the 2010 ESRI Petroleum User's Group (PUG) meeting in Houston. My talk was nothing earth-shattering, basically just a intro/tour of the work our team had been doing the previous year. My time-slot was short, 25 minutes with 5 minutes of Q & A. This was fine with me. Given my short attention span and propensity towards ADD behaviors, I actually prefer quick talks. Faced with this and the fact that my talk didn't contain much factual information, I wanted to try something a bit different standard slides. Although I hadn't worked with ArcGIS Explorer (AGX) much, I remembered hearing the ability within build 900 to perform some short of slide show so thought I would give it a try. The global nature of the materials I wanted to present also lended itself nicely to this platform.


ArcGIS Explorer Build 900

The process to do this is was pretty simple. The workflow is basically to:
  1. Stylize layers in either ArcMap or ArcGlobe (for 3D stuff).
  2. Build an AGX project
  3. Navigate to various "views" and capture "slides"
  4. Place titles on "slides" if desired
  5. Activate the show by simply hitting the go button.
The Cool
  • Wow factor provided by the geobrowser platform, especially to non-geo audiences.
  • Super easy to do, very intuitive workflow.
  • From a presentation flow persepective, the platform allows for a nice, smooth talk with soft transitions.
  • Informative media, not a boring slide of text or some dopey picture from istock.
  • Features can be identified, both to the data layer's attribute table or hyperlink field
The Not Very Cool
  • Because it is so easy, it isn't very feature rich. Aside from being able to add titles, there really isn't any way to annotate your slides
  • It is pretty buggy. The identify functionality works about 90% of the time, guaranteed to not work when it really counts.
  • Identify only works on "data layers" but not references created by layer files. This is problematic because you need to use layer files for rich symbology (from ArcGlobe). The work around for this is to add the layer as a data layer, make it 100% transparent, then add it with the desired symbology (using the layer file) for viewing.
Results



















Tuesday, September 15, 2009

Comprehensive Look at the Geoweb (Part 3 and 4)

The the story continues... I have been off and on the buzzword "Geoweb" for several years. I am now back on it so I set out to try and take a real look at the Geoweb, at least for the sake of academics. The term is bantered about a bunch and we all have our own take on what it really is. My goal was to try to comprehensively define the geoweb based on well documented patterns, models and architectures that currently exist within the web (part 1 and part 2 of this 4 part series) as well as from a purely organic perspective. Here are the slides that were used for this discussion. I can post my lectures as well if anyone is interested.



In summary, I came up with what I think is a very nice analogy in an attempt to somehow concisely define the Geoweb. I use the analog of an ecosystem defined as:

“An ecosystem is a natural unit consisting of all plants, animals and micro-organisms (biotic factors) in an area functioning together with all of the physical (abiotic) factors of the environment. Ecosystems can be permanent or temporary. An ecosystem is a unit of interdependent organisms which share the same habitat. Ecosystems usually form a number of food webs…” (Ecosystem, 2009)

Using this, we can begin to crosswalk components of the geoweb to the notion of an ecosystem. The geoweb as a unit of something finite, is composed of biotic and abiotic factions. Biotic factors including users, participants, perceptions (top-down vs. bottom-up), change and usability. Abiotic factors such as architectures, standards, formats, specs, platforms, etc... There are a number of relationships that exist between these factors, each with their own microprocesses but all interdependent in varying ways. Finally, portions of the the geoweb are permanent and some are temporary, depending on all of the factors (and their associated relationships) listed above.

If nothing else, have a look at the references cited section at the end of the slides. It includes alot of great materials from many leaders in the community that are worthwhile having a look at.


Ecosystem. (2009, August 26). In Wikipedia, The Free Encyclopedia. Retrieved 17:10, August 26, 2009, from http://en.wikipedia.org/w/index.php?title=Ecosystem&oldid=310197121

Monday, August 31, 2009

Tips and Tricks For the Geo Soloist

Imagine this scenario, a well educated, highly trained GIS/Geo professional is working for a small organization (county, environmental consulting, NGO, small federal agency, startup etc). Characteristics of such an organization typically include small budgets, pressure to maximize ROI of the organizations geospatial infrastructure, minimal resources (few people), you get the idea. This person is faced with meeting internal needs, typically required to perform the geoanalyses aligned with the organization's fundamental business processes ("I need a map off...") and is also tasked with presenting the valuable collection of geospatial products the small organization produces to the world. This professional is also commonly faced with requests from management that are typically articulated with something like:

"Hey GeoPro, I saw this great something or other at a business luncheon today, can we do that with our stuff."

If this scenario sounds familiar, you may be a Geo Soloist. Generally speaking, a Geo Soloist works completely independently of the rest of the business process and are seen by other professionals within the organization as the "technology guy/gal" or "web guy/gal" or "GIS guy/gal." They work in professional cultures that really don't understand the Geo trade, and typically work closely with non-Geo specialists such as scientists or engineers. A Geo Soloist can be thought of as a "jack of all trades" a "master of none" or a "polymath," commonly required to play the role of GIS analyst, business analyst, project manager, developer, DBA and evangelist, depending on the current project's needs or the issue of the day.

Italian polymath Leonardo da Vinci, scientist, mathematician, engineer, inventor, anatomist, painter, sculptor, architect, botanist, musician and writer.

The role of Geo Soloist is not for the faint of heart. It can be challenging and frustrating in that it requires compromises, minimized expectations, and can be disadvantageous. However, it is also a gift. It provides the opportunity to tackle a wide range of problems, provides a wide spectrum of experiences, and fosters resourcefulness, agility and ingenuity.

Serving as a Geo Soloist for many years, I have come up with a manifesto or set of rules to live by that I wanted to share. Many of these are interrelated and this list is not comprehensive but hopefully you will find something that rings home to you. They are in not particular order.
  1. Don't start from scratch: There are good "starting points" where someone else has done much of the legwork. An example of this might be some of the sample web map applications that ESRI provides for their new API's.
  2. Maximize documentation efficiency: This does not mean "do as little as possible." A Geo Soloist is typically working independently so documentation needs to serve their needs only (one benefit of not working in a group, say a team of developers). The other issue is that robust or extensive documentation takes time and requires maintenance given rapid changes. Maintenance also requires alot of time, something that is precious to all of us but especially to a Soloist. Documentation is important, just keep it relevant.
  3. Simplicity: Keep things simple. Workflows, expectations, requirements, everything. This concept should be a no-brainer but gets lost somehow. Make it your primary goal. Keep is part of every discussion.
  4. Don't get caught in a worm burrows. It is easy to do so be aware when you begin digging. Use well established patterns. Copy success stories and tweek as needed.
  5. Stay away from the bleeding edge: Use well established best practices and standards (when appropriate). Follow what the industry is doing and monitor grassroots efforts. Keep yourself educated about where the bleeding edge is and take a couple of steps back from it.
  6. Pillage: Use resources that are already available. There are so many great resources and given the vibrant, collaborative, brother/sisterhood we work in within the geospatial community, realize that someone has probably already done what you are trying to do and they are probably willing to share.
  7. Be resourceful: Student internships, collaborative funding relationships, cooperative agreements.
  8. Embrace the vacuum: This is counter intuitive to most of my other suggestions but exists in a different plane, more closely aligned to day-to-day workflows. We are taught to not work in a vacuum. I agree, but when you are working by yourself (at least as it relates to your immediate trade), trying to meet the needs of your immediate stakeholders, productivity can be very high if you do it your way. The vacuum can be a tool that lowers barriers. An example might be trying to over-collaborate (if there is such a thing) with those who are not specialists in our trade. Don't ask for permission, just do it.
  9. Be aware: Make sure you are aware of what is going on in the industry. Pick and choose patterns, best practices, standards etc. established by leaders in our community. Social networking tools such as Twitter are a great was to stay connected and informed. Be in touch with industry "buzz." Subscribe to leading industry blog sites that are relevant to your work.
  10. Manage the managers: Be sure to sell the concepts, but you are the ONE. Don't oversell but don't undersell. Manage expectations but don't underestimate your capabilities.
  11. Stay Agile: Embrace change, position yourself to manage change. Don't rest on what you know or what you are comfortable with. Don't be afraid of stepping outside your comfort zone. While the Agile process is typically thought of as a software development method, it expresses concepts that can be extended into all aspects of technology management. Have a look at it.
  12. Never stop learning: This should go without saying but it takes effort. We work on a platform that is like quicksand, ever-changing and it can swallow us up if we aren't nimble. The learning process doesn't have to be formal, simply read one blog a day or tackle 1 chapter in that nasty SQL book this week...then another next week....then another.
If you have others please let me know. In addition, I would like to pose a question to all of the GeoPros out there: Is the skillset/work experience of a Geosoloist (jack of all trades) desirable from the perspective of potential employers or is specialization?



For those of you who have been following my blog, don't worry, I haven't forgotten about parts 3 and 4, just taking more effort than first thought.

Friday, August 14, 2009

Web 2.0 and the Geoweb Part 2: Web 2.0 Patterns

Building upon part 1 of this series of lectures slides, part 2 actually examines (albeit at a pretty high level) well documented Web 2.0 patterns active in the Geoweb. Once again, the primary source of my research related to Web 2.0 patterns comes from Web 2.o Architectures by James Governor and et.al among others. Future lectures (parts 3 and 4) will comprehensively examine the Geoweb, using these Web2.0 patterns as a foundation as well as concepts examined by Geoweb experts related to usability, formats, discovery, architecture, etc....

Parts 3 and 4: Comprehensive look at the Geoweb

Wednesday, August 12, 2009

Web 2.0 and the Geoweb Part 1: Web 2.0 Examples

As I have mentioned earlier, I am ramping up for the upcoming semester and am feverishly prepping. My course, "Introduction To the Geoweb" is part of the Master of Engineering/GIS offered at the University of Colorado at Denver.

In the coming weeks, I intend to share materials I will be presenting to my students to all of you in hopes of getting some constructive feedback from the experts--YOU! I won't be sharing everything, just some selected materials that I think can benefit from some "participatory lecture development" if there is such a thing. I will also be citing much of the work that many of you have contributed so your feedback is critical.

The collection of materials I intend to share is tentatively termed "Web2.0 and the Geoweb." My hope during this series of lectures is to expose students to well documented Web 2.0 patterns and examples as a foundation for further exploration of the Geoweb. Some have suggested that a detailed look at web architectures and http are warranted before this discussion. Rest assured, the students will be prepared for these more advanced concepts.

The primary source of my research related to Web 2.0 patterns and examples comes from Web 2.o Architectures by James Governor and others. It is a good piece, articulating web2.0 patterns in a formal way and has worked nicely for foundational discovery. I have also incorporated materials from several additional sources that have proven adequate.

The story I hope to weave reads something like this: the Geoweb (which I think I can fully embrace) has roots, much of which can be described using well document Web 2.0 patterns. These patterns are best described using real world examples which can then be articulated formally using a standard method of description. This framework then serves as the foundation for further discussions mapping these patterns and subsequent reference models and architectures to Geoweb concepts, some of which have been stewing for some time and others which have emerged recently.

With that said, part 1 of 4 (or maybe 5) slides follow. These are subject to change which goes without saying. Be aware that these are lecture slides so there is a fair amount of text. Students get a little "bent without bullets."

I will be posting my recorded lectures as well. Continue to Part 2: Web 2.0 Patterns.

Friday, August 7, 2009

Back On The Geoweb Bandwagon

I am officially on the Geoweb bandwagon! I think this is the third time I have declared this in recent years, admittedly a bit premature in my previous attempts but I'm all in this time. The Geoweb has finally come of age. To give you some context, I have been a part-time instructor for several years now, teaching a number of GIS courses in the Master of Engineering Program (GIS) at the University of Colorado @ Denver. My favorite course over the years has been my web GIS course. While the most challenging given the ever changing landscape in this area, it is where my interest lies. The problem has been, what the heck do I call this course.

I have been following the Geoweb09 activities this year remotely and have had the opportunity to attend a couple of times, even dating back to its previous form, GML days. The term "Geoweb" and its numerous incarnations (Geospatial Web) have been bantered about for a few years, mostly in the context of this gathering. A couple of years ago, I actually called my course "Introduction to the Geoweb" but struggled with the label given the immaturity of the platform. Web2.0 stuff was just kicking in and my perception until recently was that the Geoweb was nothing more than some neogeos throwing up markers on a Google Map with little or no appreciation, knowledge, etc. of traditional (and very important) GIS concepts such as spatial relationships (topologies), projections, spatial analysis, etc. In addition, given my old-school roots in GIS, not having "GIS" in the course title was like having a marg without Grand Marnier--it worked and it was still decent but just wasn't right. Needless to say, I backtracked. So over the next couple of years, my labels for the course included "Introduction to Distributed GIS" and "Introduction to Internet GIS."

Those days are over now. The course is now officially recalled "Introduction to The Geoweb." This corny personal journey mimics that maturation process of the Geoweb itself. We all knew it was there and wanted to embrace it, but a few chips had to fall before we could really do so. The Geoweb is now walking. In fact, it is more like a toddler who can really move but who is a bit unpredictable.

I have been researching a number of great materials related to the Geoweb, much of which has been coming out of the Geoweb conference, and other materials which have been around for awhile. Based on these sources, I hope to develop a comprehensive look at the Geoweb that I will be sharing this semester with my students. I also plan to post these materials for some "crowd sourced lecture development" (if there is such a thing) as well so stay tuned.

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.

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.

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();

...

}

Monday, April 7, 2008

Hey GIS Pros: Neogeography Isn't All That Bad.




That's right all of you oldschoolers out there. Neogeography isn't all that bad, in fact, it is actually really amazing. And for the uninitiated GIS luddites out there still banging away at there ArcInfo command line who are wondering what I mean by neogeography, you had better figure it out quickly.

It has taken me some time to admit this. I am an old school GIS pro myself. I too, remember the days of plotting maps using 1000's of lines of scripting code (AML), entering endless commands into a black consol screen, yielding mesmerizing screens of lines, nodes or vertices and transforming data coordinate systems -- manually (sorry neogeos, this only makes sense to us old folk)! People honestly thought us GIS folks were magicians, and we thought it too.

Then, it was finally possible to actually publish these complex, sophisticated, and elegant geographic products (maps, datasets, etc) on to the web while providing some kind of interactive capabilities as well. Sure it was slow and clunky but still pretty amazing. During this period, my career objective was to master this emerging technology. However, this meant a skill-set upgrade, even after graduating just a few years earlier. So off I went, emersing myself in web technology training and after a couple of years, I became pretty good at it. This was the start of my long lasting love/hate relationship with that ever popular Internet Mapping Server we all know and love . Providing GIS functionality online, now thats the Holy Grail. Wrong!

People don't care about GIS. Sure there is a niche for those of us who understand projections, geoprocessing functions, linear referencing, geometric networks, etc... but most don't. And now that the whole world is leveraging the geo portion of information and the web, we too must come to acknowledge this. And through this acknowledgment, an important epiphany, a least for me was not to discredit neogeos and their tools of choice but to embrace them. Think about it, what an advantage we old school GIS folks have if we only step back and realize that things are changing and it's not a bad thing. Don't think of it as a threat but an evolution of GIS into GIS 2.0 if there is such a thing. We can have the best of both worlds.