예제 #1
0
func (cs *CoordinateSystem) GeodeticToGeocentric(plh *globals.PLH) *globals.XYZ {
	xyz := &globals.XYZ{}
	if _, ok := cs.FloatParams["e2"]; !ok {
		cs.SetGeocentricParameters()
	}
	e2 := cs.FloatParams["e2"]
	a := cs.FloatParams["a_orig"]
	if plh.Phi < -globals.PI_OVER_2 && plh.Phi > -1.001*globals.PI_OVER_2 {
		plh.Phi = -globals.PI_OVER_2
	} else if plh.Phi > globals.PI_OVER_2 && plh.Phi < 1.001*globals.PI_OVER_2 {
		plh.Phi = globals.PI_OVER_2
	}

	if plh.Lam > globals.PI {
		plh.Lam = plh.Lam - 2*globals.PI
	}
	sin_lat := math.Sin(plh.Phi)
	cos_lat := math.Cos(plh.Phi)
	sin2_lat := sin_lat * sin_lat
	rn := a / (math.Sqrt(1.0 - e2*sin2_lat))
	xyz.X = (rn + plh.Height) * cos_lat * math.Cos(plh.Lam)
	xyz.Y = (rn + plh.Height) * cos_lat * math.Sin(plh.Lam)
	xyz.Z = ((rn * (1 - e2)) + plh.Height) * sin_lat
	return xyz
}
예제 #2
0
func (cs *CoordinateSystem) Forward(plh *globals.PLH) *globals.XYZ {
	plh.Lam = plh.Lam - cs.FloatParams["lam0"]
	if !cs.BoolParams["over"] {
		plh.Lam = cs.adjlon(plh.Lam)
	}
	xyz := cs.Projection.Forward(cs.FloatParams, plh)

	xyz.X = cs.FloatParams["from_meter"] * (cs.FloatParams["a"]*xyz.X + cs.FloatParams["x_0"])
	xyz.Y = cs.FloatParams["from_meter"] * (cs.FloatParams["a"]*xyz.Y + cs.FloatParams["x_0"])
	return xyz
}
예제 #3
0
파일: sterea.go 프로젝트: IMQS/goproj4
func StereaForward(params map[string]float64, plh *globals.PLH) *globals.XYZ { // lat, lon float64) (x, y float64) {
	xyz := &globals.XYZ{}
	// Gauss
	// local_phi := lat * DEG_TO_RAD
	// local_lam := lon * DEG_TO_RAD

	plh.Phi = 2.0*math.Atan(params["K"]*math.Pow(math.Tan(0.5*plh.Phi+globals.PI_OVER_4), params["C"])*srat(params["e"]*math.Sin(plh.Phi), params["ratexp"])) - globals.PI_OVER_2
	plh.Lam = params["C"] * plh.Lam

	// Sterea
	sinc := math.Sin(plh.Phi)
	cosc := math.Cos(plh.Phi)
	cosl := math.Cos(plh.Lam)
	k := params["k"] * params["2R"] / (1.0 + params["sinc0"]*sinc + params["cosc0"]*cosc*cosl)
	xyz.X = k * cosc * math.Sin(plh.Lam)
	xyz.Y = k * (params["cosc0"]*sinc - params["sinc0"]*cosc*cosl)
	return xyz
}