Ejemplo n.º 1
0
    @Override
    public String toString() {
      StringBuilder bld = new StringBuilder();
      if (building != null) {
        bld.append(building.getName());
      }
      if (street != null) {
        bld.append(" str. ").append(street.getName()).append(" city ").append(city.getName());
      } else if (streetName != null) {
        bld.append(" str. ").append(streetName);
      } else if (city != null) {
        bld.append(" city ").append(city.getName());
      }
      if (connectionPoint != null && searchPoint != null) {

        bld.append(" dist=").append((int) getDistance());
      }
      return bld.toString();
    }
Ejemplo n.º 2
0
 @Override
 protected void writeBuilding(Set<Long> streetId, Building building) throws SQLException {
   super.writeBuilding(streetId, building);
   addressBuildingLocalSet.add(building.getId());
 }
Ejemplo n.º 3
0
  private List<GeocodingResult> loadStreetBuildings(
      final GeocodingResult road, BinaryMapIndexReader reader, GeocodingResult street)
      throws IOException {
    final List<GeocodingResult> streetBuildings = new ArrayList<GeocodingResult>();
    reader.preloadBuildings(street.street, null);
    log.info(
        "Preload buildings "
            + street.street.getName()
            + " "
            + street.city.getName()
            + " "
            + street.street.getId());
    for (Building b : street.street.getBuildings()) {
      if (b.getLatLon2() != null) {
        double slat = b.getLocation().getLatitude();
        double slon = b.getLocation().getLongitude();
        double tolat = b.getLatLon2().getLatitude();
        double tolon = b.getLatLon2().getLongitude();
        double coeff =
            MapUtils.getProjectionCoeff(
                road.searchPoint.getLatitude(),
                road.searchPoint.getLongitude(),
                slat,
                slon,
                tolat,
                tolon);
        double plat = slat + (tolat - slat) * coeff;
        double plon = slon + (tolon - slon) * coeff;
        if (MapUtils.getDistance(road.searchPoint, plat, plon) < DISTANCE_BUILDING_PROXIMITY) {
          GeocodingResult bld = new GeocodingResult(street);
          bld.building = b;
          bld.connectionPoint = b.getLocation();
          streetBuildings.add(bld);
          if (!Algorithms.isEmpty(b.getName2())) {
            int fi = Algorithms.extractFirstIntegerNumber(b.getName());
            int si = Algorithms.extractFirstIntegerNumber(b.getName2());
            if (si != 0 && fi != 0) {
              int num = (int) (fi + (si - fi) * coeff);
              BuildingInterpolation type = b.getInterpolationType();
              if (type == BuildingInterpolation.EVEN || type == BuildingInterpolation.ODD) {
                if (num % 2 == (type == BuildingInterpolation.EVEN ? 1 : 0)) {
                  num--;
                }
              } else if (b.getInterpolationInterval() > 0) {
                int intv = b.getInterpolationInterval();
                if ((num - fi) % intv != 0) {
                  num = ((num - fi) / intv) * intv + fi;
                }
              }
              bld.buildingInterpolation = num + "";
            }
          }
        }

      } else if (MapUtils.getDistance(b.getLocation(), road.searchPoint)
          < DISTANCE_BUILDING_PROXIMITY) {
        GeocodingResult bld = new GeocodingResult(street);
        bld.building = b;
        bld.connectionPoint = b.getLocation();
        streetBuildings.add(bld);
      }
    }
    return streetBuildings;
  }