Documentation ¶
Overview ¶
go-whosonfirst-export is a Go package for exporting Who's On First documents in Go.
Example
import ( "context" "github.com/whosonfirst/go-whosonfirst-export/v2" "io" "os ) func main() { ctx := context.Background() ex, _ := export.NewExporter(ctx, "whosonfirst://") path := "some.geojson" fh, _ := os.Open(path) defer fh.Close() body, _ := io.ReadAll(fh) body, _ = ex.Export(ctx, body) os.Stdout.Write(body) }
Index ¶
- func AssignProperties(ctx context.Context, body []byte, to_assign map[string]interface{}) ([]byte, error)
- func AssignPropertiesIfChanged(ctx context.Context, body []byte, to_assign map[string]interface{}) (bool, []byte, error)
- func CessateRecord(ctx context.Context, ex Exporter, old_body []byte) ([]byte, error)
- func CessateRecordWithTime(ctx context.Context, ex Exporter, t time.Time, old_body []byte) ([]byte, error)
- func DeprecateRecord(ctx context.Context, ex Exporter, old_body []byte) ([]byte, error)
- func DeprecateRecordWithTime(ctx context.Context, ex Exporter, t time.Time, old_body []byte) ([]byte, error)
- func EnsureProperties(ctx context.Context, body []byte, to_ensure map[string]interface{}) ([]byte, error)
- func Export(feature []byte, opts *Options, wr io.Writer) error
- func ExportChanged(feature []byte, existingFeature []byte, opts *Options, wr io.Writer) (changed bool, err error)
- func Exporters() []string
- func Format(feature []byte, opts *Options) ([]byte, error)
- func Prepare(feature []byte, opts *Options) ([]byte, error)
- func RegisterExporter(ctx context.Context, scheme string, init_func ExporterInitializationFunc) error
- func RemoveProperties(ctx context.Context, body []byte, to_remove []string) ([]byte, error)
- func SupersedeRecord(ctx context.Context, ex Exporter, old_body []byte) ([]byte, []byte, error)
- func SupersedeRecordWithParent(ctx context.Context, ex Exporter, to_supersede_f []byte, parent_f []byte) ([]byte, []byte, error)
- type Exporter
- type ExporterInitializationFunc
- type Feature
- type Options
- type WhosOnFirstExporter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssignProperties ¶ added in v2.1.0
func AssignPropertiesIfChanged ¶ added in v2.3.1
func CessateRecord ¶ added in v2.6.0
CessateRecord will assign the relevant properties to make 'old_body' as cessated (ceased) using the current time.
func CessateRecordWithTime ¶ added in v2.6.0
func CessateRecordWithTime(ctx context.Context, ex Exporter, t time.Time, old_body []byte) ([]byte, error)
CessateRecordWithTime will assign the relevant properties to make 'old_body' as cessated (ceased) using the time defined by 't'.
func DeprecateRecord ¶ added in v2.6.0
DeprecateRecord will assign the relevant properties to make 'old_body' as deprecated using the current time. This method does not handle assigning or updating "supersedes" or "superseded_by" properties.
func DeprecateRecordWithTime ¶ added in v2.6.0
func DeprecateRecordWithTime(ctx context.Context, ex Exporter, t time.Time, old_body []byte) ([]byte, error)
DeprecateRecordWithTime will assign the relevant properties to make 'old_body' as deprecated using the time defined by 't'. This method does not handle assigning or updating "supersedes" or "superseded_by" properties.
func EnsureProperties ¶ added in v2.1.0
func ExportChanged ¶
func ExportChanged(feature []byte, existingFeature []byte, opts *Options, wr io.Writer) (changed bool, err error)
ExportChanged returns a boolean which indicates whether the file was changed by comparing it to the `existingFeature` byte slice, before the lastmodified timestamp is incremented. If the `feature` is identical to `existingFeature` it doesn't write to the `io.Writer`.
func RegisterExporter ¶
func RegisterExporter(ctx context.Context, scheme string, init_func ExporterInitializationFunc) error
func RemoveProperties ¶ added in v2.1.0
func SupersedeRecord ¶ added in v2.1.0
Types ¶
type Exporter ¶
type WhosOnFirstExporter ¶
type WhosOnFirstExporter struct { Exporter // contains filtered or unexported fields }
func (*WhosOnFirstExporter) ExportFeature ¶
func (ex *WhosOnFirstExporter) ExportFeature(ctx context.Context, feature interface{}) ([]byte, error)