Package org.hibernate.search.spatial.impl

Examples of org.hibernate.search.spatial.impl.Rectangle


*/
public class RectangleTest {
  @Test
  public void boundingBoxTest() {
    Point center = Point.fromDegrees( 45, 4 );
    Rectangle rectangle = Rectangle.fromBoundingCircle( center, 50 );

    Assert.assertEquals( 44.550339, rectangle.getLowerLeft().getLatitude(), 0.000001d );
    Assert.assertEquals( 3.359047, rectangle.getLowerLeft().getLongitude(), 0.000001d );
    Assert.assertEquals( 45.449660, rectangle.getUpperRight().getLatitude(), 0.000001d );
    Assert.assertEquals( 4.640952, rectangle.getUpperRight().getLongitude(), 0.000001d );
  }
View Full Code Here


      Random random = new Random( 42 );

      for ( int i = 0; i < iterations; i++ ) {
        Point center = Point.fromDegrees( random.nextDouble() * 2 + 44 , random.nextDouble() * 2 + 3 );
        double radius = 25.0d;
        Rectangle boundingBox = Rectangle.fromBoundingCircle( center, radius );

        query = queryBuilder.bool()
            .must(
                queryBuilder.range()
                    .onField( "latitude" )
                    .from( boundingBox.getLowerLeft().getLatitude() )
                    .to( boundingBox.getUpperRight().getLatitude() )
                    .createQuery()
            )
            .must(
                queryBuilder.range()
                    .onField( "longitude" )
                    .from( boundingBox.getLowerLeft().getLongitude() )
                    .to( boundingBox.getUpperRight().getLongitude() )
                    .createQuery()
            )
            .createQuery();
        hibQuery = fullTextSession.createFullTextQuery( query, POI.class );
        hibQuery.setProjection( "id", "name" );
        startTime = System.nanoTime();
        try {
          doubleRangeDocsFetched += hibQuery.getResultSize();
        }
        finally {
          endTime = System.nanoTime();
        }
        duration = endTime - startTime;
        if ( i > warmUp ) {
          doubleRangeTotalDuration += duration;
        }
        session.clear();

        query = queryBuilder.bool()
            .must(
                queryBuilder.range()
                    .onField( "latitude" )
                    .from( boundingBox.getLowerLeft().getLatitude() )
                    .to( boundingBox.getUpperRight().getLatitude() )
                    .createQuery()
            )
            .must(
                queryBuilder.range()
                    .onField( "longitude" )
                    .from( boundingBox.getLowerLeft().getLongitude() )
                    .to( boundingBox.getUpperRight().getLongitude() )
                    .createQuery()
            )
            .createQuery();
        org.apache.lucene.search.Query filteredQuery = new ConstantScoreQuery(
            SpatialQueryBuilderFromCoordinates.buildDistanceFilter(
View Full Code Here

TOP

Related Classes of org.hibernate.search.spatial.impl.Rectangle

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.