1111from django_large_image .rest import params
1212from django_large_image .rest .base import CACHE_TIMEOUT , LargeImageMixinBase
1313
14+ thumbnail_summary = 'Returns thumbnail of full image.'
15+ thumbnail_parameters = [params .projection ] + params .STYLE
16+ region_summary = 'Returns region tile binary.'
17+ region_parameters = [params .projection ] + params .REGION
18+ pixel_summary = 'Returns single pixel.'
19+ pixel_parameters = [params .projection , params .left , params .top ] + params .STYLE
20+ histogram_summary = 'Returns histogram'
21+ histogram_parameters = [params .projection ] + params .HISTOGRAM
22+
1423
1524class DataMixin (LargeImageMixinBase ):
1625 def thumbnail (self , request : Request , pk : int = None , format : str = None ) -> HttpResponse :
@@ -22,8 +31,8 @@ def thumbnail(self, request: Request, pk: int = None, format: str = None) -> Htt
2231 @method_decorator (cache_page (CACHE_TIMEOUT ))
2332 @swagger_auto_schema (
2433 method = 'GET' ,
25- operation_summary = 'Returns thumbnail of full image as PNG.' ,
26- manual_parameters = [ params . projection ] + params . STYLE ,
34+ operation_summary = thumbnail_summary ,
35+ manual_parameters = thumbnail_parameters ,
2736 )
2837 @action (detail = False , url_path = 'thumbnail.png' )
2938 def thumbnail_png (self , request : Request , pk : int = None ) -> HttpResponse :
@@ -32,8 +41,8 @@ def thumbnail_png(self, request: Request, pk: int = None) -> HttpResponse:
3241 @method_decorator (cache_page (CACHE_TIMEOUT ))
3342 @swagger_auto_schema (
3443 method = 'GET' ,
35- operation_summary = 'Returns thumbnail of full image as JPEG.' ,
36- manual_parameters = [ params . projection ] + params . STYLE ,
44+ operation_summary = thumbnail_summary ,
45+ manual_parameters = thumbnail_parameters ,
3746 )
3847 @action (detail = False , url_path = 'thumbnail.jpeg' )
3948 def thumbnail_jpeg (self , request : Request , pk : int = None ) -> HttpResponse :
@@ -75,35 +84,35 @@ def region(self, request: Request, pk: int = None, format: str = None) -> HttpRe
7584
7685 @swagger_auto_schema (
7786 method = 'GET' ,
78- operation_summary = 'Returns region tile binary from world coordinates in given EPSG as a tiled tif image.' ,
79- manual_parameters = [ params . projection ] + params . REGION ,
87+ operation_summary = region_summary ,
88+ manual_parameters = region_parameters ,
8089 )
8190 @action (detail = False , url_path = r'region.tif' )
8291 def region_tif (self , request : Request , pk : int = None ) -> HttpResponse :
8392 return self .region (request , pk , format = 'tif' )
8493
8594 @swagger_auto_schema (
8695 method = 'GET' ,
87- operation_summary = 'Returns region tile binary from world coordinates in given EPSG as a png image.' ,
88- manual_parameters = [ params . projection ] + params .REGION ,
96+ operation_summary = region_summary ,
97+ manual_parameters = region_parameters + params .STYLE ,
8998 )
9099 @action (detail = False , url_path = r'region.png' )
91100 def region_png (self , request : Request , pk : int = None ) -> HttpResponse :
92101 return self .region (request , pk , format = 'png' )
93102
94103 @swagger_auto_schema (
95104 method = 'GET' ,
96- operation_summary = 'Returns region tile binary from world coordinates in given EPSG as a jpeg image.' ,
97- manual_parameters = [ params . projection ] + params .REGION ,
105+ operation_summary = region_summary ,
106+ manual_parameters = region_parameters + params .STYLE ,
98107 )
99108 @action (detail = False , url_path = r'region.jpeg' )
100109 def region_jpeg (self , request : Request , pk : int = None ) -> HttpResponse :
101110 return self .region (request , pk , format = 'jpeg' )
102111
103112 @swagger_auto_schema (
104113 method = 'GET' ,
105- operation_summary = 'Returns single pixel.' ,
106- manual_parameters = [ params . projection , params . left , params . top ] + params . STYLE ,
114+ operation_summary = pixel_summary ,
115+ manual_parameters = pixel_parameters ,
107116 )
108117 @action (detail = False )
109118 def pixel (self , request : Request , pk : int = None ) -> Response :
@@ -115,8 +124,8 @@ def pixel(self, request: Request, pk: int = None) -> Response:
115124
116125 @swagger_auto_schema (
117126 method = 'GET' ,
118- operation_summary = 'Returns histogram' ,
119- manual_parameters = [ params . projection ] + params . HISTOGRAM ,
127+ operation_summary = histogram_summary ,
128+ manual_parameters = histogram_parameters ,
120129 )
121130 @action (detail = False )
122131 def histogram (self , request : Request , pk : int = None ) -> Response :
@@ -141,30 +150,67 @@ def histogram(self, request: Request, pk: int = None) -> Response:
141150
142151
143152class DataDetailMixin (DataMixin ):
153+ @method_decorator (cache_page (CACHE_TIMEOUT ))
154+ @swagger_auto_schema (
155+ method = 'GET' ,
156+ operation_summary = thumbnail_summary ,
157+ manual_parameters = thumbnail_parameters ,
158+ )
144159 @action (detail = True , url_path = 'thumbnail.png' )
145160 def thumbnail_png (self , request : Request , pk : int = None ) -> HttpResponse :
146161 return super ().thumbnail_png (request , pk )
147162
163+ @method_decorator (cache_page (CACHE_TIMEOUT ))
164+ @swagger_auto_schema (
165+ method = 'GET' ,
166+ operation_summary = thumbnail_summary ,
167+ manual_parameters = thumbnail_parameters ,
168+ )
148169 @action (detail = True , url_path = 'thumbnail.jpeg' )
149170 def thumbnail_jpeg (self , request : Request , pk : int = None ) -> HttpResponse :
150171 return super ().thumbnail_jpeg (request , pk )
151172
173+ @swagger_auto_schema (
174+ method = 'GET' ,
175+ operation_summary = region_summary ,
176+ manual_parameters = region_parameters ,
177+ )
152178 @action (detail = True , url_path = r'region.tif' )
153179 def region_tif (self , request : Request , pk : int = None ) -> HttpResponse :
154180 return super ().region_tif (request , pk )
155181
182+ @swagger_auto_schema (
183+ method = 'GET' ,
184+ operation_summary = region_summary ,
185+ manual_parameters = region_parameters + params .STYLE ,
186+ )
156187 @action (detail = True , url_path = r'region.png' )
157188 def region_png (self , request : Request , pk : int = None ) -> HttpResponse :
158189 return super ().region_png (request , pk )
159190
191+ @swagger_auto_schema (
192+ method = 'GET' ,
193+ operation_summary = region_summary ,
194+ manual_parameters = region_parameters + params .STYLE ,
195+ )
160196 @action (detail = True , url_path = r'region.jpeg' )
161197 def region_jpeg (self , request : Request , pk : int = None ) -> HttpResponse :
162198 return super ().region_jpeg (request , pk )
163199
200+ @swagger_auto_schema (
201+ method = 'GET' ,
202+ operation_summary = pixel_summary ,
203+ manual_parameters = pixel_parameters ,
204+ )
164205 @action (detail = True )
165206 def pixel (self , request : Request , pk : int = None ) -> Response :
166207 return super ().pixel (request , pk )
167208
209+ @swagger_auto_schema (
210+ method = 'GET' ,
211+ operation_summary = histogram_summary ,
212+ manual_parameters = histogram_parameters ,
213+ )
168214 @action (detail = True )
169215 def histogram (self , request : Request , pk : int = None ) -> Response :
170216 return super ().histogram (request , pk )
0 commit comments