@Test public void testLengthMultiLineString() { LineString line1 = gf.createLineString(constructCoordinates( 0, 0, 1, 1 )); LineString line2 = gf.createLineString(constructCoordinates( 1, 1, 2, 0 )); MultiLineString mline = gf.createMultiLineString(new LineString[] { line1, line2 }); assertEquals(2.0, Geo.lengthOf(mline) / Geo.lengthOf(line1), 0.0001); }
public static double lengthOf(LineString line) { double dist = 0.0; Coordinate[] coords = line.getCoordinates(); for (int i = 1; i < coords.length; i++) { dist += distanceBetweenCoordinates( coords[i - 1].y, coords[i - 1].x, coords[i].y, coords[i].x ); } return dist; }
Geo { public static double lengthOf(LineString line) { double dist = 0.0; Coordinate[] coords = line.getCoordinates(); for (int i = 1; i < coords.length; i++) { dist += distanceBetweenCoordinates( coords[i - 1].y, coords[i - 1].x, coords[i].y, coords[i].x ); } return dist; } }
Geo { public static double lengthOf(LineString line) { double dist = 0.0; Coordinate[] coords = line.getCoordinates(); for (int i = 1; i < coords.length; i++) { dist += distanceBetweenCoordinates( coords[i - 1].y, coords[i - 1].x, coords[i].y, coords[i].x ); } return dist; }  }
Geo { public static double lengthOf(LineString line) { double dist = 0.0; Coordinate[] coords = line.getCoordinates(); for (int i = 1; i < coords.length; i++) { dist += distanceBetweenCoordinates( coords[i - 1].y, coords[i - 1].x, coords[i].y, coords[i].x ); } return dist; }  static double distanceBetweenCoordinatesHaversine(
      double lat1, double lng1, double lat2, double lng2
  ); static double distanceBetweenCoordinates(
      double lat1, double lng1, double lat2, double lng2
  ); static double lengthOf(LineString line); static double lengthOf(MultiLineString multiline); static double lengthOf(GeometryCollection geometryCollection); static double lengthOf(Geometry geom); static double areaOf(Polygon poly); static double areaOf(MultiPolygon multipoly); static double areaOf(GeometryCollection geometryCollection); static double areaOf(Geometry geom); static double ringArea(LinearRing ring); static Geometry clip(Geometry obj, OSHDBBoundingBox bbox); static Geometry clip(Geometry obj, P poly); }
Geo { public static double lengthOf(LineString line) { double dist = 0.0; Coordinate[] coords = line.getCoordinates(); for (int i = 1; i < coords.length; i++) { dist += distanceBetweenCoordinates( coords[i - 1].y, coords[i - 1].x, coords[i].y, coords[i].x ); } return dist; }  static double distanceBetweenCoordinatesHaversine(
      double lat1, double lng1, double lat2, double lng2
  ); static double distanceBetweenCoordinates(
      double lat1, double lng1, double lat2, double lng2
  ); static double lengthOf(LineString line); static double lengthOf(MultiLineString multiline); static double lengthOf(GeometryCollection geometryCollection); static double lengthOf(Geometry geom); static double areaOf(Polygon poly); static double areaOf(MultiPolygon multipoly); static double areaOf(GeometryCollection geometryCollection); static double areaOf(Geometry geom); static double ringArea(LinearRing ring); static Geometry clip(Geometry obj, OSHDBBoundingBox bbox); static Geometry clip(Geometry obj, P poly); static double earthRadius; }