code: private static Geometry shadowLine(LineString lineString, double[] shadowOffset, GeometryFactory factory, boolean doUnion) {
          Coordinate[] coords = lineString.getCoordinates();
          Collection<Polygon> shadows = new ArrayList<Polygon>();
          createShadowPolygons(shadows, coords, shadowOffset, factory);
          if (!doUnion) {
              return factory.buildGeometry(shadows);
          } else {
              if (!shadows.isEmpty()) {
                  CascadedPolygonUnion union = new CascadedPolygonUnion(shadows);
                  Geometry result = union.union();
                  result.apply(new UpdateZCoordinateSequenceFilter(0, 1));
                  return result;
              }
              return null;
          }
      }
docs: Compute the shadow for a linestring
  
  @param lineString the input linestring
  @param shadowOffset computed according the sun position and the height of
  the geometry
  @return