Package de.fhpotsdam.unfolding.core

Examples of de.fhpotsdam.unfolding.core.Coordinate


      int v = Integer.parseInt("" + s.charAt(i));
      String bv = PApplet.binary(v, 2);
      rowS += bv.charAt(0);
      colS += bv.charAt(1);
    }
    return new Coordinate(PApplet.unbinary(colS), PApplet.unbinary(rowS), s.length());
  }
View Full Code Here


    float wrappedRow = coordinate.row % gridSize;
    while (wrappedRow < 0) {
      wrappedRow += gridSize;
    }

    return new Coordinate(wrappedRow, wrappedColumn, coordinate.zoom);
  }
View Full Code Here

  // TILES --------------------------------------------------------

  public void processQueue() {
    while (pending.size() < max_pending && queue.size() > 0) {
      Coordinate coord = (Coordinate) queue.remove(0);
      TileLoader tileLoader = createTileLoader(coord);
      pending.put(coord, tileLoader);
      new Thread(tileLoader).start();
    }
  }
View Full Code Here

      int v = Integer.parseInt("" + s.charAt(i));
      String bv = PApplet.binary(v, 2);
      rowS += bv.charAt(0);
      colS += bv.charAt(1);
    }
    return new Coordinate(PApplet.unbinary(colS), PApplet.unbinary(rowS), s.length());
  }
View Full Code Here

      int v = Integer.parseInt("" + s.charAt(i));
      String bv = PApplet.binary(v, 2);
      rowS += bv.charAt(0);
      colS += bv.charAt(1);
    }
    return new Coordinate(PApplet.unbinary(colS), PApplet.unbinary(rowS), s.length());
  }
View Full Code Here

    return xyz;
  }

  // Location (instead of innerObj) methods ---------------
  public Location getLocationFromInnerObjectPosition(float x, float y) {
    Coordinate coord = getCoordinateFromInnerPosition(x, y);
    return provider.coordinateLocation(coord);
  }
View Full Code Here

    float br[] = new float[3];
    m.mult(new float[] { TILE_WIDTH, TILE_HEIGHT, 0 }, br);

    float col = (x - tl[0]) / (br[0] - tl[0]);
    float row = (y - tl[1]) / (br[1] - tl[1]);
    Coordinate coord = new Coordinate(row, col, 0);
    return coord;
  }
