Package com.spatial4j.core.shape

Examples of com.spatial4j.core.shape.Point


    for (Field field : fields) {
      doc.add(field);
    }
    addDocument(doc);

    Point upperleft = ctx.makePoint(-122.88, 48.54);
    Point lowerright = ctx.makePoint(-122.82, 48.62);

    Query query = strategy.makeQuery(new SpatialArgs(SpatialOperation.Intersects, ctx.makeRectangle(upperleft, lowerright)));

    commit();
View Full Code Here


  private List<Node> query$(IndexReader indexReader, Shape shape, int limit, SpatialOperation operation) throws IOException {
    if (limit <= 0)
      limit = MAX_N;

    IndexSearcher indexSearcher = new IndexSearcher(indexReader);
    Point pt = shape.getCenter();
    ValueSource valueSource = strategy.makeDistanceValueSource(pt);// the
                                    // distance
                                    // (in
                                    // degrees)
    Sort distSort = new Sort(valueSource.getSortField(false))
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

        return Arrays.copyOf(values, 2, Double[].class);
    }

    private static Double[] pointFromString(String value) {
        try {
            Point point = (Point)SPATIAL_CONTEXT.readShapeFromWkt(value);
            return new Double[] {point.getX(), point.getY()};
        } catch (ParseException e) {
            throw new IllegalArgumentException(String.format(
                    "Cannot convert \"%s\" to geo_point", value), e);
        }
    }
View Full Code Here

*/
public class ShapeBuilderTests extends ElasticsearchTestCase {

    @Test
    public void testNewPoint() {
        Point point = ShapeBuilder.newPoint(-100, 45).build();
        assertEquals(-100D, point.getX(), 0.0d);
        assertEquals(45D, point.getY(), 0.0d);
    }
View Full Code Here

        Double lng = 51.0;
        GeoPoint point = new GeoPoint(lat, lng);
        pointMapper.parse(context.createExternalValueContext(point));

        // Let's add a Dummy Shape
        Point shape = ShapeBuilder.newPoint(-100, 45).build();
        shapeMapper.parse(context.createExternalValueContext(shape));

        context = context.createExternalValueContext(generatedValue);

        // Let's add a Original String
View Full Code Here

TOP

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

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.