Skip to content

Commit

Permalink
reverse
Browse files Browse the repository at this point in the history
  • Loading branch information
nokonoko1203 committed Nov 16, 2024
1 parent 8775c90 commit fd8a1a8
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions pcd-transformer/src/transform/projection.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
use std::sync::Arc;

use pcd_core::pointcloud::point::{Point, PointCloud};
use projection_transform::{
crs::*, etmerc::ExtendedTransverseMercatorProjection, jprect::JPRZone, vshift::Jgd2011ToWgs84,
};
use projection_transform::{crs::*, jprect::JPRZone, vshift::Jgd2011ToWgs84};

use super::Transform;

pub struct ProjectionTransform {
jgd2wgs: Arc<Jgd2011ToWgs84>,
output_epsg: EpsgCode,
jpr_zone_proj: Option<ExtendedTransverseMercatorProjection>,
}

impl Transform for ProjectionTransform {
Expand All @@ -36,7 +33,22 @@ impl Transform for ProjectionTransform {
| EPSG_JGD2011_JPRECT_XVI
| EPSG_JGD2011_JPRECT_XVII
| EPSG_JGD2011_JPRECT_XVIII
| EPSG_JGD2011_JPRECT_XIX => self.transform_from_jgd2011(point_cloud, Some(input_epsg)),
| EPSG_JGD2011_JPRECT_XIX
| EPSG_JGD2011_JPRECT_I_JGD2011_HEIGHT
| EPSG_JGD2011_JPRECT_II_JGD2011_HEIGHT
| EPSG_JGD2011_JPRECT_III_JGD2011_HEIGHT
| EPSG_JGD2011_JPRECT_IV_JGD2011_HEIGHT
| EPSG_JGD2011_JPRECT_V_JGD2011_HEIGHT
| EPSG_JGD2011_JPRECT_VI_JGD2011_HEIGHT
| EPSG_JGD2011_JPRECT_VII_JGD2011_HEIGHT
| EPSG_JGD2011_JPRECT_VIII_JGD2011_HEIGHT
| EPSG_JGD2011_JPRECT_IX_JGD2011_HEIGHT
| EPSG_JGD2011_JPRECT_X_JGD2011_HEIGHT
| EPSG_JGD2011_JPRECT_XI_JGD2011_HEIGHT
| EPSG_JGD2011_JPRECT_XII_JGD2011_HEIGHT
| EPSG_JGD2011_JPRECT_XIII_JGD2011_HEIGHT => {
self.transform_from_jgd2011(point_cloud, Some(input_epsg))
}
_ => {
panic!("Unsupported input CRS: {}", input_epsg);
}
Expand All @@ -46,13 +58,9 @@ impl Transform for ProjectionTransform {

impl ProjectionTransform {
pub fn new(jgd2wgs: Arc<Jgd2011ToWgs84>, output_epsg: EpsgCode) -> Self {
// For Japan Plane Rectangular CS
let jpr_zone_proj = JPRZone::from_epsg(output_epsg).map(|zone| zone.projection());

Self {
jgd2wgs,
output_epsg,
jpr_zone_proj,
}
}

Expand All @@ -72,16 +80,12 @@ impl ProjectionTransform {
match self.output_epsg {
EPSG_WGS84_GEOGRAPHIC_3D => {
for (x, y, z, point) in point_cloud.iter() {
// Swap x and y (lat, lng -> lng, lat)
let (lng, lat, height) = (y, x, z);

let (lng, lat, height) = if let Some(input_epsg) = rectangular {
Self::rectangular_to_lnglat(lng, lat, height, input_epsg)
Self::rectangular_to_lnglat(x, y, z, input_epsg)
} else {
(lng, lat, height)
(x, y, z)
};

// JGD2011 to WGS 84 (elevation to ellipsoidal height)
let (lng, lat, height) = self.jgd2wgs.convert(lng, lat, height);

points.push(Point {
Expand Down

0 comments on commit fd8a1a8

Please sign in to comment.