koopjs/koop-provider-github

.json should also be considered an acceptable filename for geojson

Closed this issue · 5 comments

expected result here for file with extension .geojson

same file with .json extension currently returns `no geojson found':

github preview doesn't distinguish between the two, so it would cool if koop operated similarly.

Agreed, geosjon files are very frequently served with the regular json extension.

started by updating String.replace() here to use a regex, but no bueno (yet)

layer.name = file.replace('.geojson', '')
// becomes
layer.name = file.replace(/(.geojson|.json)/, '')

not sure, but maybe i need to do something similar in Geohub?

@jgravois just rewrote geohub and released 1.0.0, should be easier to fix this issue now.

The gist portion of geohub doesn't look for .geojson files, it just tries to parse the contents of each file and look for the "type": "FeatureCollection" property.

https://github.com/koopjs/geohub/blob/master/lib/gist.js

The github repo portion however does limit extraction to files with the .geojson extension.

https://github.com/koopjs/geohub/blob/master/lib/repo.js#L48

It might be as easy as changing /geojson/ to /json/ in that block, but something tells me it's going to be more complicated than that. PRs welcome! I'll try to get to it soon if you don't get to it first.

i'm headed out of town for about a week, but i'd love to take a 🔪 at fixing this when i get back if its okay with you.

@jgravois I'm out of town most of next week too (visiting EsriDC, attending JS.Geo in Philly) but actively working on getting geohub, koop-gist, and koop-github into shape. I might 🍴 it before you do but I'll leave it for the end.