Go package for indexing Who's On First documents
You will need to have both Go
(specifically a version of Go more recent than 1.7 so let's just assume you need Go 1.9 or higher) and the make
programs installed on your computer. Assuming you do just type:
make bin
All of this package's dependencies are bundled with the code in the vendor
directory.
package main
import (
"context"
"flag"
"github.com/whosonfirst/go-whosonfirst-index"
"io"
"log"
)
func main() {
var mode = flag.String("mode", "repo", "A valid go-whosonfirst-index mode")
flag.Parse()
f := func(fh io.Reader, ctx context.Context, args ...interface{}) error {
path, err := index.PathForContext(ctx)
if err != nil {
return err
}
log.Println("PATH", path)
return nil
}
i, err := index.NewIndexer(*mode, f)
if err != nil {
log.Fatal(err)
}
for _, path := range flag.Args() {
err := i.IndexPath(path)
if err != nil {
log.Fatal(err)
}
}
}
Index all the files in a directory.
Index a GeoJSON Feature.
Index all the features in GeoJSON FeatureCollection.
Index a list of files.
Index all the features in line-separated GeoJSON list.
Index all the files listed in a Who's On First "meta" (CSV) file.
Index a path.
Index all the files in the data
directory of a Who's On First repository.
Index all the records in the geojson
table of a Who's On First SQLite database.