tin

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

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

Go to latest
Published: Mar 2, 2026 License: AGPL-3.0, Apache-2.0 Imports: 15 Imported by: 3 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 (
	EPS = float64(0.000000001)
)
View Source
const (
	MAX_AVERAGING_SAMPLES = 64
)
View Source
const (
	Nil = 0xFFFFFFFF
)

Variables

View Source
var (
	EPSG4326 = geo.NewProj(4326)
	EPSG3857 = geo.NewProj(3857)
)
View Source
var (
	NAN_DATA = Data{/* contains filtered or unexported fields */}
)

Functions

func AdjacentFind

func AdjacentFind(vi []Vertex, eq func(Vertex, Vertex) bool) (index int, found bool)

优化 adjacentFind 函数

func AverageNanArr

func AverageNanArr(toAverage []float64) float64

func CheckTriangleInTile

func CheckTriangleInTile(t Triangle, tileBounds BBox2d) bool

func Circumcenter

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

func CompareLength2D

func CompareLength2D(a1, a2, b1, b2 [2]float64) int

func GenerateSampleTileBBox

func GenerateSampleTileBBox(zoom int) vec2d.Rect

新增生成北京附近瓦片边界函数

func GenerateTinMesh

func GenerateTinMesh(raster *RasterDouble, maxError float64, config *GeoConfig) (*ZemlyaMesh, *Mesh)

func InCircumcircle

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

func InTriangle

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

func IsCCW

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

func IsFacingUpwards

func IsFacingUpwards(t Triangle) bool

func IsNaN

func IsNaN(v interface{}) bool

检查是否为 NaN 的辅助函数

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 Orientation

func Orientation(a, b, c [2]float64) 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)

Splice - 优化后的边连接操作

func SubSampleRaster3x3

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

func SwapTriangles

func SwapTriangles(e *QuadEdge)

SwapTriangles - 优化后的三角形交换

func TriangleSemanticEqual

func TriangleSemanticEqual(l, r Triangle) bool

func VertexEqual

func VertexEqual(v, o Vertex) bool

Types

type BBox2d

type BBox2d [4]float64

func NewBBox2d

func NewBBox2d() *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) Max

func (b *BBox3d) Max() [3]float64

func (*BBox3d) Min

func (b *BBox3d) Min() [3]float64

func (*BBox3d) To2d

func (b *BBox3d) To2d() BBox2d

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 DefaultProgress

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

DefaultProgress 默认进度跟踪器实现

func NewDefaultProgress

func NewDefaultProgress() *DefaultProgress

NewDefaultProgress 创建默认进度跟踪器

func (*DefaultProgress) Complete

func (p *DefaultProgress) Complete()

func (*DefaultProgress) Init

func (p *DefaultProgress) Init(total int)

func (*DefaultProgress) Log

func (p *DefaultProgress) Log(format string, args ...interface{})

func (*DefaultProgress) Update

func (p *DefaultProgress) Update(current, total int)

func (*DefaultProgress) Warn

func (p *DefaultProgress) Warn(format string, args ...interface{})

type DelaunayMesh

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

func (*DelaunayMesh) InitMeshFromBBox

func (m *DelaunayMesh) InitMeshFromBBox(bb BBox2d)

func (*DelaunayMesh) Insert

func (m *DelaunayMesh) Insert(x [2]float64, tri *DelaunayTriangle)

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 DemProvider

type DemProvider interface {
	GetDEM(bbox vec2d.Rect, zoom int) (*RasterDouble, error)
	Coverage() (geo.Coverage, error)
}

新增数据获取器接口

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 GeoConfig

type GeoConfig struct {
	SrcProj geo.Proj
	Datum   geoid.VerticalDatum
	Offset  float64
}

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 {
	GeoRef    *geo.GeoReference
	Vertices  []Vertex
	Normals   []Normal
	Faces     []Face
	Triangles []Triangle
	BBox      [2][3]float64
}

func GenerateSampleMesh

func GenerateSampleMesh(bbox vec2d.Rect, srsCode int, zoom int) (*Mesh, error)

func NewMesh

func NewMesh(geoRef *geo.GeoReference) *Mesh

添加初始化方法

func (*Mesh) AddTriangle

func (m *Mesh) AddTriangle(t Triangle, decompose bool)

优化添加三角形方法

func (*Mesh) CheckTin

func (m *Mesh) CheckTin() bool

func (*Mesh) ClearDecomposed

func (m *Mesh) ClearDecomposed()

func (*Mesh) ClearTriangles

func (m *Mesh) ClearTriangles()

func (*Mesh) ComposeTriangle

func (m *Mesh) ComposeTriangle(f Face) *Triangle

func (*Mesh) Count

func (m *Mesh) Count() int

func (*Mesh) Empty

func (m *Mesh) Empty() bool

func (*Mesh) ExportOBJ

func (m *Mesh) ExportOBJ(filename string, reproj bool) error

新增OBJ导出方法

func (*Mesh) GenerateDecomposed

func (m *Mesh) GenerateDecomposed()

func (*Mesh) GenerateTriangles

func (m *Mesh) GenerateTriangles()

func (*Mesh) GetBbox

func (m *Mesh) GetBbox() BBox3d

func (*Mesh) GrabDecomposed

func (m *Mesh) GrabDecomposed(vertices []Vertex, faces []Face) ([]Vertex, []Face)

func (*Mesh) GrabTriangles

func (m *Mesh) GrabTriangles(into []Triangle) []Triangle

func (*Mesh) InitFromTriangles

func (m *Mesh) InitFromTriangles(triangles []Triangle)

type Normal

type Normal [3]float64

type OBJTileExporter

type OBJTileExporter struct{}

