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

Public Member Functions

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

Member Function Documentation

◆ attribute()

Geometry attribute ( GridCoverage  raster,
Integer  longitude,
Integer  latitude 
)

Reimplemented from RasterAttributeIntIntGeomFunction.

24  {
25  try {
26  GridGeometry gg2D = raster.getGridGeometry();
27  MathTransform gridToCRS = gg2D.getGridToCRS(PixelInCell.CELL_CENTER);
28  DirectPosition realPos=new DirectPosition2D(latitude, longitude);
29  DirectPosition gridPos = new DirectPosition2D();
30  DirectPosition res=gridToCRS.transform(realPos, gridPos);
31  Coordinate coord=new Coordinate(res.getCoordinate()[0],res.getCoordinate()[1]);
32  GeometryFactory fac=new GeometryFactory();
33  return fac.createPoint(coord);
34  } catch (TransformException e) {
35  return null;
36  }
37  }

◆ evaluate()

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

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

Referenced by RasterToWorldCoordTest.testRasterToWorldCoord(), and WorldToRasterCoordTest.testWorldToRasterCoord().

◆ getURI()

String getURI ( )
19  {
20  return POSTGIS.st_rasterToWorldCoord.stringValue();
21  }

References POSTGIS.st_rasterToWorldCoord.