How to use the viewport-mercator-project.pixelsToWorld 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 GlobalFishingWatch / map-client / app / src / map / mapViewportActions.js View on Github external
export const exportNativeViewport = nativeViewport => (dispatch) => {
  const topLeftPx = [0, 0];
  const bottomRightPx = [nativeViewport.width, nativeViewport.height];

  // compute left and right offsets to deal with antimeridian issue
  const topLeftWorld = pixelsToWorld(topLeftPx, nativeViewport.pixelUnprojectionMatrix);
  const bottomRightWorld = pixelsToWorld(bottomRightPx, nativeViewport.pixelUnprojectionMatrix);
  const leftWorldScaled = topLeftWorld[0] / nativeViewport.scale;
  const rightWorldScaled = bottomRightWorld[0] / nativeViewport.scale;

  // lat/lon corners for miniglobe
  const topLeft = nativeViewport.unproject(topLeftPx);
  const bottomRight = nativeViewport.unproject(bottomRightPx);
  const viewportBoundsGeoJSON = {
    type: 'Feature',
    geometry: {
      type: 'Polygon',
      coordinates: [
        [
          [topLeft[0], topLeft[1]],
          [bottomRight[0], topLeft[1]],
          [bottomRight[0], bottomRight[1]],
          [topLeft[0], bottomRight[1]],
github GlobalFishingWatch / map-client / app / src / map / mapViewportActions.js View on Github external
export const exportNativeViewport = nativeViewport => (dispatch) => {
  const topLeftPx = [0, 0];
  const bottomRightPx = [nativeViewport.width, nativeViewport.height];

  // compute left and right offsets to deal with antimeridian issue
  const topLeftWorld = pixelsToWorld(topLeftPx, nativeViewport.pixelUnprojectionMatrix);
  const bottomRightWorld = pixelsToWorld(bottomRightPx, nativeViewport.pixelUnprojectionMatrix);
  const leftWorldScaled = topLeftWorld[0] / nativeViewport.scale;
  const rightWorldScaled = bottomRightWorld[0] / nativeViewport.scale;

  // lat/lon corners for miniglobe
  const topLeft = nativeViewport.unproject(topLeftPx);
  const bottomRight = nativeViewport.unproject(bottomRightPx);
  const viewportBoundsGeoJSON = {
    type: 'Feature',
    geometry: {
      type: 'Polygon',
      coordinates: [
        [
          [topLeft[0], topLeft[1]],
          [bottomRight[0], topLeft[1]],
          [bottomRight[0], bottomRight[1]],
github uber / deck.gl / src / core / viewports / viewport.js View on Github external
unproject(xyz, {topLeft = true, targetZ} = {}) {
    const [x, y, z] = xyz;

    const y2 = topLeft ? y : this.height - y;
    const coord = pixelsToWorld([x, y2, z], this.pixelUnprojectionMatrix, targetZ);
    const [X, Y] = this.unprojectFlat(coord);

    if (Number.isFinite(z)) {
      // Has depth component
      return [X, Y, coord[2]];
    }

    return Number.isFinite(targetZ) ? [X, Y, targetZ] : [X, Y];
  }
github uber / deck.gl / modules / core / src / shaderlib / shadow / shadow.js View on Github external
function screenToCommonSpace(xyz, pixelUnprojectionMatrix) {
  const [x, y, z] = xyz;
  const coord = pixelsToWorld([x, y, z], pixelUnprojectionMatrix);

  if (Number.isFinite(z)) {
    return coord;
  }
  return [coord[0], coord[1], 0];
}