Skip to content

Reproducing TileOutsideBounds errors #130

Description

@kylebarron

I did this exact set of instructions (twice), and was able to reproduce a TileOutsideBounds error

Clone repo

git clone https://github.com/developmentseed/titiler
cd titiler

Build docker image:

docker build --tag titiler-lambda:latest . -f Dockerfiles/lambda/Dockerfile --no-cache

Extract package.zip locally

docker run --name titiler-lambda --volume $(pwd)/:/local -it titiler-lambda:latest bash -c 'cp /tmp/package.zip /local/package.zip'

Install serverless-offline

yarn add serverless-offline
# or
npm install serverless-offline

Paste the following into serverless.yml locally in the titiler folder (as an aside, I'd consider adding a page in the docs for deploying with Serverless framework basically with these steps)..

Content
service: titiler-lambda-sls

plugins:
  - serverless-offline

custom:
  serverless-offline:
    useChildProcesses: true
    allowCache: true
    useDocker: true

provider:
  name: aws
  runtime: python3.7
  stage: ${opt:stage, 'dev'}
  region: "us-west-2"

  deploymentBucket: ${opt:bucket}
  httpApi:
    cors: true

  # Add Tags to resources
  stackTags:
    Project: titiler

  apiGateway:
    binaryMediaTypes:
      - "*/*"
    minimumCompressionSize: 1

  # Add other buckets here if needed
  iamRoleStatements:
    - Effect: "Allow"
      Action:
        - "s3:GetObject"
        - "s3:HeadObject"
        - "s3:PutObject"
      Resource:
        - "arn:aws:s3:::${self:provider.deploymentBucket}*"

    - Effect: "Allow"
      Action:
        - "s3:GetObject"
        - "s3:HeadObject"
      Resource:
        - "arn:aws:s3:::*"

package:
  artifact: package.zip

functions:
  app:
    handler: handler.handler
    memorySize: 3008
    timeout: 10
    environment:
      # Necessary since NAIP bucket is requester-pays
      AWS_REQUEST_PAYER: requester
      AWS_ACCOUNT_ID: ${env:AWS_ACCOUNT_ID}
      AWS_ACCESS_KEY_ID: ${env:AWS_ACCESS_KEY_ID}
      AWS_SECRET_ACCESS_KEY: ${env:AWS_SECRET_ACCESS_KEY}
      AWS_REGION: ${env:AWS_REGION}
      CACHE_CONTROL: ${opt:cache-control, 'public,max-age=3600'}
      CPL_TMPDIR: /tmp
      CPL_VSIL_CURL_ALLOWED_EXTENSIONS: .tif,.TIF
      GDAL_CACHEMAX: 25%
      # https://github.com/OSGeo/gdal/issues/909#issuecomment-420036545
      GDAL_DISABLE_READDIR_ON_OPEN: EMPTY_DIR
      GDAL_HTTP_MERGE_CONSECUTIVE_RANGES: YES
      GDAL_HTTP_MULTIPLEX: YES
      GDAL_HTTP_VERSION: 2
      MAX_THREADS: 1
      PYTHONWARNINGS: ignore
      VSI_CACHE: TRUE
      VSI_CACHE_SIZE: 536870912
    events:
      - httpApi:
          path: /{proxy+}
          method: "*"

Start serverless-offline

export AWS_ACCOUNT_ID=...
export AWS_ACCESS_KEY_ID=...
export AWS_SECRET_ACCESS_KEY=...
export AWS_REGION=...

sls offline --bucket some-bucket-of-yours

Go to this address: (note this may take a little while to load the first time because serverless-offline does something with docker in the background). This is pulling from a mosaic that should be fully public.

http://localhost:3000/dev/mosaicjson/tiles/16/12406/25717.npy?url=s3%3A%2F%2Ftmp-us-west-2-kylebarron%2Ftmp%2Fnaip-analytic-mosaic.json.gz&scale=1&return_mask=True

And I get:

{"detail":"Tile 16/12406/25717 is outside image bounds"}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions