Exemplo n.º 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);
        }
Exemplo n.º 2
0
        public virtual IEnumerable <TItem> Query(SpatialExpression spatialExpression)
        {
            GeometryExpression geometryExpression = spatialExpression as GeometryExpression;
            ExtentsExpression  extentsExpression  = spatialExpression as ExtentsExpression;

            IGeometry geometry = geometryExpression != null
                                     ? geometryExpression.Geometry
                                     : null;

            IExtents extents = extentsExpression != null
                                   ? extentsExpression.Extents
                                   : geometry.Extents;

            return(geometry == null
                       ? Query(extents)
                       : Query(geometry));
        }
Exemplo n.º 3
0
        private FeatureQueryExpression transformQuery(FeatureQueryExpression query)
        {
            SpatialBinaryExpression spatial = query.SpatialPredicate;
            ICoordinateSystem       querySpatialReference = spatial.SpatialExpression.SpatialReference;

            if (querySpatialReference.EqualParams(OriginalSpatialReference))
            {
                return(query);
            }

            //if (querySpatialReference != OriginalSpatialReference)
            //{
            //    throw new InvalidOperationException("The query's spatial reference doesn't match the provider's.");
            //}

            GeometryExpression geoExpression = spatial.SpatialExpression as GeometryExpression;

            if (geoExpression != null)
            {
                IGeometry transformed = CoordinateTransformation.InverseTransform(geoExpression.Geometry,
                                                                                  GeometryFactory);
                geoExpression = new GeometryExpression(transformed);
                spatial       = spatial.IsSpatialExpressionLeft
                              ? new SpatialBinaryExpression(geoExpression, spatial.Op, spatial.Expression)
                              : new SpatialBinaryExpression(spatial.Expression, spatial.Op, geoExpression);
            }
            else
            {
                IExtents transformed = CoordinateTransformation.InverseTransform(spatial.SpatialExpression.Extents,
                                                                                 GeometryFactory);
                ExtentsExpression extentsExpression = new ExtentsExpression(transformed);
                spatial = spatial.IsSpatialExpressionLeft
                              ? new SpatialBinaryExpression(extentsExpression, spatial.Op, spatial.Expression)
                              : new SpatialBinaryExpression(spatial.Expression, spatial.Op, extentsExpression);
            }

            query = new FeatureQueryExpression(query, spatial);
            return(query);
        }
Exemplo n.º 4
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;
            }
        }