tin

package module
v0.0.0-...-c431c2d Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: AGPL-3.0, Apache-2.0 Imports: 4 Imported by: 2

README

# TIN terrain mesh generation For GO

Documentation

Index

Constants

View Source
const (
	RASTER_DATA_TYPE_INT8    = 0
	RASTER_DATA_TYPE_UINT8   = 1
	RASTER_DATA_TYPE_INT16   = 2
	RASTER_DATA_TYPE_UINT16  = 3
	RASTER_DATA_TYPE_INT32   = 4
	RASTER_DATA_TYPE_UINT32  = 5
	RASTER_DATA_TYPE_INT64   = 6
	RASTER_DATA_TYPE_UINT64  = 7
	RASTER_DATA_TYPE_FLOAT32 = 8
	RASTER_DATA_TYPE_FLOAT64 = 9
)
View Source
const (
	EarthRadius       = 6378137.0
	MinLatitude       = -85.05112878
	MaxLatitude       = 85.05112878
	MinLongitude      = -180.0
	MaxLongitude      = 180.0
	TileSize          = 256
	MaxLevelOfDetail  = 38
	HalfCircumference = 20037508.342789243076571549020
)
View Source
const (
	EPS = float64(0.000000001)
)
View Source
const (
	MAX_AVERAGING_SAMPLES = 64
)
View Source
const (
	Nil = 0xFFFFFFFF
)

Variables

View Source
var (
	NAN_DATA = Data{/* contains filtered or unexported fields */}
)

Functions

func AverageNanArr

func AverageNanArr(toAverage []float64) float64

func Circumcenter

func Circumcenter(a, b, c [2]float64) [2]float64

func Clip25DTriangleByLine

func Clip25DTriangleByLine(tv []Triangle, triangleIdx int, lorg, ldir [2]float64)
  lp - leftPoints
  op - otherPoints

  winding order counter-clockwise = inside
                  +
                 /|
                / |
               /  |
              /   |
             /    |
            /     |
           /      |
          /       |
         /        |
        /         |
l1   s0/          |s1     l0
 x----*-----------*-------x
     /            |
    /             |

lp[0] + |

\             |
  \           |
    \         |
      \       |
        \     |
          \   |
            \ |
              + lp[1]

func InCircumcircle

func InCircumcircle(a, b, c, d [2]float64) bool

func InTriangle

func InTriangle(a, b, c [2]float64, p [2]float64) bool

func InTriangleCCW

func InTriangleCCW(a, b, c [2]float64, p [2]float64) bool

func IsCCW

func IsCCW(a, b, c [2]float64) bool

func LatLongToPixelXY

func LatLongToPixelXY(latitude, longitude float64, levelOfDetail uint64) (pixelX, pixelY int64)

func MapSize

func MapSize(levelOfDetail uint64) uint64

func Max

func Max(x, y float64) float64

func Min

func Min(x, y float64) float64

func MinInt

func MinInt(x, y int) int

func Minus

func Minus(a, b [2]float64) [2]float64

func Orientation

func Orientation(a, b, c [2]float64) float32

func PixelXYTToMeters

func PixelXYTToMeters(pixelX, pixelY int64, levelOfDetail uint64) (meterX, meterY float64)

func PixelXYToLatLong

func PixelXYToLatLong(pixelX, pixelY int64, levelOfDetail uint64) (latitude, longitude float64)

func PixelXYToTileXY

func PixelXYToTileXY(pixelX, pixelY int64) (tileX, tileY int64)

func QuadKeyToTileXY

func QuadKeyToTileXY(quadKey string) (tileX, tileY int64, levelOfDetail uint64)

func Res

func Res(levelOfDetail uint64) float64

func SafeGetPixel

func SafeGetPixel(src *RasterDouble, w, h, r, c int64) float64

func SampleNearestValidAvg

func SampleNearestValidAvg(src *RasterDouble, _row, _column int, minAveragingSamples int) float64

func Splice

func Splice(a, b *QuadEdge)

func SubSampleRaster3x3

func SubSampleRaster3x3(src *RasterDouble, noDataValue float64, w, h, r, c int64) float64

func SwapTriangles

