Exemplo n.º 1
0
  public static String getPoiStringWithoutType(Amenity amenity, boolean en) {
    String type = SpecialPhrases.getSpecialPhrase(amenity.getSubType());
    String n = amenity.getName(en);

    if (type == null) {
      type = amenity.getSubType();
    }
    if (n.indexOf(type) != -1) {
      // type is contained in name e.g.
      // n = "Bakery the Corner"
      // type = "Bakery"
      // no need to repeat this
      return n;
    }
    if (n.length() == 0) {
      return type;
    }
    return type + " " + n; // $NON-NLS-1$
  }
  @Override
  public Node loadNode(Amenity n) {
    if (n.getId() % 2 == 1) {
      // that's way id
      return null;
    }
    long nodeId = n.getId() >> 1;

    //		EntityId id = new Entity.EntityId(EntityType.NODE, nodeId);
    Node entity = new Node(n.getLocation().getLatitude(), n.getLocation().getLongitude(), nodeId);

    Map<AmenityType, Map<String, String>> typeNameToTagVal =
        MapRenderingTypes.getDefault().getAmenityTypeNameToTagVal();
    AmenityType type = n.getType();
    String tag = type.getDefaultTag();
    String subType = n.getSubType();
    String val = subType;
    if (typeNameToTagVal.containsKey(type)) {
      Map<String, String> map = typeNameToTagVal.get(type);
      if (map.containsKey(subType)) {
        String res = map.get(subType);
        if (res != null) {
          int i = res.indexOf(' ');
          if (i != -1) {
            tag = res.substring(0, i);
            val = res.substring(i + 1);
          } else {
            tag = res;
          }
        }
      }
    }
    entity.putTag(tag, val);
    entity.putTag(OSMTagKey.NAME.getValue(), n.getName());
    entity.putTag(OSMTagKey.OPENING_HOURS.getValue(), n.getOpeningHours());

    // check whether this is node (because id of node could be the same as relation)
    if (entity != null && MapUtils.getDistance(entity.getLatLon(), n.getLocation()) < 50) {
      return entity;
    }
    return null;
  }
Exemplo n.º 3
0
  @Override
  public void onDraw(Canvas canvas, RectF latLonBounds, RectF tilesRect, DrawSettings nightMode) {

    if (view.getZoom() >= startZoom) {
      objects.clear();
      resourceManager.searchAmenitiesAsync(
          latLonBounds.top,
          latLonBounds.left,
          latLonBounds.bottom,
          latLonBounds.right,
          view.getZoom(),
          filter,
          objects);
      int r = getRadiusPoi(view.getZoom());
      for (Amenity o : objects) {
        int x =
            view.getRotatedMapXForPoint(
                o.getLocation().getLatitude(), o.getLocation().getLongitude());
        int y =
            view.getRotatedMapYForPoint(
                o.getLocation().getLatitude(), o.getLocation().getLongitude());
        canvas.drawCircle(x, y, r, pointAltUI);
        canvas.drawCircle(x, y, r, point);
        String id = null;
        if (RenderingIcons.containsIcon(o.getSubType())) {
          id = o.getSubType();
        } else if (RenderingIcons.containsIcon(
            o.getType().getDefaultTag() + "_" + o.getSubType())) {
          id = o.getType().getDefaultTag() + "_" + o.getSubType();
        }
        if (id != null) {
          Bitmap bmp = RenderingIcons.getIcon(view.getContext(), id);
          if (bmp != null) {
            canvas.drawBitmap(bmp, x - bmp.getWidth() / 2, y - bmp.getHeight() / 2, paintIcon);
          }
        }
      }

      if (view.getSettings().SHOW_POI_LABEL.get()) {
        TIntHashSet set = new TIntHashSet();
        for (Amenity o : objects) {
          int x =
              view.getRotatedMapXForPoint(
                  o.getLocation().getLatitude(), o.getLocation().getLongitude());
          int y =
              view.getRotatedMapYForPoint(
                  o.getLocation().getLatitude(), o.getLocation().getLongitude());
          int tx = view.getMapXForPoint(o.getLocation().getLongitude());
          int ty = view.getMapYForPoint(o.getLocation().getLatitude());
          String name = o.getName(view.getSettings().USE_ENGLISH_NAMES.get());
          if (name != null && name.length() > 0) {
            int lines = 0;
            while (lines < TEXT_LINES) {
              if (set.contains(division(tx, ty, 0, lines))
                  || set.contains(division(tx, ty, -1, lines))
                  || set.contains(division(tx, ty, +1, lines))) {
                break;
              }
              lines++;
            }
            if (lines == 0) {
              // drawWrappedText(canvas, "...", paintTextIcon.getTextSize(), x, y + r + 2 +
              // paintTextIcon.getTextSize() / 2, 1);
            } else {
              drawWrappedText(
                  canvas,
                  name,
                  paintTextIcon.getTextSize(),
                  x,
                  y + r + 2 + paintTextIcon.getTextSize() / 2,
                  lines);
              while (lines > 0) {
                set.add(division(tx, ty, 1, lines - 1));
                set.add(division(tx, ty, -1, lines - 1));
                set.add(division(tx, ty, 0, lines - 1));
                lines--;
              }
            }
          }
        }
      }
    }
  }