Using MapObjects for Enterprise GIS at The City of Calgary

In mid-1999, The City of Calgary (population 861,000) selected Esri as their Enterprise GIS. The GIS Office has now implemented a centralized SDE database, with ArcInfo for spatial data creation, ArcView for power users, ArcIMS for intranet delivery, and MapObjects in Visual Basic for desktop application development.

This paper presents a summary of how MapObjects is being used for the delivery of GIS. Existing Visual Basic applications have been spatially enabled through the use of a Map Component. With a minimum of effort, the Map Component can be added to any VB application. A technical overview of the component will be provided.

Stephen Gale, CCP, I.S.P.

Using MapObjects for Enterprise GIS

Table of Contents

Agenda

Overview

This paper contains notes for my PowerPoint presentation at the 2001 San Diego User Conference. It contains a summary of how GIS and, in particular, MapObjects is being used for the delivery of GIS at The City of Calgary. We hope to share some of our experiences, our development environment, our methodology, and our findings.

In June 1999, The City of Calgary selected Esri as our Enterprise GIS tool.

Two years ago, the GIS Project Office was formed to "provide the right information to the right person at the right time with the right resources".

GIS Internal User Profile

Our GIS Environment

GIS Tools

At a high level, The City of Calgary uses the following products:

This presentation focuses on the Visual Basic/MapObjects applications and the associated development environment, with a focus on the Drop-a-Map component. This component enables any non-GIS Visual Basic application to include a map with a minimum of development effort.

GIS at The City of Calgary


System Architecture


Spatial Database Layers

MapObjects Applications

Since acquiring Esri, we have used Visual Basic with MapObjects to develop a variety of business applications. We have found that MapObjects provides an excellent set of tools for viewing and analyzing spatial data, and good features for spatial data creation and maintenance.

Some of the MapObjects applications developed to date include:

For the desktop applications, we tried to give these applications the same basic look and feel, with easy spatial data creation tools and attribute entry.

As you will see shortly, we used the Esri sample application MoVIEW2.VBP as the foundation for our applications.

Visual Basic/MapObjects Applications


Parks GIS


Traffic Counts GIS


Transit Routes GIS


Development Environment

Standards and Quality Control

The City of Calgary's Information Technology Services (ITS) use Visual Studio as their development standard. Visual Basic is the application development language of choice, with Active Server Pages hitting VB 3-tier DCOM components for thin client and web delivery. All source code is maintained within Visual Source Safe.

Thus, these were the tools of choice for the GIS Project Office. At the present time, MapObjects applications are delivered as 'fat' Client/Server apps (with the exception of the web applications).

The Development Center of ITS provide the quality assurance and quality control necessary to deliver standard applications with a common look and feel (both the user interface and the coding style). Project and design reviews are performed early in the project to ensure that technology is used in a standard method, while code reviews are performed as development is nearing completion.

Methodology

The GIS Project Office required a methodology that would facilitate the delivery of GIS applications in a short time frame. We wanted to deliver some basic functionality, then improve it by adding additional features, again in a short timeframe.

When we acquired the Esri suite of products, we knew they would facilitate the prototyping process to help our understanding of the business function. In addition, we knew that many of the prototypes could also be robust enough to form the foundation for the production application.

Since many of these applications were expected to use existing spatial data for viewing, analysis, and thematic mapping, the rigor and length of the existing Development Methodologies may be inappropriate.

Various Rapid Application Development approaches were reviewed, and the most relevant deliverables were extracted and incorporated into the GIS/RAD methodology.

The methodology was divided into four stages. See Appendix A for an overview of the deliverables for the methodology:

Each stage of the methodology has clearly defined deliverables. However, the length and content is dependent upon the application. Each deliverable may range from a simple Powerpoint presentation or a one page summary for simple applications, to multi-page reports and more formal deliverables.

Templates for these deliverables were distributed to help ensure GIS Office project teams were approaching projects from the same direction. Over the last two years, these documents have been revised and improved. It's nice having a foundation of examples that can be copied and modified: they provide a 'running-start' for a new application. See Appendix B for the table of contents of these deliverables.

The project framework document is one of the key deliverables as it sets the direction for the project.

We have found that weekly status reports help keep a project moving. Without this weekly commitment, projects may wander.

Experiments with Code Generation

We have briefly experimented with automated code generation. Both Visual Modeler and an evaluation version of Rational Rose have been used to generate code templates from Unified Modeling Language (UML) diagrams. Small portions of the Visual Modeler code have been used within Traffic Counts and Transit Routes GIS application.

