rdf4j-postgis  Version 0.1.0.0
ValidPixelCount Class Reference
Inheritance diagram for ValidPixelCount:
Collaboration diagram for ValidPixelCount:

Public Member Functions

String getURI ()
 
Integer attribute (GridCoverage raster, Integer bandnum)
 
Value evaluate (ValueFactory valueFactory, Value... args) throws ValueExprEvaluationException
 

Member Function Documentation

◆ attribute()

Integer attribute ( GridCoverage  raster,
Integer  bandnum 
)

Reimplemented from RasterAttributeIntIntFunction.

17  {
18  RenderedImage rendered = raster.render(null);
19  Integer result=0;
20  for(int i=0;i<rendered.getSampleModel().getWidth();i++) {
21  for(int j=0;j<rendered.getSampleModel().getHeight();j++) {
22  Number sample=rendered.getData().getSample(i, j, bandnum);
23  if(!raster.getSampleDimensions().get(bandnum).getNoDataValues().contains(sample)) {
24  result++;
25  }
26  }
27  }
28  return result;
29  }

◆ evaluate()

Value evaluate ( ValueFactory  valueFactory,
Value...  args 
) throws ValueExprEvaluationException
inherited
16  {
17  if (args.length != 2) {
18  throw new ValueExprEvaluationException(getURI() + " requires exactly 2 arguments, got " + args.length);
19  }
20  LiteralType l=LiteralRegistry.getLiteral(((Literal)args[0]).getDatatype().toString());
21  if(l instanceof RasterLiteral) {
22  GridCoverage geom=((RasterLiteral)l).read(args[0].stringValue());
23  Integer parameter = Integer.valueOf(args[1].stringValue());
24  Integer result = attribute(geom,parameter);
25  return valueFactory.createLiteral(result);
26  }
27  return null;
28 }

References RasterAttributeIntIntFunction.attribute(), and LiteralRegistry.getLiteral().

Referenced by BandTest.testBand(), and BandNoDataValueTest.testBandNoDataValue().

◆ getURI()

String getURI ( )
12  {
13  return POSTGIS.ST_validpixelcount.stringValue();
14  }

References POSTGIS.ST_validpixelcount.