Stan Grochowski

MapTrack in the Assessor/Treasurer's Office:
A PowerBuilder Link to ArcInfo

The Pierce County Assessor/Treasurer's office has begun a conversion of the tax parcel maps from hard copy to digital. The conversion is being done by a conversion vendor therefore keeping track of where the maps are at any particular time is part of the task. For this purpose the Maptrack software was developed. Maptrack is a PowerBuilder application for a Sybase database. It is also linked to an ArcInfo quartersection index coverage of Pierce County. The database was originally maintained in Info as part of the quartersection coverage. However, this arragnement soon proved to be unacceptable as updating of the database needed the use of an ArcInfo license, which were in short supply as the QC process began. Putting the database into Sybase and updating and maintaining it through a Power Builder interface solved the ArcInfo license problem, but created another since there was still the need to create maps charting the progress of the project based upon what stage the quartersection maps were in. Maptrack was developed to address these problems by allowing the user to produce ArcInfo maps from menu choices within the Power Builder application. This paper will explain what data Maptrack maintains for the Assessor's office and the process by which the link is made to between Power Builder and ArcInfo.


Figure 1.

The Maptrack software is a PowerBuilder application which runs under MS Windows 3.1. Due to Maptrack being a PC application and ArcInfo a Unix application communication between the two is limited. In order to communicate system commands are required. From PowerBuilder a system command can be issued to start Hummingbird's Exceed product which is an X window emulation program. Using the Unix rlogin daemon to start an X session on the Unix host machine, connection to ArcInfo can be established. Once ArcInfo is started an AML program can then be run which produces the requested map. The problem at that point, since the system request does not start a dialogue, is to get ArcInfo to send a message back to the PowerBuilder application, so that the user may know the status of the map.

Figure 2.

MapTrack Tables

The Maptrack application consists of three tables, two of which are shown in Figure 2. One holds the general data for each tile in the ArcInfo library. Each tile being a legal quartersection. A second which contains information on what activities have been performed on the map sheet and a third table, not shown here, holding counts of the various types of features on the map, ie polygons, lines, annotations and the errors recorded for each. There is a one to many relationship between the main table and each of the other two. The main table also has a one to one relationship to the PAT of the county map index. The link to the map index is through the map_id column. Most of the time, as information is added to these tables, no connection is needed to ArcInfo and no licenses are used during these updates. It is only when map reports are requested usually on a monthly basis that any connection to ArcInfo is needed. At that time the user can make a choice from the Maps Menu and request a map. The menu choice starts a PowerBuilder script. This script, Script 1, as seen below starts several tasks. First of all it initializes a the map variable to "status" giving the map a name then it opens a new window from which to choose the printer location.

Script 1. int prt_rtn map = "status" SetPointer(HourGlass!) prt_rtn = OpenSheet(w_printer,w_main,6,original!) if prt_rtn = -1 then return end if

Figure 3.

Printer List

Once this window is opened and a selection of a printer is made either with a double-click on the printer name or highlighting the printer and clicking OK. another script is started, Script 3.

Script 3. int rtrn Close(w_printer) if printer = "ISD Phaser III" and map = "status" then rtrn = Run("c:\exceed\xstart.exe c:\exceed\user\statarci.xs") if rtrn = -1 then MessageBox ("Map Error","Error in Hummingbird Process",Exclamation!,OKCancel!) return end if elseif printer = "ISD Phaser III" and map = "control" then rtrn = Run("c:\exceed\xstart.exe c:\exceed\user\cntrarci.xs") if rtrn = -1 then MessageBox ("Map Error","Error in Hummingbird Process",Exclamation!,OKCancel!) return end if elseif printer = "ISD Phaser III" and map = "qc" then rtrn = Run("c:\exceed\xstart.exe c:\exceed\user\qcarci.xs") if rtrn = -1 then MessageBox ("Map Error","Error in Hummingbird Process",Exclamation!,OKCancel!) return end if elseif printer = "ISD Phaser III" and map = "deliv" then rtrn = Run("c:\exceed\xstart.exe c:\exceed\user\delarci.xs") if rtrn = -1 then MessageBox ("Map Error","Error in Hummingbird Process",Exclamation!,OKCancel!) return end if elseif printer = "ISD Phaser III" and map = "qc2" then MessageBox ("Map Status","Map not yet available",Exclamation!,OKCancel!) elseif printer = "ATR Phaser III" and map = "status" then rtrn = Run("c:\exceed\xstart.exe c:\exceed\user\statarca.xs") if rtrn = -1 then MessageBox ("Map Error","Error in Hummingbird Process",Exclamation!,OKCancel!) return end if elseif printer = "ATR Phaser III" and map = "control" then rtrn = Run("c:\exceed\xstart.exe c:\exceed\user\cntrarca.xs") if rtrn = -1 then MessageBox ("Map Error","Error in Hummingbird Process",Exclamation!,OKCancel!) return end if elseif printer = "ATR Phaser III" and map = "qc" then rtrn = Run("c:\exceed\xstart.exe c:\exceed\user\qcarca.xs") if rtrn = -1 then MessageBox ("Map Error","Error in Hummingbird Process",Exclamation!,OKCancel!) return end if elseif printer = "ATR Phaser III" and map = "deliv" then rtrn = Run("c:\exceed\xstart.exe c:\exceed\user\delarca.xs") if rtrn = -1 then MessageBox ("Map Error","Error in Hummingbird Process",Exclamation!,OKCancel!) return end if elseif printer = "ATR Phaser III" and map = "qc2" then MessageBox ("Map Status","Map not yet available",Exclamation!,OKCancel!) end if mapstat = 1 timer(65,w_map_trk_activity)

