@@ -163,6 +163,16 @@ public void encodeFromFeatures(FeatureSource<SimpleFeatureType, SimpleFeature> s
163163 this .intersect = urnParameters .containsKey ("intersect" ) ? Boolean .parseBoolean (urnParameters .get ("intersect" )) : true ;
164164 this .presence = urnParameters .containsKey ("presence" ) ? Boolean .parseBoolean (urnParameters .get ("presence" )) : false ;
165165
166+ /*
167+ * TODO would be nicer to check the request geometry for the data - which may not be the
168+ * scale of the result! If it's IRREGULAR MULTIPLE we want objects, otherwise we want a
169+ * state. I don't think there is a way to check that at the moment - the scale will be that
170+ * of contextualization, not the geometry for the actuator, which may depend on context.
171+ */
172+ this .rasterize = (idRequested != null || (scope .getTargetSemantics () != null
173+ && (scope .getTargetSemantics ().is (Type .QUALITY ) || scope .getTargetSemantics ().is (Type .TRAIT ))))
174+ && requestScale .getSpace () instanceof Space && ((Space ) requestScale .getSpace ()).getGrid () != null ;
175+
166176 filter = readAttributeData (source , urnParameters , filter , geomName );
167177
168178 /*
@@ -177,7 +187,7 @@ public void encodeFromFeatures(FeatureSource<SimpleFeatureType, SimpleFeature> s
177187 throw new KlabValidationException (e );
178188 }
179189 }
180-
190+
181191 /*
182192 * filters set into the resource parameters
183193 */
@@ -240,26 +250,10 @@ private Filter readAttributeData(FeatureSource<SimpleFeatureType, SimpleFeature>
240250 }
241251 return filter ;
242252 }
243- //, , IContextualizationScope scope
244- protected void parseFeatures (FeatureIterator <SimpleFeature > it , IResource resource , Map <String , String > urnParameters , IGeometry geometry , Builder builder , IContextualizationScope scope , ReferencedEnvelope bboxRefEnv
245- // ,
246- // String idRequested, Map<String, Class< ? >> attributes,
247- // Map<String, String> attributeNames, FeatureCollection<SimpleFeatureType, SimpleFeature> fc,
248- // Projection originalProjection, Rasterizer<Object> rasterizer, double cellWidth, Polygon polygonEnv,
249- // String nameAttribute
250- ) {
251-
252- Scale requestScale = geometry instanceof Scale ? (Scale ) geometry : Scale .create (geometry );
253- /*
254- * TODO would be nicer to check the request geometry for the data - which may not be the
255- * scale of the result! If it's IRREGULAR MULTIPLE we want objects, otherwise we want a
256- * state. I don't think there is a way to check that at the moment - the scale will be that
257- * of contextualization, not the geometry for the actuator, which may depend on context.
258- */
259- boolean rasterize = (idRequested != null || (scope .getTargetSemantics () != null
260- && (scope .getTargetSemantics ().is (Type .QUALITY ) || scope .getTargetSemantics ().is (Type .TRAIT ))))
261- && requestScale .getSpace () instanceof Space && ((Space ) requestScale .getSpace ()).getGrid () != null ;
262253
254+ protected void parseFeatures (FeatureIterator <SimpleFeature > it , IResource resource , Map <String , String > urnParameters ,
255+ IGeometry geometry , Builder builder , IContextualizationScope scope , ReferencedEnvelope bboxRefEnv ) {
256+ Scale requestScale = geometry instanceof Scale ? (Scale ) geometry : Scale .create (geometry );
263257 Rasterizer <Object > rasterizer = null ;
264258 double cellWidth = -1.0 ;
265259
@@ -291,7 +285,6 @@ protected void parseFeatures(FeatureIterator<SimpleFeature> it, IResource resour
291285
292286 SimpleFeature feature = it .next ();
293287 Geometry shape = (Geometry ) feature .getDefaultGeometry ();
294-
295288 if (shape .isEmpty ()) {
296289 continue ;
297290 }
@@ -308,7 +301,7 @@ protected void parseFeatures(FeatureIterator<SimpleFeature> it, IResource resour
308301 }
309302
310303 IShape objectShape = null ;
311- if (rasterize ) {
304+ if (rasterize ) {
312305 // do always intersect
313306 try {
314307 Geometry intersection = GeometryHelper .multiPolygonIntersection (polygonEnv , shape , cellWidth );
@@ -317,8 +310,8 @@ protected void parseFeatures(FeatureIterator<SimpleFeature> it, IResource resour
317310 } catch (Exception e ) {
318311 throw new KlabIOException (e );
319312 }
320-
321- }else {
313+
314+ } else {
322315 objectShape = Shape .create (shape , originalProjection )
323316 .transform (requestScale .getSpace ().getProjection ());
324317
@@ -334,7 +327,6 @@ protected void parseFeatures(FeatureIterator<SimpleFeature> it, IResource resour
334327 }
335328
336329 if (rasterize ) {
337-
338330 Object value = Boolean .TRUE ;
339331
340332 if (idRequested != null ) {
@@ -370,7 +362,7 @@ protected void parseFeatures(FeatureIterator<SimpleFeature> it, IResource resour
370362 }
371363
372364 builder = builder .startObject (scope .getTargetName (), objectName , objectScale );
373- for (String key : attributes .keySet ()) {
365+ for (String key : attributes .keySet ()) {
374366 Object nattr = feature .getAttribute (key );
375367 if (nattr == null ) {
376368 nattr = feature .getAttribute (key .toUpperCase ());
0 commit comments