Skip to content

Commit

Permalink
Merge pull request databrickslabs#254 from databrickslabs/fix/duplica…
Browse files Browse the repository at this point in the history
…ted_indexes

Fixed duplicated indexes
  • Loading branch information
Milos Colic authored Nov 13, 2022
2 parents 8846a3d + 3620d8b commit 5fd41c8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ object Mosaic {
}

val coreIndices = indexSystem.polyfill(carvedGeometry, resolution, Some(geometryAPI))
val borderIndices = indexSystem.polyfill(borderGeometry, resolution, Some(geometryAPI))
val borderIndices = indexSystem.polyfill(borderGeometry, resolution, Some(geometryAPI)).diff(coreIndices)

val coreChips = indexSystem.getCoreChips(coreIndices, keepCoreGeom, geometryAPI)
val borderChips = indexSystem.getBorderChips(geometry, borderIndices, keepCoreGeom, geometryAPI)
Expand Down
17 changes: 17 additions & 0 deletions src/test/scala/com/databricks/labs/mosaic/core/TestMosaic.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.databricks.labs.mosaic.core

import com.databricks.labs.mosaic.core.geometry.api.GeometryAPI.ESRI
import com.databricks.labs.mosaic.core.index.H3IndexSystem
import org.scalatest.funsuite.AnyFunSuite

class TestMosaic extends AnyFunSuite {

test("mosaicFill should not return duplicates with H3") {
// This tests the fix for issue #243 https://github.com/databrickslabs/mosaic/issues/243
val geom = ESRI.geometry("POLYGON ((4.42 51.78, 4.38 51.78, 4.39 51.83, 4.40 51.83, 4.41 51.8303, 4.417 51.8295, 4.42 51.83, 4.44 51.81, 4.42 51.78))", "WKT")
val result = Mosaic.mosaicFill(geom, 7, true, H3IndexSystem, ESRI)

assert(result.length == 10)
assert(result.map(x => x.index).distinct.length == 10)
}
}

0 comments on commit 5fd41c8

Please sign in to comment.