Beispiel #1
0
 /**
  * Copy the input feature to a new Schema whereby the new Feature Schema must be an extended or
  * shortened one
  *
  * @param feature
  * @param newSchema
  * @return a new Feature with newSchema as Schema and feature values
  */
 public static Feature copyFeature(Feature feature, FeatureSchema newSchema) {
   FeatureSchema oldSchema = feature.getSchema();
   Feature newF = new BasicFeature(newSchema);
   int n = 0;
   if (oldSchema.getAttributeCount() > newSchema.getAttributeCount()) {
     // for schema shortening
     n = newSchema.getAttributeCount();
   } else {
     // for schema extension
     n = oldSchema.getAttributeCount();
   }
   for (int i = 0; i < n; i++) {
     String aname = oldSchema.getAttributeName(i);
     Object value = feature.getAttribute(aname);
     newF.setAttribute(aname, value);
   }
   return newF;
 }
Beispiel #2
0
 /**
  * Copy/clone the input featureSchema since it is not proper implemented in Jump
  *
  * @param oldSchema
  * @return a clone of oldSchema
  */
 public static FeatureSchema copyFeatureSchema(FeatureSchema oldSchema) {
   FeatureSchema fs = new FeatureSchema();
   for (int i = 0; i < oldSchema.getAttributeCount(); i++) {
     AttributeType at = oldSchema.getAttributeType(i);
     String aname = oldSchema.getAttributeName(i);
     fs.addAttribute(aname, at);
     fs.setCoordinateSystem(oldSchema.getCoordinateSystem());
   }
   return fs;
 }