Exemple #1
0
 ////////////////////////////////////////////// Working with amenities
 // ////////////////////////////////////////////////
 public List<Amenity> searchAmenities(
     SearchPoiTypeFilter filter,
     double topLatitude,
     double leftLongitude,
     double bottomLatitude,
     double rightLongitude,
     int zoom,
     final ResultMatcher<Amenity> matcher) {
   final List<Amenity> amenities = new ArrayList<Amenity>();
   searchAmenitiesInProgress = true;
   try {
     if (!filter.isEmpty()) {
       for (AmenityIndexRepository index : amenityRepositories.values()) {
         if (index.checkContains(topLatitude, leftLongitude, bottomLatitude, rightLongitude)) {
           List<Amenity> r =
               index.searchAmenities(
                   MapUtils.get31TileNumberY(topLatitude),
                   MapUtils.get31TileNumberX(leftLongitude),
                   MapUtils.get31TileNumberY(bottomLatitude),
                   MapUtils.get31TileNumberX(rightLongitude),
                   zoom,
                   filter,
                   matcher);
           if (r != null) {
             amenities.addAll(r);
           }
         }
       }
     }
   } finally {
     searchAmenitiesInProgress = false;
   }
   return amenities;
 }
Exemple #2
0
  public List<Amenity> searchAmenitiesByName(
      String searchQuery,
      double topLatitude,
      double leftLongitude,
      double bottomLatitude,
      double rightLongitude,
      double lat,
      double lon,
      ResultMatcher<Amenity> matcher) {
    List<Amenity> amenities = new ArrayList<Amenity>();
    List<AmenityIndexRepositoryBinary> list = new ArrayList<AmenityIndexRepositoryBinary>();
    for (AmenityIndexRepository index : amenityRepositories.values()) {
      if (index instanceof AmenityIndexRepositoryBinary) {
        if (index.checkContains(topLatitude, leftLongitude, bottomLatitude, rightLongitude)) {
          if (index.checkContains(lat, lon)) {
            list.add(0, (AmenityIndexRepositoryBinary) index);
          } else {
            list.add((AmenityIndexRepositoryBinary) index);
          }
        }
      }
    }
    //		int left = MapUtils.get31TileNumberX(leftLongitude);
    //		int top = MapUtils.get31TileNumberY(topLatitude);
    //		int right = MapUtils.get31TileNumberX(rightLongitude);
    //		int bottom = MapUtils.get31TileNumberY(bottomLatitude);
    int left = 0;
    int top = 0;
    int right = Integer.MAX_VALUE;
    int bottom = Integer.MAX_VALUE;
    for (AmenityIndexRepositoryBinary index : list) {
      if (matcher != null && matcher.isCancelled()) {
        break;
      }
      List<Amenity> result =
          index.searchAmenitiesByName(
              MapUtils.get31TileNumberX(lon),
              MapUtils.get31TileNumberY(lat),
              left,
              top,
              right,
              bottom,
              searchQuery,
              matcher);
      amenities.addAll(result);
    }

    return amenities;
  }