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

Public Member Functions

String getURI ()
 
boolean operation (Geometry geom, CoordinateReferenceSystem crs)
 
Value evaluate (ValueFactory valueFactory, Value... args) throws ValueExprEvaluationException
 

Member Function Documentation

◆ evaluate()

Value evaluate ( ValueFactory  valueFactory,
Value...  args 
) throws ValueExprEvaluationException
inherited
19  {
20  if (args.length != 2) {
21  throw new ValueExprEvaluationException(getURI() + " requires exactly 2 arguments, got " + args.length);
22  }
23 
24  LiteralType l=LiteralRegistry.getLiteral(((Literal)args[0]).getDatatype().toString());
25  Integer srid=Integer.valueOf(args[1].stringValue());
26  if(l instanceof VectorLiteral) {
27  Geometry geom=((VectorLiteral)l).read(args[0].stringValue());
28  boolean result;
29  try {
30  result = operation(geom,CRS.forCode("EPSG:"+srid));
31  return valueFactory.createLiteral(result);
32  } catch (FactoryException e) {
33  // TODO Auto-generated catch block
34  e.printStackTrace();
35  return null;
36  }
37 
38  }
39  throw new ValueExprEvaluationException("Arguments given are not geometry literals");
40  }

References LiteralRegistry.getLiteral(), and GeometricBinaryCRSAttributeFunction.operation().

Referenced by IsInCRSAreaOfValidityTest.testIsInCRSAreaOfValidityFalse(), and IsInCRSAreaOfValidityTest.testIsInCRSAreaOfValidityTrue().

◆ getURI()

String getURI ( )
13  {
14  return POSTGIS.st_isInCRSAreaOfValidity.stringValue();
15  }

References POSTGIS.st_isInCRSAreaOfValidity.

◆ operation()

boolean operation ( Geometry  geom,
CoordinateReferenceSystem  crs 
)

Reimplemented from GeometricBinaryCRSAttributeFunction.

18  {
19  CoordinateSystemAxis x = crs.getCoordinateSystem().getAxis(0);
20  CoordinateSystemAxis y = crs.getCoordinateSystem().getAxis(1);
21  boolean xUnbounded = Double.isInfinite(x.getMinimumValue()) && Double.isInfinite(x.getMaximumValue());
22  boolean yUnbounded = Double.isInfinite(y.getMinimumValue()) && Double.isInfinite(y.getMaximumValue());
23  if (xUnbounded && yUnbounded) {
24  return false;
25  }
26  Coordinate[] c = geom.getCoordinates();
27  for (int i = 0; i < c.length; i++) {
28  if (!xUnbounded && ((c[i].x < x.getMinimumValue()) || (c[i].x > x.getMaximumValue()))) {
29  return false;
30  }
31  if (!yUnbounded && ((c[i].y < y.getMinimumValue()) || (c[i].y > y.getMaximumValue()))) {
32  return false;
33  }
34  }
35  return true;
36  }