func SwapTriangles(e *QuadEdge)

func TileXYToPixelXY

func TileXYToPixelXY(tileX, tileY int64) (pixelX, pixelY int64)

func TileXYToQuadKey

func TileXYToQuadKey(tileX, tileY int64, levelOfDetail uint64) string

func VertexEqual

func VertexEqual(v, o Vertex) bool

Types

type BBox2d

type BBox2d [4]float64

func NewBBox2d

func NewBBox2d() *BBox2d

func TileBounds

func TileBounds(tileX, tileY int64, levelOfDetail uint64) BBox2d

func (*BBox2d) Add

func (b *BBox2d) Add(p interface{})

func (BBox2d) Contains

func (b BBox2d) Contains(point []float64, epsilon float64) bool

func (*BBox2d) Grow

func (b *BBox2d) Grow(delta float64)

func (BBox2d) Height

func (b BBox2d) Height() float64

func (BBox2d) IsOnBorder

func (b BBox2d) IsOnBorder(point []float64, epsilon float64) bool

func (BBox2d) Width

func (b BBox2d) Width() float64

type BBox3d

type BBox3d [6]float64

func NewBBox3d

func NewBBox3d() *BBox3d

func (*BBox3d) Add

func (b *BBox3d) Add(p interface{})

func (BBox3d) Contains

func (b BBox3d) Contains(point []float64, epsilon float64) bool

func (BBox3d) Depth

func (b BBox3d) Depth() float64

func (*BBox3d) Grow

func (b *BBox3d) Grow(delta float64)

func (BBox3d) Height

func (b BBox3d) Height() float64

func (BBox3d) Width

func (b BBox3d) Width() float64

type Candidate

type Candidate struct {
	X          int
	Y          int
	Z          float64
	Importance float64
	Token      int
	Triangle   *DelaunayTriangle
	// contains filtered or unexported fields
}

func (*Candidate) Consider

func (c *Candidate) Consider(sx, sy int, sz, imp float64)

func (*Candidate) Less

func (c *Candidate) Less(o Candidate) bool

type CandidateList

type CandidateList struct {
	Candidates PQ
}

func (*CandidateList) Empty

func (cl *CandidateList) Empty() bool

func (*CandidateList) GrabGreatest

func (cl *CandidateList) GrabGreatest() *Candidate

func (*CandidateList) Push

func (cl *CandidateList) Push(candidate *Candidate)

func (*CandidateList) Size

func (cl *CandidateList) Size() int

type Data

type Data struct {
	// contains filtered or unexported fields
}

type DelaunayMesh

type DelaunayMesh struct {
	QuadEdges *Pool
	Triangles *Pool
	// contains filtered or unexported fields
}

type DelaunayTriangle

type DelaunayTriangle struct {
	Anchor *QuadEdge
	Next   *DelaunayTriangle
	// contains filtered or unexported fields
}

func NewDelaunayTriangle

func NewDelaunayTriangle(p *Pool) *DelaunayTriangle

func (*DelaunayTriangle) GetAnchor

func (t *DelaunayTriangle) GetAnchor() *QuadEdge
func (t *DelaunayTriangle) GetLink() *DelaunayTriangle

type Edge

type Edge struct {
	First  VertexIndex
	Second VertexIndex
}

func (*Edge) Assign

func (e *Edge) Assign(a, b VertexIndex)

func (*Edge) Intersects2d

func (e *Edge) Intersects2d(o Edge, vertices []Vertex) bool

func (*Edge) SharesPoint

func (e *Edge) SharesPoint(o Edge) bool

type Face

type Face [3]VertexIndex

type Line

type Line [3]float64

func NewLine

func NewLine(a, b [2]float64) *Line

func (Line) Eval

func (l Line) Eval(p [2]float64) float64

type Mesh

type Mesh struct {
	Vertices  []Vertex
	Normals   []Normal
	Faces     []Face
	Triangles []Triangle
	BBox      [2][3]float64
}

func GenerateTinMesh

func GenerateTinMesh(raster *RasterDouble, maxError float64) *Mesh

func (*Mesh) CheckTin

func (m *Mesh) CheckTin() bool

func (*Mesh) Count