Script 3. sets some variables which will ultimately be passed to ArcInfo in order to choose the correct map to plot and the printer to send the plot to. It then initiates the PowerBuilder Run function to start Hummingbird's Exceed X-emulation application. With it is a parameter based upon the variables set from the map and printer selection. Finally it sets the mapstat variable to 1 and begins a timer. The timer is set to a timed interval of 65 seconds and names the window from which the timed event will be triggered, in this case w_map_trk_activity. The timed event watch for the appearance of a file which the return information from ArcInfo, as shown in Script 4 below.

Script 4. integer filenum string mpstat_rtn, rtn_file rtn_file = "i:\pbdata\gis\mapstat.fil" if mapstat = 0 then return elseif FileExists(rtn_file) then filenum = FileOpen(rtn_file) if filenum = -1 then MessageBox("Map Status","Unable to read return file") mapstat = 0 return end if FileRead(filenum,mpstat_rtn) MessageBox("Map Status",mpstat_rtn) mapstat = 0 FileClose(filenum) FileDelete(rtn_file) else return end if

This timed event is the mechanism for to receive communication back from the PowerBuilder application indicating the status of the requested map. It first checks for the existence of a file called mapstat.fil, which contains information which ArcInfo, through an aml program, has written stating whether the print job has been sent to the printer or if there was some problem within the AML which creates the map. The timed event then reads the file and displays it in a message box for the PowerBuilder user. Since the timer function is an ongoing event, meaning once it is initiated it continues to fire for the duration of the current session, the mapstat variable is set to 0 when no file is expected to be returned. A return is then encountered and the rest of the script is ignored. This function has been refined in version 4 of PowerBuilder to accept a 0 to stop the timer from triggering further.

While PowerBuilder is waiting for the status file to show up. The run function seen in script 2 above has started an Exceed script, which pops up a menu as shown below in Figure 4. This menu prompts the user for a password to their Unix host machine using an rlogin daemon. The following command is then passed to Unix.

Command=/apps/maptrack/misc/startarc7 ws04 ms_prepscrb.aml &

Figure 4.

X Window Login

This command starts a c shell script startarc7, Script 5 below, with 2 parameters a printer variable in this case ws04 and an AML file variable, ms_prepscrb.aml, which creates the map we wish to have plotted. Also notice that the program is run in the background so that exceed does not try to start a window for this process.

Script 5. # @(#)cshrc - setenv OPENWINHOME /usr/openwin set path= ( /usr/ucb /usr/bin /usr/local/bin /etc /usr/etc /ushare/bin .) umask 0 setenv ARCHOME /libs/Esri7/arcexe70 setenv LD_LIBRARY_PATH $ARCHOME/lib:$OPENWINHOME/lib:/usr/lib setenv AMLPATH /apps/maptrack/amls alias arc70 '$ARCHOME/programs/arc' alias info '$ARCHOME/programs/info' # argv[1] is the plotter name and argv[2] is the aml name arc70 \&r $AMLPATH/$argv[2] $argv[1] | tee mapstat.out

