       (assoc :_current_validity (:_validity feature))
       (assoc :_validity (tf/unparse date-time-formatter (local-now)))))
 
+(defn transform-to-close [feature]
+  (-> feature
+      (assoc :_action "close")
+      (assoc :_current_validity (:_validity feature))
+      (assoc :_validity (tf/unparse date-time-formatter (local-now)))))
+
 (defn transform-to-nested [feature]
   (apply dissoc feature [:_action :_collection :_id :_validity :_current_validity]))
 

    attributes))

(defn random-json-features [out-stream dataset collection total & args]
  (let [{:keys [updates? nested geometry?] :or {updates? false nested 0 geometry? true}} args
        validity (tf/unparse date-time-formatter (local-now))
        attributes (create-attributes 3)
        new-features (repeatedly #(random-new-feature collection attributes))
        with-nested (map #(combine-to-nested-feature % "nested" geometry?) (partition (+ 1 nested) new-features))
        with-changed (if updates? (mapcat followed-by-change with-nested) with-nested)
        package {:_meta {}
                 :dataset dataset
                 :features (take total with-changed)}]
    (json/generate-stream package out-stream)))

(defn- random-json-feature-stream* [out-stream dataset collection total & args]

      1 (assoc base attr (first nested-features))
      (assoc base attr (into [] nested-features)))))

(defn followed-by [feature change? close?]
  (let [change (fn [f] (selective-feature (transform-to-change f)))
        close  (fn [f] (selective-feature (transform-to-close f)))
        result [feature]
        result (if change?
                 (conj result (change feature))
                 result)
        result (if close?
                 (conj result (close feature))
                 result)]
    result))

(defn create-attributes [simple-attributes & {:keys [names]}]
  (let [attribute-names (or names (repeatedly simple-attributes #(random-word 5)))
