sharedstreets / sharedstreets-js

SharedStreets (Node.js & Javascript)
https://sharedstreets.io
MIT License
77 stars 25 forks source link

Error: coordinates must contain numbers #90

Open jamaps opened 3 years ago

jamaps commented 3 years ago

Hi there!

Apologies if this is not the correct place to post this!

I'm getting an error when trying to match points in sharedstreets that I can't figure out. And any help would be much appreciated :)

This is what I'm running.

npm-do shst match test_points.geojson --out=matched_points.geojson

But I'm getting the following error:

 🌏  Loading geojson data...
       Matching using car routing rules on all streets
  ✨  Matching 3 points...
    Error: coordinates must contain numbers

I thought it was just some weird formatting with my geojson (coordinates as strings), but I've tried a few different point Geojson datasets and they all return the same error. Matching line geometries have worked great, I only get this error with points.

e.g. below is a geojson that I've tested

{"type": "FeatureCollection",
    "features": [
      {
        "type": "Feature",
        "properties": {"bearing":90},

        "geometry": {
          "type": "Point",
          "coordinates": [
            -79.494582662656398, 43.689484593933997
          ]
        }
      },
      {
        "type": "Feature",
        "properties": {"bearing":90},
        "geometry": {
          "type": "Point",
          "coordinates": [
            -79.281026293856101, 43.675363068044803
          ]
        }
      },
      {
        "type": "Feature",
        "properties": {"bearing":90},
        "geometry": {
          "type": "Point",
          "coordinates": [
            -79.4073484623935, 43.666125615195597   
          ]
        }
      }
    ]
  }

Thanks!

ervinanoh commented 3 years ago

Good Morning did you find a solution to your problem? I faced the same and still looking how to solve it! Thank you!

aalexsmithh commented 3 years ago

Hi @jamaps

I don't believe that this is an issue with the data you are using. I checked my own data numerous times to ensure the validity and still was running into these issues.

I suspect that this issue was caused by a change to a turf dependency that no longer handles empty geojson objects. I was able to add a null check in the tile creation process so that the Graph object can be created. Please see #94 for details!

I was able to get this work with my data, but we would need @kpwebb to merge some PRs and republish the package so you don't have to build it yourself.

vishalmhjn commented 2 years ago

Hey @jamaps, you yourself answered your question. Yes, it didn't work for me either. The hack was to convert the point to linestring with two same points. Then it works :)

"type": "LineString",
                "coordinates": [
                    [
                        -3.72085115335525,
                        40.4195518069243
                    ],
                    [
                        -3.72085115335525,
                        40.4195518069243
                    ]
                ]