You are on page 1of 3

'Title: GISC9304 Deliverable2

'Author: Neela Bariya


'Date:12 November 2018
'Purpose: To calculate the scale of an Aerial Photo

Public Class AirScaleCalc


Private Sub AirPhotoScaleCalculator_Load(sender As Object, e As EventArgs) Handles
MyBase.Load

End Sub

Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles


btnCalculate.Click
'Declaration

Dim strFocalLength As String


Dim decFocalLength As Decimal
Dim strFlyingHeight As String
Dim decFlyingHeighth As Decimal
Dim strPointElevation As String
Dim decPointElevationh As Decimal
Dim intScale As Integer
Dim strscale As String

'get user input and store it in string variables


strFocalLength = txtFocalLength.Text
strFlyingHeight = txtFlyingHeight.Text
strPointElevation = txtPointElevation.Text

'convert string to decimal variables


If IsNumeric(strFocalLength) Then
decFocalLength = Convert.ToDecimal(strFocalLength)
If decFocalLength >= 0.1 And decFocalLength <= 99.9 Then
'Focal Length should be between these values.
Else
'incorrect data
MessageBox.Show("Please enter Focal length between 0.1 to 99.9")
txtFocalLength.Text = ""
txtFocalLength.Focus()
Exit Sub
End If
Else
MessageBox.Show("Please enter numbers")
txtFocalLength.Text = ""
txtFocalLength.Focus()
Exit Sub
End If

'convert string to decimal variables


If IsNumeric(strFlyingHeight) Then
decFlyingHeighth = Convert.ToDecimal(strFlyingHeight)
If decFlyingHeighth >= 1 And decFlyingHeighth <= 1000000 Then
'good data
Else
'bad data
MessageBox.Show("Please enter Flying Height between 0.1 to 99.9")
txtFlyingHeight.Text = ""
txtFlyingHeight.Focus()
Exit Sub
End If
Else
MessageBox.Show("Please enter numbers")
txtFlyingHeight.Text = ""
txtFlyingHeight.Focus()
Exit Sub
End If

'Convert String to decimal variables


If IsNumeric(strPointElevation) Then
decPointElevationh = Convert.ToDecimal(strPointElevation)
If decPointElevationh >= -413.0 And decPointElevationh <= 9000.0 Then
'good data
Else
'bad data
MessageBox.Show("Please enter Point Elevation between -413 to 9000.00")
txtPointElevation.Text = ""
txtPointElevation.Focus()
Exit Sub
End If
Else
MessageBox.Show("Please enter numbers")
txtPointElevation.Text = ""
txtPointElevation.Focus()
Exit Sub
End If

'(Flying height - Point Elevation) cannot be less than or equal to zero


'Flying Height should be higher than Point Elevation.
If (decFlyingHeighth > decPointElevationh) Then
'do nothing
Else
MessageBox.Show("Please reverify value of Flying Height and Point Elevation.
Point Elevation cannot be higher than Flying Height")
End If

'To calculate the scale of an aerial image : S = f/ (H-e)


'Where S = Scale of an aerial image
' f = Focal length of camera (in centimetre)
' H = Flying Height of camera (in metre)
' e = elevation of a selected point (in metre)

intScale = Convert.ToDecimal(1 / ((decFocalLength / 100) / (decFlyingHeighth -


decPointElevationh)))

' to represent the scale in Ratio Scale


txtCalculateScale.Text = "1:" & intScale.ToString("###,###,###")

End Sub

Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click


' This event handler is executed when the user clciks the clear button.
' It clears all the input data.
' Then, it sets the foucs on Point Elevation text box.
txtFocalLength.Clear()
txtFlyingHeight.Clear()
txtPointElevation.Clear()
txtCalculateScale.Text = ""
txtPointElevation.Focus()

End Sub

Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles


PictureBox1.Click
'It makes the Picturebox Visible.
End Sub

Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click


' This event handler is executed when the user clciks the Exit button.
' It terminates the application
Me.Close()
End Sub

End Class

You might also like