Package com.spatial4j.core.shape

Examples of com.spatial4j.core.shape.SpatialRelation


      biasContainsThenWithin = containsThenWithin;
    }

    @Override
    public SpatialRelation relate(Shape other) {
      SpatialRelation r = relateApprox(other);
      if (r != INTERSECTS && !(r == WITHIN && biasContainsThenWithin))
        return r;
      //See if the correct answer is actually Contains, when the indexed shapes are adjacent,
      // creating a larger shape that contains the input shape.
      Rectangle oRect = (Rectangle)other;
View Full Code Here


    double w = levelW[level] / 2;
    double h = levelH[level] / 2;

    int strlen = str.length();
    Rectangle rectangle = 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(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(str.toString(),v.transpose()));
      } else {
        build(cx, cy, nextLevel, matches, str, shape, maxLevel);
      }
    }
    str.setLength(strlen);
View Full Code Here

    }

    //TODO change API to return a filtering iterator
    List<Cell> copy = new ArrayList<Cell>(cells.size());
    for (Cell cell : cells) {
      SpatialRelation rel = cell.getShape().relate(shapeFilter);
      if (rel == SpatialRelation.DISJOINT)
        continue;
      cell.shapeRel = rel;
      if (rel == SpatialRelation.WITHIN)
        cell.setLeaf();
View Full Code Here

      biasContainsThenWithin = containsThenWithin;
    }

    @Override
    public SpatialRelation relate(Shape other) {
      SpatialRelation r = relateApprox(other);
      if (r == CONTAINS)
        return r;
      if (r == DISJOINT)
        return r;
      if (r == WITHIN && !biasContainsThenWithin)
View Full Code Here

    }

    //TODO change API to return a filtering iterator
    List<Node> copy = new ArrayList<Node>(cells.size());
    for (Node cell : cells) {
      SpatialRelation rel = cell.getShape().relate(shapeFilter);
      if (rel == SpatialRelation.DISJOINT)
        continue;
      cell.shapeRel = rel;
      if (rel == SpatialRelation.WITHIN)
        cell.setLeaf();
View Full Code Here

    double w = levelW[level] / 2;
    double h = levelH[level] / 2;

    int strlen = str.length();
    Rectangle rectangle = 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(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(str.toString(),v.transpose()));
      } else {
        build(cx, cy, nextLevel, matches, str, shape, maxLevel);
      }
    }
    str.setLength(strlen);
View Full Code Here

      return shape;
    }

    @Override
    public SpatialRelation relate(Shape other) {
      SpatialRelation r = relateApprox(other);
      if (r == DISJOINT)
        return r;
      if (r == CONTAINS)
        return r;
      if (r == WITHIN && !biasContainsThenWithin)
View Full Code Here

      biasContainsThenWithin = containsThenWithin;
    }

    @Override
    public SpatialRelation relate(Shape other) {
      SpatialRelation r = relateApprox(other);
      if (r != INTERSECTS && !(r == WITHIN && biasContainsThenWithin))
        return r;
      //See if the correct answer is actually Contains, when the indexed shapes are adjacent,
      // creating a larger shape that contains the input shape.
      Rectangle oRect = (Rectangle)other;
View Full Code Here

      biasContainsThenWithin = containsThenWithin;
    }

    @Override
    public SpatialRelation relate(Shape other) {
      SpatialRelation r = relateApprox(other);
      if (r != INTERSECTS)
        return r;
      //See if the correct answer is actually Contains
      Rectangle oRect = (Rectangle)other;
      boolean pairTouches = shape1.relate(shape2).intersects();
View Full Code Here

    throw new UnsupportedOperationException();
  }

  public SpatialRelation relate(Rectangle r) {
    //Check BBox for disjoint & within.
    SpatialRelation bboxR = bbox.relate(r);
    if (bboxR == DISJOINT || bboxR == WITHIN)
      return bboxR;
    //Either CONTAINS, INTERSECTS, or DISJOINT

    Point scratch = new PointImpl(0, 0, null);
    Point prC = r.getCenter();
    SpatialRelation result = linePrimary.relate(r, prC, scratch);
    if (result == DISJOINT)
      return DISJOINT;
    SpatialRelation resultOpp = linePerp.relate(r, prC, scratch);
    if (resultOpp == DISJOINT)
      return DISJOINT;
    if (result == resultOpp)//either CONTAINS or INTERSECTS
      return result;
    return INTERSECTS;
View Full Code Here

TOP

Related Classes of com.spatial4j.core.shape.SpatialRelation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.