Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rescale parameter is sent with space from scientific notation #39

Closed
abarciauskas-bgse opened this issue Aug 20, 2021 · 2 comments
Closed

Comments

@abarciauskas-bgse
Copy link

having trouble tracking the root cause down but something is encoding the "+" in e+38 to a space which is causing the render_parameters function in titiler to throw an error.

If you review the stack trace below, you'll see the rescale parameter is passed as you might expect to tilejson but then ends up with a space replacing the when sent to RenderParams in titiler/core/dependencies.py.

Any ideas welcome.

INFO:     127.0.0.1:65350 - "GET /info HTTP/1.1" 200 OK
bidx=1&rescale=-3.4028235e+38%2C3.4028235e+38
INFO:     127.0.0.1:65350 - "GET /tilejson.json?bidx=1&rescale=-3.4028235e+38,3.4028235e+38 HTTP/1.1" 500 Internal Server Error
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/uvicorn/protocols/http/h11_impl.py", line 373, in run_asgi
    result = await app(self.scope, self.receive, self.send)
  File "/usr/local/lib/python3.9/site-packages/uvicorn/middleware/proxy_headers.py", line 75, in __call__
    return await self.app(scope, receive, send)
  File "/usr/local/lib/python3.9/site-packages/fastapi/applications.py", line 199, in __call__
    await super().__call__(scope, receive, send)
  File "/usr/local/lib/python3.9/site-packages/starlette/applications.py", line 112, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/usr/local/lib/python3.9/site-packages/starlette/middleware/errors.py", line 181, in __call__
    raise exc from None
  File "/usr/local/lib/python3.9/site-packages/starlette/middleware/errors.py", line 159, in __call__
    await self.app(scope, receive, _send)
  File "/usr/local/lib/python3.9/site-packages/starlette/middleware/base.py", line 25, in __call__
    response = await self.dispatch_func(request, self.call_next)
  File "/usr/local/lib/python3.9/site-packages/rio_viz/app.py", line 63, in dispatch
    response = await call_next(request)
  File "/usr/local/lib/python3.9/site-packages/starlette/middleware/base.py", line 45, in call_next
    task.result()
  File "/usr/local/lib/python3.9/site-packages/starlette/middleware/base.py", line 38, in coro
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.9/site-packages/starlette/middleware/gzip.py", line 18, in __call__
    await responder(scope, receive, send)
  File "/usr/local/lib/python3.9/site-packages/starlette/middleware/gzip.py", line 35, in __call__
    await self.app(scope, receive, self.send_with_gzip)
  File "/usr/local/lib/python3.9/site-packages/starlette/middleware/cors.py", line 78, in __call__
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.9/site-packages/starlette/exceptions.py", line 82, in __call__
    raise exc from None
  File "/usr/local/lib/python3.9/site-packages/starlette/exceptions.py", line 71, in __call__
    await self.app(scope, receive, sender)
  File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 580, in __call__
    await route.handle(scope, receive, send)
  File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 241, in handle
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 52, in app
    response = await func(request)
  File "/usr/local/lib/python3.9/site-packages/fastapi/routing.py", line 206, in app
    solved_result = await solve_dependencies(
  File "/usr/local/lib/python3.9/site-packages/fastapi/dependencies/utils.py", line 550, in solve_dependencies
    solved = await run_in_threadpool(call, **sub_values)
  File "/usr/local/lib/python3.9/site-packages/starlette/concurrency.py", line 40, in run_in_threadpool
    return await loop.run_in_executor(None, func, *args)
  File "/usr/local/Cellar/[email protected]/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "<string>", line 7, in __init__
  File "/usr/local/lib/python3.9/site-packages/titiler/core/dependencies.py", line 344, in __post_init__
    [tuple(map(float, r.split(","))) for r in self.rescale]
  File "/usr/local/lib/python3.9/site-packages/titiler/core/dependencies.py", line 344, in <listcomp>
    [tuple(map(float, r.split(","))) for r in self.rescale]
ValueError: could not convert string to float: '-3.4028235e 38'
@vincentsarago
Copy link
Member

Thanks for the report @abarciauskas-bgse
The problem was in TiTiler. For some reason (which I believe is uri encoding), the + within -3.4028235e+38 string was removed when decoded in TiTiler. the simple fix is to remove the white space -3.4028235e 38 -> -3.4028235e38 but I'll see if we can better encode those value to avoid this.

For now if you install titiler.core==0.3.6 it should work correctly

@abarciauskas-bgse
Copy link
Author

Thank you @vincentsarago

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants