/// <summary>
 /// Initializes a new instance of the <see cref="SpatialRelationFunction"/> class.
 /// </summary>
 /// <param name="spatialDialect">The spatial dialect.</param>
 /// <param name="relation">The relation.</param>
 public SpatialRelationFunction(ISpatialDialect spatialDialect, SpatialRelation relation)
     : base(relation.ToString(), NHibernateUtil.Boolean)
 {
     this.spatialDialect = spatialDialect;
     this.relation = relation;
     this.allowedArgsCount = 2;
 }
Beispiel #2
0
 /// <summary>
 /// If you were to call aShape.relate(bShape) and aShape.relate(cShape), you could call
 /// this to merge the intersect results as if bShape & cShape were combined into {@link MultShape}.
 /// </summary>
 /// <param name="this"></param>
 /// <param name="other"></param>
 /// <returns></returns>
 public static SpatialRelation Combine(this SpatialRelation @this, SpatialRelation other)
 {
     if (@this == other)
         return @this;
     if (@this == SpatialRelation.WITHIN || other == SpatialRelation.WITHIN)
         return SpatialRelation.WITHIN;
     return SpatialRelation.INTERSECTS;
 }
		public SpatialCriteria RelatesToShape(object shape, SpatialRelation relation)
		{
			return new SpatialCriteria
				   {
					   Relation = relation,
					   Shape = shape
				   };
		}
        public override SqlString GetSpatialRelationString(object geometry, SpatialRelation relation, object anotherGeometry, bool criterion)
        {
            switch (relation)
            {
                case SpatialRelation.Covers:
                    string[] patterns = new string[] {
                        "T*****FF*",
                        "*T****FF*",
                        "***T**FF*",
                        "****T*FF*",
                    };
                    SqlStringBuilder builder = new SqlStringBuilder();
                    builder.Add("(");
                    for (int i = 0; i < patterns.Length; i++)
                    {
                        if (i > 0)
                            builder.Add(" OR ");
                        builder
                            .Add(SpatialDialect.IsoPrefix)
                            .Add("Relate")
                            .Add("(")
                            .AddObject(geometry)
                            .Add(", ")
                            .AddObject(anotherGeometry)
                            .Add(", '")
                            .Add(patterns[i])
                            .Add("')")
                            .ToSqlString();
                    }
                    builder.Add(")");
                    return builder.ToSqlString();

                case SpatialRelation.CoveredBy:
                    return GetSpatialRelationString(anotherGeometry, SpatialRelation.Covers, geometry, criterion);

                default:
                    return new SqlStringBuilder(6)
                        .Add(SpatialDialect.IsoPrefix)
                        .Add(relation.ToString())
                        .Add("(")
                        .AddObject(geometry)
                        .Add(", ")
                        .AddObject(anotherGeometry)
                        .Add(")")
                        .ToSqlString();
            }
        }
 public SpatialCriteria RelatesToShape(string shapeWkt, SpatialRelation relation, double distErrorPercent = Constants.Documents.Indexing.Spatial.DefaultDistanceErrorPct)
 {
     return(new WktCriteria(shapeWkt, relation, distErrorPercent));
 }
Beispiel #6
0
 public IDocumentQuery <T> RelatesToShape(string fieldName, string shapeWKT, SpatialRelation rel, double distanceErrorPct = 0.025)
 {
     return(GenerateSpatialQueryData(fieldName, shapeWKT, rel, distanceErrorPct));
 }
 /// <inheritdoc />
 IAsyncDocumentQuery <T> IFilterDocumentQueryBase <T, IAsyncDocumentQuery <T> > .RelatesToShape <TValue>(Expression <Func <T, TValue> > propertySelector, string shapeWkt, SpatialRelation relation, SpatialUnits units, double distanceErrorPct)
 {
     Spatial(propertySelector.ToPropertyPath(), shapeWkt, relation, units, distanceErrorPct);
     return(this);
 }