View Full Code Here

      return getLocationFromInnerObjectPosition(innerObjectXY[0], innerObjectXY[1]);
    }
  }

  public float[] getInnerObjectFromLocation(Location location) {
    Coordinate coord = provider.locationCoordinate(location).zoomTo(0);
    return new float[] { coord.column * TILE_WIDTH, coord.row * TILE_HEIGHT, 0 };

    // PMatrix3D m = new PMatrix3D();
    // Coordinate coord = provider.locationCoordinate(location).zoomTo(0);
    // float[] out = new float[3];
View Full Code Here

    }

    Vector visibleKeys = getVisibleKeys(pg);

    if (visibleKeys.size() > 0) {
      Coordinate previous = (Coordinate) visibleKeys.get(0);
      pg.pushMatrix();
      pg.scale(1.0f / PApplet.pow(2, previous.zoom));

      for (int i = 0; i < visibleKeys.size(); i++) {
        Coordinate coord = (Coordinate) visibleKeys.get(i);
        if (coord.zoom != previous.zoom) {
          pg.popMatrix();
          pg.pushMatrix();
          pg.scale(1.0f / PApplet.pow(2, coord.zoom));
        }
View Full Code Here

      float[] innerTL = getInnerObjectFromObjectPosition(0, 0);
      float[] innerTR = getInnerObjectFromObjectPosition(getWidth(), 0);
      float[] innerBR = getInnerObjectFromObjectPosition(getWidth(), getHeight());
      float[] innerBL = getInnerObjectFromObjectPosition(0, getHeight());

      Coordinate coordTL = getCoordinateFromInnerPosition(innerTL[0], innerTL[1]).zoomTo(zoomLevel);
      Coordinate coordTR = getCoordinateFromInnerPosition(innerTR[0], innerTR[1]).zoomTo(zoomLevel);
      Coordinate coordBR = getCoordinateFromInnerPosition(innerBR[0], innerBR[1]).zoomTo(zoomLevel);
      Coordinate coordBL = getCoordinateFromInnerPosition(innerBL[0], innerBL[1]).zoomTo(zoomLevel);

      minCol = (int) PApplet.min(new float[] { coordTL.column, coordTR.column, coordBR.column, coordBL.column });
      maxCol = (int) PApplet.max(new float[] { coordTL.column, coordTR.column, coordBR.column, coordBL.column });
      minRow = (int) PApplet.min(new float[] { coordTL.row, coordTR.row, coordBR.row, coordBL.row });
      maxRow = (int) PApplet.max(new float[] { coordTL.row, coordTR.row, coordBR.row, coordBL.row });
    }

    // Add tile padding (to pre-load, and because we might be zooming out between zoom levels)
    minCol -= grid_padding;
    minRow -= grid_padding;
    maxCol += grid_padding;
    maxRow += grid_padding;

    // log.debug("getVisibleKeys: " + minCol + "," + maxCol + "; " + minRow + "," + maxRow);
    // PApplet.println("getVisibleKeys: " + minCol + "," + maxCol + "; " + minRow + "," + maxRow);

    // we don't wrap around the world yet, so:
    int numberTiles = (int) UnfoldingMap.getScaleFromZoom(zoomLevel);
    minCol = PApplet.constrain(minCol, 0, numberTiles);
    maxCol = PApplet.constrain(maxCol, 0, numberTiles);
    minRow = PApplet.constrain(minRow, 0, numberTiles);
    maxRow = PApplet.constrain(maxRow, 0, numberTiles);

    // grab coords for visible tiles
    for (int col = minCol; col <= maxCol; col++) {
      for (int row = minRow; row <= maxRow; row++) {

        // source coordinate wraps around the world:
        Coordinate coord = provider.sourceCoordinate(new Coordinate(row, col, zoomLevel));
        // make sure we still have ints:
        coord.roundValues();

        // keep this for later:
        visibleKeys.add(coord);

        if (!images.containsKey(coord)) {
          // fetch it if we don't have it
          grabTile(coord);

          // see if we have a parent coord for this tile?
          boolean gotParent = false;
          for (int i = (int) coord.zoom; i > 0; i--) {
            Coordinate zoomed = coord.zoomTo(i).container();
            zoomed.roundValues();
            if (images.containsKey(zoomed)) {
              visibleKeys.add(zoomed);
              gotParent = true;
              break;
            }
          }

          // or if we have any of the children
          if (!gotParent) {
            Coordinate zoomed = coord.zoomBy(1).container();
            Coordinate[] kids = { zoomed, zoomed.right(), zoomed.down(), zoomed.right().down() };
            for (int i = 0; i < kids.length; i++) {
              zoomed = kids[i];
              // make sure we still have ints:
              zoomed.row = PApplet.round(zoomed.row);
              zoomed.column = PApplet.round(zoomed.column);
              zoomed.zoom = PApplet.round(zoomed.zoom);
              if (images.containsKey(zoomed)) {
                visibleKeys.add(zoomed);
              }
            }
          }

        }

      } // rows
    } // columns

    // sort by zoom so we draw small zoom levels (big tiles) first:
    Collections.sort(visibleKeys, zoomComparator);

    // stop fetching things we can't see:
    // (visibleKeys also has the parents and children, if needed, but that
    // shouldn't matter)
    queue.retainAll(visibleKeys);

    // sort what's left by distance from center:
    queueSorter.setCenter(new Coordinate((minRow + maxRow) / 2.0f, (minCol + maxCol) / 2.0f, zoomLevel));
    Collections.sort(queue, queueSorter);

    // load up to 4 more things:
    processQueue();
View Full Code Here

TOP

Related Classes of de.fhpotsdam.unfolding.core.Coordinate

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.