Esempio n. 1
0
func TestUnProjectESPG3857(t *testing.T) {
	point := geometry.NewPoint(
		-13042847.101257065,
		3858205.880090526,
	)

	latLng := NewEspg3857().UnProject(point)

	if latLng.Lat != 32.720064477996 || latLng.Lng != -117.16588899493217 {
		t.Errorf("ESPG3857 unproject failed: %+v", latLng)
	}
}
Esempio n. 2
0
func TestUnTransformESPG3857(t *testing.T) {
	point := geometry.NewPoint(
		1.0000022299196951,
		0.9999948419882011,
	)

	p := NewEspg3857().UnTransform(point, 2.0)

	if p.X != 44.68203449467896 || p.Y != 103.35370445267007 {
		t.Errorf("espg3857 failed to untransform point: %+v", p)
	}
}
Esempio n. 3
0
func TestTransformESPG3857(t *testing.T) {
	point := geometry.NewPoint(
		44.68203449249269,
		103.35370445251465,
	)

	p := NewEspg3857().Transform(point, 2.0)

	if p.X != 1.0000022299196951 || p.Y != 0.9999948419882011 {
		t.Errorf("espg3857 failed to transform point: %+v", p)
	}
}
Esempio n. 4
0
func TestCetnterBoundsZoom(t *testing.T) {
	bounds := geo.NewLatLngBounds(
		32.7204706651118, -117.16439634561537,
		32.71965828903011, -117.1673735976219,
	)

	size := geometry.NewPoint(1107, 360)

	proj := crs.NewEspg3857()

	//	first test should max out at 30
	center, zoom := CenterBoundsZoom(proj, bounds, size, 30.0)
	if zoom != 18.0 {
		t.Errorf("boundZoom failed to zoom correctly: %v", zoom)
	}

	if center.Lat != 32.720064477996 || center.Lng != -117.16588497161865 {
		t.Errorf("center calulated incorrectly: %+v", center)
	}
}
Esempio n. 5
0
func TestPointToLatLngESPG3857(t *testing.T) {
	point := geometry.NewPoint(
		44.68203449249269,
		103.35370445251465,
	)

	//	coordinate ref system
	crs := NewEspg3857()

	//	no scale
	latLng := PointToLatLng(crs, point, 0.0)
	if latLng.Lat != 32.720064477996 || latLng.Lng != -117.16588899493217 {
		t.Errorf("espg3857 failed to convert point to latLng: %v", latLng)
	}

	//	2x scale
	latLng = PointToLatLng(crs, point, 2.0)
	if latLng.Lat != 80.6838883930096 || latLng.Lng != -164.29147224873307 {
		t.Errorf("espg3857 failed to convert point to latLng: %v", latLng)
	}

}
Esempio n. 6
0
func TestBoundsZoom(t *testing.T) {
	bounds := geo.NewLatLngBounds(
		32.7204706651118, -117.16439634561537,
		32.71965828903011, -117.1673735976219,
	)

	size := geometry.NewPoint(1107, 360)

	proj := crs.NewEspg3857()

	//	first test should max out at 30
	zoom := BoundsZoom(proj, bounds, size, 30.0)
	if zoom != 18.0 {
		t.Error("boundZoom failed to zoom correctly")
	}

	//	make sure the max zoom works
	zoom = BoundsZoom(proj, bounds, size, 16.0)
	if zoom != 16.0 {
		t.Error("boundZoom failed to zoom correctly")
	}
}