Skip to content

Commit

Permalink
invoke callback in onClose method
Browse files Browse the repository at this point in the history
  • Loading branch information
adeet1 committed May 31, 2024
1 parent 8b1e199 commit 8d4bd16
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ class SimpleFeatureWriteSupport(callback: (Envelope, Long) => Unit) extends Writ

def getCount: Long = count

override protected def onClose(bounds: Envelope, count: Long): Unit = {}
// Invoke the callback function for adding bounds to the storage metadata partition
override protected def onClose(bounds: Envelope, count: Long): Unit = {
println("MultipleGeometriesObserver onClose")
callback(bounds, count)
}
}

private val observer = new MultipleGeometriesObserver
Expand All @@ -84,10 +88,7 @@ class SimpleFeatureWriteSupport(callback: (Envelope, Long) => Unit) extends Writ
override def finalizeWrite(): FinalizedWriteContext = {
// Get the bounding boxes that span each geometry type
val bboxes = observer.getBoundingBoxes

for (bbox <- bboxes) {
callback(bbox, observer.getCount)
}
observer.close()

// If the SFT has no geometries, then there's no need to create GeoParquet metadata
if (bboxes.isEmpty) {
Expand Down

0 comments on commit 8d4bd16

Please sign in to comment.