export

package module
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 2, 2021 License: BSD-3-Clause Imports: 6 Imported by: 2

README

go-whosonfirst-export

Go package for exporting Who's On First documents.

Install

You will need to have both Go (version 1.12 or higher) and the make programs installed on your computer. Assuming you do just type:

make tools

All of this package's dependencies are bundled with the code in the vendor directory.

What is this?

This is an experimental-cum-evolving package to format Who's On First documents in Go. It is meant to be a port of the py-mapzen-whosonfirst-geojson package and mmmmmmmaybe some or all of the py-mapzen-whosonfirst-export package.

It is also in flux and you should assume anything you see or read now will change.

Example

Simple
import (
	"github.com/whosonfirst/go-whosonfirst-export"
	"github.com/whosonfirst/go-whosonfirst-export/options"	
	"io/ioutil"
	"os
)

func main() {

	path := "some.geojson"     	
	fh, _ := os.Open(path)
	defer fh.Close()

	body, _ := ioutil.ReadAll(fh)

	opts, _ := options.NewDefaultOptions()
	export.Export(body, opts, os.Stdout)
}

Error handling removed for the sake of brevity.

To do

This package needs to hold hands with the go-whosonfirst-validate package.

See also

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Export

func Export(feature []byte, opts options.Options, wr io.Writer) error

func ExportChanged added in v0.3.2

func ExportChanged(feature []byte, existingFeature []byte, opts options.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 Format

func Format(feature []byte, opts options.Options) ([]byte, error)

func Prepare

func Prepare(feature []byte, opts options.Options) ([]byte, error)

Types

type Feature

type Feature struct {
	Type       string      `json:"type"`
	Id         int64       `json:"id"`
	Properties interface{} `json:"properties"`
	Bbox       []float64   `json:"bbox,omitempty"`
	Geometry   interface{} `json:"geometry"`
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL