kiwi-postgis  Version 0.1.0.0
AsLatLonText Class Reference
Inheritance diagram for AsLatLonText:
Collaboration diagram for AsLatLonText:

Public Member Functions

String operation (Geometry geom)
 
String convertDecimalToLatLonText (Double D, Boolean lng)
 
String getURI ()
 
Value evaluate (ValueFactory valueFactory, Value... args) throws ValueExprEvaluationException
 

Member Function Documentation

◆ convertDecimalToLatLonText()

String convertDecimalToLatLonText ( Double  D,
Boolean  lng 
)

Referenced by AsLatLonText.operation().

22  {
23  String dir;
24  if(D<0) {
25  if(lng) {
26  dir="W";
27  }else {
28  dir="S";
29  }
30  }else {
31  if(lng) {
32  dir="E";
33  }else {
34  dir="N";
35  }
36  }
37  Double deg=D<0?-D:D;
38  Double min=D%1*60;
39  Double sec=(D*60%1*6000)/100;
40  return deg+"°"+min+"'"+sec+"\""+dir;
41  }

◆ evaluate()

Value evaluate ( ValueFactory  valueFactory,
Value...  args 
) throws ValueExprEvaluationException
inherited

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

16  {
17  if (args.length != 1) {
18  throw new ValueExprEvaluationException(getURI() + " requires exactly 1 arguments, got " + args.length);
19  }
20 
21  LiteralType l=LiteralRegistry.getLiteral(((Literal)args[0]).getDatatype().toString());
22  if(l instanceof VectorLiteral) {
23  Geometry geom=((VectorLiteral)l).read(args[0].stringValue());
24  String result = operation(geom);
25  return valueFactory.createLiteral(result);
26  }
27  throw new ValueExprEvaluationException("Argument given is not a geometry literal");
28 
29  }

◆ getURI()

String getURI ( )

References POSTGIS.ST_ASLATLONTEXT.

44  {
45  return POSTGIS.ST_ASLATLONTEXT.stringValue();
46  }

◆ operation()

String operation ( Geometry  geom)

References AsLatLonText.convertDecimalToLatLonText().

13  {
14  if(geom.getGeometryType().equalsIgnoreCase("POINT")) {
15  return convertDecimalToLatLonText(geom.getCoordinate().x,false)+" "+convertDecimalToLatLonText(geom.getCoordinate().getY(),true);
16  }else {
17  return convertDecimalToLatLonText(geom.getCentroid().getCoordinate().x,false)+" "+convertDecimalToLatLonText(geom.getCentroid().getCoordinate().getY(),true);
18 
19  }
20  }
String convertDecimalToLatLonText(Double D, Boolean lng)
Definition: AsLatLonText.java:22