Beispiel #8
0
 protected override object GenerateSpatialQueryData(string fieldName, string shapeWKT, SpatialRelation relation, double distanceErrorPct)
 {
     isSpatialQuery        = true;
     spatialFieldName      = fieldName;
     queryShape            = shapeWKT;
     spatialRelation       = relation;
     this.distanceErrorPct = distanceErrorPct;
     return(this);
 }
        public SqlString GetSpatialRelationString(object geometry, SpatialRelation relation, object anotherGeometry, bool criterion)
        {

            SqlStringBuilder sql =
                new SqlStringBuilder();
          //  sql.Add("((");
            SqlString str = IsOGCStrict
                                ? GetOGCSpatialRelateString(geometry, anotherGeometry, relation)
                                : GetNativeSpatialRelateString(geometry, anotherGeometry, relation).Append(" = 'TRUE'");
            sql.Add(str);
           // sql.Add(") and (").AddObject(geometry).Add(" is not null").Add(")))");
            return sql.ToSqlString();
        }
Beispiel #10
0
 public QuadCell(QuadPrefixTree outerInstance, string token, SpatialRelation shapeRel)
     : base(outerInstance, token)
 {
     this.shapeRel = shapeRel;
 }
Beispiel #11
0
 public void AssertFalse(IGeometry geometry, SpatialRelation relation, IGeometry geometry2)
 {
     AssertThat(geometry, relation, geometry2, false);
 }
Beispiel #12
0
 public void AssertTrue(IGeometry geometry, SpatialRelation relation, IGeometry geometry2)
 {
     AssertThat(geometry, relation, geometry2, true);
 }
Beispiel #13
0
 public SqlString GetSpatialRelationString(object geometry, SpatialRelation relation, object anotherGeometry, bool criterion)
 {
     return(worker.GetSpatialRelationString(geometry, relation, anotherGeometry, criterion));
 }
 private void RegisterSpatialFunction(SpatialRelation relation)
 {
     adaptor.RegisterFunction(SpatialDialect.HqlPrefix + relation, new SpatialRelationFunction(this, relation));
 }
Beispiel #15
0
 public void SetLeaf()
 {
     Debug.Assert(GetLevel() != 0);
     shapeRel = SpatialRelation.WITHIN;
 }
Beispiel #16
0
 /// <summary>
 /// Not DISJOINT, i.e. there is some sort of intersection.
 /// </summary>
 public static bool Intersects(this SpatialRelation @this)
 {
     return(@this != SpatialRelation.DISJOINT);
 }
 /// <summary>
 /// Returns true if the provided cell, and all its sub-cells down to
 /// detailLevel all intersect the queryShape.
 /// </summary>
 private bool AllCellsIntersectQuery(Cell cell, SpatialRelation relate/*cell to query*/)
 {
     if (relate == SpatialRelation.NOT_SET)
     {
         relate = cell.Shape.Relate(outerInstance.queryShape);
     }
     if (cell.Level == outerInstance.detailLevel)
     {
         return relate.Intersects();
     }
     if (relate == SpatialRelation.WITHIN)
     {
         return true;
     }
     if (relate == SpatialRelation.DISJOINT)
     {
         return false;
     }
     // Note: Generating all these cells just to determine intersection is not ideal.
     // It was easy to implement but could be optimized. For example if the docs
     // in question are already marked in the 'outside' bitset then it can be avoided.
     ICollection<Cell> subCells = cell.GetSubCells(null);
     foreach (Cell subCell in subCells)
     {
         if (!AllCellsIntersectQuery(subCell, SpatialRelation.NOT_SET))
         {
             //recursion
             return false;
         }
     }
     return true;
 }
Beispiel #18
0
 public QuadCell(String token, SpatialRelation shapeRel, QuadPrefixTree enclosingInstance)
     : base(enclosingInstance, token)
 {
     this.shapeRel = shapeRel;
 }
Beispiel #19
0
 /// <inheritdoc />
 IDocumentQuery <T> IDocumentQueryBase <T, IDocumentQuery <T> > .RelatesToShape <TValue>(Expression <Func <T, TValue> > propertySelector, string shapeWKT, SpatialRelation relation, double distanceErrorPct)
 {
     Spatial(propertySelector.ToPropertyPath(), shapeWKT, relation, distanceErrorPct);
     return(this);
 }
 public SqlString GetSpatialRelationString(object geometry, SpatialRelation relation, object anotherGeometry, bool criterion)
 {
     switch (relation)
     {
         case SpatialRelation.Covers:
             string[] patterns = new string[] {
                 "T*****FF*",
                 "*T****FF*",
                 "***T**FF*",
                 "****T*FF*",
             };
             SqlStringBuilder builder = new SqlStringBuilder();
             builder.Add("(CASE WHEN ");
             for (int i = 0; i < patterns.Length; i++)
             {
                 if (i > 0)
                     builder.Add(" OR ");
                 builder
                     .AddObject(geometry)
                     .Add(".STRelate(")
                     .AddObject(anotherGeometry)
                     .Add(", '")
                     .Add(patterns[i])
                     .Add("') = 1")
                     .ToSqlString();
             }
             builder.Add(" THEN 1 ELSE 0 END)");
             builder.Add(criterion ? " = 1" : "");
             return builder.ToSqlString();
         case SpatialRelation.CoveredBy:
             return GetSpatialRelationString(anotherGeometry, SpatialRelation.Covers, geometry, criterion);
         default:
             return new SqlStringBuilder(8)
                 .AddObject(geometry)
                 .Add(".ST")
                 .Add(relation.ToString())
                 .Add("(")
                 .AddObject(anotherGeometry)
                 .Add(")")
                 .Add(criterion ? " = 1" : "")
                 .ToSqlString();
     }
 }