We felt that Visual Modeler saved time by clarifying which methods and behaviours were required within the classes by using the UML, with some limited benefits due to code generation. The code generated by Rational Rose (which included some data access and significant error checking) was very nice. Rose also has the ability to revise the UML based on code changes. We would like to follow-up on the Rational Rose approach to code generation as time permits.

Experiments with Automated Testing

We have used some limited automated testing. We have developed automated test scripts for MoView, Parks GIS, the Drop-a-Map Component, and for Traffic Counts GIS. These scripts confirm basic functionality, as well as some limited regression and stress/performance tests.

We found that developing test scripts is like a separate development effort. It requires planning and manpower. It will not find bugs in new code, but it will help identify new bugs in code already written. It is great for regression testing (ensure that a bug that has been removed does not return), as well confirming that basic functions work after an enhancement is implemented.

I believe the benefits begin to accrue as soon as the first piece of user interface is considered complete. If an automated script is recorded for that component, it can be reused as further development proceeds, thus ensuring that future coding does not break what already works.

As an example, when we Beta tested MapObjects 2.1, we ran an automated test script against the Esri sample program MoVIEW2. Within 30 seconds, the screen turned black during a test of the 'redlining' functions. The Esri MapObjects team corrected the problem for the next Beta release.

Development Environment


GIS RAD Methodology


Automation


Code Generation


Visual Component Manager


Visual Test in the GIS Project Office


Automated Testing


Automated Testing Effort

Application Design

Various Esri sample programs were used to jump start our Visual Basic/MapObjects development effort. In addition, a variety of books and magazines were scrutinized.

MoVIEW2 as a Foundation

Esri’s MoVIEW2 sample application provided a wealth of GIS functionality. This Visual Basic/MapObjects application includes:

If you look at any of our GIS Visual Basic/MapObjects applications, you will see these features as the foundation. We needed to add some basic error checking, but the code seems very stable. If you have not had a chance to try it out, it is installed in folder C:\Program Files\Esri\MapObjects2\Samples\VB\MoView2

Esri's MoVIEW Sample


Edit On-Screen Shapes

The EDIT.VBP sample provided a jump-start approach to giving the user the ability to drawing new spatial information. This example allows the user to draw a polygon, add/move/delete vertices, and save features (en-mass) to a shape file.

The basic concept (encapsulated within the clsEditLayer class) has been used in our Parks GIS (Openspace creation), Transit Routes (bus stop and bus zone creation), and Traffic Counts (intersection and study location creation).

This program is installed in folder C:\Program Files\Esri\MapObjects2\Samples\VB\Edit

Esri's EDIT Sample


ObjectTable for Editing the SDE Database

The ObjectTable sample application provided an excellent template for spatial data creation and entry of associated attribute values in a seamless manner, while directly editing the GIS SDE database or a shape file. (We did not want to create and maintain spatial data with Coverages using ArcInfo 7, followed by replicating the coverages to the SDE on a regular basis).

