rdf4j-postgis  Version 0.1.0.0
AsLatLonText Class Reference

Returns a Lat/Lon text representation of a given geometry. More...

Inheritance diagram for AsLatLonText:
Collaboration diagram for AsLatLonText:

Public Member Functions

String operation (Geometry geom)
 
String convertDecimalToLatLonText (Double D, Boolean lng)
 Converts a decimal number to a latitude longitude representation. More...
 
String getURI ()
 
Value evaluate (ValueFactory valueFactory, Value... args) throws ValueExprEvaluationException
 

Detailed Description

Returns a Lat/Lon text representation of a given geometry.

Member Function Documentation

◆ convertDecimalToLatLonText()

String convertDecimalToLatLonText ( Double  D,
Boolean  lng 
)

Converts a decimal number to a latitude longitude representation.

Parameters
Dthe decimal number
lngindicates if a latitude or longitude number should be returned
Returns
The number in lat/lon representation
30  {
31  String dir;
32  if(D<0) {
33  if(lng) {
34  dir="W";
35  }else {
36  dir="S";
37  }
38  }else {
39  if(lng) {
40  dir="E";
41  }else {
42  dir="N";
43  }
44  }
45  Double deg=D<0?-D:D;
46  Double min=D%1*60;
47  Double sec=(D*60%1*6000)/100;
48  return deg+"°"+min+"'"+sec+"\""+dir;
49  }

Referenced by AsLatLonText.operation().

◆ evaluate()

Value evaluate ( ValueFactory  valueFactory,
Value...  args 
) throws ValueExprEvaluationException
inherited
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  }

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

Referenced by AsBinaryTest.testAsBinary(), AsEncodedPolylineTest.testAsEncodedPolyline(), AsGARSTest.testAsGARS(), AsGeoJSONTest.testAsGeoJSON(), AsGeoRSSTest.testAsGeoRSS(), AsGeoURITest.testAsGeoURI(), AsLatLonTextTest.testAsLatLonText(), AsOSMLinkTest.testAsOSMLink(), AsPolyshapeTest.testAsPolyShape(), AsTextTest.testAsText(), AsTextRawTest.testAsTextRaw(), AsTextTest.testAsTextZ(), DumpTest.testDump(), GeomCRSToWKTTest.testGeomCRSToWKT(), GeometryTypeTest.testLineString(), SridGetAxis1OrientationTest.testSridAxis1Orientation(), SridGetAxis2OrientationTest.testSridAxis2Orientation(), SridGetAxis1NameTest.testSridGetAxis1Name(), SridGetAxis2NameTest.testSridGetAxis2Name(), and SridGetDatumTest.testSridGetDatum().

◆ getURI()

String getURI ( )
52  {
53  return POSTGIS.ST_ASLATLONTEXT.stringValue();
54  }

References POSTGIS.ST_ASLATLONTEXT.

◆ operation()

String operation ( Geometry  geom)

Reimplemented from GeometricStringExportFunction.

15  {
16  if(geom.getGeometryType().equalsIgnoreCase("POINT")) {
17  return convertDecimalToLatLonText(geom.getCoordinate().x,false)+" "+convertDecimalToLatLonText(geom.getCoordinate().getY(),true);
18  }else {
19  return convertDecimalToLatLonText(geom.getCentroid().getCoordinate().x,false)+" "+convertDecimalToLatLonText(geom.getCentroid().getCoordinate().getY(),true);
20 
21  }
22  }
String convertDecimalToLatLonText(Double D, Boolean lng)
Converts a decimal number to a latitude longitude representation.
Definition: AsLatLonText.java:30

References AsLatLonText.convertDecimalToLatLonText().