code: public static double length3D(Geometry geom) {
                  double sum = 0;
                  for (int i = 0; i < geom.getNumGeometries(); i++) {
                          Geometry subGeom = geom.getGeometryN(i);
                          if (subGeom instanceof Polygon) {
                                  sum += length3D((Polygon) subGeom);
                          } else if (subGeom instanceof LineString) {
                                  sum += length3D((LineString) subGeom);
                          }
                  }
                  return sum;
          }
docs: Returns the 3D length of the geometry
  
  
  @param geom
  @return