Closed flibbertigibbet closed 9 years ago
@notthatbreezy , I looked into the Geotrellis source, and it doesn't look to be directly doable. Although possible, since the bytes would not be streamed, it could only return a max of 2GB.
Sorry to weigh in so late - been jumping around between other things all day and just saw this.
I think just saving the file as Kathryn does here makes sense and probably won't be too weird. Plus it is easier to reason about (at least to me) than sending bytes over the wire somehow else. Perhaps it would be better to try and save the file with jobId
as part of the filename to prevent headaches when/if multiple people try to grab one of these files.
It looks like this returns bytes. How large have these geotiffs been so far? 2gb would be a pretty good size geotiff
One issue I could see happening is some odd race conditions where 2 near simultaneous requests trample on each other.
Keying the filename definitely makes sense too I think.
If saved by jobId
then we'd need to implement caching/clearing of some sort. Since we're not using the Play library, it's not straightforward to delete a file after it's been downloaded. So I take it people can download results from different calculation jobs at the same time, if there's multiple users in the system.
Yes, writeBytes
, which would mean calling into the GeoTiff's Encoder
thing directly.
@notthatbreezy once you have bytes, what would you do with them? There doesn't seem to be any equivalent to the getFromFile
directive for sending bytes as a file download.
I think it should be possible to call
GeoTiff.render(tile, extent, LatLng, <whatever compression you want>)
I don't think you have to touch the encoder since GeoTiff.render
handles that. Then you would send the bytes (not sure of the syntax in spray but there is this and some docs in spray that point this as well. The content-type would just need to be whatever is appropriate for returning a GeoTiff/Tiff
I also found this, which discusses content-type: http://spray.io/documentation/1.2.3/spray-httpx/marshalling/#custom-marshallers
Judging from the comments, it looks like GeoTiff compression doesn't actually work (LZW results in unreadable file on Macs.)
Okay, the HttpData
wrap worked fine without the custom marshal stuff. Maybe this is good to go now.
+1
Sorry! Meant to get to this earlier, but was stuck on another project -- I have to do some more digging in the source, but it seems like we should be able to just return bytes here (we're on an older version of GeoTrellis so that's why I'm unsure of how to do it).
Also - not sure much is gained from gzipping since GeoTiff is an already compressed format