コード例 #1
0
  protected static EditableFeatureAttributeDescriptor addGeometryColumn(EditableFeatureType fType) {

    EditableFeatureAttributeDescriptor attrTmp = null;
    EditableFeatureAttributeDescriptor attr = null;
    Iterator iter = fType.iterator();
    while (iter.hasNext()) {
      attrTmp = (EditableFeatureAttributeDescriptor) iter.next();
      if (attrTmp.getDataType() == DataTypes.GEOMETRY) {
        if (attr != null) {
          // Two geom fields not allowed
          fType.remove(attrTmp.getName());
        } else {
          attr = attrTmp;
          attr.setName(GEOMETRY_ATTIBUTE_NAME);
        }
      }
    }

    if (attr == null) {
      attr = fType.add(GEOMETRY_ATTIBUTE_NAME, DataTypes.GEOMETRY);
      try {
        attr.setDefaultValue(geomManager.createNullGeometry(SUBTYPES.GEOM2D));
      } catch (CreateGeometryException e) {
        logger.error("Error creating the envelope", e);
      }
    }

    fType.setDefaultGeometryAttributeName(attr.getName());
    return attr;
  }