Skip to content

Commit

Permalink
JSON
Browse files Browse the repository at this point in the history
JSON file
  • Loading branch information
christophev-git committed Mar 5, 2024
1 parent 59b404d commit 56664c9
Show file tree
Hide file tree
Showing 5 changed files with 335 additions and 0 deletions.
47 changes: 47 additions & 0 deletions Form1.Designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions Form1.vb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Public Class Form1
Private m_classif As Integer = -1
Private m_nomclassif As String = ""
Public ListeDalle As System.Collections.Generic.List(Of dalle_lidar)
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim workpath As String = ""
Expand Down Expand Up @@ -58,4 +60,29 @@

MsgBox("Téléchargement terminé", vbApplicationModal, vbInformation)
End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
For Each s As String In [Enum].GetNames(GetType(Classification_LIDAR))
ListBox1.Items.Add(s)
Next
End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
If TBtaille.Text = "" Then Exit Sub
If ListBox1.SelectedIndex < 0 Then Exit Sub
If ListeDalle Is Nothing Then Exit Sub
If ListeDalle.Count = 0 Then Exit Sub

m_nomclassif = ListBox1.SelectedItem
m_classif = ListBox1.SelectedIndex
m_classif = [Enum].GetValues(GetType(Classification_LIDAR))(ListBox1.SelectedIndex)
For Each d As dalle_lidar In ListeDalle

Dim p1 As New PipeLine(d, m_nomclassif, TBtaille.Text, m_classif)
p1.CreatePipeLine()

Next

MsgBox("Traitement JSON terminé", vbExclamation)
End Sub
End Class
3 changes: 3 additions & 0 deletions LIDAR.vbproj.user
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@
<Compile Update="Form1.vb">
<SubType>Form</SubType>
</Compile>
<Compile Update="lidar\Form1.vb">
<SubType>Form</SubType>
</Compile>
</ItemGroup>
</Project>
78 changes: 78 additions & 0 deletions PipeLine.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
Imports System.ComponentModel

Public Class PipeLine
Private m_DalleLidar As dalle_lidar
Public ReadOnly Property DalleLidar() As dalle_lidar
Get
Return m_DalleLidar
End Get

End Property


Private m_OutNameFile As String
Public Property OutNameFile() As String
Get
Return m_OutNameFile
End Get
Set(ByVal value As String)
m_OutNameFile = value
End Set
End Property

Private m_taillegrille As Double
Public Property TailleGrille() As Double
Get
Return m_taillegrille
End Get
Set(ByVal value As Double)
m_taillegrille = value
End Set
End Property
Private m_classification As Integer
Public Property Classification() As Integer
Get
Return m_classification
End Get
Set(ByVal value As Integer)
m_classification = value
End Set
End Property

Private m_prefixe As String
Public ReadOnly Property Prefixe() As String
Get
Return m_prefixe
End Get

End Property
Public Sub CreatePipeLine()
Using F As New System.IO.StreamWriter(m_DalleLidar.WorkPath & "\" & m_prefixe & "_" & m_DalleLidar.Radicale & ".json")
F.WriteLine("{")
F.WriteLine(Chr(34) & "pipeline" & Chr(34) & ": [")
F.WriteLine(Chr(34) & m_DalleLidar.JsonName & Chr(34) & ",")
F.WriteLine("{")
F.WriteLine(Chr(34) & "type" & Chr(34) & ": " & Chr(34) & "filters.range" & Chr(34) & ",")
F.WriteLine(Chr(34) & "limits" & Chr(34) & ": " & Chr(34) & "Classification[" & m_classification & ":" & m_classification & "]" & Chr(34))
F.WriteLine("},")
F.WriteLine("{")
F.WriteLine(Chr(34) & "filename" & Chr(34) & ": " & Chr(34) & m_OutNameFile & Chr(34) & ",")
F.WriteLine(Chr(34) & "gdaldriver" & Chr(34) & ": " & Chr(34) & "GTiff" & Chr(34) & ",")
F.WriteLine(Chr(34) & "output_type" & Chr(34) & ": " & Chr(34) & "all" & Chr(34) & ",")
F.WriteLine(Chr(34) & "resolution" & Chr(34) & ": " & Chr(34) & m_taillegrille & Chr(34) & ",")
F.WriteLine(Chr(34) & "type" & Chr(34) & ": " & Chr(34) & "writers.gdal" & Chr(34))
F.WriteLine("}")
F.WriteLine("]")
F.WriteLine("}")

End Using
End Sub

Public Sub New(dalle_lid As dalle_lidar, prefixe As String, taille As Double, classif As Integer)
m_DalleLidar = dalle_lid
m_taillegrille = taille
m_classification = classif
m_OutNameFile = Get_JsonFilename(dalle_lid.WorkPath) & "\\" & prefixe & "_" & dalle_lid.Radicale & ".tif"
m_prefixe = prefixe
End Sub
End Class
180 changes: 180 additions & 0 deletions VariableGlobale.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
Option Explicit On
Imports System.Security.Policy
Imports Girtec.Geo

Module VariableGlobale


Private Structure STARTUPINFO
Dim cb As Long
Dim lpReserved As String
Dim lpDesktop As String
Dim lpTitle As String
Dim dwX As Long
Dim dwY As Long
Dim dwXSize As Long
Dim dwYSize As Long
Dim dwXCountChars As Long
Dim dwYCountChars As Long
Dim dwFillAttribute As Long
Dim dwFlags As Long
Dim wShowWindow As Integer
Dim cbReserved2 As Integer
Dim lpReserved2 As Long
Dim hStdInput As Long
Dim hStdOutput As Long
Dim hStdError As Long
End Structure

Private Structure PROCESS_INFORMATION
Dim hProcess As Long
Dim hThread As Long
Dim dwProcessID As Long
Dim dwThreadID As Long
End Structure

Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal _
hHandle As Long, ByVal dwMilliseconds As Long) As Long

