MCPcopy
hub / github.com/golang/geo / TestLoopRelations

Function TestLoopRelations

s2/loop_test.go:807–1431  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

805}
806
807func TestLoopRelations(t *testing.T) {
808 // this loop is used in the regression test cases below.
809 containingLoop := LoopFromPoints([]Point{
810 PointFromLatLng(LatLngFromDegrees(-38.0, -135.0)),
811 PointFromLatLng(LatLngFromDegrees(-38.0, 149.0)),
812 PointFromLatLng(LatLngFromDegrees(77.0, 149.0)),
813 PointFromLatLng(LatLngFromDegrees(77.0, -135.0)),
814 })
815
816 innerTile := LoopFromPoints([]Point{
817 PointFromLatLng(LatLngFromDegrees(37.99616267972809, 13.007812500000002)),
818 PointFromLatLng(LatLngFromDegrees(37.99616267972809, 13.359375000000002)),
819 PointFromLatLng(LatLngFromDegrees(38.272819658516866, 13.359375000000002)),
820 PointFromLatLng(LatLngFromDegrees(38.272819658516866, 13.007812500000002)),
821 })
822
823 // +0.2 lat +0.2 lon from innerTile
824 extendedTile := LoopFromPoints([]Point{
825 PointFromLatLng(LatLngFromDegrees(37.99616267972809, 13.007812500000002)),
826 PointFromLatLng(LatLngFromDegrees(37.99616267972809, 13.559375000000002)),
827 PointFromLatLng(LatLngFromDegrees(38.472819658516866, 13.559375000000002)),
828 PointFromLatLng(LatLngFromDegrees(38.472819658516866, 13.007812500000002)),
829 })
830
831 tests := []struct {
832 a, b *Loop
833 contains bool // A contains B
834 contained bool // B contains A
835 disjoint bool // A and B are disjoint (intersection is empty)
836 covers bool // (A union B) covers the entire sphere
837 sharedEdge bool // the loops share at least one edge (possibly reversed)
838 }{
839 // Check full and empty relationships with normal loops and each other.
840 {
841 a: FullLoop(),
842 b: FullLoop(),
843 contains: true,
844 contained: true,
845 covers: true,
846 sharedEdge: true,
847 },
848 {
849 a: FullLoop(),
850 b: northHemi,
851 contains: true,
852 covers: true,
853 sharedEdge: false,
854 },
855 {
856 a: FullLoop(),
857 b: EmptyLoop(),
858 contains: true,
859 disjoint: true,
860 covers: true,
861 sharedEdge: false,
862 },
863 {
864 a: northHemi,

Callers

nothing calls this directly

Calls 13

LoopFromPointsFunction · 0.85
PointFromLatLngFunction · 0.85
LatLngFromDegreesFunction · 0.85
FullLoopFunction · 0.85
EmptyLoopFunction · 0.85
testLoopNestedPairFunction · 0.85
cloneLoopFunction · 0.85
ContainsNestedMethod · 0.80
IsEmptyMethod · 0.65
InvertMethod · 0.45
ContainsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…