コード例 #1
0
        private Boolean inGeometryFilter(FeatureDataRow feature)
        {
            if (_viewDefinition == null || _viewDefinition.SpatialPredicate == null)
            {
                return(true);
            }

            SpatialBinaryExpression spatialQueryExpression = _viewDefinition.SpatialPredicate;
            SpatialOperation        op = spatialQueryExpression.Op;

            GeometryExpression geometryExpression
                = spatialQueryExpression.SpatialExpression as GeometryExpression;
            ExtentsExpression extentsExpression
                = spatialQueryExpression.SpatialExpression as ExtentsExpression;

            if (!SpatialExpression.IsNullOrEmpty(geometryExpression))
            {
                return(SpatialBinaryExpression.IsMatch(op,
                                                       spatialQueryExpression.IsSpatialExpressionLeft,
                                                       geometryExpression.Geometry,
                                                       feature.Geometry));
            }

            if (!SpatialExpression.IsNullOrEmpty(extentsExpression))
            {
                return(SpatialBinaryExpression.IsMatch(op,
                                                       spatialQueryExpression.IsSpatialExpressionLeft,
                                                       extentsExpression.Extents,
                                                       feature.Extents));
            }

            return(true);
        }
コード例 #2
0
        public IEnumerable <UInt32> ExecuteOidQuery(SpatialBinaryExpression query)
        {
            if (query == null)
            {
                throw new ArgumentNullException("query");
            }

            SpatialExpression spatialExpression = query.SpatialExpression;

            if (SpatialExpression.IsNullOrEmpty(spatialExpression))
            {
                yield break;
            }

            if (query.Expression == null)
            {
                throw new ArgumentException("The SpatialQueryExpression must have " +
                                            "a non-null Expression.");
            }

            ExtentsExpression  extentsExpression  = spatialExpression as ExtentsExpression;
            GeometryExpression geometryExpression = spatialExpression as GeometryExpression;

            IExtents filterExtents = extentsExpression != null
                                         ? extentsExpression.Extents
                                         : null;
            IGeometry filterGeometry = geometryExpression != null
                                           ? geometryExpression.Geometry
                                           : null;

            Assert.IsTrue(filterExtents != null || filterGeometry != null);

            Boolean          isLeft = query.IsSpatialExpressionLeft;
            SpatialOperation op     = query.Op;

            LayerExpression layerExpression = query.Expression as LayerExpression;

            if (layerExpression != null)
            {
                for (UInt32 i = 0; i < _geometries.Count; i++)
                {
                    if (isGeometryAtIndexAMatch((Int32)i, op, isLeft, filterGeometry))
                    {
                        yield return(i);
                    }
                }

                yield break;
            }

            OidCollectionExpression oidsCollection = query.Expression as OidCollectionExpression;

            if (oidsCollection != null)
            {
                if (oidsCollection.Right == null)
                {
                    throw new ArgumentException("The OidCollectionExpression in the query " +
                                                "has a null collection");
                }

                IEnumerable oids = oidsCollection.Right.Collection;

                if (oids == null)
                {
                    yield break;
                }

                foreach (Object oid in oids)
                {
                    if (isGeometryAtIndexAMatch((Int32)oid, op, isLeft, filterGeometry))
                    {
                        yield return((UInt32)oid);
                    }
                }

                yield break;
            }
        }