resample

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2021 License: MIT Imports: 1 Imported by: 0

README

orb/resample Godoc Reference

Package orb/resample has a couple functions for resampling line geometry into more or less evenly spaces points.

func Resample(ls orb.LineString, df orb.DistanceFunc, totalPoints int) orb.LineString
func ToInterval(ls orb.LineString, df orb.DistanceFunc, dist float64) orb.LineString

For example, resampling a line string so the points are 1 planar unit apart:

ls := resample.ToInterval(ls, planar.Distance, 1.0)

Documentation

Overview

Package resample has a couple functions for resampling line geometry into more or less evenly spaces points.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Resample

func Resample(ls orb.LineString, df orb.DistanceFunc, totalPoints int) orb.LineString

Resample converts the line string into totalPoints-1 evenly spaced segments. This function will modify the linestring input.

Example
package main

import (
	"fmt"

	"github.com/paulmach/orb"
	"github.com/paulmach/orb/planar"
	"github.com/paulmach/orb/resample"
)

func main() {
	ls := orb.LineString{
		{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0},
		{5, 0}, {6, 0}, {7, 0}, {8, 0}, {9, 0}, {10, 0},
	}

	// downsample in this case so there are 2.5 units between points
	ls = resample.ToInterval(ls, planar.Distance, 2.5)
	fmt.Println(ls)

}
Output:

[[0 0] [2.5 0] [5 0] [7.5 0] [10 0]]

func ToInterval

func ToInterval(ls orb.LineString, df orb.DistanceFunc, dist float64) orb.LineString

ToInterval coverts the line string into evenly spaced points of about the given distance. This function will modify the linestring input.

Example
package main

import (
	"fmt"

	"github.com/paulmach/orb"
	"github.com/paulmach/orb/planar"
	"github.com/paulmach/orb/resample"
)

func main() {
	ls := orb.LineString{{0, 0}, {10, 0}}

	// upsample so there are 6 total points
	ls = resample.Resample(ls, planar.Distance, 6)
	fmt.Println(ls)

}
Output:

[[0 0] [2 0] [4 0] [6 0] [8 0] [10 0]]

Types

This section is empty.

Jump to

Keyboard shortcuts

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