@Override
    protected HttpResult<Iterable<Region>> doInBackground(Void... voids) {
      Projection projection = mapView.getProjection();

      // We want to download data that's off screen so the user can see something while panning
      GeoPoint northWest = projection.fromPixels(-mapView.getWidth(), -mapView.getHeight());
      GeoPoint southEast = projection.fromPixels(2 * mapView.getWidth(), 2 * mapView.getHeight());

      Location northWestLoc = LocationConversionHelper.location(northWest);
      Location southEastLoc = LocationConversionHelper.location(southEast);

      int size = min(mapView.getWidth(), mapView.getHeight()) / settingsHelper.getHeatMapDensity();
      if (size < 1) size = 1;

      int gridSizeX = MAP_BUFFER_SIZE * mapView.getWidth() / size;
      int gridSizeY = MAP_BUFFER_SIZE * mapView.getHeight() / size;

      return averagesDriver.index(
          sensorManager.getVisibleSensor(),
          northWestLoc.getLongitude(),
          northWestLoc.getLatitude(),
          southEastLoc.getLongitude(),
          southEastLoc.getLatitude(),
          gridSizeX,
          gridSizeY);
    }
Пример #2
0
  /**
   * @param canvas
   * @param mapView
   * @param shadow
   * @see TrackingOverlay#draw(Canvas, MapView, boolean)
   */
  private void drawDots(Canvas canvas, MapView mapView, boolean shadow) {
    this.mCanvas = canvas;
    this.mScreenPoint = new Point();
    this.mPrevScreenPoint = new Point();
    mProjection = mapView.getProjection();
    mTopLeft = mProjection.fromPixels(0, 0);
    mBottumRight = mProjection.fromPixels(this.mCanvas.getWidth(), this.mCanvas.getHeight());

    transformSegmentToCanvasDots();

    drawStartStopCircles();

    super.draw(this.mCanvas, mapView, shadow);
    this.mCanvas = null;
  }
  /** Either the Path or the Dots are calculated based on he current track coloring method */
  private synchronized void calculateTrackAsync() {
    GeoPoint oldTopLeft = mGeoTopLeft;
    GeoPoint oldBottumRight = mGeoBottumRight;
    mGeoTopLeft = mProjection.fromPixels(0, 0);
    mGeoBottumRight = mProjection.fromPixels(mWidth, mHeight);

    if (mRequeryFlag
        || oldTopLeft == null
        || oldBottumRight == null
        || mGeoTopLeft.getLatitudeE6() / 100 != oldTopLeft.getLatitudeE6() / 100
        || mGeoTopLeft.getLongitudeE6() / 100 != oldTopLeft.getLongitudeE6() / 100
        || mGeoBottumRight.getLatitudeE6() / 100 != oldBottumRight.getLatitudeE6() / 100
        || mGeoBottumRight.getLongitudeE6() / 100 != oldBottumRight.getLongitudeE6() / 100) {
      calculateStepSize();

      mScreenPoint.x = -1;
      mScreenPoint.y = -1;
      this.mPrevDrawnScreenPoint.x = -1;
      this.mPrevDrawnScreenPoint.y = -1;

      switch (mTrackColoringMethod) {
        case (DRAW_CALCULATED):
        case (DRAW_MEASURED):
        case (DRAW_RED):
        case (DRAW_GREEN):
          calculatePath();
          synchronized (mPath) // Switch the fresh path with the old Path object
          {
            Path oldPath = mPath;
            mPath = mPathCalculation;
            mPathCalculation = oldPath;
          }
          break;
        case (DRAW_DOTS):
          calculateDots();
          synchronized (mDotPath) // Switch the fresh path with the old Path object
          {
            Vector<DotVO> oldDotPath = mDotPath;
            mDotPath = mDotPathCalculation;
            mDotPathCalculation = oldDotPath;
          }
          break;
      }
      mLoggerMap.onDateOverlayChanged();
    }
  }
Пример #4
0
  /**
   * @param canvas
   * @param mapView
   * @param shadow
   * @see TrackingOverlay#draw(Canvas, MapView, boolean)
   */
  public void drawPath(Canvas canvas, MapView mapView, boolean shadow) {
    this.mCanvas = canvas;
    this.mScreenPoint = new Point();
    this.mPrevScreenPoint = new Point();
    mProjection = mapView.getProjection();
    mTopLeft = mProjection.fromPixels(0, 0);
    mBottumRight = mProjection.fromPixels(this.mCanvas.getWidth(), this.mCanvas.getHeight());

    this.mPath.rewind();
    this.mShader = null;
    transformSegmentToPath();

    // Just the rendering bits left to do
    Paint routePaint = new Paint();
    routePaint.setPathEffect(new CornerPathEffect(10));
    //      Log.d( TAG, "Drawing color is "+trackColoringMethod );
    switch (trackColoringMethod) {
      case (DRAW_CALCULATED):
      case (DRAW_MEASURED):
        routePaint.setShader(this.mShader);
        break;
      case (DRAW_RED):
        routePaint.setColor(Color.RED);
        break;
      case (DRAW_GREEN):
      default:
        routePaint.setColor(Color.GREEN);
        break;
    }
    routePaint.setStyle(Paint.Style.STROKE);
    routePaint.setStrokeWidth(8);
    routePaint.setAntiAlias(true);

    this.mCanvas.drawPath(this.mPath, routePaint);

    drawStartStopCircles();

    super.draw(this.mCanvas, mapView, shadow);
    this.mCanvas = null;
  }