Beispiel #1
0
  @Override
  public void draw(BoundingBox boundingBox, byte zoomLevel, Canvas canvas, Point topLeftPoint) {
    long tileLeft = MercatorProjection.longitudeToTileX(boundingBox.minLongitude, zoomLevel);
    long tileTop = MercatorProjection.latitudeToTileY(boundingBox.maxLatitude, zoomLevel);
    long tileRight = MercatorProjection.longitudeToTileX(boundingBox.maxLongitude, zoomLevel);
    long tileBottom = MercatorProjection.latitudeToTileY(boundingBox.minLatitude, zoomLevel);

    int tileSize = this.displayModel.getTileSize();
    int pixelX1 = (int) (MercatorProjection.tileToPixel(tileLeft, tileSize) - topLeftPoint.x);
    int pixelY1 = (int) (MercatorProjection.tileToPixel(tileTop, tileSize) - topLeftPoint.y);
    int pixelX2 =
        (int) (MercatorProjection.tileToPixel(tileRight, tileSize) - topLeftPoint.x + tileSize);
    int pixelY2 =
        (int) (MercatorProjection.tileToPixel(tileBottom, tileSize) - topLeftPoint.y + tileSize);

    for (int lineX = pixelX1; lineX <= pixelX2 + 1; lineX += tileSize) {
      canvas.drawLine(lineX, pixelY1, lineX, pixelY2, this.paintBack);
    }

    for (int lineY = pixelY1; lineY <= pixelY2 + 1; lineY += tileSize) {
      canvas.drawLine(pixelX1, lineY, pixelX2, lineY, this.paintBack);
    }

    for (int lineX = pixelX1; lineX <= pixelX2 + 1; lineX += tileSize) {
      canvas.drawLine(lineX, pixelY1, lineX, pixelY2, this.paintFront);
    }

    for (int lineY = pixelY1; lineY <= pixelY2 + 1; lineY += tileSize) {
      canvas.drawLine(pixelX1, lineY, pixelX2, lineY, this.paintFront);
    }
  }
  @Test
  public void executeQueryTest() {
    MapFile mapFile = new MapFile(MAP_FILE);

    MapFileInfo mapFileInfo = mapFile.getMapFileInfo();
    Assert.assertTrue(mapFileInfo.debugFile);

    for (byte zoomLevel = ZOOM_LEVEL_MIN; zoomLevel <= ZOOM_LEVEL_MAX; ++zoomLevel) {
      int tileX = MercatorProjection.longitudeToTileX(0.04, zoomLevel);
      int tileY = MercatorProjection.latitudeToTileY(0.04, zoomLevel);
      Tile tile = new Tile(tileX, tileY, zoomLevel, 256);

      MapReadResult mapReadResult = mapFile.readMapData(tile);

      Assert.assertEquals(1, mapReadResult.pointOfInterests.size());
      Assert.assertEquals(1, mapReadResult.ways.size());

      checkPointOfInterest(mapReadResult.pointOfInterests.get(0));
      checkWay(mapReadResult.ways.get(0));
    }

    mapFile.close();
  }