func (m *Mesh) Count() int

func (*Mesh) Empty

func (m *Mesh) Empty() bool

func (*Mesh) GetBbox

func (m *Mesh) GetBbox() BBox3d

type Normal

type Normal [3]float64

type PQ

type PQ []*Candidate

func (PQ) Len

func (pq PQ) Len() int

func (PQ) Less

func (pq PQ) Less(i, j int) bool

func (*PQ) Pop

func (pq *PQ) Pop() interface{}

func (*PQ) Push

func (pq *PQ) Push(x interface{})

func (PQ) Swap

func (pq PQ) Swap(i, j int)

type Plane

type Plane [3]float64

func NewPlane

func NewPlane(p, q, r [3]float64) *Plane

func (Plane) Eval

func (p Plane) Eval(x, y float64) float64

type Pool

type Pool struct {
	Values []interface{}
}

func NewPool

func NewPool() *Pool

type QuadEdge

type QuadEdge struct {
	// contains filtered or unexported fields
}

func Connect

func Connect(a, b *QuadEdge) *QuadEdge

func New

func New(p *Pool) *QuadEdge

func (*QuadEdge) Dest

func (e *QuadEdge) Dest() [2]float64

func (*QuadEdge) DestNext

func (e *QuadEdge) DestNext() *QuadEdge

func (*QuadEdge) DestPrev

func (e *QuadEdge) DestPrev() *QuadEdge

func (*QuadEdge) Init

func (e *QuadEdge) Init()

func (*QuadEdge) Init2

func (e *QuadEdge) Init2(ed *QuadEdge)

func (*QuadEdge) LeftFace

func (e *QuadEdge) LeftFace() *DelaunayTriangle

func (*QuadEdge) LeftNext

func (e *QuadEdge) LeftNext() *QuadEdge

func (*QuadEdge) LeftPrev

func (e *QuadEdge) LeftPrev() *QuadEdge

func (*QuadEdge) Next

func (e *QuadEdge) Next() *QuadEdge

func (*QuadEdge) Orig

func (e *QuadEdge) Orig() [2]float64

func (*QuadEdge) OrigNext

func (e *QuadEdge) OrigNext() *QuadEdge

func (*QuadEdge) OrigPrev

func (e *QuadEdge) OrigPrev() *QuadEdge

func (*QuadEdge) Pool

func (e *QuadEdge) Pool() *Pool

func (*QuadEdge) RecycleNext

func (e *QuadEdge) RecycleNext()

func (*QuadEdge) RightNext

func (e *QuadEdge) RightNext() *QuadEdge

func (*QuadEdge) RightPrev

func (e *QuadEdge) RightPrev() *QuadEdge

func (*QuadEdge) Rot

func (e *QuadEdge) Rot() *QuadEdge

func (*QuadEdge) SetDest

func (e *QuadEdge) SetDest(d [2]float64)

func (*QuadEdge) SetEndPoints

func (e *QuadEdge) SetEndPoints(org [2]float64, dest [2]float64)

func (*QuadEdge) SetLeftFace

func (e *QuadEdge) SetLeftFace(f *DelaunayTriangle)

func (*QuadEdge) SetOrig

func (e *QuadEdge) SetOrig(d [2]float64)

func (*QuadEdge) Sym

func (e *QuadEdge) Sym() *QuadEdge

func (*QuadEdge) Tor

func (e *QuadEdge) Tor() *QuadEdge

type Raster

type Raster struct {
	Size     [2]int
	Bounds   [4]float64
	NoData   interface{}
	Type     int32
	Data     interface{}
	Hemlines bool
	// contains filtered or unexported fields
}

func NewRaster

func NewRaster(row, column, dataType int) *Raster

func NewRasterWithData

func NewRasterWithData(row, column int, data interface{}) *Raster

func NewRasterWithNoData

func NewRasterWithNoData(row, column int, noData interface{}) *Raster

func (*Raster) Cols

func (r *Raster) Cols() int

func (*Raster) Count

func (r *Raster) Count() int

func (*Raster) East

func (r *Raster) East() float64

func (*Raster) GetRow

func (r *Raster) GetRow(row int) interface{}

