[Portugal] VB.net and mapwindowgis

pedro soares pedro_gara yahoo.com.br
Terça-Feira, 6 de Dezembro de 2011 - 11:46:25 EST


Oi preciso mesmo de uma ajudinha (Grande)

eu não sou programador! dou uns pontapés em VB e python, no entanto nada de especial, dado que muitas vezes perco mto tempo a tentar arranjar soluções.

e é isso que venho pedir

estou com um problema!! estou a tentar uma aplicação simples que seja possivel adicionar ao mapa e à legenda uma layer, que consiga ver a sua tabela de atributos,que consiga alterar a sua visiblidade\invisibilidade e finalmente que possa fazer uma query e/ou calculation +-*/etc com duas ou mais layers.
na realidade consigo adicionar uma layer ao mapa e à legenda (mas não tenho bem a certeza que estejam interligados). assim que tento utilizar a visibilidade/invisibilidade faz as coisas ao contrário (quando a check box está "check" o layer não se vê no mapa, quando está uncheck o layer ve-ze no mapa)grrrrr.
e finalmente qnd tiver isto resolvido gostaria de poder criar o tal calculation.
Este é o meu codigo: 
alguem me diga onde está errado e como corrigi-lo (será pelo amarelo...?)

Public Class Form1

    Private shapefile As New MapWinGIS.Shapefile
    Private Grid As New MapWinGIS.Grid
    Private GridHeader As New MapWinGIS.GridHeader



    Private Sub AxMap1_MouseDownEvent(ByVal sender As System.Object, ByVal e As AxMapWinGIS._DMapEvents_MouseDownEvent) Handles AxMap1.MouseDownEvent

    End Sub

  


    Private Sub btnZoomout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnZoomout.Click
        'Zoom out
        AxMap1.CursorMode = MapWinGIS.tkCursorMode.cmZoomOut
    End Sub

    Private Sub pan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Pan.Click
        'Pan
        AxMap1.CursorMode = MapWinGIS.tkCursorMode.cmPan
    End Sub

    Private Sub btnZoomin_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnZoomin.Click
        'Zoom in
        AxMap1.CursorMode = MapWinGIS.tkCursorMode.cmZoomIn
    End Sub

    Private Sub btnZoomextent_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnZoomextent.Click
        'Zoom to full extent
        AxMap1.ZoomToMaxExtents()
    End Sub

    Private Sub OpenfileToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenVectorToolStripMenuItem.Click
        Dim openFD As New OpenFileDialog
        Dim hndl As Integer
        'initialize dialog
        If OpenFileDialogSHP.ShowDialog(Me) = DialogResult.OK Then

            If openFD.CheckFileExists Then

                'open the shapefile
                shapefile.Open(OpenFileDialogSHP.FileName)
                'add the layer to the map
                AxMap1.AddLayer(shapefile, True)
            End If


            If (Not CheckedListBox1.Items.Contains(OpenFileDialogSHP.FileName)) Then
                CheckedListBox1.Items.Add(OpenFileDialogSHP.FileName)
                CheckedListBox1.SetItemChecked(hndl, True)
            End If
        End If

    End Sub

    Private Sub ZoomToLayer()

    End Sub

    Private Sub btnZoomtolayer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnZoomtolayer.Click
        Dim hndl As Integer
        'Get handle for layer at position 0 in map
        hndl = AxMap1.get_LayerHandle(0)
        'Zoom to the layer at position 0 in the map
        AxMap1.ZoomToLayer(hndl)
    End Sub

    Private Sub OpenRasterToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenRasterToolStripMenuItem.Click
        Dim grid As New MapWinGIS.Grid()
        Dim openFD As New OpenFileDialog
        Dim dresult As Windows.Forms.DialogResult
        'Filters allow only shapefiles and raster files to show when Open window appears
        openFD.Filter = grid.CdlgFilter
        dresult = openFD.ShowDialog()
        'open the dialog
        If OpenFileDialogGRID.ShowDialog(Me) = DialogResult.OK Then
            'open the grid
            grid.Open("")
            'Close the grid
            grid.Close()
        End If

    End Sub

    Private Sub btnselect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnselect.Click
        'select tool
        AxMap1.CursorMode = MapWinGIS.tkCursorMode.cmSelection
    End Sub


    Private Sub btnShowDataGrid_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShowDataGrid.Click
        Dim sfWorld As New MapWinGIS.Shapefile
        Dim hndsfWorld As Integer = AxMap1.NumLayers - 1 ' this is the handle of the layer you want to work with
        ' get the shapefile object from the layer handle,
        ' it would be better to pass the handle instead of the shapefile
        sfWorld = AxMap1.get_GetObject(hndsfWorld)

        Dim myTableForm As New Formtable(sfWorld)
        myTableForm.ShowDialog()
    End Sub


   Private Sub CheckedListBox1_ItemCheck(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ItemCheckEventArgs) Handles CheckedListBox1.ItemCheck
        Dim hndl As Integer 
        'Get the layer handle for the layer at position 0 
        hndl = AxMap1.get_LayerHandle(0)
        'Set the specified layer is visible or not based on the state of the Check Box Item 
        AxMap1.set_LayerVisible(hndl, CheckedListBox1.GetItemChecked(0))
    End Sub

End Class



para a janela de atributos é o seguinte:

Public Class Formtable
    Dim pMyShapeFile As New MapWinGIS.Shapefile()
    Public Sub New(ByVal myShapeFile As MapWinGIS.Shapefile)
        InitializeComponent()
        pMyShapeFile = myShapeFile
    End Sub
    Private Sub FormTable_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim myDataTable As New DataTable
        Dim myDataRow As DataRow
        For i As Integer = 0 To pMyShapeFile.NumFields - 1
            myDataTable.Columns.Add(pMyShapeFile.Field(i).Name)
        Next i

        For j As Integer = 0 To pMyShapeFile.NumShapes - 1
            myDataRow = myDataTable.NewRow
            For k As Integer = 0 To pMyShapeFile.NumFields - 1
                myDataRow(k) = pMyShapeFile.CellValue(k, j)
            Next k
            myDataTable.Rows.Add(myDataRow)
        Next j
        DataGridView1.DataSource = myDataTable
    End Sub

End Class
-------------- próxima parte ----------
Um anexo em HTML foi limpo...
URL: http://lists.osgeo.org/pipermail/portugal/attachments/20111206/c5adadb4/attachment-0001.html


Mais informações acerca da lista Portugal