Private Declare Function CreateProcessA Lib "kernel32" (ByVal _
lpApplicationName As Long, ByVal lpCommandLine As String, ByVal _
lpProcessAttributes As Long, ByVal lpThreadAttributes As Long,
ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long,
ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As Long,
lpStartupInfo As STARTUPINFO, lpProcessInformation As _
PROCESS_INFORMATION) As Long

Private Declare Function CloseHandle Lib "kernel32" (ByVal _
hObject As Long) As Long

Private Const NORMAL_PRIORITY_CLASS = &H20&
Private Const INFINITE = -1&
' Public mFint As FormIntegration
Public typeintegration As Integer = -1
Public verrou_candidat As New Object
Public verrou_tampon As New Object
Public verrou_parcelle As New Object
Public arret_recherche As Boolean = False
Public finedigeo As Boolean = False


Public SRID As Integer = 2154
Public UserSchemaName As String

Public RayonSelection As Double = 2
Public cheminhypo As String = "\\Serveur-ad\ftp\BIA\"
Public SchemaNameA2iA As String = "a2ia"
Public millesime As String = "2023"



Public TopoName As String = "topo2023"
Public TopoGenName As String = "topogen2023"
Public TopoComName As String = "topocommune2023"

Public ListeDalle As System.Collections.Generic.List(Of dalle_lidar)




Public Function Get_JsonFilename(pathAndnamefile As String) As String

Return pathAndnamefile.Replace("\", "\\")

End Function




Public Function ColorTranslation(ByVal coloint As Integer) As Color
If Math.Sign(coloint) = -1 Then
Return Color.FromArgb(coloint)
Else
Dim A, R, G, B As Integer
Dim stcolor As String = System.Convert.ToString(coloint, 16)
stcolor = stcolor.PadLeft(6, "0"c)
A = 255
B = System.Convert.ToInt32(stcolor.Substring(0, 2), 16)
G = System.Convert.ToInt32(stcolor.Substring(2, 2), 16)
R = System.Convert.ToInt32(stcolor.Substring(4, 2), 16)
Return System.Drawing.Color.FromArgb(A, R, G, B)
End If
End Function








Function GetUserName() As String
If TypeOf My.User.CurrentPrincipal Is
Security.Principal.WindowsPrincipal Then
' The application is using Windows authentication.
' The name format is DOMAIN\USERNAME.
Dim parts() As String = Split(My.User.Name, "\")
Dim username As String = parts(1).ToLower()
Return username
Else
' The application is using custom authentication.
Return My.User.Name
End If
End Function








Private _debugsw As New IO.StreamWriter(Date.Now().ToShortDateString().Replace("/", "-") & "_" & Date.Now().ToShortTimeString().Replace(":", "-") & ".log") With {
.AutoFlush = True
}
Private _debuglock As New Object()
Friend Sub Debug(v As String)
SyncLock _debuglock
_debugsw.WriteLine(v)
End SyncLock
End Sub


Public Sub ExecCmd(cmdline As String)
Dim proc As PROCESS_INFORMATION
Dim start As STARTUPINFO
Dim ReturnValue As Integer

' Initialize the STARTUPINFO structure:
start.cb = Len(start)

' Start the shelled application:
ReturnValue = CreateProcessA(0&, cmdline$, 0&, 0&, 1&,
NORMAL_PRIORITY_CLASS, 0&, 0&, start, proc)

' Wait for the shelled application to finish:
Do
ReturnValue = WaitForSingleObject(proc.hProcess, 0)
My.Application.DoEvents()
Loop Until ReturnValue <> 258

ReturnValue = CloseHandle(proc.hProcess)
End Sub

Public Enum Classification_LIDAR
Non_Classe = 1
Sol = 2
Veg_b = 3
Veg_m = 4
Veg_h = 5
Bati = 6
Eau = 9
Pont = 17
Sursol = 64
Artefact = 65
Pv = 66
Divers = 67
End Enum


End Module

0 comments on commit 56664c9

Please sign in to comment.