func (*OBJTileExporter) Extension

func (s *OBJTileExporter) Extension() string

func (*OBJTileExporter) RelativeTilePath

func (s *OBJTileExporter) RelativeTilePath(zoom, x, y int) string

func (*OBJTileExporter) SaveTile

func (s *OBJTileExporter) SaveTile(mesh *Mesh, path string) error

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)

func (*PQ) Update

func (pq *PQ) Update(entry *Candidate, importance float64)

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{}
	New    func() interface{}
}

func NewPool

func NewPool(newFn func() interface{}) *Pool

func (*Pool) Get

func (p *Pool) Get() interface{}

func (*Pool) Len

func (p *Pool) Len() int

func (*Pool) Put

func (p *Pool) Put(item interface{})

type Progress

type Progress interface {
	Init(total int)
	Update(current, total int)               // 更新进度
	Complete()                               // 标记任务完成
	Log(format string, args ...interface{})  // 普通日志
	Warn(format string, args ...interface{}) // 警告日志
}

Progress 接口定义进度跟踪行为

type QuadEdge

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

func Connect

func Connect(a, b *QuadEdge) *QuadEdge

Connect - 优化后的边连接创建

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) CellSize

func (r *Raster) CellSize() float64

func (*Raster) ColLeftToX

func (r *Raster) ColLeftToX(col int) float64

ColLeftToX converts column index to X coordinate

func (*Raster) ColToX

func (r *Raster) ColToX(col int) float64

ColToX converts column index to X coordinate (center of cell)

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) RowBottomToY

func (r *Raster) RowBottomToY(rowFromBottom int) float64

RowBottomToY converts row index from bottom to Y coordinate

func (*Raster) RowToY

func (r *Raster) RowToY(row int) float64

RowToY converts row index to Y coordinate (center of cell)

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) ToVertices

func (r *Raster) ToVertices(receiverFn VertexReceiverFn)

func (*Raster) Value

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

func (*Raster) West

func (r *Raster) West() float64

func (*Raster) XToCol

func (r *Raster) XToCol(x float64) int

XToCol converts X coordinate to column index

func (*Raster) YToRow

func (r *Raster) YToRow(y float64) int

YToRow converts Y coordinate to row index

type RasterAdapter

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

func NewRasterAdapter

func NewRasterAdapter(tileGrid *geo.TileGrid, coverage geo.Coverage, origin *RasterDouble) *RasterAdapter

func (*RasterAdapter) Coverage

func (f *RasterAdapter) Coverage() (geo.Coverage, error)

func (*RasterAdapter) GetDEM

func (f *RasterAdapter) GetDEM(bbox vec2d.Rect, zoom int) (*RasterDouble, error)

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) DataSlice

func (r *RasterChar) DataSlice() []int8

func (*RasterChar) Fill

func (r *RasterChar) Fill(data int8)

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 CreateSampleDEM

func CreateSampleDEM(bbox vec2d.Rect, zoom int, maxElev float64) *RasterDouble

创建虚拟DEM

func NewRasterDouble

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

func NewRasterDoubleWithData

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

func (*RasterDouble) DataSlice

func (r *RasterDouble) DataSlice() []float64

func (*RasterDouble) Fill

func (r *RasterDouble) Fill(data float64)

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) DataSlice

func (r *RasterInt) DataSlice() []int32

func (*RasterInt) Fill

func (r *RasterInt) Fill(data int32)

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
	SrcProj geo.Proj            // 原始坐标系
	Datum   geoid.VerticalDatum // 高程基准
	Offset  float64             // 高程偏移
}

func (*RasterMesh) ExportToPLY

func (r *RasterMesh) ExportToPLY(w io.Writer) error

在RasterMesh结构体下方添加新方法

func (*RasterMesh) LoadRaster

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

type RasterType

type RasterType int

type TileExporter

type TileExporter interface {
	SaveTile(mesh *Mesh, path string) error
	Extension() string
	RelativeTilePath(zoom, x, y int) string
}
var DefaultTileExporter TileExporter = &OBJTileExporter{}

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 TinTiler

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

func NewTinTiler

func NewTinTiler(config *TinTilerConfig) *TinTiler

func (*TinTiler) Run

func (t *TinTiler) Run() error

func (*TinTiler) Stop

func (t *TinTiler) Stop()

type TinTilerConfig

type TinTilerConfig struct {
	OutputDir     string
	TileGrid      *geo.TileGrid
	MinZoom       int
	MaxZoom       int
	SpecificZooms []int
	Concurrency   int
	MaxError      float64
	Provider      DemProvider // 替换原来的DEMLoader
	Exporter      TileExporter
	Progress      Progress
	Coverage      geo.Coverage
	AutoZoom      bool
	Datum         geoid.VerticalDatum
	Offset        float64
}

type Triangle

type Triangle [3]Vertex

func Clip25DTriangleByLine

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

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

lp[0] + |

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

func Clip25dTrianglesTo01Quadrant

func Clip25dTrianglesTo01Quadrant(tv []Triangle) []Triangle

func (Triangle) Equal

func (l Triangle) Equal(r Triangle) bool

func (Triangle) IsValid

func (t Triangle) IsValid() 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
}

https://isprs-archives.copernicus.org/articles/XLI-B2/459/2016/isprs-archives-XLI-B2-459-2016.pdf

func NewZemlyaMesh

func NewZemlyaMesh(config *GeoConfig) *ZemlyaMesh

func (*ZemlyaMesh) GreedyInsert

func (z *ZemlyaMesh) GreedyInsert(maxError float64)

func (*ZemlyaMesh) LoadRaster

func (z *ZemlyaMesh) LoadRaster(raster *RasterDouble) error

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
⌂ 换网址