omanges / turfpy

A Python library for performing geospatial data analysis which reimplements turf.js.
MIT License
121 stars 27 forks source link

line_segment() doesn't return all segments of MultiLineString #86

Closed kapitan-iglu closed 3 years ago

kapitan-iglu commented 3 years ago

I just discovered weird behavior of line_segment() when used with MultiLineString:

from turfpy.misc import line_segment
from json import dumps

mls = {
  "type": "Feature",
    "properties": {},
    "geometry": {
        "type": "MultiLineString",
        "coordinates": [
            [
                [51,47],
                [51,43]
            ],
            [
                [45,47],
                [45,43]
            ]
        ]
    }
}

print(dumps(line_segment(mls), indent=4))

result contains only first segment:

{
    "type": "FeatureCollection",
    "features": [
        {
            "type": "Feature",
            "geometry": {
                "type": "LineString",
                "coordinates": [
                    [51,43],
                    [51,47]
                ]
            },
            "properties": {},
            "bbox": [51,43,51,47],
            "id": 0
        }
    ]
}

If I add return True on line misc.py:157 to let iterate over all features (instead of stopping after first feature), line_segment() returns correct result...

Is it bug or feature?