rdf4j-postgis  Version 0.1.0.0
Polygon Class Reference

Creates a Polygon from a LineString given as a WKT String. More...

Inheritance diagram for Polygon:
Collaboration diagram for Polygon:

Public Member Functions

String getURI ()
 
Geometry construct (String input, Integer srid)
 
Value evaluate (ValueFactory valueFactory, Value... args) throws ValueExprEvaluationException
 

Detailed Description

Creates a Polygon from a LineString given as a WKT String.

Member Function Documentation

◆ construct()

Geometry construct ( String  input,
Integer  srid 
)

Reimplemented from GeometricConstructorInteger.

22  {
23  WKTReader wktreader=new WKTReader();
24  Geometry geom;
25  try {
26  geom = wktreader.read(input);
27  if("LINESTRING".equals(geom.getGeometryType().toUpperCase())){
28  return LiteralUtils.createGeometry(geom.getCoordinates(), "Polygon", srid);
29  }
30  } catch (ParseException e) {
31  // TODO Auto-generated catch block
32  e.printStackTrace();
33  }
34 
35  return null;
36  }

References LiteralUtils.createGeometry().

◆ evaluate()

Value evaluate ( ValueFactory  valueFactory,
Value...  args 
) throws ValueExprEvaluationException
inherited
16  {
17  if (args.length != 2) {
18  throw new ValueExprEvaluationException(getURI() + " requires exactly 1 arguments, got " + args.length);
19  }
20 
21  String input=args[0].stringValue();
22  Integer srid = Integer.valueOf(args[1].stringValue());
23  LiteralType l=LiteralRegistry.getLiteral(((Literal)args[0]).getDatatype().toString());
24  if(l instanceof VectorLiteral) {
25  Geometry result = construct(input,srid);
26  return valueFactory.createLiteral(((VectorLiteral) l).unparse(result),((Literal)args[0]).getDatatype());
27  }
28  throw new ValueExprEvaluationException("Arguments given are not geometry literals");
29  }

References GeometricConstructorInteger.construct(), and LiteralRegistry.getLiteral().

◆ getURI()

String getURI ( )
17  {
18  return POSTGIS.st_polygon.stringValue();
19  }

References POSTGIS.st_polygon.