Imports SharpMap.Geometries
Imports SharpMap.Forms
Imports BruTile.Web
Imports BruTile
Imports SharpMap.Layers
Imports RBX.Decode
Imports RBX.Decode.hgs
Imports System.IO
Imports SharpMap.Data.Providers
Public Class Form1
Dim map As SharpMap.Map
Dim vec As SharpMap.Layers.VectorLayer
Dim cc As New List(Of SharpMap.Geometries.Geometry)
Dim vec_ds As GeometryProvider
Dim wgs_def As String = "GEOGCS[""WGS 84"",DATUM[""WGS_1984"",SPHEROID[""WGS 84"",6378137,298.257223563,AUTHORITY[""EPSG"",""7030""]],AUTHORITY[""EPSG"",""6326""]],PRIMEM[""Greenwich"",0,AUTHORITY[""EPSG"",""8901""]],UNIT[""degree"",0.01745329251994328,AUTHORITY[""EPSG"",""9122""]],AUTHORITY[""EPSG"",""4326""]]"
Dim crs_def As String = "PROJCS[""Popular Visualisation CRS / Mercator"", GEOGCS[""Popular Visualisation CRS"", DATUM[""Popular Visualisation Datum"", SPHEROID[""Popular Visualisation Sphere"", 6378137, 0, AUTHORITY[""EPSG"",""7059""]], TOWGS84[0, 0, 0, 0, 0, 0, 0], AUTHORITY[""EPSG"",""6055""]],PRIMEM[""Greenwich"", 0, AUTHORITY[""EPSG"", ""8901""]], UNIT[""degree"", 0.0174532925199433, AUTHORITY[""EPSG"", ""9102""]], AXIS[""E"", EAST], AXIS[""N"", NORTH], AUTHORITY[""EPSG"",""4055""]], PROJECTION[""Mercator""], PARAMETER[""False_Easting"", 0], PARAMETER[""False_Northing"", 0], PARAMETER[""Central_Meridian"", 0], PARAMETER[""Latitude_of_origin"", 0], UNIT[""metre"", 1, AUTHORITY[""EPSG"", ""9001""]], AXIS[""East"", EAST], AXIS[""North"", NORTH], AUTHORITY[""EPSG"",""3785""]]"
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
map = mb.Map
'map.MinimumZoom = 100
map.BackColor = Color.White
Dim tilLayer As TileLayer
'tilLayer = New TileLayer(New OsmTileSource(), "TLayerOSM")
Dim ts = New GoogleTileSource(GoogleMapType.GoogleMap)
tilLayer = New TileLayer(ts, "TLayerGMap")
map.Layers.Add(tilLayer)
mb.ActiveTool = MapBox.Tools.Pan
'Dim csf As New ProjNet.CoordinateSystems.CoordinateSystemFactory()
'Dim wgc = ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84 ' csf.CreateFromWkt(wgs_def)
'Dim crc = csf.CreateFromWkt(crs_def)
'Dim ctf = New ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory()
'Dim ctrans = ctf.CreateFromCoordinateSystems(wgc, crc)
vec = New VectorLayer("Coords")
vec_ds = New SharpMap.Data.Providers.GeometryProvider(cc)
'vec.CoordinateTransformation = ctrans
vec.DataSource = vec_ds
map.Center = New SharpMap.Geometries.Point(4700000, 1500000)
map.Zoom = 1000000
map.Layers.Add(vec)
Label1.AllowDrop = True
mb.Refresh()
End Sub
Private Sub Label1_Click(sender As System.Object, e As System.EventArgs) Handles Label1.Click
End Sub
Private Sub Label1_DragDrop(sender As Object, e As System.Windows.Forms.DragEventArgs) Handles Label1.DragDrop
If (e.Data.GetDataPresent(DataFormats.FileDrop)) Then
For Each f As String In e.Data.GetData(DataFormats.FileDrop)
If File.Exists(f) Then
decodeData(f)
End If
Next
End If
End Sub
Sub decodeData(fn As String)
Dim dec As Decoder
If fn.ToLower.EndsWith(".in") Then
' sms
dec = New SMSDecoder
ElseIf fn.ToLower.EndsWith(".bin") Then
' GPRS
dec = New GPRSDecoder
Else
dec = Nothing
End If
If Not dec Is Nothing Then
Dim coords As RecivedCoords = dec.Decode(fn)
plotcoords(coords)
End If
End Sub
Sub plotcoords(coords As RecivedCoords)
For Each c As RecivedCoord In coords
Dim pt As New SharpMap.Geometries.Point(c.Lat * 100000, c.Longitude * 100000)
'pt.SpatialReference =
cc.Add(pt)
Next
map.ZoomToBox(vec.Envelope)
mb.Refresh()
End Sub
Private Sub Label1_DragEnter(sender As Object, e As System.Windows.Forms.DragEventArgs) Handles Label1.DragEnter
If (e.Data.GetDataPresent(DataFormats.FileDrop)) Then
e.Effect = DragDropEffects.Copy
End If
End Sub
Private Sub mb_MapCenterChanged(center As SharpMap.Geometries.Point) Handles mb.MapCenterChanged
Debug.WriteLine("C " & center.X & "-" & center.Y & " Z:" & mb.Map.Zoom)
End Sub
Private Sub mb_MouseDown(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles mb.MouseDown
Dim p As SharpMap.Geometries.Point = mb.Map.ImageToWorld(New System.Drawing.Point(e.X, e.Y))
Dim p2 As SharpMap.Geometries.Point = SharpMap.Geometries.Point.FromDMS(47, 1, 0, 15, 0, 0)
Debug.WriteLine(p.X & "-" & p.Y)
End Sub
Private Sub mb_Click(sender As System.Object, e As System.EventArgs) Handles mb.Click
End Sub
Private Sub Form1_Resize(sender As Object, e As System.EventArgs) Handles Me.Resize
mb.Refresh()
End Sub
Private Sub mb_RegionChanged(sender As Object, e As System.EventArgs) Handles mb.RegionChanged
End Sub
End Class