Home
Comparative Analysis of Programming Languages
Contents
1. and uninstallation of various products All subsequent experiments were completed in this way clean install of Windows ArcGIS and the application The virtual computer running on this system is Microsoft Virtual PC running an instance of Microsoft XP Professional with 555 MB RAM Results of this machine are outlined in Figure 7 Dell 4400 MTA virtual 434 STA virtual is 1389 5 pa 2 C virtual 1457 S VB virtual J 10 i C physical 416 VB physical 912 0 100 200 300 400 500 Seconds Figure 7 Dell 4400 experimental results 11 Computer time was acquired on an instance of Microsoft Windows Server 2003 Enterprise Edition running on Microsoft Virtual Server 2003 at 1 33 GHz and 1 95 GB RAM on a Dell 2950 host with dual Intel Xeon 5150 processors at 2 66 GHz with 16 GB RAM running Microsoft Server 2003 R2 Enterprise x64 Edition Figure 8 shows the results on this virtual machine It was observed that the applications run consistently faster on the virtual machines It was observed that memory usage was low and the majority of delay in the C app was because it was I O bound repeatedly accessing the registry While running the slow C app regmon results were monitored It could be seen that the app was continually re creating a COM object because it repeatedly got the same registry key in HKET CLASSES ROOT Dell 2950 MTA virtual 27 104 STA virtual 2
2. Therefore VB Script is unable to duplicate the functionality in ArcMap It definitely can be used to script tools published in ArcToolbox because those COM objects implement Dispatch but any early binding COM objects who do not implement Di spat ch cannot be called with VB Script This does not mean that a tool cannot be created in VB Script using a hybrid of the ArcToolbox tools and compiled VB or C components If the developer would spend the time to develop the compiled components he she may as well develop all of the functionality in the compiled language Implement the Tool in Python After termination of the VB Script portion of the project Python was explored Python is said to have good COM support and probably should have the ability to support early binding COM methods In Python Programming on Win32 Hammond and Robinson state that Python does support early binding but only for Di spatch objects Hammond and Robinson 2000 The utility makepy will create a Python class from the COM interface for use in the Python program Here is an example run of makepy hon23 Li b site 32com client gt makepy py hon21 wi n32com gen_py 2396BA16 B4C6 4D51 D arcgi packages PY hon23 Lib site 32com client gt makepy py dogserver 1 0 Type hon21 wi n32com gen_py 2396BA16 B4C6 4D51 y Having generated the wrapper Python class it can be used in a Python script import win32comclien
3. D arcgis python23 Li b site packages win32com client gt makepy py Generating to D arcgis python23 lib site packages win32com gen_py 1CE6AC65 43F5 4529 8FCO D7ED298E4FIAx0x1x0 py D arcgis python23 Li b site packages win32com client gt makepy py Generating to D arcgis python23 lib site packages win32com gen_py 0475BDB1 E5B2 4CA2 9127 B4B1683E70C2x0x1x0 py D arcgis python23 Li b site packages win32com client gt makepy py Generating to D arcgis python23 lib site packages win32com gen_py C4B094C2 FF32 4FAL ABCB 7820F8D6FB68x0x1x0 py The desired functionality was still out of reach by merely using the resulting classes In order to prove the COM objects were able to be instantiated at all the Python COM browser was used The entire list of all ESRI objects was shown which is of considerable size Examples of a few objects as seen in the object browser are shown in Figure 2 The file names for the objects are also reported The ESRI Dat aSourcesFile object library filename is shown in Figure 3 O Python Object Browser 9 ESRI DataSourcesFile Object Library I ESRI DataSourcesGDB OBJECT Library ESRI DataSourcesOleDB Object Library ESRI DataSourcesRaster Object Library ESRI DataSourcesRasterU Object Library 5 ESRI DataS ourcesSMUUI Object Library ESRI Developer Kit Library Lookup Library ESRI Developer Kit Support Type Library ESRI Developer Kit VB6 Code Support Library ESRI
4. as the most efficient way to create polygons Perhaps in the case of this application where many polygons were created it is not the most efficient method It may be efficient for the creation of a single polygon The code was changed to declare and instantiate the Poi nt Cl ass objects once outside the function as member variables to avoid duplicate construction destruction This modification improved the performance by 4 minutes Figure 6 shows the improvement between C physical 1 and STA physical Additional analysis of COM performance prompted comparison between apartment threading models to eliminate marshalling overhead Again Appendix A of the developer guide provides more information on COM briefly outlining the meaning of apartment threading models ESRI 2004 All subsequent experiments compare the performance of the C application using both threading models Experiments shown on the bar graphs are designated as running the STA or MTA threading models 10 Additionally the applications were compared on operating systems running on Microsoft Virtual PC and Microsoft Virtual Server 2003 Experiments shown on the bar graphs are designated as running physical or virtual Knowing these facts about the experiments and environments the names of the experiments on the graphs may be interpreted as follows 1 VB physical VBA app run on physical computer 2 VB virtual VBA app run on virtual im
5. rcinfoltem Interface B B B The type info can n The type info can not be loaded B B B Figure 4 Example type library showing errors in the Python Object Browser In later experimentation a test program used theesri catalog olb module This approach allowed the object to be instantiated After the program ran many files appeared in the lt python dir gt Lib site packages comtypes gen folder that were not there before Such behavior suggests that using the object browser or an application could instantiate and possibly internally makepy the objects To further prove it is the case all the objects from the lt python di r gt Lib site packages comtypes gen folder were deleted and the program was rerun It generated the following output instead which is promising but also showed some unexpected output emp model gt i env py et module enerating ypes gen 1CE6AC65_43F5_ 4529 8FCO_D7ED298E4F1A 0 1 n ing ypes gen 00020430 0000 0000 C000_ 000000000046 0 2 comtypes gen stdole _0475BDB1_E5B2_4CA2_9127_B4B1683E70C2_0_ y es gen 5E1F7BC3_67C5_4AEE_8EC6_C4B73AAC42ED_0_ comt ypes gen esriSystem _C4B094C2_FF32_4FA1_ ABCB_7820F8D6FB68_0_ comt ypes gen esri Geometry _59FCCD31_434C_4017_BDEF_DB4B7EDC9CE0_0_ ERD ypes gen 4ECCAGE2_ B16B_4ACA_BD17_E74CAE4C150A_0_ com com g s gen esri SystemUl g g com g u k s gen esri Display s gen esri
6. faster than the original COM program written in C Figure 9 shows the results Caller is the C program that calls dogserver CSCaller isaC program that calls dogserver using COM interop Catcaller is the C program that calls cat server All three programs call the method to write to the text file 5000 times This gives strong evidence that although code written with today s C class wrappers to ArcObjects may run 12 slow in time ESRI will rewrite them in pure C and vastly improve their performance COM interop catcaller 1 39 cscaller 8 359 Experiment caller 1 484 0 2 4 6 8 10 Seconds Figure 9 COM interop experimental results Hopefully in the interim ESRI will rewrite the most heavily used COM objects first so the benefits demon stated here can be reaped as soon as possible Discussion It was proven that some languages are unable to deliver complete functionality It was also found that the development time was roughly equal The reason for this research topic was such that many organizations are faced with maintaining an obsolete un supported product They must move forward to a more current technology The agonizing question which language is best for the future of the organization With development time maintainability online support and industry acceptance of VB VBA C VB NET and C being equal it appears that the longevity of the
7. implementing the solution demonstrated in VBA Small programs that demonstrated various parts of the complete solution along with the whole solution within ArcMap were sufficient Implement the Tool in C NET ESRI provides a wealth of document ation and code samples from both ESRI documentation and from the user community in the ESRI user forums As stated in the introduction the VBA implementation of ArcObjects is mature and well documented and the number of C code samples is steadily increasing Therefore it was relatively easy to continue the development paradigm using C find C samples on the web modify the samples to incorporate the desired functionality and repeat The resulting application was completely command line driven a command line program using parameters such as shapefile name distance between points and output shapefile name can be typed from the command line or invoked from ArcToolbox Results Original expectations were that all languages would be equal and an organization could choose to use any language that best suited its IT staff However the manual stated that VB script was unable to support early binding COM objects If a homogenous VB script solution is strongly desired an Dispatch wrapper shell for the required COM objects of the application at hand could be created The drawback of this solution is that any future updates to the underlying objects could break the wrapper and
8. need to be updated accordingly Python was also disqualified It was better than VBScript in that it supports early binding COM objects but not without problems and some of the objects were not able to be supported Figure 4 There was also the question of ctypes s availability only in Python 2 3 VBA integrated into ArcMap was able to deliver all functionality without problem Additionally compiled VB and C demonstrated their abilities to support the functionality C which implements the NET language specification was able to deliver the desired functionality Because all NET languages support the common language specification all NET languages may be considered identical and are thus able to deliver the desired functionality Development Time Because not all languages were able to deliver the final product only VBA and C will be discussed Most development is an iterative process of find an example modify the example to more closely match end result and repeat It may not be a fair comparison to redo the same exact application in all languages to see which one is easier to develop Lessons learned in writing the program in one language can be exploited in the other languages Each language should be used to write a different end product of comparable complexity in order to eliminate such learning experiences There is also the unfair advantage of a language the developer has more experienc
9. 4 794 Experiment C virtual 33 VB virtual 19 0 10 20 30 40 Seconds Figure 8 Dell 2950 experimental results This behavior draws the conclusion that the NET classes are just COM interop wrapper classes They are not doing anything more than adding extra overhead as the following pseudo code outlines Create instance of class Call class method Class creates COM object Class calls COM object Class releases COM object Class goes out of scope it is destructed ESRI s ArcObjects is the single most extensive COM object model in the world ESRI cannot simply rewrite everything overnight They can however create several thousand wrapper classes with one line of code for in ol b out dnet olb do tl bimp i In time ESRI will rewrite all objects in pure C The COM interop overhead will then be eliminated To demonstrate a simple COM object dogserver that appends a single line containing date and time to a text file was written in C and called with a C caller Afterwards a COM interop wrapper was created with tlbimp as demonstrated above and called from a C caller It was understandably slower because of the added overhead of the wrapper class created by tlbimp Next a pure C implementation cat server which also appends date and time to a text file saved as a callable C class in a DLL assembly was called from a C caller It turned out to be
10. A Comparative Analysis of Programming Languages for GIS Kurt Swendson Department of Resource Analysis Saint Mary s University of Minnesota Minneapolis MN 55404 Keywords GIS ArcMap ArcView ArcObjects C Python VB Script VBA Abstract Many GIS departments in organizations throughout the world have developed customized tools using an Environmental Systems Research Institute ESRI proprietary language named Avenue Avenue is reaching the end of its life cycle and will soon be unsupported ESRI has moved on to new versions of its software which is not backward compatible with Avenue This project explores the various options available to GIS professionals in order to bring their customized tools up to date using the latest software Introduction GIS professionals may rewrite their customized GIS applications written in Avenue using many different languages and methods Which of these is the best in terms of development speed execution speed maintainability and future scalability ability to upgrade Although the GIS sector is made up of highly skilled and trained professionals the subset of these people who also have computer programming skills is much smaller and thus more expensive Marble 2005 Careful planning and selection of a migration strategy is valuable in that it can save countless hours of research and development and additionally save future development hours for inevitable further upgrades and mi
11. Display Object Library ESRI DisplayU Object Library 5 ESRI Editor Object Library Figure 2 This figure shows an example of the Python Object Browser E Python Object Browser SMRouterFactory CoClass SMNetAttributesAccess CoClass SMFlagCreator CoClass B Filename C esri aregis com esriD ataS ourcesFile alb estiCFCTNode Enum Module estiCTTFuzzy Enum Module T TT iba Figure 3 A fully qualified file name shown in the Python Object Browser Some properties of some of the objects examined in the object browser presented error messages An application that uses the methods in the object shown in Figure 4 may not be able to do so using Python Perhaps the errors shown here are a problem with the object browser and not a shortcoming of the language specification O Python Object Browser C ESRI DataSourcesFile Object Library E ID 1CE6ACES 43F5 4529 8FC0 D7ED298E 4F14 Type Library B The type info can n The type info can not be loaded The type info can n The type info can not be loaded The type info can n The type info can not be loaded The type info can n The type info can not be loaded The type info can n The type info can not be loaded The type info can n The type info can not be loaded B The type info can n The type info can not be loaded l
12. GeoDatabase com s gen esriDataSourcesFile done getm do impor done import wkspfact inst obj done inst obj Check out spatial extension done check out add tool box done add tool box start dogserver done dogserver start shapefile C temp model gt Upon observing the gen folder all of the deleted py files were re generated along with many more The next experiment was to call a method that creates a typed return value and call a method from that returned object In short implement the following VB code in Python Dim pWsFact As WorkspaceFactory Set pWsFact CreateObj ect esriDataSourcesFile ShapefileWorkspaceFactory 1 Di m D As Workspace Set pws pWsFact OpenFromFile d bb 0 Step 1 was accomplished in previous experiments create an WorkspaceFactory The earlier example i env py did just CreateObj ect The next step is to call Queryl nterface onl Workspace Factory and getan Workspace and from that call the method OpenFromFile OpenFromFile is shown in Figure 5 in the object browser E Python Object Browser I IWorkspace Interface B IWorkspaceFactory Interface Provides access to members that create and open workspaces and supply Help reference in esriGeoDatabase chm E Open Function 20 2 Dispatch ID 1610678273 B Named Params fileName hWnd Workspace E Retum Type HRESULT E Argument String Flags 1 B Argument User Defined Flags 1 B Argu
13. ULT ExecuteSQL in BSTR sqlStmt After weeks of experimentation the integrity of the Python development environment began to decay When running pyt honwi n Windows Explorer and Notepad freeze and become unusable until pyt honwi n is exited Python documentation states CoUnl nitialize is not working correctly and experience confirms it About 30 seconds after the script completes execution Windows presents an error message Such behavior raised suspicion that critical Python system files were corrupt so Python was completely uninstalled and re installed It unfortunately still showed the same undesirable behavior after reinstalling Python It is entirely possible that the author s inexperience with Python caused some of the observed behavior but it is evident that many of the problems identified are still valid problems regardless of the experience of the developer Compiled VB and C Restated In the process of trying to use Python portions of the code were successfully written in compiled VB and C It is therefore possible to implement the code in the compiled languages This statement is important C can implement any functionality especially COM implementations Compiled VB code is syntactically identical to the VBA code written within ArcMap and therefore is equally able to implement the desired functionality There was no need to prove these two languages were viable by completely
14. age run on that physical computer 3 C physical C app default threading model run on physical computer 4 STA physical C app explicitly coded to use STA threading model run on physical computer 5 STA virtual C app explicitly coded to use STA threading model run on virtual image run on that physical computer 6 MTA physical C app explicitly coded to use MTA threading model run on physical computer 7 MTA virtual C app explicitly coded to use MTA threading model run on virtual image run on that physical computer The virtual system running on the HP dv5000 computer is Microsoft Virtual PC running Microsoft XP Professional using 660 MB RAM To prove the performance issues are not an anomaly of a single machine the same application was installed and run on other computers The next experimental machine was a newly built Dell Dimension 4400 with a Pentium 4 1 33 GHz with 750 MB RAM running Windows XP Professional The OS was installed from scratch ArcGIS 9 1 was installed and the application was copied to the computer and run This clean install removes any risk of system corruption from continued development installation HP dv5000 MTA virtual EEE 785 STA virtua a 649 Z VB virtua I 32 E MTA physical 787 266 ki STA physical 759 61 C physical 1 1009 109 VB physical ii 27 0 500 1000 1500 Seconds Figure 6 HP dv5000 experimental results
15. chosen language should be the deciding factor Microsoft has announced the transition of Visual Studio 6 VB C from full support to end of lifetime support Microsoft 2006 Microsoft is also strongly recommending that organizations migrate their code to the new languages that support INET ESRI and Microsoft both show examples of web services VB NET and C to leverage the latest languages Knowing this it is quite evident that programs written in the more recent languages such as Visual Basic 6 will soon need to be migrated to the newer NET compliant languages Therefore the strategic solution would be migration of Avenue directly to NET if possible and thus prevent another costly round of refactoring Some organizations convert their code in a reactionary way with little thought to consider the future This study has shown what languages are viable and provides evidence to help make a prudent choice regarding the future Applications needing quick response time may need to be written in VBA in the interim until ESRI completes its C rewrite of all ArcObjects Acknowledgments I would like to thank Tim Loesch of the Minnesota DNR and the Resource Analysis staff at Saint Mary s University of Minnesota for their help during this project References Environmental Systems Research Institute Inc 2004 ArcGIS Desktop Developer Guide 139 Online manual provided with install of ArcGIS 9 software Environme
16. e ArcView 3 3 tool worked by selecting a polygon in ArcView then processing was done on the selection The ArcMap tool was developed to start with a shapefile containing polygons The entire group of polygons served as the input for processing Therefore porting the tool to a command line program that accepts parameters such as shapefile name distance between points and output file name could easily be done From there the tool could be integrated into ArcToolbox and Model Builder Previous coursework at Saint Mary s University of Minnesota created a toolbox that contained examples of a command line script that received its parameters from ArcToolbox thus proving it can be done During the development of the VBA code there was difficulty with implementation of the relational operator function so an alternate plan was devised draw a blanket of points and hexagons larger than the target area and use the ArcToolbox tools to clip the points and hexagons that fell within the target area Discussions with the DNR resulted in some new ideas and example code using the relational operator eliminating the need to perform the clip operations The example code provided many interesting ideas but the code ended up not being used Eventually after experimentation inspired by the example code the relational operator became workable With the relational operator successfully implemented as each point or hexagon is generated t
17. e in All in all the development time of VBA and C were fairly equal Part of the development time was learning the ArcObjects object model The ArcObjects model is much larger and more complex than many developers encounter Execution Time After the languages VBA and C had been proven as viable languages their execution times were compared The first test was conducted on the original computer the applications were developed on an HP Pavilion dv5000 with an AMD Turion 64 bit 1 8 GHz with 1 GB RAM running 32 bit Windows XP Professional The VBA application performed acceptably taking less than a minute to create approximately 500 points and 200 hexagons over an area of 250 000 square miles In comparison the C application took 37 times longer to perform the exact same thing This prompted a careful analysis of the source code which revealed little room for improvement The only questionable code which followed the ESRI example of efficient creation of polygons did the following within a function that was called repeatedly once for each hexagon Point Point Point Point Point Point Point new Poin new Poin new Poin pPointsRi tClass tClass tClass new PointClass tClass tClass tClass ngo pPointsRingl pPointsRing2 pPointsRing3 ng4 new Poin ng5 new Poin ng6 new Poin pPointsR pPointsRi pPointsR ESRI code samples provided with the ArcGIS install were described
18. f ace to transform it into an Wor k SpaceFact ory Here is an example of the generated files E6AC65_43F5_ 4529 8FCO_D7ED298E4F1A 0_1_0 py txt 554 apefileWorkspaceFactory cominterfaces mt ypes gen 00020430 0000 0000 C000_ 000000000046 0 Unknown ypes gen 0475BDB1_E5B2_4CA2_9127_B4B1683E70C2_0_1 WorkspaceFactory ypes gen 0475BDB1_E5B2_4CA2_9127_B4B1683E70C2_0_1 WorkspaceFactory2 Within the generated files the section shown here defines the workspace factory ileWorkspaceFactory CoClass hapefile Workspace Factory id_ GUI D A06ADB96 D95C 11D1 AA81 1CE6AC65 43F5 4529 BFCO ry cominterfaces 0000 0000 c000_ 900000000046 0 es gen 0475BDB1_E5B2_4CA2_9127_B4B1683E70C2_0_1 ctory es gen 0475BDB1_E 5B2_4CA2_9127_B4B1683E70C2_0_1 rkspaceFactory2 Here is the final implementation in the Python code pWsFact comtypes client CreateObj ect esriDataSourcesFile ShapefileWorkspaceFactory WsFact Querylnterface comtypes Unknown face comtypes gen 0475BDB1_E 5B2_4CA2_912 spaceFactory int now open files p pws 02 OpenFromFile c temp model 0 print done open files It can be seen that 02 is of the proper interface type to call the OpenFromFile method This is the desired COM object Workspace methods COMMETHOD propget helpstring u The connection
19. grations when Environmental Systems Research Institute ESRI and or the rest of the computer industry moves to yet another software package There are countless computer languages and operating systems available in the market today but it is safe to assume the ESRI products will run on Microsoft Windows using programming languages available for this operating system Although ESRI does support Unix operating systems this study will focus on software running on a Microsoft platform The ESRI website shows the lifecycle chart for the various ArcView versions Product Lifecycle Support Policy n d All versions but the latest version ArcView 3 3 have been retired and ESRI no longer supports them ArcView 3 3 has been moved from general availability to extended support to mature support which is still supported but at a cost Product Lifecycle Support Policy ArcGIS 3 3 n d ESRI s new object oriented software running under ArcGIS 9 x is a COM based model named ArcObjects Swendson Kurt 2007 A Comparative Analysis of Programming Languages in GIS Volume 9 Papers in Resource Analysis 13 pp Saint Mary s University of Minnesota Central Services Press Winona MN Retrieved date from http www gis smumn edu Welcome to ArcObjects Online n d Therefore languages that support COM are the only valid languages to review Of those languages the following will be studied VBA Visual Basic for Applicat
20. he relational operator method asks Does it overlap the target area If it does the feature is saved otherwise it is ignored The actual implementation asked not disjoint which covered all true operations overlap within intersect etc With successful use of the relational operator function the random point function was obtainable draw random points until the exact desired number of points fall within the target area A brief outline of the original point hexagon tool is stated here 1 Get extent of the target area Get user input on how far apart to put the points 3 Adda small amount to the extent to make it bigger 4 Create blanket of points over adjusted extent 5 If hexagons are requested draw hexagons over adjusted extent 6 Call clip tools to clip points 7 Call clip tools to clip hexagons exactly by target area clipped hexagons 8 Call clip tools to do spatial join of hexagons to target area complete hexagons After implementing the relational operator the logic changed slightly 1 Create relational operator on target area 2 Get user input on how far apart to put the points 3 Create blanket of points over adjusted extent 4 If hexagons are requested draw hexagons over adjusted extent 5 If relational operator is not disjoint save feature The triangle points are the vertices of the hexagons Generating the points in this manner do not use the trigonometry functions
21. ions VB Script Python Script Microsoft Visual Basic Microsoft Visual C and C NET This study will choose an example ArcView tool written in Avenue the programming language used in ArcView and duplicate all or part of its functionality using all of the above technologies comparing and contrasting the different languages with regards to ease of development ease of use speed of execution reliability supportability and integration into ArcToolbox and Model Builder Methods Description of Original Tool With cooperation of the Minnesota DNR a sample Avenue application was provided It performs a number of useful GIS functions of varying complexity The tool as stated in the user manual The Sampling Tool was designed to assist biologists in using ArcView to generate spatially explicit random or systematic sampling schemes to support resource monitoring mapping and research needs The tool works either with polygons in a theme or with graphics that have been added to a view Samples can be entirely within a single polygon or shape or distributed among several disjoint polygons or shapes A number of user defined constraints and settings are offered as input options Minnesota DNR 2005 The requirements of this project were to select a sample of existing tools from the given ArcView 3 3 application implement the same functionality in different languages and test for speed reliability integration into ArcTo
22. ment Pointer Pointer User Defined Flags 10 B Function Kind Pure Virtual E Invoke Kind Function E Number Optional Params 0 E Create Function a ContainsWorkspace Function a REC GetWorkspaceName Function Figure 5 IWorkspaceFactory interface shown in the Python Object Browser The only successful way to determine the coclass that was used by OpenFromFi e was to run the compiled VB application i env exe while concurrently running r egmon It showed that the app looked up a coclass namedesri GeoDatabase AggregateDatasetEnuml mpl The above code sample which is the successful code instantiates Workspace Nowhere is AggregateDatasetEnuml mp shown A web search of that coclass name turned up only one example which did notdoaCreatelnstance of that coclass In addition the coclass is not documented anywhere in the ESRI website The definition of aggregation could be a possible explanation why this coclass is never used explicitly The only way the coclass was revealed was to write the target program in another language run r eg mon to see what COM objects it is using Only then could the correct COM object be identified and used in the Python code It seems excessive that such an effort is required to create an app in Python first create a test app in another language Next experiment After successful instantiation of pWsFact createobj shapefilework Spacefactory callQuerylnter
23. ntal Systems Research Institute Inc Product Lifecycle Support Policy ArcView GIS 3 3 Retrieved June 2006 from http downloads esri com support pro duct 20life 20cycle other_ S589arcvi ewgis pdf Environmental Systems Research Institute Inc Welcome to ArcObjects Online Retrieved June 2006 from http edndoc esri com arcobjects 8 3 d efault asp Hammond M and Robinson A 2000 Python Programming on Win32 O Reilly amp Associates Sebastopol CA Marble D F 2005 Defining the Components of the Geospatial Workforce Who Are We Arc News Vol 27 No 4 1 Microsoft Corporation Microsoft Support Lifecycle Retrieved June 2006 from http support microsoft com Nifecycle LN en us amp p 1 3003 amp x 15 amp y 10 Minnesota DNR 2005 DNR Sampling Tool V2 8 Nov 09 2005 Minnesota DNR Saint Paul MN
24. olbox and ease of use From these requirements the following course of action was chosen examine functionality of the existing ArcView 3 3 tool choose various functions from the tool to convert to VBA within ArcMap then duplicate the same functionality in the other languages The functions chosen from the tool were as follows 1 Random points Within a selected group of polygons generate n number of randomly spaced points 2 Systematic square points Within a selected group of polygons generate a matrix of points evenly spaced by n degrees 3 Systematic triangle points Within a selected group of polygons generate a matrix of points evenly spaced by n degrees Every other row of points offset by n 2 degrees resulting in points arranged in a triangular pattern 4 Tiled hexagons Within a selected group of polygons generate a tiling of hexagons having sides of n degrees long completely covering the area This was completed by first generating the triangle points and connecting the points in a hexagonal pattern The code for each tool could easily be changed to space the points by any unit of measure meters miles feet etc Implement the Tool in ArcMap Keeping in mind the original project parameters the true graphical user interface GUT oriented design of the original tool was unacceptable The original project parameters were to develop a tool that would work within ArcToolbox or Model Builder Th
25. roperties o he workspace HRESULT ConnectionProperties retva out OI NTER POINTER comt ypes gen 5E1F7BC3_67C5_4AEE_8EC6_ C4B73AAC42ED_0_1_0 1 PropertySet ConnectionProperties COMMETHOD propget elpstring u The factory hat created e workspace HRESULT WorkspaceFactory retval out OINTER POINTER WorkspaceFactory Factory COMMETHOD propget helpstring u The datasets in the workspace HRESULT Datasets in esriDatasetType DatasetType retval out OI NTER POINTER EnumDataset Datasets COMMETHOD propget helpstring u The DatasetNames in the workspace HRESULT DatasetNames in esriDatasetType DatasetType retval out OI NTER POINTE EnumDatasetName DatasetNames COMMETHOD propget helpstring u The file system ull pa of e workspace HRESULT PathName retval out POINTER BSTR PathName COMME THOD ropget helpstring u The Type of the Workspace ESULT Type retval out OINTER esriWorkspaceType Type COMMETHOD elpstring u TRUE if the workspace is a ile system directory HRESULT IsDirectory retval out OI NTER VARI ANT BOOL isDir COMME THOD elpstring u Checks if the workspace exists ESULT Exists retval out OINTER VARIANT BOOL Exists COMME D elpstring u Executes the specified SQL statement ES
26. shown in Figure 1 The resulting programs reported maximum and minimum X and Y coordinates of an input polygon shapefile They also proved using compiled VB and C the implementation is possible Having thus identified the COM objects required to implement some References ieny bp Visual Basic For Applications Visual Basic runtime objects and procedures Visual Basic objects and procedures OLE Automation ESRI Catalog Object Library ESRI Paloa il ject Library IAS Helper COM Component 1 0 Type Library IAS RADIUS Protocol 1 0 Type Library Active DS Type Library Active Setup Control Library ActiveMovie control type library ActiveReports PDF Export Filter a Figure 1 This figure shows the dependent ESRI libraries required to calculate the envelope of a polygon Screenshot taken from the Microsoft Visual Basic IDE functionality each of the ESRI libraries were run through mak epy to create the Python wrapper classes D arcgis python23 Li b site packages win32com client gt makepy py Generating to D arcgis python23 lib site packages win32com gen_py 2396BA16 B4C6 4051 86E7 B4667200E86FxX0x1x0 py D arcgis python23 Li b site packages win32com client gt makepy py Generating to D arcgis python23 lib site packages win32com gen_py ADC7DE29 DCOB 448E BBF6 27E4E34CF2ECxOx1x0 py
27. t w win32com client Dispatch Dogserver Dog w Bark The problem with mak epy classes is that they do not support early binding COM objects The discussion by Hammond and Robinson about early binding actually is an early binding class of a late binding method Another COM library comt ypes is available on the web It does true early binding of COM objects Comt ypes is dependent on another Python package named ct ypes Ct ypes works exclusively with Python 2 3 After installing Python 2 4 from python org which is the most current version the ct ypes install presented an error requiring version 2 3 of Python to be installed Perhaps when porting ct ypes from 2 3 to 2 4 it was declared problematic or a feature of questionable value and thus doing early binding COM with Python will only be an anomaly of 2 3 It could also be possible that the package is being written for 2 4 and not yet complete Perhaps the ctypes install is erroneously hard coded to version 2 3 and if the versioning were changed to versions 2 3 and later it would work for all qualified versions Proof of Concept Using VB and C Upon experiencing such trouble it was decided to prove the get extent call would work as a compiled VB and C program First make the i env example program that minimally does the Envel ope interface to determine the extent of a shapefile Specific details about i env will be discussed later Project references are
28. which require much more processing time Instead alternate rows of points are offset by half the distance between the points The resulting triangular array of points can be easily connected to create regular hexagons Implement the Tool in VB Script After successful implementation of the functionality in VBA the same code was attempted in VB Script VB Script has some drawbacks no early bound COM objects are allowed Di spat ch is the interface that allows discovery of interfaces and methods at runtime late bound objects All of the tools shown in ArcToolbox are late bound COM objects ESRI s ArcGIS Desktop Developer Guide Appendix A provides an unparalleled introduction to using COM and ArcObjects It states The object classes within the ESRI object libraries do not implement the Dispatch interface this means that these object libraries cannot be used with late binding scripting languages such as Java Script and VBScript since these languages require that all COM servers accessed support the Dispatch interface ESRI 2004 Developers can easily see all the methods available for an object by using IntelliSense in VB VBA If instantiating an object that uses GP Di spat ch and the control space keystrokes are keyed IntelliSense shows nothing This additionally supports experimental evidence where VBScript could not instantiate Envel ope to get extent In addition no examples could be found on the web
Download Pdf Manuals
Related Search
Related Contents
Samsung GT-E1252 Керівництво користувача 取扱説明書 Fernseher als EcoTopTen かんたんスタートガイド TOURING RALLYE RACING TECHNOLOGY Logging Into Cognos User Guide Acer 1520 Series Laptop User Manual MO-Iシリーズ 取扱説明書 ATTESTATION Fly dect - Esse-ti Copyright © All rights reserved.
Failed to retrieve file