Repository: uscuni/neatnet

Issue:
clean integer index when returning `nodes.remove_false_nodes()`
Not critical, but it would be nice to return a clean integer index when returning [`nodes.remove_false_nodes()`](https://github.com/uscuni/sgeop/blob/86352bfe585950ef3f98a879809124390d6c87ff/sgeop/nodes.py#L263). This helps with granular testing and troubleshooting when bugs crop up.

Hints from issue comments:
@jGaboardi: Actually will add this to `nodes.remove_false_nodes()` itself.

Solution patch:
diff --git a/sgeop/nodes.py b/sgeop/nodes.py
index 9fc4c95..555d308 100644
--- a/sgeop/nodes.py
+++ b/sgeop/nodes.py
@@ -338,7 +338,7 @@ def merge_geometries(block: gpd.GeoSeries) -> shapely.LineString:
             fixed_index.append(ix)
 
     aggregated.loc[loops.index[fixed_index], aggregated.geometry.name] = fixed_loops
-    return aggregated
+    return aggregated.reset_index(drop=True)
 
 
 def _rotate_loop_coords(


Test patch:
diff --git a/sgeop/tests/test_nodes.py b/sgeop/tests/test_nodes.py
index 6dac1bd..994a02f 100644
--- a/sgeop/tests/test_nodes.py
+++ b/sgeop/tests/test_nodes.py
@@ -786,3 +786,53 @@ def test_no_rotate_intersects_2(self):
             edges[~edges.is_ring],
         )
         numpy.testing.assert_array_equal(observed, self.known)
+
+
+def test_fix_topology():
+    p20 = shapely.Point(2, 0)
+    p30 = shapely.Point(3, 0)
+    p40 = shapely.Point(4, 0)
+    p21 = shapely.Point(2, 1)
+    p41 = shapely.Point(4, 1)
+
+    p251 = shapely.Point(2.5, 1)
+    p215 = shapely.Point(2, 1.5)
+    p315 = shapely.Point(3, 1.5)
+
+    p27508 = shapely.Point(2.75, 0.8)
+    p32508 = shapely.Point(3.25, 0.8)
+    p31 = shapely.Point(3, 1)
+
+    line2040 = shapely.LineString((p20, p40))
+    line41313041 = shapely.LineString((p41, p21, p30, p41))
+    line251215315251 = shapely.LineString((p215, p315, p251, p215))
+    line275083250831 = shapely.LineString((p27508, p32508, p31, p27508))
+
+    known = geopandas.GeoDataFrame(
+        {
+            "geometry": [
+                shapely.LineString((p251, p215, p315, p251)),
+                shapely.LineString((p31, p27508, p32508, p31)),
+                shapely.LineString((p30, p41, p31)),
+                shapely.LineString((p20, p30)),
+                shapely.LineString((p30, p40)),
+                shapely.LineString((p251, p21, p30)),
+                shapely.LineString((p31, p251)),
+            ],
+            "_status": ["changed"] * 7,
+        }
+    )
+
+    observed = sgeop.nodes.fix_topology(
+        geopandas.GeoDataFrame(
+            geometry=[
+                line2040,
+                line2040,
+                line41313041,
+                line251215315251,
+                line275083250831,
+            ]
+        )
+    )
+
+    geopandas.testing.assert_geodataframe_equal(observed, known)