Beispiel #21
0
 /// <inheritdoc />
 IDocumentQuery <T> IDocumentQueryBase <T, IDocumentQuery <T> > .RelatesToShape(string fieldName, string shapeWKT, SpatialRelation relation, double distanceErrorPct)
 {
     Spatial(fieldName, shapeWKT, relation, distanceErrorPct);
     return(this);
 }
 public SqlString GetSpatialRelationString(object geometry, SpatialRelation relation, object anotherGeometry, bool criterion)
 {
     return new SqlStringBuilder(8)
         .Add(DialectPrefix)
         .Add("[")
         .Add(relation.ToString())
         .Add("](")
         .AddObject(geometry)
         .Add(", ")
         .AddObject(anotherGeometry)
         .Add(")")
         .Add(criterion ? " = 1" : "")
         .ToSqlString();
 }
Beispiel #23
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SpatialRelationCriterion"/> class.
 /// </summary>
 /// <param name="propertyName">Name of the property.</param>
 /// <param name="relation">The relation.</param>
 /// <param name="anotherGeometry">Another geometry.</param>
 public SpatialRelationCriterion(string propertyName, SpatialRelation relation, object anotherGeometry)
 {
     this.propertyName    = propertyName;
     this.relation        = relation;
     this.anotherGeometry = anotherGeometry;
 }
		protected void RegisterSpatialFunction(SpatialRelation relation)
		{
			RegisterFunction(SpatialDialect.HqlPrefix + relation, new SpatialRelationFunction(this, relation));
		}
Beispiel #25
0
 public void RegisterSpatialFunction(SpatialRelation relation)
 {
     adaptor.RegisterFunction(SpatialDialect.HqlPrefix + relation.ToString(), new SpatialRelationFunction(this, relation));
 }
Beispiel #26
0
 protected SpatialCriteria(SpatialRelation relation, double distanceErrorPct)
 {
     _relation         = relation;
     _distanceErrorPct = distanceErrorPct;
 }
