Using A Spreadsheet For Surveying C
Using A Spreadsheet For Surveying C
Using A Spreadsheet For Surveying C
* AGH University of Science and Technology, Faculty of Mining Surveying and Environmental
Engineering, Department of Geomatics, Krakow
** The paper has been worked out within University research program no. 11.1.150.006
77
78 E. Jasiñska, J. Ruchel
As it can be seen, the name of the procedure contains the name of the object
and the event associated with it. It can also include certain parameters proper for
the type of objects and events involved. The headers of the procedures are auto-
matically generated by VBA.
Procedure is a very important component of the program, because for the code
to be executed it must be enclosed into a procedure. A procedure makes the smallest
part of the code which can be executed independently from other parts of the code.
Module contains one or more procedures and a declaration section in which
declarations common for all the procedures for the given module are placed.
Project consists of all the modules, forms and objects of the home application
of the document being created and the document itself.
VBA has a very complex (multi-window) and at the same time user friendly
interface, providing convenient ways of creating applications. The most important
windows are:
– Project Explorer window, containing all elements of the spreadsheet and of
the project.
– View Designer window, which allows to design the look of our form in the
graphical mode.
– Toolbox window, containing the list of available objects that can be used in
the projecting mode.
80 E. Jasiñska, J. Ruchel
– Properties window, displaying present values of all the properties for the
object active in the Project Explorer. In this window we can modify the
properties of the active object. If needed, the values can be changed also
from the code level in time of executing certain procedures.
– Code window, containing the procedures and declarations created for the
project.
Adding objects to a worksheet is done by placing them on the sheet with the
mouse cursor and defining their size and position with the mouse and the mecha-
nisms of the graphic environment of MS Windows. With the Properties window
we can determine values for the chosen object’s characteristics (Fig. 2).
Visual Basic for Applications is a user friendly programming language on ac-
count of the embedded error control feature. The errors occurring during writing
a program can be divided into several groups:
– Text editing errors – these can be avoided by a careful examination of what
has been written. These errors are not dangerous for the application.
– Errors occurring in time of compilation – making the compilation of the
program impossible – such as: syntax mismatches for declarations and in-
structions, or wrong identification of certain program elements.
Using a Spreadsheet for Surveying Computations 81
Tu wpisujemy
Here enter kod
the procedure’s code
procedury
Fig. 1. The program code window – an event procedure template (Excel 2003)
The illustration applied for this paper will be a computation of the classical
leveling net according to the adjustment algorithm by means of the least squares
method.
The basic formulas used in the program are listed below:
– Observation weights:
1
pi = 2 .
mi
p – starting point,
k – ending point,
Di – observation measured,
wi – distance correction,
Dapprox. = Dx 2 + Dy 2 – approximated distance
Ap–k – azimuth for the side measured
dxp, dxk, dyp, dyk – partial coordinates;
• for angular observations:
ái – observation measured,
vi – angle correction,
a 0i – approximated angle,
Al, Bl, Ap, Bp – gradients respectively for the left and right
arm of the angle:
Dx Dy
A= × r, B= × r,
Dx + Dy 2
2
Dx + Dy 2
2
V = A× x + w.
( AT × p× A) × X + ( AT × p× w ) = 0,
-x = ( AT × p× A) -1 × ( AT × p× w ).
Xi = Xi0 + dx i ,
Yi = Yi 0 + dy i .
[ pvv]
m0 = ± , cov( x) = m02 × ( AT × p× A) -1 .
n-u
The program code enables to display the results on the monitor in the desired
form and to save them into files (e.g. text files).
Exemplary windows from the application thus created (Figs 3–6).
Fig. 3. The start window of the finished application designed for adjusting the classical
leveling net – it requires entering data and running by pressing the WYRÓWNAJ (‘adjust’)
button
Using a Spreadsheet for Surveying Computations 85
Fig. 6. The result window with results of the leveling net adjustment computations
4. Summary
Choosing the Visual Basic for Applications to create an application provides
many advantages. The project can be expanded (new features added) with no lim-
itations. It provides access to the indirect results and gives possibility to display
the results in any desired form. We bear no additional costs – assuming we own
the MS Office application packet. An element of a very high importance here is
a proper decimal separator character (for a given Windows installation). Visual
Basic for Applications (and Visual Basic) requires the “.” (dot) as a decimal separa-
tor. In the Windows systems changing the decimal separator can be made through
the Control Panel (regional settings or international settings – depending on a sys-
tem version).
The text files created during the computations are very useful as they are easy
to view and edit. They can also be employed in other programs. In particular, the
cooperation with AutoCad becomes convenient and easy, as the program also has
the implementation of VBA language embedded.
References
[1] Czaja J.: Modele statystyczne w informacji o terenie. Wydawnictwa AGH,
Kraków 1996.
[2] Hausbrandt S.: Rachunek wyrównawczy i obliczenia geodezyjne. Vol. 1 and 2.
PPWK, Warszawa 1971.
Using a Spreadsheet for Surveying Computations 87