// possibly consider hilbert curve // http://en.wikipedia.org/wiki/Hilbert_curve // http://blog.notdot.net/2009/11/Damn-Cool-Algorithms-Spatial-indexing-with-Quadtrees-and-Hilbert-Curves // if we actually use the range property in the query, this could be useful private void CheckBattenberg( char c, double cx, double cy, int level, IList <Cell> matches, StringBuilder str, IShape shape, int maxLevel) { if (Debugging.AssertsEnabled) { Debugging.Assert(str.Length == level); } double w = levelW[level] / 2; double h = levelH[level] / 2; int strlen = str.Length; IRectangle rectangle = m_ctx.MakeRectangle(cx - w, cx + w, cy - h, cy + h); SpatialRelation v = shape.Relate(rectangle); if (SpatialRelation.CONTAINS == v) { str.Append(c); //str.append(SpatialPrefixGrid.COVER); matches.Add(new QuadCell(this, str.ToString(), v.Transpose())); } else if (SpatialRelation.DISJOINT == v) { // nothing } else // SpatialRelation.WITHIN, SpatialRelation.INTERSECTS { str.Append(c); int nextLevel = level + 1; if (nextLevel >= maxLevel) { //str.append(SpatialPrefixGrid.INTERSECTS); matches.Add(new QuadCell(this, str.ToString(), v.Transpose())); } else { Build(cx, cy, nextLevel, matches, str, shape, maxLevel); } } str.Length = strlen; }
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); }
protected virtual void AssertRelation(string msg, SpatialRelation expected, IShape a, IShape b) { AssertIntersect(msg, expected, a, b); //check flipped a & b w/ transpose(), while we're at it AssertIntersect(msg, expected.Transpose(), b, a); }
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); }