-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathGDALResourceHandler
50 lines (34 loc) · 1.44 KB
/
GDALResourceHandler
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef OSGEARTH_CEF_GDAL_RESOURCE_HANDLER
#define OSGEARTH_CEF_GDAL_RESOURCE_HANDLER 1
#include "include/cef_resource_handler.h"
#include "include/cef_scheme.h"
#include <osg/Image>
namespace osgEarth { namespace Cef
{
// Implements a resource handler for previewing GDAL files
// You can specify a url of the type gdal://gdal/path/to/file.tif and this will return a jpeg preview of the image.
class GDALResourceHandler : public CefResourceHandler {
public:
GDALResourceHandler();
virtual bool ProcessRequest(CefRefPtr<CefRequest> request, CefRefPtr<CefCallback> callback) OVERRIDE;
virtual void GetResponseHeaders(CefRefPtr<CefResponse> response, int64& response_length, CefString& redirectUrl) OVERRIDE;
virtual void Cancel() OVERRIDE;
virtual bool ReadResponse(void* data_out, int bytes_to_read, int& bytes_read, CefRefPtr<CefCallback> callback) OVERRIDE;
private:
IMPLEMENT_REFCOUNTING(GDALResourceHandler);
osg::ref_ptr< osg::Image> _image;
int _readOffset;
std::string _data;
};
class GDALHandlerFactory : public CefSchemeHandlerFactory
{
public:
virtual CefRefPtr<CefResourceHandler> Create(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const CefString& scheme_name,
CefRefPtr<CefRequest> request)
OVERRIDE;
IMPLEMENT_REFCOUNTING(GDALHandlerFactory);
};
} }
#endif