@Override
  public ODocument toDoc(ShapeCollection<Shape> shapes) {

    ODocument doc = new ODocument(getName());
    List<ODocument> geometries = new ArrayList<ODocument>(shapes.size());
    for (Shape s : shapes) {
      geometries.add(shapeFactory.toDoc(s));
    }
    doc.field("geometries", geometries);
    return doc;
  }
  @Override
  public ShapeCollection<Shape> fromDoc(ODocument doc) {

    List<ODocument> geometries = doc.field("geometries");

    List<Shape> shapes = new ArrayList<Shape>();

    Geometry[] geoms = new Geometry[geometries.size()];
    for (ODocument geometry : geometries) {
      Shape shape = shapeFactory.fromDoc(geometry);
      shapes.add(shape);
    }

    return new ShapeCollection(shapes, SPATIAL_CONTEXT);
  }