Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

akhenakh/tgo

Repository files navigation

tgo

Tests

GoDoc

Go bindings for tidwall/tg Geometry library for C - Fast point-in-polygon

This is partial but functional, tg is a very small self contained C library, tgo compiles tg, no external dependencies needed.

Usage

Simply go get this library with CGO enabled (you'll need a C compiler).

Read from WKT

// Unmarshal from WKT
input := "POLYGON((0 0,0 1,1 1,1 0,0 0))"
g, _ := tgo.UnmarshalWKT(input)
// Marshal to WKT
output := g.AsText()
fmt.Println(output) // Prints: POLYGON((0 0,0 1,1 1,1 0,0 0))

Read from GeoJSON

input := `{"type":"Feature","properties":{},"geometry":{"coordinates":[-79.20159897229003,43.636785010689835],"type":"Point"}}`
g, _ := tgo.UnmarshalGeoJSON(input)

Read from WKB

input := []byte{1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 248, 63, 0, 0, 0, 0, 0, 0, 4, 64}
g, _ := tgo.UnmarshalWKB(input)

Intersects

if Intersects(g1, g2) {
	fmt.Println("Intersects")
}

Point in Polygon on large FeatureCollections

// load your collection using UnmarshalGeoJSON
found := g.StabOne(2, 48)
if found != nil {
	fmt.Println(found.Properties())
}
// Output: {"properties":{ "ADMIN": "France", "ISO_A2": "FR", "ISO_A3": "FRA" }}

Types

input := "POLYGON((0 0,0 1,1 1,1 0,0 0))"
g, _ := tgo.UnmarshalWKT(input)
if g.Types() == tgo.Polygon() {
	p, _ := g.AsPoly()
	p.HolesCount()
}

Tests

Some tests are borrowed from simplefeatures.

About

Go bindings for TG Fast point-in-polygon Geometry

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

Contributors

AltStyle によって変換されたページ (->オリジナル) /