code: public static double getDistance(LineString tripGeometry) {
        double distance = 0;
        for (int i = 0; i < tripGeometry.getNumPoints() - 1; i++) {
          try {
            distance += JTS.orthodromicDistance(tripGeometry.getCoordinateN(i), tripGeometry.getCoordinateN(i + 1), DefaultGeographicCRS.WGS84);
          } catch (TransformException e) {
            throw new RuntimeException(e);
          }
        }
  
        return distance;
      }
docs: Get the length of a linestring in meters