/// <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.MaxX.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> /// Returns features within the specified bounding box. /// </summary> /// <param name="envelope"></param> /// <returns></returns> public override Collection <Geometry> GetGeometriesInView(BoundingBox envelope) { // Identifies all the features within the given BoundingBox var geoms = new Collection <Geometry>(); foreach (var feature in _features) { if (envelope.Intersects(feature.Geometry.EnvelopeInternal)) { geoms.Add(feature.Geometry); } } return(geoms); }
private List <JObject> FilterPosition(List <JObject> batch, double minX, double minY, double maxX, double maxY) { var filteredBatch = new List <JObject>(); var geometryFactory = new GeometryFactory(); Geometry point; var rdr = new WKTReader(geometryFactory); var boundingBox = new NetTopologySuite.Geometries.Envelope(minX, maxX, minY, maxY); //Check if bounding box was provided, if there are no values present then return original batch if (minX == 0) { return(batch); } else { foreach (var document in batch) { try { foreach (var jp in document.Properties().ToList()) { if (jp.Name == "byg404Koordinat") { point = rdr.Read(jp.Value.ToString()); if (boundingBox.Intersects(point.EnvelopeInternal)) { filteredBatch.Add(document); } } else if (jp.Name == "tek109Koordinat") { point = rdr.Read(jp.Value.ToString()); if (boundingBox.Intersects(point.EnvelopeInternal)) { filteredBatch.Add(document); } } } } catch (NetTopologySuite.IO.ParseException e) { _logger.LogError("Error writing data: {0}.", e.GetType().Name); _logger.LogInformation(document.ToString()); break; } } return(filteredBatch); } }
/// <summary> /// Gets the object IDs in the view. /// </summary> /// <param name="bbox">The bbox.</param> /// <returns></returns> public override Collection <uint> GetObjectIDsInView(BoundingBox bbox) { // Identifies all the features within the given BoundingBox Envelope envelope = bbox; Collection <uint> geoms = new Collection <uint>(); for (int i = 0; i < _features.Count; i++) { if (envelope.Intersects(_features[i].Geometry.EnvelopeInternal)) { geoms.Add(Convert.ToUInt32(i)); } } return(geoms); }
/// <summary> /// /// </summary> /// <param name="envelope"></param> /// <param name="ds"></param> public override void ExecuteIntersectionQuery(BoundingBox envelope, FeatureDataSet ds) { // Identifies all the features within the given BoundingBox var dataTable = CreateFeatureDataTable(); dataTable.BeginLoadData(); foreach (Feature feature in _features) { if (envelope.Intersects(feature.Geometry.EnvelopeInternal)) { CreateNewRow(dataTable, feature); } } dataTable.EndLoadData(); ds.Tables.Add(dataTable); }
/// <summary> /// Computes the full extents of the data source as a /// <see cref="BoundingBox"/>. /// </summary> /// <returns> /// A BoundingBox instance which minimally bounds all the features /// available in this data source. /// </returns> public override BoundingBox GetExtents() { if (Table.Rows.Count == 0) { return(null); } BoundingBox box; double minX = Double.PositiveInfinity, minY = Double.PositiveInfinity, maxX = Double.NegativeInfinity, maxY = Double.NegativeInfinity; foreach (DataRowView dr in Table.DefaultView) { if (minX > (double)dr[XColumn]) { minX = (double)dr[XColumn]; } if (maxX < (double)dr[XColumn]) { maxX = (double)dr[XColumn]; } if (minY > (double)dr[YColumn]) { minY = (double)dr[YColumn]; } if (maxY < (double)dr[YColumn]) { maxY = (double)dr[YColumn]; } } box = new BoundingBox(minX, maxX, minY, maxY); return(box); }
/// <summary> /// Returns geometry Object IDs whose bounding box intersects 'bbox' /// </summary> /// <param name="bbox"></param> /// <returns></returns> public override Collection <uint> GetObjectIDsInView(BoundingBox bbox) { DataRow[] drow; Collection <uint> objectlist = new Collection <uint>(); if (Table.Rows.Count == 0) { return(null); } string strSQL = 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); drow = Table.Select(strSQL); foreach (DataRow dr in drow) { objectlist.Add(Convert.ToUInt32(dr[0])); } return(objectlist); }
private List <string> newfilterAdressPosition(List <string> batch, double minX, double minY, double maxX, double maxY) { var filteredBatch = new List <string>(); var geometryFactory = new GeometryFactory(); Geometry line; Geometry point; Geometry polygon; Geometry multipoint; string name; string value = ""; var rdr = new WKTReader(geometryFactory); var boundingBox = new NetTopologySuite.Geometries.Envelope(minX, maxX, minY, maxY); foreach (var document in batch) { var o = JObject.Parse(document); foreach (var jp in o.Properties().ToList()) { if (jp.Name == "position") { point = rdr.Read(jp.Value.ToString()); if (boundingBox.Intersects(point.EnvelopeInternal)) { filteredBatch.Add(document); } } else if (jp.Name == "roadRegistrationRoadLine") { try { if (jp.Value != null) { line = rdr.Read(jp.Value.ToString()); if (boundingBox.Intersects(line.EnvelopeInternal)) { filteredBatch.Add(document); } } else { if (jp.Name == "roadRegistrationRoadArea") { name = jp.Name; value = (string)jp.Value; polygon = rdr.Read(jp.Value.ToString()); if (boundingBox.Intersects(polygon.EnvelopeInternal)) { filteredBatch.Add(document); } } else if (jp.Name == "roadRegistrationRoadConnectionPoints") { multipoint = rdr.Read(jp.Value.ToString()); if (boundingBox.Intersects(multipoint.EnvelopeInternal)) { filteredBatch.Add(document); } } } } /* Gets parse exception when they are values in both roadRegistrationRoadConnectionPoints and roadRegistrationArea, * also when they are null values in those fields */ catch (NetTopologySuite.IO.ParseException e) { _logger.LogError("Error writing data: {0}.", e.GetType().Name); _logger.LogInformation(document); break; } } } } return(filteredBatch); }
/// <summary> /// Gets the features in view. /// </summary> /// <param name="bbox">The bbox.</param> /// <param name="ds">The ds.</param> public void GetFeaturesInView(BoundingBox bbox, FeatureDataSet ds) { ExecuteIntersectionQuery(bbox, ds); }
public override Envelope ExpandEnvelope(Envelope env) => _inner.ExpandEnvelope(env);