I am unnable to translate this into a visualbasic net type as net do not accept string *8,for example, inside the structure
This was a nice type of data and now I need help to use it.
10-02-2005, 05:21 AM
Phil Weber
Why do you need String * 8? If it's because you're reading records from/writing to a file, you can do this:
Public Structure header_mia
<VBFixedString(8)>Public eti1 As String
' ...
This is the reason why
"I need a subrutine to translate wgs84 geographic coordinates to UTM in the ED50 elipsoide (as the CAD files they give to me comes with these coordinates). I college gave me this subrutine for vb6 and as I an upgrading from vb6 to visual studio 2005 this is the reason why I do not find all the information I need at the moment I need. On the other hand I have a big confidence with people like you in the forums. Kind regards."
Here is the full subrutine and I still need to learn how to read from a binary file and the get that is not acepted.
Is is to much is a beg you to teach us how to cope with this?. I am sure many people would appreciate it.
"
Public S_LAT As Double
Public N_LAT As Double
Public E_LONG As Double
Public W_LONG As Double
Public LAT_INC As Double
Public LONG_INC As Double
Public GS_COUNT As Long
Public cabeceras() As String
Public NUM_OREC As Long
Public NUM_SREC As Long
Public NUM_FILE As Long
Public GS_TYPE As String
Public VERSION As String
Public SYSTEM_F As String
Public SYSTEM_T As String
Public MAJOR_F As Double
Public MINOR_F As Double
Public MAJOR_T As Double
Public MINOR_T As Double
Public nombre As String
Public Const nrejs As Long = 150
Public Type nodo
ilat As Single
ilon As Single
plat As Single
plon As Single
End Type
Public Type header_mia
eti1 As String * 8
NUM_OREC As Long
padding1 As Long
eti2 As String * 8
NUM_SREC As Long
padding2 As Long
eti3 As String * 8
NUM_FILE As Long
padding3 As Long
eti4 As String * 8
GS_TYPE As String * 8
eti5 As String * 8
VERSION As String * 8
eti6 As String * 8
SYSTEM_F As String * 8
eti7 As String * 8
SYSTEM_T As String * 8
eti8 As String * 8
MAJOR_F As Double
eti9 As String * 8
MINOR_F As Double
eti10 As String * 8
MAJOR_T As Double
eti11 As String * 8
MINOR_T As Double
End Type
Public Type sub_grid
eti1 As String * 8
SUB_NAME As String * 8
eti2 As String * 8
PARENT As String * 8
eti3 As String * 8
CREATED As String * 8
eti4 As String * 8
UPDATED As String * 8
eti5 As String * 8
S_LAT As Double
eti6 As String * 8
N_LAT As Double
eti7 As String * 8
E_LONG As Double
eti8 As String * 8
W_LONG As Double
eti9 As String * 8
LAT_INC As Double
eti10 As String * 8
LONG_INC As Double
eti11 As String * 8
GSCOUNT As Long
padding As Long
End Type
Sub et2ed(ByVal lon As Double, ByVal lat As Double, lonf As Double, latf As Double)
Dim lone0 As Double, late0 As Double, lonw0 As Double, latw0 As Double
Dim latw As Double, lonw As Double
Dim x As Double, y As Double, nh As Integer
lone0 = lon
lonw0 = lon
late0 = lat
latw0 = lat
For f = 1 To 15
Call gsbread(lone0, late0, lonw, latw)
If latw <> 0 Then
inclat = lone0 - lonw
inclon = late0 - latw
If f = 1 Then
lone0 = lonw0 + inclon
late0 = latw0 + inclat
Else
lone0 = lone0 - (lonw - lonw0)
late0 = late0 - (latw - latw0)
End If
Else
late0 = 0: lone0 = 0
Exit For
End If
Next f
latf = late0
lonf = lone0
End Sub
Sub gsbread(ByVal lon As Double, ByVal lat As Double, lonf As Double, latf As Double)
Dim i(nrejs) As Long
Dim j(nrejs) As Long
Dim M(nrejs) As Long
Dim n(nrejs) As Long
Dim p(4) As Long
Dim posicion(nrejs) As Long
Dim punto(4) As nodo
Dim cabecera As header_mia
Dim ggrid(nrejs) As sub_grid
msel = 1000000
lon = -lon 'POSITIVE WEST
Open nombre For Binary As #1
Get #1, , cabecera
'Selección de la grid adecuada
For f = 1 To cabecera.NUM_FILE
Get #1, , ggrid(f)
posicion(f) = Seek(1)
Seek #1, ggrid(f).GSCOUNT * 16 + posicion(f)
If i(f) > 0 And j(f) > 0 And i(f) < M(f) And j(f) < n(f) Then 'Rejilla v´alida
If ggrid(f).LAT_INC < msel Then
msel = ggrid(f).LAT_INC
sel = f
End If
End If
Next f
If sel <> 0 Then 'Ha sido seleccionada alguna rejilla
p(1) = n(sel) * (i(sel) - 1) + j(sel)
p(2) = p(1) + 1
p(3) = p(1) + n(sel)
p(4) = p(3) + 1
For ij = 1 To 4 'Lectura de los nodos
Seek #1, posicion(sel) + (p(ij) - 1) * 16
Get #1, , punto(ij)
Next ij
lata = ggrid(sel).S_LAT + (i(sel) - 1) * ggrid(sel).LAT_INC
lona = ggrid(sel).E_LONG + (j(sel) - 1) * ggrid(sel).LONG_INC
y = (lat - lata) / ggrid(sel).LAT_INC
x = (lon - lona) / ggrid(sel).LONG_INC
'COEFICIENTES
a0 = punto(1).ilat
a1 = punto(2).ilat - punto(1).ilat
a2 = punto(3).ilat - punto(1).ilat
a3 = punto(1).ilat + punto(4).ilat - punto(2).ilat - punto(3).ilat
ip = a0 + a1 * x + a2 * y + a3 * x * y
latf = lat + ip