package producer

import "fmt"

func calculateProj(topLeftX, topLeftY, width, height, resolution float64) string {
	var projections []string
	// 计算图像的地理范围
	bottomRightX := topLeftX + float64(width)*resolution
	bottomRightY := topLeftY + float64(height)*resolution

	// 根据地理范围和分辨率选择适当的投影信息
	// 这里只是一个示例，你需要根据实际情况选择合适的投影系统和参数
	projections = append(projections, fmt.Sprintf(`PROJCS["Custom Projection",
	GEOGCS["WGS 84",
		DATUM["WGS_1984",
			SPHEROID["WGS 84",6378137,298.257223563,
				AUTHORITY["EPSG","7030"]],
			AUTHORITY["EPSG","6326"]],
		PRIMEM["Greenwich",0,
			AUTHORITY["EPSG","8901"]],
		UNIT["degree",0.0174532925199433,
			AUTHORITY["EPSG","9122"]],
		AUTHORITY["EPSG","4326"]],
	PROJECTION["Transverse_Mercator"],
	PARAMETER["latitude_of_origin",0],
	PARAMETER["central_meridian",%f],
	PARAMETER["scale_factor",0.9996],
	PARAMETER["false_easting",%f],
	PARAMETER["false_northing",0],
	UNIT["metre",1,
		AUTHORITY["EPSG","9001"]],
	AXIS["Easting",EAST],
	AXIS["Northing",NORTH]]`,
		(topLeftX+bottomRightX)/2, (topLeftY+bottomRightY)/2))

	projections = append(projections, `PROJCS["WGS 84 / UTM zone 51N",
	GEOGCS["WGS 84",
		DATUM["WGS_1984",
			SPHEROID["WGS 84",6378137,298.257223563,
				AUTHORITY["EPSG","7030"]],
			AUTHORITY["EPSG","6326"]],
		PRIMEM["Greenwich",0,
			AUTHORITY["EPSG","8901"]],
		UNIT["degree",0.0174532925199433,
			AUTHORITY["EPSG","9122"]],
		AUTHORITY["EPSG","4326"]],
	PROJECTION["Transverse_Mercator"],
	PARAMETER["latitude_of_origin",0],
	PARAMETER["central_meridian",123],
	PARAMETER["scale_factor",0.9996],
	PARAMETER["false_easting",500000],
	PARAMETER["false_northing",0],
	UNIT["metre",1,
		AUTHORITY["EPSG","9001"]],
	AXIS["Easting",EAST],
	AXIS["Northing",NORTH],
	AUTHORITY["EPSG","32651"]]`)

	projections = append(projections, `PROJCS["WGS 84 / Pseudo-Mercator",
	GEOGCS["WGS 84",DATUM["WGS_1984",
		SPHEROID["WGS 84",6378137,298.257223563,
			AUTHORITY["EPSG","7030"]],
		AUTHORITY["EPSG","6326"]],
		PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],
		UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],
		AUTHORITY["EPSG","4326"]],
	PROJECTION["Mercator_1SP"],
	PARAMETER["central_meridian",0],
	PARAMETER["scale_factor",1],
	PARAMETER["false_easting",0],
	PARAMETER["false_northing",0],
	UNIT["metre",1,AUTHORITY["EPSG","9001"]],
	AXIS["X",EAST],
	AXIS["Y",NORTH],
	EXTENSION["PROJ4","+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext  +no_defs"],
	AUTHORITY["EPSG","3857"]]`)

	projections = append(projections, `GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]]`)

	// 输出投影信息
	return projections[4]
}
