public void ExecuteIntersectionQuery(IGeometry geom, FeatureDataSet ds) { var fdt = (FeatureDataTable)_schemaTable.Copy(); /* // NOTE WHY IS THIS, No other provider behaves like that? * if (ds.Tables.Count > 0) * { * fdt = ds.Tables[0]; * } * else * { * fdt = new FeatureDataTable(); * }*/ var pGeom = NetTopologySuite.Geometries.Prepared.PreparedGeometryFactory.Prepare(geom); fdt.BeginLoadData(); foreach (var feature in _geometrys) { feature.Value.Where(pGeom.Intersects).ToList() .ForEach(v => { var newRow = (FeatureDataRow)fdt.LoadDataRow(GetAssetProperties(feature.Key), true); newRow.Geometry = v; } ); } fdt.EndLoadData(); ds.Tables.Add(fdt); }
/// <summary> /// Returns the data associated with all the geometries that are intersected by 'geom' /// </summary> /// <param name="box">Geometry to intersect with</param> /// <param name="ds">FeatureDataSet to fill data into</param> public override void ExecuteIntersectionQuery(Envelope box, FeatureDataSet ds) { var table = (FeatureDataTable)_baseTable.Copy(); table.TableName = _content.TableName; table.BeginLoadData(); using (var rdr = CreateReader(7, box)) { if (rdr.HasRows) { var geometryIndex = rdr.FieldCount - 1; while (rdr.Read()) { if (rdr.IsDBNull(geometryIndex)) { continue; } var geom = _reader.Read((byte[])rdr.GetValue(geometryIndex)); if (geom.Header.IsEmpty) { continue; } if (!box.Intersects(geom.Header.Extent)) { continue; } var data = new object[geometryIndex]; rdr.GetValues(data); var fdr = (FeatureDataRow)table.LoadDataRow(data, true); fdr.Geometry = geom.GetGeometry(); } } } table.EndLoadData(); if (table.Rows.Count > 0) { ds.Tables.Add(table); } }