question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Along doesn't work with MultiLineString

See original GitHub issue

Please provide the following when reporting an issue:

  • GeoJSON data as a gist file or geojson.io (filename extension must be .geojson).
  • Snippet of source code or for complex examples use jsfiddle.

Hi guys, thx for your awesome work!

I’d like to ask if you are planning to add MultiLineString support to turf.along()?

Currently, it doesn’t work, I’m getting error messages like: angular.js:14961 TypeError: Cannot read property '1' of undefined

Uncaught Error: Coordinate is not a valid Point

This would be important to implement, since currently turf.along() fails with antimeridian cases. GeoJSON standard says antimeridian geometries should be MultiLineString type: https://tools.ietf.org/html/rfc7946#section-3.1.9

Reproduced:

https://jsfiddle.net/8h16u93j/

https://raw.githubusercontent.com/Turfjs/turf/master/packages/turf-length/test/in/multi-linestring.geojson

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
dpmcmlxxvicommented, May 21, 2019

@csimpi morganherlocker said it well. The multi-parts are in an array so, yes, they have an order but not necessarily a meaningful order across users and data sets.

However, even if this feature request doesn’t make it in Turf, think of this as an opportunity. There may be a user appetite for a new library with advanced geospatial processing built on top of Turf that allows for more complex algorithms. A turf-toolbox if you will. There are a few packages currently in Turf that would probably qualify but they are already in.

1reaction
morganherlockercommented, May 20, 2019

I don’t get this part: order is not guaranteed. The coordinates of the different lines are in an array with indexes, so the order is static, one line comes after the previous, what part that I don’t understand?

I stand corrected! I had mixed up the fact that JSON does not guarantee Object key order, but it does, in fact maintain array order as you say.

I am still skeptical of this design though, since there is nothing about MultiLineString that suggests the data has a logical order or connection between parts. We would need to carefully define how the coordinates would be traversed, and we generally avoid algorithms that are non-obvious given the inputs and operation with very few exceptions. Should this algorithm ignore gaps between lines? Should it add the distance between linestrings to the running total? I can see reasonable reasons for both, which suggests to me that it may be a thing for users to decide in a helper function. I’m a little on the fence here to be honest, but I am always hesitant to introduce more complexity.

Read more comments on GitHub >

github_iconTop Results From Across the Web

QGIS Difference Algorithm: multilinestring won't work with ...
I already used the 'Fix geometries' on both layers, and the buffer trick. Both don't work. Could I perhaps somehow convert multilinestrings ......
Read more >
python - Multi line string with arguments. How to declare?
Using textwrap.dedent() around a multi-line string solves all of the problems of my previous answer! Here's the official documentation on it ( ...
Read more >
MULTILINESTRING | CockroachDB Docs
A MultiLineString can be created from SQL by calling an aggregate function such as ST_Collect or ST_Union on a column that contains LineString...
Read more >
MultiLineString - SQL Server - Microsoft Learn
The following example shows three valid MultiLineString instances and one MultiLineString instance that is not valid. SQL Copy. DECLARE @g1 ...
Read more >
RFC 7946: The GeoJSON Format
GeoJSON supports the following geometry types: Point, LineString, Polygon, MultiPoint, ... In other words, every point on a line that does not cross...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found