How to use the viewport-mercator-project.projectFlat function in viewport-mercator-project

To help you get started, we’ve selected a few viewport-mercator-project examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github uber / deck.gl / src / core / lib / viewport-transition-utils.js View on Github external
Number.isFinite(endViewport[key]);
  }

  const viewport = {};

  // TODO: add this as an option for applications.
  const rho = 1.414;

  const startZoom = startViewport.zoom;
  const startCenter = [startViewport.longitude, startViewport.latitude];
  const startScale = zoomToScale(startZoom);
  const endZoom = endViewport.zoom;
  const endCenter = [endViewport.longitude, endViewport.latitude];
  const scale = zoomToScale(endZoom - startZoom);

  const startCenterXY = new Vector2(projectFlat(startCenter, startScale));
  const endCenterXY = new Vector2(projectFlat(endCenter, startScale));
  const uDelta = endCenterXY.subtract(startCenterXY);

  const w0 = Math.max(startViewport.width, startViewport.height);
  const w1 = w0 / scale;
  const u1 = Math.sqrt((uDelta.x * uDelta.x) + (uDelta.y * uDelta.y));
  // u0 is treated as '0' in Eq (9).

  // Linearly interpolate 'bearing' and 'pitch' if exist.
  for (const key of ['bearing', 'pitch']) {
    if (Number.isFinite(startViewport[key])) {
      assert(Number.isFinite(endViewport[key]));
      viewport[key] = lerp(startViewport[key], endViewport[key], t);
    }
  }
github uber / deck.gl / src / core / lib / viewport-transition-utils.js View on Github external
}

  const viewport = {};

  // TODO: add this as an option for applications.
  const rho = 1.414;

  const startZoom = startViewport.zoom;
  const startCenter = [startViewport.longitude, startViewport.latitude];
  const startScale = zoomToScale(startZoom);
  const endZoom = endViewport.zoom;
  const endCenter = [endViewport.longitude, endViewport.latitude];
  const scale = zoomToScale(endZoom - startZoom);

  const startCenterXY = new Vector2(projectFlat(startCenter, startScale));
  const endCenterXY = new Vector2(projectFlat(endCenter, startScale));
  const uDelta = endCenterXY.subtract(startCenterXY);

  const w0 = Math.max(startViewport.width, startViewport.height);
  const w1 = w0 / scale;
  const u1 = Math.sqrt((uDelta.x * uDelta.x) + (uDelta.y * uDelta.y));
  // u0 is treated as '0' in Eq (9).

  // Linearly interpolate 'bearing' and 'pitch' if exist.
  for (const key of ['bearing', 'pitch']) {
    if (Number.isFinite(startViewport[key])) {
      assert(Number.isFinite(endViewport[key]));
      viewport[key] = lerp(startViewport[key], endViewport[key], t);
    }
  }

  // If change in center is too small, do linear interpolaiton.