The first line of script 5 defines it as a .cshrc file to the cshell, which means that it contains startup environment variables for the shell. In it, as in most cshrc files, the path must get set along with various environment variables ie., ARCHOME, OPENWINHOME, etc. Also it starts arc and runs the correct aml for the requested map. The output from the Arc session is tee'd to a file to keep a record of how Arc was responding to the aml. However this file is never complete and seems to end when the process moves to the background. Once the AML, as shown in Script 6, is running however then error processing is turned over to the AML. The AML uses the new error reporting features of Arc70, aml$errorline and aml$message, to return error messages which are then written to the status file. If the plot is successful a message telling the user that the plot is printing is sent to the status file.

Script 6. &severity &error &routine exit &args plotter &sys date workspace /apps/maptrack/data /* Connect to ATR Sybase Database */ connect atrsyb /* Begin Plot Creation */ ap disp 1040 $HOME/xxms_prepscrb.gra pagesize 11 8.5 maplim .55 .55 7.5 7 mape 1059706.375 508361.1627358 1280736.69609 763296.812 mappos ll ll box .5 .5 10.5 8 &r /apps/amls/logogis '0.5,0.5,2.44,1' lineset /apps/maptrack/misc/stan.lin /* Create relate for Sybase tables */ relate add mt activity atrsyb map_id map_id first ro ~ /* Do reselects from ATR data for shading */ shadeset colornames resel qmaps polys ^mt where act_typ = 's' polygonshades qmaps 9 asel qmaps polys resel qmaps polys ^mt where act_typ = 'p' polygonshades qmaps 120 /* Fill in other layers , legend and statistics for graphs */ ... many lines of code ... /* Create graphs */ ... many more lines of code ... /* Send plot to plotter */ &if [exists $HOME/xxms_prepscrb.eps -file] &then &sv a [delete $HOME/xxms_prepscrb.eps -file] postscript $HOME/xxms_prepscrb.gra $HOME/xxms_prepscrb.eps 1 /apps/maptrack/misc/mapstatl.parm &sys lpr -s -P%plotter% $HOME/xxms_prepscrb.eps &type The End &sys date /* Create file for return message to PowerBuilder */ &if %plotter% = ws04 &then &sv place = ISD &else &if %plotter% = ws06 &then &sv place = ATR &else &sv place = Unknown &sv fileunit = [open $HOME/mapstat.fil openstatus -write] &sv b [write %fileunit% [quote The Prep/Scrub Map is now printing on %plotter% at %place%]] &sv a [close %fileunit%] &workspace $HOME /* FTP Status file to Server ATR */ &data ftp atr cd pbdata/gis send mapstat.fil quit &end &return /* Deal with Errors and Error Messages */ &routine exit &sv msg [quote Error: %aml$message%] &sv msg2 [quote Error on LINE: %aml$errorline% of FILE %aml$fullfile%] &type %msg% &sv fileunit = [open $HOME/mapstat.err openstatus -write] &sv b [write %fileunit% %msg%] &sv c [write %fileunit% %msg2%] &sv a [close %fileunit%] &sv fileunit2 = [open $HOME/mapstat.fil openstatus -write] &sv b [write %fileunit2% %msg2%] &sv a [close %fileunit2%] &workspace $HOME /* FTP Error file to Server ATR */ &data ftp atr cd pbdata/gis send mapstat.fil quit &end &if [show program] = ARCPLOT &then quit &sys date quit &stop

In the &data block, near the bottom of this AML, the FTP process which sends the file to the ATR PC network file server, is coded. The login and password to the ATR server are not coded. Besides being a security issue coding the login name or password did not to work correctly within the &data block. FTP, however, will allow for server, login and password combinations to be read from a hidden file called .netrc on the UNIX host. This file must have read or write permissions set for the owner exclusively and will not work if any other permissions are set. This provides some measure of security for passwords keeping them out the body of the program itself. After the AML is run and the status file is sent to the ATR server and PowerBuilder finds the file with the timed event the following message box is displayed, Figure 5.

Figure 5.

Map Status Message

The user can then, of course, pick up his completed plot at that time. The user may report back to GIS staff if the Map Status box reports an error. The error messages besides being reported to the user are captured in a file which is stored in the user's home directory,. so that the message is not lost when the OK button is pressed. Other files are also stored in the users home directory reporting on the status of ArcInfo when the plot started and on the FTP process. If the plot is successful it will look like the following plot in Figure 6.

Figure 6.

Map Output


Stan Grochowski
GIS Systems Analyst/Programmer
Pierce County ISD/GIS
615 South 9th St, Suite 220
Tacoma, WA 98405-4666
Tel: (206) 596-2916
FAX: (206) 596-6622
Email: sgrocho@co.pierce.wa.us