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

Public Member Functions

String getURI ()
 
double attribute (Geometry geom)
 
Value evaluate (ValueFactory valueFactory, Value... args) throws ValueExprEvaluationException
 

Static Public Member Functions

static double length3D (CoordinateSequence pts)
 FROM org.h2gis.drivers.utility; GPL3. More...
 
static double length3D (Geometry geom)
 Returns the 3D length of the geometry. More...
 
static double length3D (LineString lineString)
 Returns the 3D perimeter of a line string. More...
 
static double length3D (Polygon polygon)
 Returns the 3D perimeter of a polygon. More...
 

Member Function Documentation

◆ attribute()

double attribute ( Geometry  geom)

Reimplemented from GeometricDoubleAttributeFunction.

19  {
20  return length3D(geom);
21  }
static double length3D(CoordinateSequence pts)
FROM org.h2gis.drivers.utility; GPL3.
Definition: LineLength3D.java:37

References LineLength3D.length3D().

◆ 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  double result = attribute(geom);
25  return valueFactory.createLiteral(result);
26  }
27  throw new ValueExprEvaluationException("Argument given is not a geometry literal");
28 
29  }

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

Referenced by AreaTest.testArea(), CompactnessRatioTest.testCompactnessRatio(), CompactnessRatioTest.testCompactnessRatioNaN(), CircularityTest.testIsScaleneTriangleFalse(), CircularityTest.testIsScaleneTriangleTrue(), LengthTest.testLineString(), MTest.testM(), MinimumBoundingRadiusTest.testMinimumBoundingRadius(), MinimumClearanceTest.testMinimumClearance(), MinimumDiameterTest.testMinimumDiameter(), MaxMTest.testMMax(), MinMTest.testMMin(), PerimeterTest.testPerimeter(), XTest.testX(), MaxXTest.testXMax(), MinXTest.testXMin(), YTest.testY(), MaxYTest.testYMax(), MinYTest.testYMin(), ZTest.testZ(), MaxZTest.testZMax(), and MinZTest.testZMin().

◆ getURI()

String getURI ( )
14  {
15  return POSTGIS.st_lineLength3D.stringValue();
16  }

References POSTGIS.st_lineLength3D.

◆ length3D() [1/4]

static double length3D ( CoordinateSequence  pts)
static

FROM org.h2gis.drivers.utility; GPL3.

Computes the length of a linestring specified by a sequence of points. if a coordinate has a NaN z return 0.

Parameters
ptsthe points specifying the linestring
Returns
the length of the linestring
37  {
38  // optimized for processing CoordinateSequences
39  int n = pts.size();
40  if (n <= 1) {
41  return 0.0;
42  }
43 
44  double len = 0.0;
45 
46  Coordinate p = new Coordinate();
47  pts.getCoordinate(0, p);
48  double x0 = p.x;
49  double y0 = p.y;
50  double z0 = p.z;
51 
52  if (Double.isNaN(z0)) {
53  return 0.0;
54  }
55 
56  for (int i = 1; i < n; i++) {
57  pts.getCoordinate(i, p);
58 
59  double x1 = p.x;
60  double y1 = p.y;
61  double z1 = p.z;
62  if (Double.isNaN(z1)) {
63  return 0.0;
64  }
65  double dx = x1 - x0;
66  double dy = y1 - y0;
67  double dz = z1 - z0;
68 
69  len += Math.sqrt(dx * dx + dy * dy + dz * dz);
70  x0 = x1;
71  y0 = y1;
72  z0 = z1;
73  }
74  return len;
75  }

Referenced by Length3D.attribute(), Perimeter3D.attribute(), LineLength3D.attribute(), and LineLength3D.length3D().

◆ length3D() [2/4]

static double length3D ( Geometry  geom)
static

Returns the 3D length of the geometry.

Parameters
geom
Returns
84  {
85  double sum = 0;
86  for (int i = 0; i < geom.getNumGeometries(); i++) {
87  Geometry subGeom = geom.getGeometryN(i);
88  if (subGeom instanceof Polygon) {
89  sum += length3D((Polygon) subGeom);
90  } else if (subGeom instanceof LineString) {
91  sum += length3D((LineString) subGeom);
92  }
93  }
94  return sum;
95  }

References LineLength3D.length3D().

◆ length3D() [3/4]

static double length3D ( LineString  lineString)
static

Returns the 3D perimeter of a line string.

Parameters
lineString
Returns
103  {
104  return length3D(lineString.getCoordinateSequence());
105  }

References LineLength3D.length3D().

◆ length3D() [4/4]

static double length3D ( Polygon  polygon)
static

Returns the 3D perimeter of a polygon.

Parameters
polygon
Returns
113  {
114  double len = 0.0;
115  len += length3D(polygon.getExteriorRing().getCoordinateSequence());
116  for (int i = 0; i < polygon.getNumInteriorRing(); i++) {
117  len += length3D(polygon.getInteriorRingN(i));
118  }
119  return len;
120  }

References LineLength3D.length3D().