func (*Raster) North

func (r *Raster) North() float64

func (*Raster) Rows

func (r *Raster) Rows() int

func (*Raster) SetTransform

func (r *Raster) SetTransform(trans func(*Vertex) Vertex)

func (*Raster) SetValue

func (r *Raster) SetValue(row, column int, data interface{})

func (*Raster) SetXYPos

func (r *Raster) SetXYPos(x, y, res float64)

func (*Raster) South

func (r *Raster) South() float64

func (*Raster) Value

func (r *Raster) Value(row, column int) interface{}

func (*Raster) West

func (r *Raster) West() float64

type RasterChar

type RasterChar struct {
	Raster
}

func NewRasterChar

func NewRasterChar(row, column int, noData int8) *RasterChar

func NewRasterCharWithData

func NewRasterCharWithData(row, column int, data []int8) *RasterChar

func (*RasterChar) GetRow

func (r *RasterChar) GetRow(row int) []int8

func (*RasterChar) SetValue

func (r *RasterChar) SetValue(row, column int, data int8)

func (*RasterChar) Value

func (r *RasterChar) Value(row, column int) int8

type RasterDouble

type RasterDouble struct {
	Raster
}

func NewRasterDouble

func NewRasterDouble(row, column int, noData float64) *RasterDouble

func NewRasterDoubleWithData

func NewRasterDoubleWithData(row, column int, data []float64) *RasterDouble

func (*RasterDouble) GetRow

func (r *RasterDouble) GetRow(row int) []float64

func (*RasterDouble) SetValue

func (r *RasterDouble) SetValue(row, column int, data float64)

func (*RasterDouble) Value

func (r *RasterDouble) Value(row, column int) float64

type RasterInt

type RasterInt struct {
	Raster
}

func NewRasterInt

func NewRasterInt(row, column int, noData int32) *RasterInt

func NewRasterIntWithData

func NewRasterIntWithData(row, column int, data []int32) *RasterInt

func (*RasterInt) GetRow

func (r *RasterInt) GetRow(row int) []int32

func (*RasterInt) SetValue

func (r *RasterInt) SetValue(row, column int, data int32)

func (*RasterInt) Value

func (r *RasterInt) Value(row, column int) int32

type RasterMesh

type RasterMesh struct {
	DelaunayMesh
	Raster *RasterDouble
}

func (*RasterMesh) LoadRaster

func (r *RasterMesh) LoadRaster(raster *RasterDouble)

type RasterType

type RasterType int

type TileMaker

type TileMaker struct {
	// contains filtered or unexported fields
}

func NewTileMaker

func NewTileMaker(m *Mesh) *TileMaker

func (*TileMaker) GenTile

func (tm *TileMaker) GenTile(scale bool) (*Mesh, error)

type Triangle

type Triangle [3]Vertex

func Clip25dTrianglesTo01Quadrant

func Clip25dTrianglesTo01Quadrant(tv []Triangle) []Triangle

func (Triangle) Equal

func (l Triangle) Equal(r Triangle) bool

type Vertex

type Vertex [3]float64

func (Vertex) Equal

func (v Vertex) Equal(o Vertex) bool

type VertexIndex

type VertexIndex int

type VertexReceiverFn

type VertexReceiverFn func(x, y float64, v interface{})

type ZemlyaMesh

type ZemlyaMesh struct {
	RasterMesh
	Sample       *RasterDouble
	Insert       *RasterDouble
	Result       *RasterDouble
	Used         *RasterChar
	Token        *RasterInt
	Candidates   CandidateList
	MaxError     float64
	Counter      int
	CurrentLevel int
	MaxLevel     int
}

func NewZemlyaMesh

func NewZemlyaMesh() *ZemlyaMesh

func (*ZemlyaMesh) GreedyInsert

func (z *ZemlyaMesh) GreedyInsert(maxError float64)

func (*ZemlyaMesh) ScanTriangle

func (z *ZemlyaMesh) ScanTriangle(t *DelaunayTriangle)

func (*ZemlyaMesh) ToMesh

func (z *ZemlyaMesh) ToMesh() *Mesh

Jump to

Keyboard shortcuts

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