In addition, the ObjectTable program (found at Esri's web site at http://gis.Esri.com/arcscripts) provided a great example of inheritance in Visual Basic using 'containment and delegation' for any Object Oriented developers.

Esri's ObjectTable Sample


FindClosest for Snapping

The FindClosest sample routine (also found at Esri's web site at http://gis.Esri.com/arcscripts) provided the foundation for 'snapping' to features with the SDE. Although not perfect, it was sufficient to deliver business results (ie. spatial data creation and maintenance) to our clients in a reasonable timeframe.

LinePoint

The LinePoint sample application (again found at Esri's web site at http://gis.Esri.com/arcscripts) provided key insights to using MapObjects.

Books/Magazines

The following are the major resources we have used:


Our Map Component

Functional Overview

In an effort to deliver commonly used functionality to other (non-spatial) Visual Basic applications, the GIS Office modified the Parks application to be a reusable Map Component, with read-only capabilities.

This Map Component is intended to add the following features with a minimal of GIS programming knowledge:

Using the Component

Our goal was to minimize the effort to spatially-enable an application. Thus, the following simple lines of code (plus error checking) are required to use the Map Component:

This component is currently being rolled out to 90 users, with a link to the Parks asset management system. It is also being user-tested in the newly developed Excavation Permits application.

Drop-A-Map - Intended Use


Drop-A-Map - Intended Use


Technical Overview

Our goal was to create a reusable map component that could easily be added to any Visual Basic application. In the Microsoft world, there are several options, with pros and cons for each approach.

We chose to implement as a late-bound ActiveX EXE. The program can be run standalone, or fired up from another application. Adding a real-time link between a late-bound component and the application was a bit of a challenge since events are not exposed directly. The technique used is called 'using a Change Event with Callback', and works very well.

In summary, here is how this technique works: the client programmer adds a Label onto a form and sets the Label's Visible property to False. The client programmer then adds an Event Handler for the Label's Change event. A reference to the Label is passed to the Map Component when the connection is first made. In the Map Component (after the user has selected a Point, Single Address, etc), the last step is to assign a value to the Label field which reflects the type of selection. Back in the client, the Label's Change event fires, and knows which info to pick up from the Map Component based on the value of the label.


Excavation Permits - Map Component


Excavation Permits - Permit Status


Our Next Steps

Currently at The City of Calgary we are busy planning for the deployment of ArcGIS (ArcInfo 8.1, ArcView 8.1, and ArcSDE 8.1). We want a clear understanding of ArcEditor's spatial data creation and maintenance functionality. Then our focus will probably shift to VB, VBA, and ArcObjects development where appropriate.

The future of MapObjects depends upon Esri. We hope that a new version of MapObjects will be developed using ArcObjects, but expose the same (or very similar) behavior as MapObjects.


Conclusion

The Esri sample applications provided an excellent jump-start for our MapObjects application development effort. GIS application development now takes a reasonable timeframe: how long, of course, depends upon the size of the application. However, MapObjects is a very effective set of objects for rapid development, and it is relatively easy of use.

The use of the Map Component helps minimize the learning curve in spatially-enabling an application.


Acknowledgements

My apologies for not including the many other people who have helped make the GIS Project of "The GIS Center of Excellence".

Questions and Statistics

Appendices


Appendix A - GIS RAD Overview

The GIS Project Office required a methodology that would facilitate the delivery of GIS applications in a short time frame. As many of these applications were expected to use existing spatial data for viewing, analysis, and thematic mapping, the rigor and length of the existing Development Methodologies may be inappropriate.

Various Rapid Application Development approaches were reviewed, and the most relevant deliverables were extracted and incorporated into the GIS/RAD methodology.

The methodology was divided into four stages:

Each stage has clearly defined deliverables. However, the length and content is dependent upon the application. The deliverable may range from a simple Powerpoint presentation or a one page summary for simple applications, to multi-page reports and more formal deliverables. However, the descriptions below convey the intended contents.

Stage 1 – Requirements Definition Stage Deliverables

Stage 2 – User Design Stage Deliverables

Stage 3 – Construction Stage Deliverables

Stage 4 – Transition Stage Deliverables

On-Going Deliverables


Appendix B - GIS RAD Deliverables Table of Contents

Templates for the GIS RAD deliverables were distributed to help ensure everyone was approaching projects from the same direction. As we gained experience, the documents and their contents were refined to what they are today.

Appendix A contains an overview description of the deliverables, and this appendix contains the table of contents.

Stage 1 – Requirements Definition Stage Deliverables

Stage 2 – User Design Stage Deliverables

Stage 3 – Construction Stage Deliverables

Stage 4 – Transition Stage Deliverables

On-Going Deliverables


Appendix C - Creating an ActiveX Map Control

Creating a reusable GIS ActiveX Control Map in Visual Basic is straightforward when using MapObjects. The following steps create a project group (an ActiveX Control and a Test Project), adds the Esri Map Component to the UserControl Form, adds an ImageList and a ToolBar, adds under fifty lines of code, drops the new control into the Test Project, and Runs! "MAKE" the ActiveX Control and you can use it in PowerPoint, Word, Excel, etc!



Creating an ActiveX Map Control

Open VB6 and Select ActiveX Control

Open VB6 and Select ActiveX Control


Creating an ActiveX Map Control

Add a Second Project so You Can Test the Control

Add a Second Project


Creating an ActiveX Map Control

Select the Esri MapObjects Control from Projects/Components

(don't forget to add your shape files to the map properties)

Add Esri Map Control


Creating an ActiveX Map Control

Add an ImageList and the Necessary Bitmaps

Add ImageList and Bitmaps


Creating an ActiveX Map Control

Add a ToolBar, link to ImageList and Images

Add Toolbar and Link Images


Creating an ActiveX Map Control

Add Code (22 Lines)

Add 22 Lines of Code


Creating an ActiveX Map Control

Add Remaining Code (25 Lines)

Add 25 Lines of Code


Creating an ActiveX Map Control

Add Your New Control to the Test Project Form

Add New Control to Test Project


Creating an ActiveX Map Control

Run the Test Project to Try Out Your New Control

Try Out the New Control


Creating an ActiveX Map Control

Make the ActiveX Control for Use in PowerPoint, Word, etc

MAKE the OCX


Appendix D - Visual Basic/MapObjects Application Gotchas

This appendix is extracted from Chapter 9 of our GIS Application Development Standards document. It contains features and obscure requirements that have caused application development difficulties in the past. They are provided here so that developers will be aware of them, and can therefore avoid them in the future.