private GeometryDescriptor reprojectGeometry(GeometryDescriptor descr) {
   if (descr == null) {
     return null;
   }
   GeometryType type =
       ftf.createGeometryType(
           descr.getType().getName(),
           descr.getType().getBinding(),
           reprojection,
           descr.getType().isIdentified(),
           descr.getType().isAbstract(),
           descr.getType().getRestrictions(),
           descr.getType().getSuper(),
           descr.getType().getDescription());
   type.getUserData().putAll(descr.getType().getUserData());
   GeometryDescriptor gd =
       ftf.createGeometryDescriptor(
           type,
           descr.getName(),
           descr.getMinOccurs(),
           descr.getMaxOccurs(),
           descr.isNillable(),
           descr.getDefaultValue());
   gd.getUserData().putAll(descr.getUserData());
   return gd;
 }
  /**
   * Clones the given schema, changing the geometry attribute to match the given dimensionality.
   *
   * @param schema schema to clone
   * @param dimensionality dimensionality for the geometry 1= points, 2= lines, 3= polygons
   */
  private FeatureType cloneWithDimensionality(FeatureType schema, int dimensionality) {
    SimpleFeatureType simpleFt = (SimpleFeatureType) schema;
    SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
    builder.setName(schema.getName());
    builder.setCRS(schema.getCoordinateReferenceSystem());
    for (AttributeDescriptor desc : simpleFt.getAttributeDescriptors()) {
      if (isMixedGeometry(desc)) {
        GeometryDescriptor geomDescriptor = (GeometryDescriptor) desc;
        GeometryType geomType = geomDescriptor.getType();

        Class<?> geometryClass = getGeometryForDimensionality(dimensionality);

        GeometryType gt =
            new GeometryTypeImpl(
                geomType.getName(),
                geometryClass,
                geomType.getCoordinateReferenceSystem(),
                geomType.isIdentified(),
                geomType.isAbstract(),
                geomType.getRestrictions(),
                geomType.getSuper(),
                geomType.getDescription());

        builder.add(
            new GeometryDescriptorImpl(
                gt,
                geomDescriptor.getName(),
                geomDescriptor.getMinOccurs(),
                geomDescriptor.getMaxOccurs(),
                geomDescriptor.isNillable(),
                geomDescriptor.getDefaultValue()));
      } else {
        builder.add(desc);
      }
    }
    schema = builder.buildFeatureType();
    return schema;
  }