/// <summary> /// Retrieves all features within the given BoundingBox. /// </summary> /// <param name="bbox">Bounds of the region to search.</param> /// <param name="ds">FeatureDataSet to fill data into</param> public void ExecuteIntersectionQuery(BoundingBox bbox, FeatureDataSet ds) { DataRow[] rows; if (Table.Rows.Count == 0) { return; } string statement = XColumn + " > " + bbox.Left.ToString(Map.NumberFormatEnUs) + " AND " + XColumn + " < " + bbox.Right.ToString(Map.NumberFormatEnUs) + " AND " + YColumn + " > " + bbox.Bottom.ToString(Map.NumberFormatEnUs) + " AND " + YColumn + " < " + bbox.Top.ToString(Map.NumberFormatEnUs); rows = Table.Select(statement); FeatureDataTable fdt = new FeatureDataTable(Table); foreach (DataColumn col in Table.Columns) { fdt.Columns.Add(col.ColumnName, col.DataType, col.Expression); } foreach (DataRow dr in rows) { fdt.ImportRow(dr); FeatureDataRow fdr = fdt.Rows[fdt.Rows.Count - 1] as FeatureDataRow; fdr.Geometry = new Point((double)dr[XColumn], (double)dr[YColumn]); } ds.Tables.Add(fdt); }
/// <summary> /// Retrieves all features within the given BoundingBox. /// </summary> /// <param name="bbox">Bounds of the region to search.</param> /// <param name="ds">FeatureDataSet to fill data into</param> public override void ExecuteIntersectionQuery(BoundingBox bbox, FeatureDataSet ds) { DataRow[] rows; if (Table.Rows.Count == 0) { return; } string statement = XColumn + " >= " + bbox.MinX.ToString("R", Map.NumberFormatEnUs) + " AND " + XColumn + " <= " + bbox.MaxX.ToString("R", Map.NumberFormatEnUs) + " AND " + YColumn + " >= " + bbox.MinY.ToString("R", Map.NumberFormatEnUs) + " AND " + YColumn + " <= " + bbox.MaxY.ToString("R", Map.NumberFormatEnUs); rows = Table.Select(statement); FeatureDataTable fdt = new FeatureDataTable(Table); foreach (DataColumn col in Table.Columns) { fdt.Columns.Add(col.ColumnName, col.DataType, col.Expression); } foreach (DataRow dr in rows) { fdt.ImportRow(dr); FeatureDataRow fdr = fdt.Rows[fdt.Rows.Count - 1] as FeatureDataRow; fdr.Geometry = Factory.CreatePoint(new Coordinate((double)dr[XColumn], (double)dr[YColumn])); } ds.Tables.Add(fdt); }
/// <summary> /// Retrieves all features within the given BoundingBox. /// </summary> /// <param name="bbox">Bounds of the region to search.</param> /// <param name="d"></param> public IEnumerable <IFeature> GetFeatures(IEnvelope bbox) { DataRow[] rows; if (Table.Rows.Count == 0) { return(null); } string statement = XColumn + " >= " + bbox.MinX.ToString(Map.numberFormat_EnUS) + " AND " + XColumn + " <= " + bbox.MaxX.ToString(Map.numberFormat_EnUS) + " AND " + YColumn + " >= " + bbox.MinY.ToString(Map.numberFormat_EnUS) + " AND " + YColumn + " <= " + bbox.MaxY.ToString(Map.numberFormat_EnUS); rows = Table.Select(statement); FeatureDataTable fdt = new FeatureDataTable(Table); foreach (DataColumn col in Table.Columns) { fdt.Columns.Add(col.ColumnName, col.DataType, col.Expression); } foreach (DataRow dr in rows) { fdt.ImportRow(dr); FeatureDataRow fdr = fdt.Rows[fdt.Rows.Count - 1] as FeatureDataRow; fdr.Geometry = SharpMap.Converters.Geometries.GeometryFactory.CreatePoint((double)dr[XColumn], (double)dr[YColumn]); } return(fdt); }
internal FeatureDataReader(IGeometryFactory factory, FeatureDataTable source, FeatureQueryExpression query, FeatureQueryExecutionOptions options) { if (source == null) { throw new ArgumentNullException("source"); } if (options != FeatureQueryExecutionOptions.FullFeature) { throw new ArgumentException("Only QueryExecutionOptions.All is supported.", "options"); } _factory = factory; _options = options; _query = query; _table = source.Clone(); foreach (FeatureDataRow row in source.Select(query.SpatialPredicate)) { _table.ImportRow(row); } }
/// <summary> /// Retrieves all features within the given BoundingBox. /// </summary> /// <param name="bounds">Bounds of the region to search.</param> /// <param name="fcs">FeatureDataSet to fill data into</param> public override void ExecuteIntersectionQuery(Envelope bounds, IFeatureCollectionSet fcs, CancellationToken?cancellationToken = null) { if (Table.Rows.Count == 0) { return; } string statement = XColumn + " > " + bounds.MinX.ToString(Map.NumberFormatEnUs) + " AND " + XColumn + " < " + bounds.MaxX.ToString(Map.NumberFormatEnUs) + " AND " + YColumn + " > " + bounds.MinY.ToString(Map.NumberFormatEnUs) + " AND " + YColumn + " < " + bounds.MaxY.ToString(Map.NumberFormatEnUs); var rows = Table.Select(statement); var fdt = new FeatureDataTable(Table); foreach (DataColumn col in Table.Columns) { fdt.Columns.Add(col.ColumnName, col.DataType, col.Expression); } foreach (var dr in rows) { fdt.ImportRow(dr); var fdr = (FeatureDataRow)fdt.Rows[fdt.Rows.Count - 1]; fdr.Geometry = Factory.CreatePoint(new Coordinate((double)dr[XColumn], (double)dr[YColumn])); } fcs.Add(fdt); }
public void ExecuteIntersectionQueryReturnsExpectedFeatures() { DataTable source = CreateDataTableSource(); DataTablePoint provider = new DataTablePoint(source, "oid", "x", "y"); var query = new Envelope(400, 600, 400, 600); FeatureDataTable expected = new FeatureDataTable(); expected.TableName = "PointSource"; foreach (DataColumn column in source.Columns) { expected.Columns.Add(column.ColumnName, column.DataType); } foreach (DataRowView rowView in source.DefaultView) { if (query.Contains(new Coordinate((double)rowView["x"], (double)rowView["y"]))) { expected.ImportRow(rowView.Row); } } FeatureDataSet dataSet = new FeatureDataSet(); provider.ExecuteIntersectionQuery(query, dataSet); Assert.IsNotNull(dataSet); Assert.IsNotNull(dataSet.Tables); Assert.AreEqual(1, dataSet.Tables.Count); FeatureDataTable actual = dataSet.Tables[0]; Assert.AreEqual(expected.Rows.Count, actual.Rows.Count); foreach (DataRowView expectedRowView in expected.DefaultView) { DataRow[] actualRows = actual.Select("oid = " + expectedRowView["oid"]); Assert.AreEqual(1, actualRows.Length); Assert.AreEqual(expectedRowView["oid"], actualRows[0]["oid"]); Assert.AreEqual(expectedRowView["x"], actualRows[0]["x"]); Assert.AreEqual(expectedRowView["y"], actualRows[0]["y"]); } }
public void ExecuteIntersectionQueryReturnsExpectedFeatures() { DataTable source = CreateDataTableSource(); DataTablePoint provider = new DataTablePoint(source, "oid", "x", "y"); var query = new Envelope(400, 600, 400, 600); FeatureDataTable expected = new FeatureDataTable(); expected.TableName = "PointSource"; foreach (DataColumn column in source.Columns) { expected.Columns.Add(column.ColumnName, column.DataType); } foreach (DataRowView rowView in source.DefaultView) { if (query.Contains(new Coordinate((double) rowView["x"], (double) rowView["y"]))) { expected.ImportRow(rowView.Row); } } FeatureDataSet dataSet = new FeatureDataSet(); provider.ExecuteIntersectionQuery(query, dataSet); Assert.IsNotNull(dataSet); Assert.IsNotNull(dataSet.Tables); Assert.AreEqual(1, dataSet.Tables.Count); FeatureDataTable actual = dataSet.Tables[0]; Assert.AreEqual(expected.Rows.Count, actual.Rows.Count); foreach (DataRowView expectedRowView in expected.DefaultView) { DataRow[] actualRows = actual.Select("oid = " + expectedRowView["oid"]); Assert.AreEqual(1, actualRows.Length); Assert.AreEqual(expectedRowView["oid"], actualRows[0]["oid"]); Assert.AreEqual(expectedRowView["x"], actualRows[0]["x"]); Assert.AreEqual(expectedRowView["y"], actualRows[0]["y"]); } }
/// <summary> /// Returns a datarow based on a RowID /// </summary> /// <param name="index"></param> /// <returns>datarow</returns> public IFeature GetFeature(int index) { //hack assume index is rowindex var rows = Table.Rows[index]; var featureDataTable = new FeatureDataTable(Table); foreach (DataColumn col in Table.Columns) { featureDataTable.Columns.Add(col.ColumnName, col.DataType, col.Expression); } featureDataTable.ImportRow(rows); var featureDataRow = featureDataTable.Rows[0] as FeatureDataRow; featureDataRow.Geometry = SharpMap.Converters.Geometries.GeometryFactory.CreatePoint((double)rows[XColumn], (double)rows[YColumn]); return(featureDataRow); }
internal FeatureDataReader(IGeometryFactory factory, FeatureDataTable source, FeatureQueryExpression query, FeatureQueryExecutionOptions options) { if (source == null) throw new ArgumentNullException("source"); if (options != FeatureQueryExecutionOptions.FullFeature) { throw new ArgumentException("Only QueryExecutionOptions.All is supported.", "options"); } _factory = factory; _options = options; _query = query; _table = source.Clone(); foreach (FeatureDataRow row in source.Select(query.SpatialPredicate)) { _table.ImportRow(row); } }
/// <summary> /// Retrieves all features within the given BoundingBox. /// </summary> /// <param name="bbox">Bounds of the region to search.</param> /// <param name="ds">FeatureDataSet to fill data into</param> public void ExecuteIntersectionQuery(BoundingBox bbox, FeatureDataSet ds) { DataRow[] rows; if (Table.Rows.Count == 0) { return; } string statement = XColumn + " > " + bbox.Left.ToString(Map.NumberFormatEnUs) + " AND " + XColumn + " < " + bbox.Right.ToString(Map.NumberFormatEnUs) + " AND " + YColumn + " > " + bbox.Bottom.ToString(Map.NumberFormatEnUs) + " AND " + YColumn + " < " + bbox.Top.ToString(Map.NumberFormatEnUs); rows = Table.Select(statement); FeatureDataTable fdt = new FeatureDataTable(Table); foreach (DataColumn col in Table.Columns) { fdt.Columns.Add(col.ColumnName, col.DataType, col.Expression); } foreach (DataRow dr in rows) { fdt.ImportRow(dr); FeatureDataRow fdr = fdt.Rows[fdt.Rows.Count - 1] as FeatureDataRow; fdr.Geometry = new Point((double) dr[XColumn], (double) dr[YColumn]); } ds.Tables.Add(fdt); }
/// <summary> /// Retrieves all features within the given BoundingBox. /// </summary> /// <param name="bounds">Bounds of the region to search.</param> /// <param name="fcs">FeatureDataSet to fill data into</param> public override void ExecuteIntersectionQuery(Envelope bounds, IFeatureCollectionSet fcs, CancellationToken? cancellationToken = null) { if (Table.Rows.Count == 0) { return; } string statement = XColumn + " > " + bounds.MinX.ToString(Map.NumberFormatEnUs) + " AND " + XColumn + " < " + bounds.MaxX.ToString(Map.NumberFormatEnUs) + " AND " + YColumn + " > " + bounds.MinY.ToString(Map.NumberFormatEnUs) + " AND " + YColumn + " < " + bounds.MaxY.ToString(Map.NumberFormatEnUs); var rows = Table.Select(statement); var fdt = new FeatureDataTable(Table); foreach (DataColumn col in Table.Columns) { fdt.Columns.Add(col.ColumnName, col.DataType, col.Expression); } foreach (var dr in rows) { fdt.ImportRow(dr); var fdr = (FeatureDataRow)fdt.Rows[fdt.Rows.Count - 1]; fdr.Geometry = Factory.CreatePoint(new Coordinate((double) dr[XColumn], (double) dr[YColumn])); } fcs.Add(fdt); }
/// <summary> /// Retrieves all features within the given BoundingBox. /// </summary> /// <param name="bbox">Bounds of the region to search.</param> /// <param name="ds">FeatureDataSet to fill data into</param> public void ExecuteIntersectionQuery(IEnvelope bbox, FeatureDataSet ds) { DataRow[] rows; if (Table.Rows.Count == 0) { return; } string statement = XColumn + " > " + bbox.MinX.ToString(Map.numberFormat_EnUS) + " AND " + XColumn + " < " + bbox.MaxX.ToString(Map.numberFormat_EnUS) + " AND " + YColumn + " > " + bbox.MinY.ToString(Map.numberFormat_EnUS) + " AND " + YColumn + " < " + bbox.MaxY.ToString(Map.numberFormat_EnUS); rows = Table.Select(statement); FeatureDataTable fdt = new FeatureDataTable(Table); foreach (DataColumn col in Table.Columns) { fdt.Columns.Add(col.ColumnName, col.DataType, col.Expression); } foreach (DataRow dr in rows) { fdt.ImportRow(dr); FeatureDataRow fdr = fdt.Rows[fdt.Rows.Count - 1] as FeatureDataRow; fdr.Geometry = SharpMap.Converters.Geometries.GeometryFactory.CreatePoint((double)dr[XColumn], (double)dr[YColumn]); } ds.Tables.Add(fdt); }
public void Insert(FeatureDataRow <Guid> feature) { _features.ImportRow(feature); }
/// <summary> /// Returns a datarow based on a RowID /// </summary> /// <param name="index"></param> /// <returns>datarow</returns> public IFeature GetFeature(int index) { //hack assume index is rowindex var rows = Table.Rows[index]; var featureDataTable = new FeatureDataTable(Table); foreach (DataColumn col in Table.Columns) { featureDataTable.Columns.Add(col.ColumnName, col.DataType, col.Expression); } featureDataTable.ImportRow(rows); var featureDataRow = featureDataTable.Rows[0] as FeatureDataRow; featureDataRow.Geometry = SharpMap.Converters.Geometries.GeometryFactory.CreatePoint((double) rows[XColumn], (double) rows[YColumn]); return featureDataRow; }