ConceptualMesh.add_line accepts a snap_to_polygons parameter and documents it:
def add_line(self, geometry, line_id, resolution, snap_to_polygons=True, is_barrier=False, ...):
"""
snap_to_polygons (bool): If True, the line's endpoints will be snapped to
nearby polygon boundaries to ensure connectivity.
"""
The value is never stored. The dict appended to self.raw_lines has no snap_to_polygons key, so nothing downstream can read it:
self.raw_lines.append({
'geometry': geometry,
'line_id': line_id,
'lc': resolution,
'is_barrier': is_barrier,
'dist_min': dist_min,
'dist_max': dist_max,
'straddle_width': straddle_width
})
_enforce_connectivity then snaps every line unconditionally:
for i, line_data in enumerate(self.raw_lines):
original_line = line_data['geometry']
snapped_line = snap(original_line, poly_boundaries, tolerance)
self.raw_lines[i]['geometry'] = snapped_line
So snap_to_polygons=False silently does nothing — the line is snapped anyway. A user who deliberately wants a line left un-snapped (for instance a line intentionally ending just short of a zone edge) gets the opposite of what they asked for, with no warning.
Options
- Implement it — store the flag and skip those lines in
_enforce_connectivity. This is what the docstring already promises.
- Remove it — drop the parameter and the docstring entry, and document that all lines are snapped with
connectivity_tolerance.
Option 1 is probably worth it: connectivity_tolerance is global, so per-feature opt-out is the only way to exempt a single line today.
Pre-existing on develop — not introduced by #12, though #12 adds connectivity_tolerance as a generate() override, which makes the missing per-feature control more noticeable.
ConceptualMesh.add_lineaccepts asnap_to_polygonsparameter and documents it:The value is never stored. The dict appended to
self.raw_lineshas nosnap_to_polygonskey, so nothing downstream can read it:_enforce_connectivitythen snaps every line unconditionally:So
snap_to_polygons=Falsesilently does nothing — the line is snapped anyway. A user who deliberately wants a line left un-snapped (for instance a line intentionally ending just short of a zone edge) gets the opposite of what they asked for, with no warning.Options
_enforce_connectivity. This is what the docstring already promises.connectivity_tolerance.Option 1 is probably worth it:
connectivity_toleranceis global, so per-feature opt-out is the only way to exempt a single line today.Pre-existing on
develop— not introduced by #12, though #12 addsconnectivity_toleranceas agenerate()override, which makes the missing per-feature control more noticeable.