FObermaier wrote:
cmd.CommandText = " SELECT T1.postcode, T1.huisnummer, T1.toevoeging, T1.ID_Verblijf, T1.X, T1.Y FROM [tblBestemming] AS T1 LEFT JOIN [tblBestemming2WNP] AS T2 ON T1.postcode = T2.postcode AND T1.huisnummer = T2.huisnummer AND T1.toevoeging = T2.toevoeging AND T1.ID_Verblijf = T2.ID_Verblijf WHERE T2.postcode Is Null;"
To get all the adresses who are not connected...
Joska wrote:I have a solution i used before with SQL. I make a datatable of teh connections between addresses and measure points and use this SQL...Hahaha ofcourse but i was thinking that maybe it could be a part of the current code since your code is to find addresses within so i was think that maybe a simple ifnot statement somewhere would suffice :) I will try union, thanxIf you keep track of the feature ids of features, that are actually inside any polygon, you could iterate over the whole featureset, skipping those with tracked ids.
S.th like this// ...var trackedFids = new System.Collections.Generic.List<int>(); var candidates = sishp.QueryFeatures(new DotSpatial.Data.Extent(geom.Envelope)); foreach (var candidate in candidates) { if (geom.Contains(DotSpatial.Topology.Geometry.FromBasicGeometry(candidate.BasicGeometry))) { trackedFids.Add(candiate.Fid); // do sth with candidate } } /* * A couple of lines later.... */ trackedFids.Sort(); int found = 0 foreach(var candidate in shp....Features) { if (trackedFids[found] == candiate.Fid) { while (trackedFids[found] == candiate.Fid) found++; continue; } // Do sth with candidate }
cmd.CommandText = " SELECT T1.postcode, T1.huisnummer, T1.toevoeging, T1.ID_Verblijf, T1.X, T1.Y FROM [tblBestemming] AS T1 LEFT JOIN [tblBestemming2WNP] AS T2 ON T1.postcode = T2.postcode AND T1.huisnummer = T2.huisnummer AND T1.toevoeging = T2.toevoeging AND T1.ID_Verblijf = T2.ID_Verblijf WHERE T2.postcode Is Null;"
To get all the adresses who are not connected...
'maak een nieuwe datatabel voor tabellen uit de database
Dim dtKoppel As New DataTable()
'maak een connectie met de database en vul de tabel
Dim conSwungDatabase As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & strSwungPadFile & ";Persist Security Info=False;User Id=admin;Password=;")
conSwungDatabase.Open()
Using cmd As New System.Data.OleDb.OleDbCommand()
cmd.Connection = conSwungDatabase
cmd.CommandText = " SELECT T1.postcode, T1.huisnummer, T1.toevoeging, T1.ID_Verblijf, T1.X, T1.Y FROM [tblBestemming] AS T1 LEFT JOIN [tblBestemming2WNP] AS T2 ON T1.postcode = T2.postcode AND T1.huisnummer = T2.huisnummer AND T1.toevoeging = T2.toevoeging AND T1.ID_Verblijf = T2.ID_Verblijf WHERE T2.postcode Is Null;"
Dim rdrK As System.Data.OleDb.OleDbDataReader = cmd.ExecuteReader()
dtKoppel.Load(rdrK)
End Using
'sluit de connectie
conSwungDatabase.Close()
'maak een nieuwe featureset aan
Dim f As New Feature()
Dim fsKoppel As New FeatureSet(f.FeatureType)
fsKoppel.Projection = Form1.myVenster.Projection
For Each Col As DataColumn In dtKoppel.Columns
fsKoppel.DataTable.Columns.Add(New DataColumn(Col.ColumnName, Col.DataType))
Next
'loop through the temporary datatable and load in the features and attributes
For RowIndex As Integer = 0 To dtKoppel.Rows.Count - 1
'extract the data from the datatable
Dim Xadres As Double = dtKoppel.Rows(RowIndex).Item("X")
Dim Yadres As Double = dtKoppel.Rows(RowIndex).Item("Y")
'add the feature to the featureset
fsKoppel.AddFeature(New Feature(New Coordinate(Xadres, Yadres)))
'now update the feature's row with attributes
For ColumnIndex As Integer = 0 To dtKoppel.Columns.Count - 1
fsKoppel.DataTable.Rows(RowIndex).Item(ColumnIndex) = dtKoppel.Rows(RowIndex).Item(ColumnIndex)
Next
Form1.ProgressBar.Value = (RowIndex / dtKoppel.Rows.Count) * 100
Next
fsKoppel.SaveAs(Form1.txtExportPad.Text & "Niet_gekoppelde_adressen.shp", True)