Beispiel #27
0
        /// <summary>
        /// Called after bounding box is intersected.
        /// </summary>
        /// <param name="r"></param>
        /// <param name="bboxSect">INTERSECTS or CONTAINS from enclosingBox's intersection</param>
        /// <returns>DISJOINT, CONTAINS, or INTERSECTS (not WITHIN)</returns>
        protected override SpatialRelation RelateRectanglePhase2(Rectangle r, SpatialRelation bboxSect)
        {
            //Rectangle wraps around the world longitudinally creating a solid band; there are no corners to test intersection
            if (r.GetWidth() == 360)
            {
                return SpatialRelation.INTERSECTS;
            }

            if (inverseCircle != null)
            {
                return inverseCircle.Relate(r).Inverse();
            }

            //if a pole is wrapped, we have a separate algorithm
            if (enclosingBox.GetWidth() == 360)
            {
                return RelateRectangleCircleWrapsPole(r, ctx);
            }

            //This is an optimization path for when there are no dateline or pole issues.
            if (!enclosingBox.GetCrossesDateLine() && !r.GetCrossesDateLine())
            {
                return base.RelateRectanglePhase2(r, bboxSect);
            }

            //do quick check to see if all corners are within this circle for CONTAINS
            int cornersIntersect = NumCornersIntersect(r);
            if (cornersIntersect == 4)
            {
                //ensure r's x axis is within c's.  If it doesn't, r sneaks around the globe to touch the other side (intersect).
                SpatialRelation xIntersect = r.RelateXRange(enclosingBox.GetMinX(), enclosingBox.GetMaxX());
                if (xIntersect == SpatialRelation.WITHIN)
                    return SpatialRelation.CONTAINS;
                return SpatialRelation.INTERSECTS;
            }

            //INTERSECT or DISJOINT ?
            if (cornersIntersect > 0)
                return SpatialRelation.INTERSECTS;

            //Now we check if one of the axis of the circle intersect with r.  If so we have
            // intersection.

            /* x axis intersects  */
            if (r.RelateYRange(GetYAxis(), GetYAxis()).Intersects() // at y vertical
                  && r.RelateXRange(enclosingBox.GetMinX(), enclosingBox.GetMaxX()).Intersects())
                return SpatialRelation.INTERSECTS;

            /* y axis intersects */
            if (r.RelateXRange(GetXAxis(), GetXAxis()).Intersects())
            { // at x horizontal
                double yTop = GetCenter().GetY() + radiusDEG;
                Debug.Assert(yTop <= 90);
                double yBot = GetCenter().GetY() - radiusDEG;
                Debug.Assert(yBot >= -90);
                if (r.RelateYRange(yBot, yTop).Intersects())//back bottom
                    return SpatialRelation.INTERSECTS;
            }

            return SpatialRelation.DISJOINT;
        }
 /// <inheritdoc />
 IAsyncDocumentQuery <T> IFilterDocumentQueryBase <T, IAsyncDocumentQuery <T> > .RelatesToShape(string fieldName, string shapeWkt, SpatialRelation relation, SpatialUnits units, double distanceErrorPct)
 {
     Spatial(fieldName, shapeWkt, relation, units, distanceErrorPct);
     return(this);
 }
Beispiel #29
0
        protected virtual SpatialRelation RelateRectanglePhase2(Rectangle r, SpatialRelation bboxSect, SpatialContext ctx)
        {
            /*
             !! DOES NOT WORK WITH GEO CROSSING DATELINE OR WORLD-WRAP.
             TODO upgrade to handle crossing dateline, but not world-wrap; use some x-shifting code from RectangleImpl.
             */

            //At this point, the only thing we are certain of is that circle is *NOT* WITHIN r, since the bounding box of a
            // circle MUST be within r for the circle to be within r.

            //--Quickly determine if they are DISJOINT or not.
            //see http://stackoverflow.com/questions/401847/circle-rectangle-collision-detection-intersection/1879223#1879223
            double closestX;
            double ctr_x = GetXAxis();
            if (ctr_x < r.GetMinX())
                closestX = r.GetMinX();
            else if (ctr_x > r.GetMaxX())
                closestX = r.GetMaxX();
            else
                closestX = ctr_x;

            double closestY;
            double ctr_y = GetYAxis();
            if (ctr_y < r.GetMinY())
                closestY = r.GetMinY();
            else if (ctr_y > r.GetMaxY())
                closestY = r.GetMaxY();
            else
                closestY = ctr_y;

            //Check if there is an intersection from this circle to closestXY
            bool didContainOnClosestXY = false;
            if (ctr_x == closestX)
            {
                double deltaY = Math.Abs(ctr_y - closestY);
                double distYCirc = (ctr_y < closestY ? enclosingBox.GetMaxY() - ctr_y : ctr_y - enclosingBox.GetMinY());
                if (deltaY > distYCirc)
                    return SpatialRelation.DISJOINT;
            }
            else if (ctr_y == closestY)
            {
                double deltaX = Math.Abs(ctr_x - closestX);
                double distXCirc = (ctr_x < closestX ? enclosingBox.GetMaxX() - ctr_x : ctr_x - enclosingBox.GetMinX());
                if (deltaX > distXCirc)
                    return SpatialRelation.DISJOINT;
            }
            else
            {
                //fallback on more expensive calculation
                didContainOnClosestXY = true;
                if (!Contains(closestX, closestY))
                    return SpatialRelation.DISJOINT;
            }

            //At this point we know that it's *NOT* DISJOINT, so there is some level of intersection. It's *NOT* WITHIN either.
            // The only question left is whether circle CONTAINS r or simply intersects it.

            //If circle contains r, then its bbox MUST also CONTAIN r.
            if (bboxSect != SpatialRelation.CONTAINS)
                return SpatialRelation.INTERSECTS;

            //Find the farthest point of r away from the center of the circle. If that point is contained, then all of r is
            // contained.
            double farthestX = r.GetMaxX() - ctr_x > ctr_x - r.GetMinX() ? r.GetMaxX() : r.GetMinX();
            double farthestY = r.GetMaxY() - ctr_y > ctr_y - r.GetMinY() ? r.GetMaxY() : r.GetMinY();
            if (Contains(farthestX, farthestY))
                return SpatialRelation.CONTAINS;
            return SpatialRelation.INTERSECTS;
        }
