whosonfirst / go-whosonfirst-export

Go package for exporting Who's On First documents.
BSD 3-Clause "New" or "Revised" License
2 stars 1 forks source link

Figure out where to wire in ExportToWriter #2

Closed thisisaaronland closed 3 years ago

thisisaaronland commented 5 years ago

As in a go-whosonfirst-readwrite/writer:

func write_feature(body []byte, wr writer.Writer) (string, error) {

        rsp := gjson.GetBytes(body, "properties.wof:id")

        if !rsp.Exists() {
                return "", errors.New("Missing wof:id")
        }

        wof_id := rsp.Int()

        path, err := uri.Id2RelPath(wof_id)

        if err != nil {
        return "", err
        }

        r := bytes.NewReader(body)
        fh := ioutil.NopCloser(r)

    err = wr.Write(path, fh)

    if err != nil {
                return "", err
        }

        return path, nil
}
straup commented 4 years ago

No longer relevant, as this is handled and wrapped by go-whosonfirst-writer.