testing

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2024 License: MIT Imports: 3 Imported by: 0

README

testing

This package contains functions and variables for using pre made geometries.

The tile variables are very large and are initially stored as strings. In order to access them, you must first compile compile them by calling CompileTiles. Once compiled, access the tiles via the Tiles function (this does no processing besides endusring that compilation has already occured).

package my_test

import (
    "github.com/go-spatial/geom/encoding/wkt"
    gtesting "github.com/go-spatial/testing"
)

func init {
    // put this in init so benchmarks aren't skewed
    gtesting.CompileTiles(wkt.DecodeString)
}

func TestMy(t *testing) {
    tiles := gtesting.Tiles()
    ...
}

Documentation

Overview

This file contains geometries hand picked out of natural earth for as they serve for good edge cases

Index

Constants

This section is empty.

Variables

View Source
var NaturalEarth = []geom.Geometry{_ne_10m_admin_0_countries0, _ne_10m_admin_0_countries1, _ne_10m_admin_0_countries2, _ne_10m_admin_0_countries3, _ne_10m_admin_0_countries4, _ne_10m_admin_0_countries5, _ne_10m_admin_0_countries6, _ne_10m_admin_0_countries7, _ne_10m_admin_0_countries8, _ne_10m_admin_0_countries9, _ne_10m_parks_and_protected_lands_line0, _ne_10m_parks_and_protected_lands_line1, _ne_10m_parks_and_protected_lands_line2, _ne_10m_parks_and_protected_lands_line3, _ne_10m_parks_and_protected_lands_line4, _ne_10m_parks_and_protected_lands_line5, _ne_10m_parks_and_protected_lands_line6, _ne_10m_parks_and_protected_lands_line7, _ne_10m_parks_and_protected_lands_line8, _ne_10m_parks_and_protected_lands_line9, _ne_10m_parks_and_protected_lands_area0, _ne_10m_parks_and_protected_lands_area1, _ne_10m_parks_and_protected_lands_area2, _ne_10m_parks_and_protected_lands_area3, _ne_10m_parks_and_protected_lands_area4, _ne_10m_parks_and_protected_lands_area5, _ne_10m_parks_and_protected_lands_area6, _ne_10m_parks_and_protected_lands_area7, _ne_10m_parks_and_protected_lands_area8, _ne_10m_parks_and_protected_lands_area9, _ne_110m_coastline0, _ne_110m_coastline1, _ne_110m_coastline2, _ne_110m_coastline3, _ne_110m_coastline4, _ne_110m_coastline5, _ne_110m_coastline6, _ne_110m_coastline7, _ne_110m_coastline8, _ne_110m_coastline9, _ne_50m_lakes0, _ne_50m_lakes1, _ne_50m_lakes2, _ne_50m_lakes3, _ne_50m_lakes4, _ne_50m_lakes5, _ne_50m_lakes6, _ne_50m_lakes7, _ne_50m_lakes8, _ne_50m_lakes9, _ne_50m_antarctic_ice_shelves_lines0, _ne_50m_antarctic_ice_shelves_lines1, _ne_50m_antarctic_ice_shelves_lines2, _ne_50m_antarctic_ice_shelves_lines3, _ne_50m_antarctic_ice_shelves_lines4, _ne_50m_antarctic_ice_shelves_lines5, _ne_50m_antarctic_ice_shelves_lines6, _ne_50m_antarctic_ice_shelves_lines7, _ne_50m_antarctic_ice_shelves_lines8, _ne_50m_antarctic_ice_shelves_lines9, _ne_50m_antarctic_ice_shelves_polys0, _ne_50m_antarctic_ice_shelves_polys1, _ne_50m_antarctic_ice_shelves_polys2, _ne_50m_antarctic_ice_shelves_polys3, _ne_50m_antarctic_ice_shelves_polys4, _ne_50m_antarctic_ice_shelves_polys5, _ne_50m_antarctic_ice_shelves_polys6, _ne_50m_antarctic_ice_shelves_polys7, _ne_50m_antarctic_ice_shelves_polys8, _ne_50m_antarctic_ice_shelves_polys9, SouthAfrica}
View Source
var NaturalEarthLineStrings = []geom.LineString{
	_ne_10m_parks_and_protected_lands_line0[0],
	_ne_10m_parks_and_protected_lands_line1[0],
	_ne_10m_parks_and_protected_lands_line2[0],
	_ne_10m_parks_and_protected_lands_line3[0],
	_ne_10m_parks_and_protected_lands_line4[0],
	_ne_10m_parks_and_protected_lands_line5[0],
	_ne_10m_parks_and_protected_lands_line6[0],
	_ne_10m_parks_and_protected_lands_line7[0],
	_ne_10m_parks_and_protected_lands_line8[0],
	_ne_10m_parks_and_protected_lands_line9[0],
	_ne_110m_coastline0[0],
	_ne_110m_coastline1[0],
	_ne_110m_coastline2[0],
	_ne_110m_coastline3[0],
	_ne_110m_coastline4[0],
	_ne_110m_coastline5[0],
	_ne_110m_coastline6[0],
	_ne_110m_coastline7[0],
	_ne_110m_coastline8[0],
	_ne_110m_coastline9[0],
}
View Source
var NaturalEarthMultiLineStrings = []geom.MultiLineString{
	_ne_10m_parks_and_protected_lands_line0,
	_ne_10m_parks_and_protected_lands_line1,
	_ne_10m_parks_and_protected_lands_line2,
	_ne_10m_parks_and_protected_lands_line3,
	_ne_10m_parks_and_protected_lands_line4,
	_ne_10m_parks_and_protected_lands_line5,
	_ne_10m_parks_and_protected_lands_line6,
	_ne_10m_parks_and_protected_lands_line7,
	_ne_10m_parks_and_protected_lands_line8,
	_ne_10m_parks_and_protected_lands_line9,
	_ne_110m_coastline0,
	_ne_110m_coastline1,
	_ne_110m_coastline2,
	_ne_110m_coastline3,
	_ne_110m_coastline4,
	_ne_110m_coastline5,
	_ne_110m_coastline6,
	_ne_110m_coastline7,
	_ne_110m_coastline8,
	_ne_110m_coastline9,
}
View Source
var NaturalEarthMultiPolygons = []geom.MultiPolygon{
	_ne_10m_admin_0_countries0,
	_ne_10m_admin_0_countries1,
	_ne_10m_admin_0_countries2,
	_ne_10m_admin_0_countries3,
	_ne_10m_admin_0_countries4,
	_ne_10m_admin_0_countries5,
	_ne_10m_admin_0_countries6,
	_ne_10m_admin_0_countries7,
	_ne_10m_admin_0_countries8,
	_ne_10m_admin_0_countries9,
	_ne_10m_parks_and_protected_lands_area0,
	_ne_10m_parks_and_protected_lands_area1,
	_ne_10m_parks_and_protected_lands_area2,
	_ne_10m_parks_and_protected_lands_area3,
	_ne_10m_parks_and_protected_lands_area4,
	_ne_10m_parks_and_protected_lands_area5,
	_ne_10m_parks_and_protected_lands_area6,
	_ne_10m_parks_and_protected_lands_area7,
	_ne_10m_parks_and_protected_lands_area8,
	_ne_10m_parks_and_protected_lands_area9,
}
View Source
var NaturalEarthPolygons = []geom.Polygon{
	_ne_10m_admin_0_countries0[0],
	_ne_10m_admin_0_countries1[0],
	_ne_10m_admin_0_countries2[0],
	_ne_10m_admin_0_countries3[0],
	_ne_10m_admin_0_countries4[0],
	_ne_10m_admin_0_countries5[0],
	_ne_10m_admin_0_countries6[0],
	_ne_10m_admin_0_countries7[0],
	_ne_10m_admin_0_countries8[0],
	_ne_10m_admin_0_countries9[0],
	_ne_10m_parks_and_protected_lands_area0[0],
	_ne_10m_parks_and_protected_lands_area1[0],
	_ne_10m_parks_and_protected_lands_area2[0],
	_ne_10m_parks_and_protected_lands_area3[0],
	_ne_10m_parks_and_protected_lands_area4[0],
	_ne_10m_parks_and_protected_lands_area5[0],
	_ne_10m_parks_and_protected_lands_area6[0],
	_ne_10m_parks_and_protected_lands_area7[0],
	_ne_10m_parks_and_protected_lands_area8[0],
	_ne_10m_parks_and_protected_lands_area9[0],
}
View Source
var SouthAfrica = geom.Polygon{{{1819514.49895631, -3321879.59560247}, {1872841.04652977, -3259336.43645738}, {1916802.37086163, -3293924.66604287}, {1935567.3329096, -3348120.97848911}, {1985511.35513536, -3357378.82383501}, {2055503.16789979, -3381433.59312285}, {2115307.13646222, -3372139.13005548}, {2214671.69484802, -3307233.92829931}, {2214786.74673059, -2847249.72378093}, {2244838.29845916, -2865671.45466973}, {2310837.81089824, -2982758.22795976}, {2300580.93556669, -3058336.7652327}, {2325420.63701461, -3102066.74310732}, {2405157.34423313, -3089347.09708633}, {2460825.19761699, -3033833.46299146}, {2513541.97021281, -2996535.65388003}, {2540786.25600654, -2937341.00750129}, {2595090.74458189, -2908783.37953791}, {2642008.90229593, -2923739.8484122}, {2695185.88242204, -2958292.75306769}, {2785789.23994977, -2964402.10763063}, {2856977.59229298, -2935658.5023084}, {2868241.17159706, -2897235.77903124}, {2887811.49682305, -2838496.76452479}, {2948380.5604046, -2828692.06397227}, {2981849.15304563, -2782764.85595039}, {3018918.86961126, -2701622.64046915}, {3118864.44000407, -2611201.59655871}, {3276376.21984322, -2522491.95733426}, {3321666.39341882, -2523801.97571279}, {3375527.93224626, -2544166.86915464}, {3413040.5985598, -2529732.47290565}, {3472211.78176806, -2541748.88322715}, {3525532.5767474, -2711906.71971838}, {3554496.88818563, -2798488.17771242}, {3534661.94362972, -2935346.24016276}, {3544165.2291304, -2979689.81966292}, {3487991.14746321, -2957054.59323386}, {3455811.13590701, -2965858.00233447}, {3445301.1464338, -3001886.39223346}, {3414904.43905751, -3048468.76972319}, {3415945.65859482, -3091504.89494925}, {3482382.36818769, -3159234.23055326}, {3547536.24928985, -3145719.06041483}, {3570201.4701571, -3090255.26452264}, {3654632.29418468, -3091298.76275588}, {3626818.5015722, -3182335.52778015}, {3613668.07139389, -3286977.70075212}, {3584864.83259127, -3344170.30912519}, {3508901.8271212, -3408446.5953216}, {3487145.51612629, -3426908.94539456}, {3439968.49167645, -3491980.89366278}, {3408915.98856949, -3558139.39908667}, {3345787.02060065, -3650979.23317981}, {3219977.78700501, -3785914.94306974}, {3141408.85639462, -3865073.4861791}, {3057346.19839128, -3925468.50613005}, {2940999.98213742, -3977215.72283295}, {2884250.64105735, -3984180.81666949}, {2869886.41351788, -4021371.76817098}, {2802230.15396972, -4001556.65452325}, {2747126.05481048, -4027080.17871381}, {2626476.89814832, -4001238.22989337}, {2559033.48458292, -4017586.23112947}, {2512943.70042342, -4010566.19949738}, {2398133.42680194, -4063610.93243522}, {2303094.81920095, -4084956.99102728}, {2234322.55639181, -4136075.78868796}, {2183688.2228706, -4139333.64776577}, {2136585.98214444, -4091088.19987486}, {2098964.01654246, -4088618.57492182}, {2051021.8970735, -4028516.4009664}, {2045764.02603983, -4047148.18263461}, {2030968.3539407, -4011058.08505739}, {2031589.6341066, -3932719.0457152}, {1995423.07481918, -3843822.24661598}, {2031348.02515319, -3819773.54520248}, {2028437.21252405, -3718976.19361688}, {1955540.3397246, -3597179.80513362}, {1899602.11441669, -3487959.80039069}, {1899435.28918695, -3487614.81492639}}, {{3225845.43301633, -3369995.69161198}, {3177247.5178167, -3330856.94817966}, {3125221.05651633, -3356754.86466859}, {3064905.10707644, -3406574.10821812}, {3005544.08826193, -3487614.81492639}, {3089048.74463479, -3586744.64972601}, {3128879.70638221, -3573893.2755542}, {3149347.43629229, -3532661.16288536}, {3211389.16397079, -3512557.37040567}, {3230315.19865436, -3470655.63347595}, {3264462.59740259, -3408446.5953216}}}

