geojson

package module
v0.12.3 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2020 License: BSD-3-Clause Imports: 2 Imported by: 31

README

go-whosonfirst-geojson-v2

Go tools for working with Who's On First documents

Install

You will need to have both Go (specifically version 1.12 or higher because we're using Go modules) 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.

Important

This is work in progress. It may change (and break your code) still. This package aims to replace the existing go-whosonfirst-geojson package. If you want to follow along, please consult:

https://github.com/whosonfirst/go-whosonfirst-geojson-v2/issues/1

geojson-v2?

Yeah, I don't really like it either but this package is basically 100% backwards incompatible with github.com/whosonfirst/go-whosonfirst-geojson and while I don't really think anyone else is using it I don't like the idea of suddenly breaking everyone's code.

Interfaces

Unlike the first go-whosonfirst-geojson package this one at least attempts to define a simplified interface for working with GeoJSON features. These are still in flux.

Please finish writing me.

geojson.Feature
type Feature interface {
	Type() string
	Id() int64
	Name() string
	Placetype() string
	ToString() string
	ToBytes() []byte
	BoundingBoxes() (BoundingBoxes, error)
	Polygons() ([]Polygon, error)
	ContainsCoord(geom.Coord) (bool, error)
}
geojson.BoundingBoxes
type BoundingBoxes interface {
	Bounds() []*geom.Rect
	MBR() geom.Rect
}
geojson.Centroid
type Centroid interface {
	Coord() geom.Coord
	Source() string
}
geojson.Polygon
type Polygon interface {
	ExteriorRing() geom.Polygon
	InteriorRings() []geom.Polygon
	ContainsCoord(geom.Coord) bool
}

Usage

Simple
import (
	"github.com/whosonfirst/go-whosonfirst-geojson-v2/whosonfirst"
	"log"
)

func main() {

	path := "/usr/local/data/whosonfirst-data/data/101/736/545/101736545.geojson"
	f, err := whosonfirst.LoadFeatureFromFile(path)

	if err != nil {
		log.Fatal(err)
	}

	// prints "Montreal"
	log.Println("Name is ", f.Name())
}

See also

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BoundingBoxes

type BoundingBoxes interface {
	Bounds() []*geom.Rect
	MBR() geom.Rect
}

type Centroid

type Centroid interface {
	Coord() geom.Coord
	Source() string
	ToString() (string, error)
}

type Feature

type Feature interface {
	Id() string
	Name() string
	Placetype() string
	String() string
	Bytes() []byte
	BoundingBoxes() (BoundingBoxes, error)
	Polygons() ([]Polygon, error)
	SPR() (spr.StandardPlacesResult, error)
	ContainsCoord(geom.Coord) (bool, error)
}

type Geometry

type Geometry interface{}

type Polygon

type Polygon interface {
	ExteriorRing() geom.Polygon
	InteriorRings() []geom.Polygon
	ContainsCoord(geom.Coord) bool
}

Jump to

Keyboard shortcuts

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