Пример #1
0
  protected EditableFeatureType getTheFeatureType() throws InitializeException {
    EditableFeatureType fType = super.getTheFeatureType();
    try {
      this.open();
      this.resourcesBegin();
    } catch (DataException e) {
      throw new InitializeException(this.getName(), e);
    }
    try {

      EditableFeatureAttributeDescriptor attr = addGeometryColumn(fType);
      attr.setGeometryType(this.shpFile.getGeometryType());
      attr.setGeometrySubType(this.shpFile.getGeometrySubType());
      // String srs = this.getSRSFromPrj(this.shpFile.getSRSParameters());
      // if (srs == null){
      // // TODO petar ??
      // srs = "EPSG:23030";
      // }
      IProjection srs = getShpParameters().getSRS();
      if (srs == null) {
        srs = CRSFactory.getCRS("EPSG:23030");
      }

      attr.setSRS(srs);

      return fType;
    } catch (ReadException e) {
      throw new InitializeException(e);
    } finally {
      this.resourcesEnd();
    }
  }
Пример #2
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;
  }