Skip to content

Commit

Permalink
update random documentation (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomchavakis authored Nov 19, 2021
1 parent 4f3249b commit ad55b29
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# :hammer: [![release](https://badgen.net/github/release/tomchavakis/turf-go)](https://github.com/tomchavakis/turf-go/releases/latest) [![GitHub license](https://badgen.net/github/license/tomchavakis/turf-go)](https://github.com/tomchavakis/turf-go/blob/master/LICENSE) [![Go Report Card](https://goreportcard.com/badge/github.com/tomchavakis/turf-go)](https://goreportcard.com/report/github.com/tomchavakis/turf-go) [![Coverage Status](https://coveralls.io/repos/github/tomchavakis/turf-go/badge.svg?branch=master)](https://coveralls.io/github/tomchavakis/turf-go?branch=master)
# :hammer: [![release](https://badgen.net/github/release/tomchavakis/turf-go)](https://github.com/tomchavakis/turf-go/releases/latest) [![GoDoc](https://godoc.org/github.com/tomchavakis/turf-go?status.svg)](https://godoc.org/github.com/tomchavakis/turf-go) [![GitHub license](https://badgen.net/github/license/tomchavakis/turf-go)](https://github.com/tomchavakis/turf-go/blob/master/LICENSE) [![Go Report Card](https://goreportcard.com/badge/github.com/tomchavakis/turf-go)](https://goreportcard.com/report/github.com/tomchavakis/turf-go) [![Coverage Status](https://coveralls.io/repos/github/tomchavakis/turf-go/badge.svg?branch=master)](https://coveralls.io/github/tomchavakis/turf-go?branch=master)

# turf-go
A Go language port of [Turfjs](http://turfjs.org/docs/)
Expand Down
27 changes: 17 additions & 10 deletions random/random.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,22 @@ type PolygonOptions struct {
}

// Position returns a random position within a bounding box
//
// Examples:
// random.Position(geojson.BBOX{West: -180,South: -90,East: 180, North: 90 })
// random.Position(geojson.BBOX{West: -180,South: -90,East: 180, North: 90 })
func Position(bbox geojson.BBOX) geometry.Position {
pos := coordInBBox(bbox)
res := geometry.NewPosition(nil, pos[0], pos[1])
return *res
}

// Point returns a GeoJSON FeatureCollection of random Point within a bounding box
// Point returns a GeoJSON FeatureCollection of random Point within a bounding box.
//
// count is how many geometries will be generated. default = 1
//
// Examples:
// random.Point(0, geojson.BBOX{West: -180,South: -90,East: 180, North: 90})
// random.Point(10, geojson.BBOX{West: -180,South: -90,East: 180, North: 90})
// random.Point(0, geojson.BBOX{West: -180,South: -90,East: 180, North: 90})
// random.Point(10, geojson.BBOX{West: -180,South: -90,East: 180, North: 90})
func Point(count int, bbox geojson.BBOX) (*feature.Collection, error) {
if count == 0 {
count = 1
Expand Down Expand Up @@ -75,7 +78,8 @@ func Point(count int, bbox geojson.BBOX) (*feature.Collection, error) {
return nil, errors.New("can't generate a random point")
}

// LineString returns a GeoJSON FeatureCollection of random LineString within a bounding box
// LineString returns a GeoJSON FeatureCollection of random LineString within a bounding box.
//
// count=1 how many geometries will be generated
//
// Examples:
Expand Down Expand Up @@ -146,12 +150,15 @@ func LineString(count int, options LineStringOptions) (*feature.Collection, erro
return nil, errors.New("can't generate a random LineString")
}

// Polygon returns a GeoJSON FeatureCollection of random Polygon
// Polygon returns a GeoJSON FeatureCollection of random Polygon.
//
// count=1 how many geometries will be generated
//
// Examples:
// random.Polygon(10,PolygonOptions{
// BBox: geojson.BBOX{West: -180,South: -90,East: 180, North: 90},
// NumVertices: nil,
// MaxRadialLength: nil,
// random.Polygon(10,PolygonOptions{
// BBox: geojson.BBOX{West: -180,South: -90,East: 180, North: 90},
// NumVertices: nil,
// MaxRadialLength: nil,
// })
func Polygon(count int, options PolygonOptions) (*feature.Collection, error) {

Expand Down

0 comments on commit ad55b29

Please sign in to comment.