South Africa has a hole in it

Functions

func BoxPolygon

func BoxPolygon(dim float64) geom.Polygon

BoxPolygon returns a polygon that is a box with side lengths of dim, a clockwise winding order, and points at (0, 0) and (dim, dim).

func CompileTiles

func CompileTiles(wktDecoder func(string) (geom.Geometry, error))

CompileTiles will compile some Natural Earth tiles so they are accessible through the Tiles function. It takes a WKT decoding function which can be accessible in the package github.com/go-spatial/geom/encoding/wkt as the function DecodeString.

package my_test

import (
	gtesting "github.com/go-spatial/testing"
	"github.com/go-spatial/geom/encoding/wkt"
)

func init {
	// put this in init so benchmarks aren't skewed
	gtesting.CompileTiles(wkt.DecodeString)
}

func TestMy(t *testing) {
	tiles := gtesting.Tiles()
	...
}

func FuncLineString

func FuncLineString(start, end float64, points int, fn ParamFunc) geom.LineString

FuncLineString returns a line string constructed from calling fn in the interval [start, end] points number of times. The number of points must be >= 2, or the function panics.

func SelfIntBoxLineString

func SelfIntBoxLineString(dim float64) geom.LineString

func SinLineString

func SinLineString(amp, start, end float64, points int) geom.LineString

SinLineString returns a line string that is a sin wave with the given amplitude and domain (x values) of the set [start, end]. points is the number of points in the line and must be >= 2, or the function panics.

func Tiles

func Tiles() []geom.Collection

Tiles returns geom.Collections that represent Natural Earth tiles generated with the utility https://github.com/ear7h/tile-dump. The tiles must be compiled at runtime by calling the CompileTiles function (see documentation for it) or this funciton will panic.

package my_test

import (
	gtesting "github.com/go-spatial/testing"
	"github.com/go-spatial/geom/encoding/wkt"
)

func init {
	// put this in init so benchmarks aren't skewed
	gtesting.CompileTiles(wkt.DecodeString)
}

func TestMy(t *testing) {
	tiles := gtesting.Tiles()
	...
}

Types

type ParamFunc

type ParamFunc func(t float64) [2]float64

Directories

Path Synopsis
Package must provides helpers to decode wkt geometries to be used in tests
Package must provides helpers to decode wkt geometries to be used in tests

Jump to

Keyboard shortcuts

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