Package org.hibernate.search.spatial.impl

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


  public boolean projectedBoundingBoxCellsIdsInclusionTest( Point center, Double radius) {
    Integer spatialHashLevel = SpatialHelper.findBestSpatialHashLevelForSearchRange( radius );

    List<String> cellsIds = SpatialHelper.getSpatialHashCellsIds( center, radius, spatialHashLevel );

    Point edge = null;

    boolean validated = true;

    for ( int heading = 0; heading < 360; heading++ ) {
      edge = center.computeDestination( radius, heading );
View Full Code Here


      final Integer iterations = 2000;
      final Integer warmUp = 50;
      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(
                new QueryWrapperFilter( query ),
                center,
                radius,
                "location"
            )
        );
        hibQuery = fullTextSession.createFullTextQuery( filteredQuery, POI.class );
        hibQuery.setProjection( "id", "name" );
        startTime = System.nanoTime();
        try {
          distanceDoubleRangeDocsFetched += hibQuery.getResultSize();
        }
        finally {
          endTime = System.nanoTime();
        }
        duration = endTime - startTime;
        if ( i > warmUp ) {
          distanceDoubleRangeTotalDuration += duration;
        }
        rangeResults = hibQuery.list();
        session.clear();

        luceneQuery = SpatialQueryBuilderFromCoordinates.buildSpatialHashQuery( center, radius, "location" );
        hibQuery = fullTextSession.createFullTextQuery( luceneQuery, POI.class );
        hibQuery.setProjection( "id", "name" );
        startTime = System.nanoTime();

        try {
          spatialHashDocsFetched += hibQuery.getResultSize();
        }
        finally {
          endTime = System.nanoTime();
        }
        duration = endTime - startTime;
        if ( i > warmUp ) {
          spatialHashTotalDuration += duration;
        }
        session.clear();

        luceneQuery = SpatialQueryBuilderFromCoordinates.buildSpatialQueryByHash( center, radius, "location" );
        hibQuery = fullTextSession.createFullTextQuery( luceneQuery, POI.class );
        hibQuery.setProjection( "id", "name" );
        startTime = System.nanoTime();

        try {
          spatialDocsFetched += hibQuery.getResultSize();
        }
        finally {
          endTime = System.nanoTime();
        }
        duration = endTime - startTime;
        if ( i > warmUp ) {
          spatialTotalDuration += duration;
        }
        spatialHashResults = hibQuery.list();
        session.clear();

        if ( rangeResults.size() != spatialHashResults.size() ) {
          luceneQuery = SpatialQueryBuilderFromCoordinates.buildDistanceQuery( center, radius, "location" );
          hibQuery = fullTextSession.createFullTextQuery( luceneQuery, POI.class );
          hibQuery.setProjection( "id", "name" );

          System.out.println(
              ">>>>> Different numbers of documents fetched for point (" +
                  Double.toString( center.getLatitude()) +
                  "," +
                  Double.toString( center.getLongitude()) +
                  ") and radius " +
                  Double.toString( radius )
          );
          System.out.println( "Range results : " + rangeResults );
          System.out.println( "Spatial Hash results : " + spatialHashResults );
View Full Code Here

      org.apache.lucene.search.Query luceneQuery;

      FullTextQuery hibQuery;

      Point center = Point.fromDegrees( 46, 4 );
      double radius = 50.0d;

      luceneQuery = SpatialQueryBuilderFromCoordinates.buildSpatialQueryByHash( center, radius, "location" );
      hibQuery = fullTextSession.createFullTextQuery( luceneQuery, POI.class );
      hibQuery.setProjection( "id", "name", "type" );
View Full Code Here

      Double longitude = getLongitude( value );

      if ( ( latitude != null ) && ( longitude != null ) ) {

        if (quadTreeIndex) {
          Point point = Point.fromDegrees( latitude, longitude );

          for ( int i = topQuadTreeLevel; i <= bottomQuadTreeLevel; i++ ) {
            luceneOptions.addFieldToDocument( SpatialHelper.formatFieldName(i, name), SpatialHelper.getQuadTreeCellId(point, i), document );
          }
        }
View Full Code Here

      Double longitude = getLongitude( value );

      if ( ( latitude != null ) && ( longitude != null ) ) {

        if ( spatialHashIndex ) {
          Point point = Point.fromDegrees( latitude, longitude );

          for ( int i = topSpatialHashLevel; i <= bottomSpatialHashLevel; i++ ) {
            luceneOptions.addFieldToDocument( SpatialHelper.formatFieldName( i, name ), SpatialHelper.getSpatialHashCellId( point, i ), document );
          }
        }
View Full Code Here

TOP

Related Classes of org.hibernate.search.spatial.impl.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.