Esempio n. 1
0
        /// <summary>
        /// Returns the features that intersects with 'geom'
        /// </summary>
        /// <param name="geom">Geometry</param>
        /// <returns>FeatureDataTable</returns>
        public FeatureDataTable ExecuteIntersectionQuery(Geometry geom)
        {
            FeatureDataSet fds = new FeatureDataSet();

            ExecuteIntersectionQuery(geom, fds);
            return(fds.Tables[0]);
        }
Esempio n. 2
0
        /// <summary>
        /// Returns the data associated with all the geometries that are intersected by 'geom'
        /// </summary>
        /// <param name="geom">Geometry to intersect with</param>
        /// <param name="ds">FeatureDataSet to fill data into</param>
        public void ExecuteIntersectionQuery(Geometry geom, FeatureDataSet ds)
        {
            OgrGeometry ogrGeometry = OgrGeometry.CreateFromWkb(GeometryToWKB.Write(geom));

            _ogrLayer.SetSpatialFilter(ogrGeometry);
            ExecuteIntersectionQuery(ds);
        }
Esempio n. 3
0
        /// <summary>
        /// Returns geometries within the specified bounding box
        /// </summary>
        /// <param name="bbox"></param>
        /// <returns></returns>
        public Collection <Geometry> GetGeometriesInView(BoundingBox bbox)
        {
            Collection <Geometry> geoms = new Collection <Geometry>();

            _ogrLayer.SetSpatialFilterRect(bbox.Left, bbox.Bottom, bbox.Right, bbox.Top);
            _ogrLayer.ResetReading();

            try
            {
                OgrFeature ogrFeature;
                while ((ogrFeature = _ogrLayer.GetNextFeature()) != null)
                {
                    Geometry geom = ParseOgrGeometry(ogrFeature.GetGeometryRef());
                    if (geom != null)
                    {
                        geoms.Add(geom);
                    }
                    ogrFeature.Dispose();
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }

            return(geoms);
        }
Esempio n. 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="geom"></param>
        /// <param name="ds"></param>
        public void ExecuteIntersectionQuery(Geometry geom, FeatureDataSet ds)
        {
            GeoAPI.Geometries.IGeometry geometry  = GeometryConverter.ToNTSGeometry(geom, _geometryFactory);
            FeatureDataTable            dataTable = CreateFeatureDataTable();

            foreach (Feature feature in _features)
            {
                if (feature.Geometry.Intersects(geometry))
                {
                    CreateNewRow(dataTable, feature);
                }
            }

            ds.Tables.Add(dataTable);
        }
Esempio n. 5
0
 private static Geometry ParseOgrGeometry(OgrGeometry ogrGeometry)
 {
     if (ogrGeometry != null)
     {
         //Just in case it isn't 2D
         ogrGeometry.FlattenTo2D();
         byte[] wkbBuffer = new byte[ogrGeometry.WkbSize()];
         ogrGeometry.ExportToWkb(wkbBuffer);
         Geometry geom = GeometryFromWKB.Parse(wkbBuffer);
         if (geom == null)
         {
             Debug.WriteLine(string.Format("Failed to parse '{0}'", ogrGeometry.GetGeometryType()));
         }
         return(geom);
     }
     return(null);
 }
Esempio n. 6
0
 public FeatureDataTable QueryFeatures(Geometry geom, double distance)
 {
     throw new NotSupportedException();
 }