28 {
29 projPJ pj_latlon;
30 projPJ pj_utm;
31 int zone = 0;
32 zone =
static_cast<int>((lon_rad *
RAD_TO_DEG + 180) / 6) + 1;
33 std::string latlon_src =
34 "+proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs";
35 std::string utm_dst =
36 absl::StrCat("+proj=utm +zone=", zone, " +ellps=GRS80 +units=m +no_defs");
37 if (!(pj_latlon = pj_init_plus(latlon_src.c_str()))) {
38 return false;
39 }
40 if (!(pj_utm = pj_init_plus(utm_dst.c_str()))) {
41 return false;
42 }
43 double longitude = lon_rad;
44 double latitude = lat_rad;
45 pj_transform(pj_latlon, pj_utm, 1, 1, &longitude, &latitude, nullptr);
46 utm_xy->x = longitude;
47 utm_xy->y = latitude;
48 pj_free(pj_latlon);
49 pj_free(pj_utm);
50 return true;
51}