Beispiel #30
0
 internal WktCriteria(string shapeWKT, SpatialRelation relation, double distanceErrorPct)
     : base(relation, distanceErrorPct)
 {
     _shapeWKT = shapeWKT;
 }
        private SqlString GetOGCSpatialRelateString(object arg1, object arg2,
                                         SpatialRelation spatialRelation)
        {

            SqlStringBuilder sql = new SqlStringBuilder();
            sql.Add("MDSYS.");
            switch (spatialRelation)
            {
                case SpatialRelation.Intersects:
                    sql.Add("OGC_INTERSECTS");
                    break;
                case SpatialRelation.Contains:
                    sql.Add("OGC_CONTAINS");
                    break;
                case SpatialRelation.Crosses:
                    sql.Add("OGC_CROSS");
                    break;
                case SpatialRelation.Disjoint:
                    sql.Add("OGC_DISJOINT");
                    break;
                case SpatialRelation.Equals:
                    sql.Add("OGC_EQUALS");
                    break;
                case SpatialRelation.Overlaps:
                    sql.Add("OGC_OVERLAP");
                    break;
                case SpatialRelation.Touches:
                    sql.Add("OGC_TOUCH");
                    break;
                case SpatialRelation.Within:
                    sql.Add("OGC_WITHIN");
                    break;
                default:
                    throw new ArgumentException("Usupported SpatialRelation ("
                            + spatialRelation + ").");
            }
            sql.Add("(")
                .Add("MDSYS.ST_GEOMETRY.FROM_SDO_GEOM(")
                    .AddObject(arg1).Add("),").Add(
                    "MDSYS.ST_GEOMETRY.FROM_SDO_GEOM(").AddObject(arg2)
                    .Add(")").Add(")");
            return sql.ToSqlString();

        }
Beispiel #32
0
 public CircleCriteria(double radius, double latitude, double longitude, SpatialUnits?radiusUnits, SpatialRelation relation, double distErrorPercent)
     : base(relation, distErrorPercent)
 {
     _radius      = radius;
     _latitude    = latitude;
     _longitude   = longitude;
     _radiusUnits = radiusUnits;
 }
Beispiel #33
0
 public bool Relates(IGeometry g, SpatialRelation relation)
 {
     return(_shape.Relates(g.GetInternal(), (tkSpatialRelation)relation));
 }
 protected internal override bool Visit(Cell cell)
 {
     //cell.relate is based on the bufferedQueryShape; we need to examine what
     // the relation is against the queryShape
     visitRelation = cell.Shape.Relate(outerInstance.queryShape);
     if (visitRelation == SpatialRelation.WITHIN)
     {
         CollectDocs(inside);
         return false;
     }
     else if (visitRelation == SpatialRelation.DISJOINT)
     {
         CollectDocs(outside);
         return false;
     }
     else if (cell.Level == outerInstance.detailLevel)
     {
         CollectDocs(inside);
         return false;
     }
     return true;
 }
