Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        /// <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);
        }
Exemplo n.º 3
0
        /**
         * Extracts the coordinates which intersect an {@link Envelope}.
         *
         * @param coordinates the coordinates to scan
         * @param env the envelope to intersect with
         * @return an array of the coordinates which intersect the envelope
         */
        public static Coordinate[] Intersection(Coordinate[] coordinates, Envelope env)
        {
            var coordList = new CoordinateList();

            for (int i = 0; i < coordinates.Length; i++)
            {
                var c = coordinates[i];
                if (env.Intersects(c))
                {
                    coordList.Add(c, true);
                }
            }
            return(coordList.ToCoordinateArray());
        }
Exemplo n.º 4
0
        /// <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);
        }
Exemplo n.º 5
0
        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);
        }