Package com.spatial4j.core.shape.impl

Examples of com.spatial4j.core.shape.impl.PointImpl


  /** Construct a point. */
  public Point makePoint(double x, double y) {
    verifyX(x);
    verifyY(y);
    return new PointImpl(x, y, this);
  }
View Full Code Here


    Coordinate[] coords = geom.getCoordinates();
    int outside = 0;
    int i = 0;
    for (Coordinate coord : coords) {
      i++;
      SpatialRelation sect = circle.relate(new PointImpl(coord.x, coord.y, ctx));
      if (sect == SpatialRelation.DISJOINT)
        outside++;
      if (i != outside && outside != 0)//short circuit: partially outside, partially inside
        return SpatialRelation.INTERSECTS;
    }
View Full Code Here

  @Test
  public void testMakeRect() {
    //test rectangle constructor
    assertEquals(new RectangleImpl(1,3,2,4, ctx),
        new RectangleImpl(new PointImpl(1,2, ctx),new PointImpl(3,4, ctx), ctx));

    //test ctx.makeRect
    assertEquals(ctx.makeRectangle(1, 3, 2, 4),
        ctx.makeRectangle(ctx.makePoint(1, 2), ctx.makePoint(3, 4)));
  }
View Full Code Here

            Rectangle randomPointSpace = null;
            MAX_TRIES = 1000;//give many attempts
            for (int j = 0; j < MAX_TRIES; j++) {
              Point p;
              if (j < 4) {
                p = new PointImpl(0, 0, ctx);
                InfBufLine.cornerByQuadrant(r, j + 1, p);
              } else {
                if (randomPointSpace == null) {
                  if (pointR == DISJOINT) {
                    randomPointSpace = intersectRects(r,s.getBoundingBox());
View Full Code Here

    assertJtsConsistentRelate(r.getCenter());
  }

  @Test
  public void testRegressions() {
    assertJtsConsistentRelate(new PointImpl(-10, 4, ctx));//PointImpl not JtsPoint, and CONTAINS
    assertJtsConsistentRelate(new PointImpl(-15, -10, ctx));//point on boundary
    assertJtsConsistentRelate(ctx.makeRectangle(135, 180, -10, 10));//180 edge-case
  }
View Full Code Here

    int calcClosestQuad = line.getLinePrimary().quadrant(rect.getCenter());
    assertTrue(farthestDistanceQuads.contains(calcClosestQuad));
  }

  private BufferedLine newRandomLine() {
    Point pA = new PointImpl(randomInt(9), randomInt(9), ctx);
    Point pB = new PointImpl(randomInt(9), randomInt(9), ctx);
    int buf = randomInt(5);
    return new BufferedLine(pA, pB, buf, ctx);
  }
View Full Code Here

    assertEquals(dist, DistanceUtils.degrees2Dist(distDEG, radius), EPS);
    //test across rad & deg
    assertEquals(distDEG,DistanceUtils.toDegrees(distRAD),EPS);
    //test point on bearing
    assertEquals(
        DistanceUtils.pointOnBearingRAD(0, 0, DistanceUtils.dist2Radians(dist, radius), DistanceUtils.DEG_90_AS_RADS, ctx, new PointImpl(0, 0, ctx)).getX(),
        distRAD, 10e-5);
  }
View Full Code Here

    Assert.assertEquals("1854801717", searchResponse.getHits().getAt(0).getId());
    Assert.assertEquals("1854801716", searchResponse.getHits().getAt(1).getId());
  }

  protected ShapeBuilder buildSquareShape(double centerLat, double centerLon, double distanceMeter) {
    Point point = new PointImpl(centerLon, centerLat, SPATIAL_CONTEXT);
    double radius = DistanceUtils.dist2Degrees(distanceMeter / 10E3, DistanceUtils.EARTH_MEAN_RADIUS_KM);
    Rectangle shape = SPATIAL_CONTEXT.makeCircle(point, radius).getBoundingBox();
    return ShapeBuilder.newEnvelope().bottomRight(shape.getMinX(), shape.getMinY()).topLeft(shape.getMaxX(), shape.getMaxY());
  }
View Full Code Here

    // Assert
    Assert.assertEquals(0, searchResponse.getHits().hits().length);
  }

  protected ShapeBuilder buildSquareShape(double centerLat, double centerLon, double distanceMeter) {
    Point point = new PointImpl(centerLon, centerLat, SPATIAL_CONTEXT);
    double radius = DistanceUtils.dist2Degrees(distanceMeter / 10E3, DistanceUtils.EARTH_MEAN_RADIUS_KM);
    Rectangle shape = SPATIAL_CONTEXT.makeCircle(point, radius).getBoundingBox();
    return ShapeBuilder.newEnvelope().bottomRight(shape.getMinX(), shape.getMinY()).topLeft(shape.getMaxX(), shape.getMaxY());
  }
View Full Code Here

                new RectangleImpl(0,10,0,10,SpatialContext.GEO))
                .relation(ShapeRelation.WITHIN);

        // Intersect shapes
        filter = FilterBuilders.geoShapeFilter("location",
                new PointImpl(0, 0, SpatialContext.GEO))
                .relation(ShapeRelation.INTERSECTS);

        // Using pre-indexed shapes
        filter = FilterBuilders.geoShapeFilter("location", "New Zealand", "countries")
                .relation(ShapeRelation.DISJOINT);
View Full Code Here

TOP

Related Classes of com.spatial4j.core.shape.impl.PointImpl

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.