Beispiel #35
0
        /// <summary>
        /// Called after bounding box is intersected.
        /// </summary>
        /// <param name="r"></param>
        /// <param name="bboxSect">INTERSECTS or CONTAINS from enclosingBox's intersection</param>
        /// <returns>DISJOINT, CONTAINS, or INTERSECTS (not WITHIN)</returns>
        protected override SpatialRelation RelateRectanglePhase2(Rectangle r, SpatialRelation bboxSect)
        {
            //Rectangle wraps around the world longitudinally creating a solid band; there are no corners to test intersection
            if (r.GetWidth() == 360)
            {
                return(SpatialRelation.INTERSECTS);
            }

            if (inverseCircle != null)
            {
                return(inverseCircle.Relate(r).Inverse());
            }

            //if a pole is wrapped, we have a separate algorithm
            if (enclosingBox.GetWidth() == 360)
            {
                return(RelateRectangleCircleWrapsPole(r, ctx));
            }

            //This is an optimization path for when there are no dateline or pole issues.
            if (!enclosingBox.GetCrossesDateLine() && !r.GetCrossesDateLine())
            {
                return(base.RelateRectanglePhase2(r, bboxSect));
            }

            //do quick check to see if all corners are within this circle for CONTAINS
            int cornersIntersect = NumCornersIntersect(r);

            if (cornersIntersect == 4)
            {
                //ensure r's x axis is within c's.  If it doesn't, r sneaks around the globe to touch the other side (intersect).
                SpatialRelation xIntersect = r.RelateXRange(enclosingBox.GetMinX(), enclosingBox.GetMaxX());
                if (xIntersect == SpatialRelation.WITHIN)
                {
                    return(SpatialRelation.CONTAINS);
                }
                return(SpatialRelation.INTERSECTS);
            }

            //INTERSECT or DISJOINT ?
            if (cornersIntersect > 0)
            {
                return(SpatialRelation.INTERSECTS);
            }

            //Now we check if one of the axis of the circle intersect with r.  If so we have
            // intersection.

            /* x axis intersects  */
            if (r.RelateYRange(GetYAxis(), GetYAxis()).Intersects() &&          // at y vertical
                r.RelateXRange(enclosingBox.GetMinX(), enclosingBox.GetMaxX()).Intersects())
            {
                return(SpatialRelation.INTERSECTS);
            }

            /* y axis intersects */
            if (r.RelateXRange(GetXAxis(), GetXAxis()).Intersects())
            {             // at x horizontal
                double yTop = GetCenter().GetY() + radiusDEG;
                Debug.Assert(yTop <= 90);
                double yBot = GetCenter().GetY() - radiusDEG;
                Debug.Assert(yBot >= -90);
                if (r.RelateYRange(yBot, yTop).Intersects())                //back bottom
                {
                    return(SpatialRelation.INTERSECTS);
                }
            }

            return(SpatialRelation.DISJOINT);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="SpatialRelationCriterion"/> class.
 /// </summary>
 /// <param name="propertyName">Name of the property.</param>
 /// <param name="relation">The relation.</param>
 /// <param name="anotherGeometry">Another geometry.</param>
 public SpatialRelationCriterion(string propertyName, SpatialRelation relation, object anotherGeometry)
 {
     this.propertyName = propertyName;
     this.relation = relation;
     this.anotherGeometry = anotherGeometry;
 }
Beispiel #37
0
 private void RegisterSpatialFunction(SpatialRelation relation)
 {
     RegisterFunction(SpatialDialect.HqlPrefix + relation.ToString(), new SpatialRelationFunction(this, relation));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SpatialRelationProjection"/> class.
 /// </summary>
 /// <param name="propertyName">Name of the property.</param>
 /// <param name="relation">The relation.</param>
 /// <param name="anotherPropertyName">Name of another property.</param>
 public SpatialRelationProjection(string propertyName, SpatialRelation relation, string anotherPropertyName)
     : base(propertyName)
 {
     this.relation = relation;
     this.anotherPropertyName = anotherPropertyName;
 }
        private void AssertIntersect(String msg, SpatialRelation expected, Shape a, Shape b)
        {
            SpatialRelation sect = a.Relate(b, ctx);
            if (sect == expected)
                return;
            if (expected == SpatialRelation.WITHIN || expected == SpatialRelation.CONTAINS)
            {
                if (a.GetType() == b.GetType()) // they are the same shape type
                    Assert.Equal(/*msg,*/ a, b);
                else
                {
                    //they are effectively points or lines that are the same location
                    Assert.True(!a.HasArea(), msg);
                    Assert.True(!b.HasArea(), msg);

                    Rectangle aBBox = a.GetBoundingBox();
                    Rectangle bBBox = b.GetBoundingBox();
                    if (aBBox.GetHeight() == 0 && bBBox.GetHeight() == 0
                        && (aBBox.GetMaxY() == 90 && bBBox.GetMaxY() == 90
                            || aBBox.GetMinY() == -90 && bBBox.GetMinY() == -90))
                    {
                        ; //== a point at the pole
                    }
                    else
                    {
                        Assert.Equal( /*msg,*/ aBBox, bBBox);
                    }
                }
            }
            else
            {
                Assert.Equal(/*msg,*/ expected, sect);
            }
        }
Beispiel #40
0
 public QuadCell(QuadPrefixTree _enclosing, string token, SpatialRelation shapeRel
     )
     : base(token)
 {
     this._enclosing = _enclosing;
     this.shapeRel = shapeRel;
 }
 protected void AssertRelation(String msg, SpatialRelation expected, Shape a, Shape b)
 {
     msg = a + " intersect " + b; //use different msg
     AssertIntersect(msg, expected, a, b);
     //check flipped a & b w/ transpose(), while we're at it
     AssertIntersect("(transposed) " + msg, expected.Transpose(), b, a);
 }
 public void RegisterSpatialFunction(SpatialRelation relation)
 {
     adaptor.RegisterFunction(SpatialDialect.HqlPrefix + relation.ToString(), new SpatialRelationFunction(this, relation));
 }
Beispiel #43
0
            protected override void OnAssertFail(/*AssertionError*/ Exception e, /*Circle*/ IShape shape, IRectangle r, SpatialRelation ic)
            {
                ICircle s = shape as ICircle;
                //Check if the circle's edge appears to coincide with the shape.
                double radius = s.Radius;

                if (radius == 180)
                {
                    throw e;//if this happens, then probably a bug
                }
                if (radius == 0)
                {
                    IPoint p = s.Center;
                    //if touches a side then don't throw
                    if (p.X == r.MinX || p.X == r.MaxX ||
                        p.Y == r.MinY || p.Y == r.MaxY)
                    {
                        return;
                    }
                    throw e;
                }
                double eps = 0.0000001;

                s.Reset(s.Center.X, s.Center.Y, radius - eps);
                SpatialRelation rel1 = s.Relate(r);

                s.Reset(s.Center.X, s.Center.Y, radius + eps);
                SpatialRelation rel2 = s.Relate(r);

                if (rel1 == rel2)
                {
                    throw e;
                }
                s.Reset(s.Center.X, s.Center.Y, radius);//reset
                Console.WriteLine("Seed " + /*getContext().GetRunnerSeedAsString() +*/ ": Hid assertion due to ambiguous edge touch: " + s + " " + r);
            }
		public SqlString GetSpatialRelationString(object geometry, SpatialRelation relation, object anotherGeometry, bool criterion)
		{
			return worker.GetSpatialRelationString(geometry, relation, anotherGeometry, criterion);
		}
Beispiel #45
0
 public QuadCell(QuadPrefixTree outerInstance, string token, SpatialRelation shapeRel)
     : base(outerInstance, token)
 {
     this.m_shapeRel = shapeRel;
 }
 private void RegisterSpatialFunction(SpatialRelation relation)
 {
     RegisterFunction(SpatialDialect.HqlPrefix + relation.ToString(), new SpatialRelationFunction(this, relation));
 }
        private SqlString GetNativeSpatialRelateString(object geometry, object anotherGeometry, SpatialRelation realtion)
        {
            SqlStringBuilder sql = new SqlStringBuilder();
            string mask = "";
            bool negate = false;
            switch (realtion)
            {
                case SpatialRelation.Intersects:
                    mask = "ANYINTERACT"; // OGC Compliance verified
                    break;
                case SpatialRelation.Contains:
                    mask = "CONTAINS+COVERS";
                    break;
                case SpatialRelation.Crosses:
                    throw new NotImplementedException(
                            "Oracle Spatial does't have equivalent CROSSES relationship");
                case SpatialRelation.Disjoint:
                    mask = "ANYINTERACT";
                    negate = true;
                    break;
                case SpatialRelation.Equals:
                    mask = "EQUAL";
                    break;
                case SpatialRelation.Overlaps:
                    mask = "OVERLAPBDYDISJOINT+OVERLAPBDYINTERSECT";
                    break;
                case SpatialRelation.Touches:
                    mask = "TOUCH";
                    break;
                case SpatialRelation.Within:
                    mask = "INSIDE+COVEREDBY";
                    break;
                default:
                    throw new ApplicationException(
                            "Undefined SpatialRelation passed :" + realtion);
            }

            if (negate)
            {
                sql.Add("CASE WHEN ");
            }
            sql.Add("SDO_RELATE(")
                    .AddObject(geometry)
                    .Add(",")
                    .AddObject(anotherGeometry)
                    .Add(",'mask=" + mask + "') ");

            if (negate)
            {
                sql.Add(" = 'TRUE' THEN 'FALSE' ELSE 'TRUE' END");
            }
            return sql.ToSqlString();
        }