Creating a line polygon but it creats double lines

Sep 8, 2014 at 1:16 AM
Hello reader

I am wondering why the code below adds 2 lines on every same spot....

        Dim count As Long
        Dim strFilenaamExtensie As String = Format(Now, "hhmmss")
        Dim filename As String = Form1.txtExportPad.Text & "AS_DMC10mbakjes_" & Mid(GLOBAL_AsFilenaam, 1, Len(GLOBAL_AsFilenaam) - 4) & "_" & strFilenaamExtensie & ".shp"
        Dim f As New Feature()
        Dim fs As New FeatureSet(f.FeatureType)
        Try
            'Set projection
            fs.Projection = Form1.myVenster.Projection
            'ADD THESE COLUMNS
            fs.DataTable.Columns.Add(New DataColumn("ID", GetType(System.Int64)))
            fs.DataTable.Columns.Add(New DataColumn("REDlinks", GetType(System.Int64)))
            fs.DataTable.Columns.Add(New DataColumn("REDrechts", GetType(System.Int64)))
            fs.DataTable.Columns.Add(New DataColumn("WONlinks", GetType(System.Int32)))
            fs.DataTable.Columns.Add(New DataColumn("WONrechts", GetType(System.Int32)))
            fs.DataTable.Columns.Add(New DataColumn("OZGlinks", GetType(System.Int32)))
            fs.DataTable.Columns.Add(New DataColumn("OZGrechts", GetType(System.Int32)))


            'FOR EACH LINE IN AN ARRAY IN THE MEMORY CREATE A LINE
            For count = 0 To BakjesLijst.Count - 1
                Dim coord As Coordinate() = New Coordinate(1) {}
                'Per polyline
                coord(0) = New Coordinate(BakjesLijst(count).X1bakje, BakjesLijst(count).Y1bakje)
                coord(1) = New Coordinate(BakjesLijst(count).X2bakje, BakjesLijst(count).Y2bakje)
                Dim ls As New LineString(coord)
                f = New Feature(ls)
                fs.Features.Add(f)

                ' now the resulting features knows what columns it has
                ' add values for the columns
                Dim feature As IFeature = fs.AddFeature(ls)
                feature.DataRow.BeginEdit()
                feature.DataRow("ID") = count + 1
                feature.DataRow("REDlinks") = BakjesLijst(count).ReductiepuntenLinks
                feature.DataRow("REDrechts") = BakjesLijst(count).ReductiepuntenRechts
                feature.DataRow("WONlinks") = BakjesLijst(count).AantalWoningenLinks
                feature.DataRow("WONrechts") = BakjesLijst(count).AantalWoningenRechts
                feature.DataRow("OZGlinks") = BakjesLijst(count).OnderzoeksgebiedLinks
                feature.DataRow("OZGrechts") = BakjesLijst(count).OnderzoeksgebiedRechts
                feature.DataRow.EndEdit()
            Next

            fs.SaveAs(filename, True)
            Form1.myVenster.AddLayer(filename)
            
Sep 8, 2014 at 1:25 AM
a found it.... stupid me

f = New Feature(ls)
            fs.Features.Add(f)
shoudl be deleted as its double with Dim feature As IFeature = fs.AddFeature(ls)

thx!
Marked as answer by jany_ on 9/9/2014 at 1:23 AM