private List<Metacard> createMetacardList(int start, int finish) {
    List<Metacard> list = new LinkedList<Metacard>();

    for (int i = start; i <= finish; i++) {
      MetacardImpl metacard = new MetacardImpl();

      metacard.setId(ID_PREFIX + i);
      metacard.setSourceId(SOURCE_PREFIX + i);
      metacard.setTitle(TITLE_PREFIX + i);
      // for testing a attribute with multiple values
      AttributeDescriptor ad =
          new AttributeDescriptorImpl(FORMAT, true, true, true, true, BasicTypes.STRING_TYPE);
      Set<AttributeDescriptor> ads =
          new HashSet<AttributeDescriptor>(metacard.getMetacardType().getAttributeDescriptors());
      ads.add(ad);
      metacard.setType(new MetacardTypeImpl("test", ads));
      metacard.setLocation(WKT);
      AttributeImpl attr = new AttributeImpl(FORMAT, FORMAT);
      attr.addValue(FORMAT);
      metacard.setAttribute(attr);
      // for testing a attribute with no attribute descriptor
      metacard.setAttribute(RELATION, RELATION);

      list.add(metacard);
    }

    return list;
  }
Ejemplo n.º 2
0
  public static Attribute unmarshalFrom(GeometryElement element) throws ConversionFailedException {
    AttributeImpl attribute = null;
    GML311ToJTSGeometryConverter converter = new GML311ToJTSGeometryConverter();
    WKTWriter wktWriter = new WKTWriter();

    for (Value xmlValue : element.getValue()) {
      JAXBElement<AbstractGeometryType> xmlGeometry = xmlValue.getGeometry();
      Geometry geometry =
          converter.createGeometry(new DefaultRootObjectLocator(xmlValue), xmlGeometry.getValue());
      String wkt = wktWriter.write(geometry);

      if (attribute == null) {
        attribute = new AttributeImpl(element.getName(), wkt);
      } else {
        attribute.addValue(wkt);
      }
    }
    return attribute;
  }